Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

feat: add toml support for initial db #103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions loads-broker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "demo loadtest",
"plans": [
{
"name": "connection loadtest",
"description": "autopush: connect and idle forever",


"steps": [
{
"name": "***************** RUN #01 ***********************",
"instance_count": 8,
"instance_region": "us-east-1",
"instance_type": "m3.medium",
"run_max_time": 300,
"container_name": "bbangert/ap-loadtester:latest",
"volume_mapping": "/var/log:/var/log/$RUN_ID:rw",
"additional_command_args": "./apenv/bin/aplt_testplan wss://autopush.stage.mozaws.net 'aplt.scenarios:connect_and_idle_forever,3000000,5,0'",
"docker_series": "push_tester",
"prune_running": false
},
{
"name": "***************** RUN #02 ***********************",
"run_delay": 330,
"instance_count": 16,
"instance_region": "us-east-1",
"instance_type": "m3.medium",
"run_max_time": 300,
"container_name": "bbangert/ap-loadtester:latest",
"volume_mapping": "/var/log:/var/log/$RUN_ID:rw",
"additional_command_args": "./apenv/bin/aplt_testplan wss://autopush.stage.mozaws.net 'aplt.scenarios:connect_and_idle_forever,10000,5,0'",
"docker_series": "push_tester",
"prune_running": false
}
]
}
]
}
27 changes: 27 additions & 0 deletions loads-broker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name = "demo loadtest"

[[plans]]
name = "connection loadtest"
description = "autopush: connect and idle forever"


[[plans.steps]]
name = "***************** RUN #01 ***********************"
instance_count = 8
instance_type = "m3.medium"
container_name = "bbangert/ap-loadtester:latest"
additional_command_args = "./apenv/bin/aplt_testplan wss://autopush.stage.mozaws.net 'aplt.scenarios:connect_and_idle_forever,10000,5,0'"
run_max_time = 300
volume_mapping = "/var/log:/var/log/$RUN_ID:rw"
docker_series = "push_tests"

[[plans.steps]]
name = "***************** RUN #02 ***********************"
instance_count = 8
run_delay = 330
instance_type = "m3.medium"
container_name = "bbangert/ap-loadtester:latest"
additional_command_args = "./apenv/bin/aplt_testplan wss://autopush.stage.mozaws.net 'aplt.scenarios:connect_and_idle_forever,10000,5,0'"
run_max_time = 300
volume_mapping = "/var/log:/var/log/$RUN_ID:rw"
docker_series = "push_tests"
9 changes: 8 additions & 1 deletion loadsbroker/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from collections import OrderedDict
from uuid import uuid4

import toml

from sqlalchemy import (
create_engine,
Boolean,
Expand Down Expand Up @@ -427,7 +429,12 @@ def setup_database(session, db_file):
file"""
logger.debug("Verifying database setup.")
with open(db_file) as fp:
data = json.load(fp, object_pairs_hook=OrderedDict)
if db_file.lower().endswith('json'):
data = json.load(fp, object_pairs_hook=OrderedDict)
elif db_file.lower().endswith('toml'):
data = toml.loads(fp.read())
else:
exit('ERROR: initial db file format not recogized. Aborting!')

# Verify the project exists
project = session.query(Project).filter_by(name=data["name"]).first()
Expand Down
7 changes: 5 additions & 2 deletions loadsbroker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ def _parse(sysargs=None):
type=str, default='root')
parser.add_argument('--influx-secure', help='Use TLS for InfluxDB',
action='store_true', default=False)
parser.add_argument('--initial-db', help="JSON file to initialize the db.",
parser.add_argument('--initial-db',
help="TOML (or JSON) file to initialize the db.",
type=str, default=os.path.join(
os.path.dirname(__file__), '..', 'pushgo.json'))
os.path.dirname(__file__),
'..', 'loads-broker.toml')
)
args = parser.parse_args(sysargs)
return args, parser

Expand Down
102 changes: 0 additions & 102 deletions pushgo.json

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
README = f.read()

requires = ['cornice', 'docker-py==1.6.0', 'boto', 'paramiko', 'sqlalchemy',
'tornado', 'requests', 'influxdb>=2.0.1']
'tornado', 'requests', 'influxdb>=2.0.1', 'toml']
tests_require = ['nose', 'nose-cov', 'flake8', 'moto', 'freezegun']


Expand Down