From 7e2ad2dad361336a4d46166e6aec32cd80c15e03 Mon Sep 17 00:00:00 2001 From: Ben Bangert Date: Wed, 15 Mar 2017 22:38:53 -0700 Subject: [PATCH] feat: setup environment data from the test plan Environment data from a test plan is passed into the container as loads-broker passed it. Closes #25 --- CHANGELOG.md | 0 ardere/aws.py | 13 +++++++------ tests/fixtures.py | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/ardere/aws.py b/ardere/aws.py index 4baea56..7123a78 100644 --- a/ardere/aws.py +++ b/ardere/aws.py @@ -142,6 +142,12 @@ def create_service(self, step): "additional_command_args"] shell_command3 = ['sh', '-c', '{}'.format(shell_command2)] + # Prep the env vars + env_vars = [{"name": "WAITFORCLUSTER", "value": shell_script}] + for env_var in step.get("environment_data", []): + name, value = env_var.split("=", 1) + env_vars.append({"name": name, "value": value}) + # ECS wants a family name for task definitions, no spaces, 255 chars family_name = step["name"] + "-" + self._plan_uuid task_response = self._ecs_client.register_task_definition( @@ -153,12 +159,7 @@ def create_service(self, step): "cpu": step["cpu_units"], # using only memoryReservation sets no hard limit "memoryReservation": 256, - "environment": [ - { - "name": "WAITFORCLUSTER", - "value": shell_script - } - ], + "environment": env_vars, "entryPoint": shell_command3 } ], diff --git a/tests/fixtures.py b/tests/fixtures.py index f51c662..d36c93c 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -10,6 +10,9 @@ "instance_type": "t2.medium", "run_max_time": 140, "cpu_units": 2048, + "environment_data": [ + "SOME_VAR=great-value" + ], "container_name": "bbangert/ap-loadtester:latest", "additional_command_args": "./apenv/bin/aplt_testplan wss://autopush.stage.mozaws.net 'aplt.scenarios:notification_forever,1000,1,0'" }