Skip to content

Commit

Permalink
testing: use original prod.yml when setting up production environment…
Browse files Browse the repository at this point in the history
… for testing

Changelog: none
Signed-off-by: Greg Di Stefano <[email protected]>
  • Loading branch information
GregorioDiStefano committed Jul 18, 2017
1 parent 6b696c3 commit 1ec6476
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 212 deletions.
198 changes: 0 additions & 198 deletions extra/production-environment/production-testing-env.yml

This file was deleted.

24 changes: 17 additions & 7 deletions tests/production_test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import argparse
import conftest
import shutil
import common
from MenderAPI import auth, adm
sys.path.insert(0, "./tests")
Expand All @@ -29,6 +30,20 @@

args = parser.parse_args()

def fill_production_template():

# copy production environment yml file
subprocess.check_output(["cp", "template/prod.yml", "production-testing-env.yml"], cwd="../")
subprocess.check_output("sed -i 's/template\///g' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i 's/ALLOWED_HOSTS: my-gateway-dns-name/ALLOWED_HOSTS: ~./' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i '0,/set-my-alias-here.com/s/set-my-alias-here.com/localhost/' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i 's|DEPLOYMENTS_AWS_URI:.*|DEPLOYMENTS_AWS_URI: https://localhost:9000|' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i 's/MINIO_ACCESS_KEY:.*/MINIO_ACCESS_KEY: Q3AM3UQ867SPQQA43P2F/' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i 's/MINIO_SECRET_KEY:.*/MINIO_SECRET_KEY: abcssadasdssado798dsfjhkksd/' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i 's/DEPLOYMENTS_AWS_AUTH_KEY:.*/DEPLOYMENTS_AWS_AUTH_KEY: Q3AM3UQ867SPQQA43P2F/' ../production-testing-env.yml", shell=True)
subprocess.check_output("sed -i 's/DEPLOYMENTS_AWS_AUTH_SECRET:.*/DEPLOYMENTS_AWS_AUTH_SECRET: abcssadasdssado798dsfjhkksd/' ../production-testing-env.yml", shell=True)


def setup_docker_volumes():
docker_volumes = ["mender-artifacts",
"mender-deployments-db",
Expand All @@ -53,19 +68,14 @@ def setup_docker_volumes():
"CERT_STORAGE_CN": "localhost"},
cwd="../")
assert ret == 0, "failed to generate keys"

# copy production environment yml file
if not os.path.exists("../production-testing-env.yml"):
ret = subprocess.call(["cp", "extra/production-testing-env.yml", "."],
cwd="../")
assert ret == 0, "failed to copy extra/production-testing-env.yml"
fill_production_template()

# start docker-compose
ret = subprocess.call(["docker-compose",
"-p", "testprod",
"-f", "docker-compose.yml",
"-f", "docker-compose.storage.minio.yml",
"-f", "production-testing-env.yml",
"-f", "./production-testing-env.yml",
"up", "-d"],
cwd="../")

Expand Down
11 changes: 4 additions & 7 deletions tests/tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ def perform_upgrade():
ret = subprocess.call(["cp", "-r", "tests/upgrade-from/keys-generated", "."], cwd="..")
assert ret == 0, "faled to copy keys from original environment"

ret = subprocess.call(["cp", "extra/production-environment/production-testing-env.yml", "."], cwd="..")
assert ret == 0, "copying extra/production-envrionment folder failed."

ret = subprocess.call(["docker-compose", "-p", "testprod", "-f", "docker-compose.yml", "-f", "docker-compose.storage.minio.yml", "-f", "production-testing-env.yml", "up", "-d"], cwd="..")
assert ret == 0
subprocess.check_call(["./production_test_env.py", "--start"])

# give time for all microservices to come online
time.sleep(30)
Expand Down Expand Up @@ -193,6 +189,7 @@ def test_decommissioning_post_upgrade(self):
def test_run_upgrade_test(upgrade_from):
# run these tests sequentially since they expose the storage proxy and the api gateports to the host
with filelock.FileLock(".update_test_lock"):
t = None
try:
t = BackendUpdating(upgrade_from)
t.test_original_deployments_persisted()
Expand All @@ -204,5 +201,5 @@ def test_run_upgrade_test(upgrade_from):
# exception is handled by pytest
raise e
finally:
if isinstance(t, BackendUpdating):
t.teardown()
if isinstance(t, BackendUpdating):
t.teardown()

0 comments on commit 1ec6476

Please sign in to comment.