From 288dc5332ed38401914f90630a4c7ca83bee80c5 Mon Sep 17 00:00:00 2001 From: Omar Zevallos <45883639+omzevall@users.noreply.github.com> Date: Tue, 29 Jan 2019 15:23:54 -0500 Subject: [PATCH] Code cleanup (in progress) --- azure-pipelines.yml | 10 +++++----- test/{lib/pytest_fixtures.py => conftest.py} | 0 test/test_avere_template_deploy.py | 1 - test/test_edasim.py | 16 +++++++--------- test/test_vdbench.py | 11 +++++------ test/test_vfxt_cluster_status.py | 2 -- 6 files changed, 17 insertions(+), 23 deletions(-) rename test/{lib/pytest_fixtures.py => conftest.py} (100%) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3fe7fb89..5ae96e28 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,7 +28,7 @@ jobs: displayName: 'Install Python dependencies' - script: | - pytest test/test_avere_template_deploy.py --doctest-modules --junitxml=junit/test-results01.xml + pytest --disable-pytest-warnings test/test_avere_template_deploy.py --doctest-modules --junitxml=junit/test-results01.xml displayName: 'Test template-based deployment of Avere vFXT' env: AVERE_ADMIN_PW: $(controllerpassword) @@ -40,7 +40,7 @@ jobs: VFXT_TEST_VARS_FILE: pipelines.json - script: | - pytest test/test_vfxt_cluster_status.py -k TestVfxtClusterStatus --doctest-modules --junitxml=junit/test-results02.xml + pytest --disable-pytest-warnings test/test_vfxt_cluster_status.py -k TestVfxtClusterStatus --doctest-modules --junitxml=junit/test-results02.xml displayName: 'Test cluster status, health, etc.' condition: succeeded() env: @@ -53,7 +53,7 @@ jobs: VFXT_TEST_VARS_FILE: pipelines.json - script: | - pytest test/test_vfxt_cluster_status.py -k TestVfxtSupport --doctest-modules --junitxml=junit/test-results03.xml + pytest --disable-pytest-warnings test/test_vfxt_cluster_status.py -k TestVfxtSupport --doctest-modules --junitxml=junit/test-results03.xml CONTROLLER_IP=$(grep controller_ip $VFXT_TEST_VARS_FILE | sed -E 's/^.*controller_ip": "([^"]+)".*$/\1/') CONTROLLER_NAME=$(grep controller_name $VFXT_TEST_VARS_FILE | sed -E 's/^.*controller_name": "([^"]+)".*$/\1/') @@ -90,7 +90,7 @@ jobs: VFXT_TEST_VARS_FILE: pipelines.json # - script: | - # pytest test/test_vdbench.py --doctest-modules --junitxml=junit/test-results04.xml + # pytest --disable-pytest-warnings test/test_vdbench.py --doctest-modules --junitxml=junit/test-results04.xml # displayName: 'Test vdbench on Avere vFXT' # env: # AZURE_TENANT_ID: $(SPTENANTID) @@ -100,7 +100,7 @@ jobs: # VFXT_TEST_VARS_FILE: pipelines.json - script: | - pytest test/test_edasim.py --doctest-modules --junitxml=junit/test-results05.xml + pytest --disable-pytest-warnings test/test_edasim.py --doctest-modules --junitxml=junit/test-results05.xml displayName: 'Test edasim on Avere vFXT' env: AZURE_TENANT_ID: $(SPTENANTID) diff --git a/test/lib/pytest_fixtures.py b/test/conftest.py similarity index 100% rename from test/lib/pytest_fixtures.py rename to test/conftest.py diff --git a/test/test_avere_template_deploy.py b/test/test_avere_template_deploy.py index 78600d7a..f4ae1c8a 100755 --- a/test/test_avere_template_deploy.py +++ b/test/test_avere_template_deploy.py @@ -15,7 +15,6 @@ import pytest # local libraries from lib.helpers import split_ip_range, wait_for_op -from lib.pytest_fixtures import resource_group, test_vars # noqa: F401 class TestVfxtTemplateDeploy: diff --git a/test/test_edasim.py b/test/test_edasim.py index 811ab077..69e44087 100644 --- a/test/test_edasim.py +++ b/test/test_edasim.py @@ -15,9 +15,7 @@ import pytest import requests # local libraries -from lib import helpers -from lib.pytest_fixtures import (mnt_nodes, resource_group, # noqa: F401 - scp_cli, ssh_con, storage_account, test_vars) +from lib.helpers import run_ssh_commands, wait_for_op class TestEdasim: @@ -29,7 +27,7 @@ class TestEdasim: echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> ~/.profile source ~/.profile && cd $GOPATH && go get -v github.com/Azure/Avere/src/go/... """.split("\n") - helpers.run_ssh_commands(ssh_con, commands) + run_ssh_commands(ssh_con, commands) def test_storage_account(self, resource_group, ssh_con, storage_account, test_vars): # noqa: F811, E501 log = logging.getLogger("test_storage_account") @@ -45,7 +43,7 @@ class TestEdasim: export AZURE_STORAGE_ACCOUNT= {0} export AZURE_STORAGE_ACCOUNT_KEY={1} """.format(storage_account.name, key).split("\n") - helpers.run_ssh_commands(ssh_con, commands) + run_ssh_commands(ssh_con, commands) test_vars["cmd1"] = "AZURE_STORAGE_ACCOUNT=\"{}\" AZURE_STORAGE_ACCOUNT_KEY=\"{}\" ".format(storage_account.name, key) def test_event_hub(self, ssh_con, test_vars): # noqa: F811 @@ -64,7 +62,7 @@ class TestEdasim: atd.deploy_name = "test_event_hub" log.debug('Generated deploy parameters: \n{}'.format( json.dumps(atd.deploy_params, indent=4))) - deploy_result = helpers.wait_for_op(atd.deploy()) + deploy_result = wait_for_op(atd.deploy()) test_vars["deploy_eh_outputs"] = deploy_result.properties.outputs log.debug(test_vars["deploy_eh_outputs"]) policy_primary_key = test_vars["deploy_eh_outputs"]["eventHubSharedAccessPolicyPrimaryKey"]["value"] @@ -74,7 +72,7 @@ class TestEdasim: export AZURE_EVENTHUB_SENDERKEY={0} export AZURE_EVENTHUB_NAMESPACENAME="edasimeventhub2" """.format(policy_primary_key).split("\n") - helpers.run_ssh_commands(ssh_con, commands) + run_ssh_commands(ssh_con, commands) test_vars["cmd2"] = "AZURE_EVENTHUB_SENDERKEYNAME=\"RootManageSharedAccessKey\" AZURE_EVENTHUB_SENDERKEY=\"{}\" AZURE_EVENTHUB_NAMESPACENAME=\"edasimeventhub2\"".format(policy_primary_key) def test_edasim_setup(self, mnt_nodes, ssh_con): # noqa: F811 @@ -100,7 +98,7 @@ class TestEdasim: sudo curl --retry 5 --retry-delay 5 -o orchestrator.service https://raw.githubusercontent.com/Azure/Avere/master/src/go/cmd/edasim/deploymentartifacts/bootstrap/systemd/orchestrator.service sudo curl --retry 5 --retry-delay 5 -o worker.service https://raw.githubusercontent.com/Azure/Avere/master/src/go/cmd/edasim/deploymentartifacts/bootstrap/systemd/worker.service """.split("\n") - helpers.run_ssh_commands(ssh_con, commands) + run_ssh_commands(ssh_con, commands) def test_edasim_deploy(self, test_vars): # noqa: F811 atd = test_vars["atd_obj"] @@ -120,7 +118,7 @@ class TestEdasim: "nfsExportPath": "/msazure", } atd.deploy_name = "test_edasim_deploy" - deploy_result = helpers.wait_for_op(atd.deploy()) + deploy_result = wait_for_op(atd.deploy()) test_vars["deploy_edasim_outputs"] = deploy_result.properties.outputs diff --git a/test/test_vdbench.py b/test/test_vdbench.py index 74b13841..ee10ca6d 100644 --- a/test/test_vdbench.py +++ b/test/test_vdbench.py @@ -17,8 +17,7 @@ from scp import SCPClient from sshtunnel import SSHTunnelForwarder # local libraries -from lib import helpers -from lib.pytest_fixtures import (mnt_nodes, ssh_con, test_vars) # noqa: F401 +from lib.helpers import create_ssh_client, run_ssh_commands, wait_for_op class TestVDBench: @@ -33,7 +32,7 @@ class TestVDBench: sudo chmod +x /nfs/node0/bootstrap/vdbenchVerify.sh /nfs/node0/bootstrap/vdbenchVerify.sh """.split("\n") - helpers.run_ssh_commands(ssh_con, commands) + run_ssh_commands(ssh_con, commands) def test_vdbench_deploy(self, test_vars): # noqa: F811 log = logging.getLogger("test_vdbench_deploy") @@ -56,7 +55,7 @@ class TestVDBench: "bootstrapScriptPath": "/bootstrap/bootstrap.vdbench.sh", } atd.deploy_name = "test_vdbench" - deploy_result = helpers.wait_for_op(atd.deploy()) + deploy_result = wait_for_op(atd.deploy()) test_vars["deploy_vd_outputs"] = deploy_result.properties.outputs def test_vdbench_run(self, test_vars): # noqa: F811 @@ -70,7 +69,7 @@ class TestVDBench: ) as ssh_tunnel: sleep(1) try: - ssh_client = helpers.create_ssh_client( + ssh_client = create_ssh_client( test_vars["controller_user"], "127.0.0.1", ssh_tunnel.local_bind_port, @@ -86,7 +85,7 @@ class TestVDBench: cd ./run_vdbench.sh inmem.conf uniquestring1 """.split("\n") - helpers.run_ssh_commands(ssh_client, commands) + run_ssh_commands(ssh_client, commands) finally: ssh_client.close() diff --git a/test/test_vfxt_cluster_status.py b/test/test_vfxt_cluster_status.py index b4a9ebec..69ce4122 100644 --- a/test/test_vfxt_cluster_status.py +++ b/test/test_vfxt_cluster_status.py @@ -16,8 +16,6 @@ from sshtunnel import SSHTunnelForwarder # local libraries from lib.helpers import (create_ssh_client, run_averecmd, run_ssh_commands, upload_gsi) -from lib.pytest_fixtures import (averecmd_params, mnt_nodes, # noqa: F401 - resource_group, scp_cli, ssh_con, test_vars) class TestVfxtClusterStatus: