From e744d7990cc6b03866ca17790ea6852af6ab992c Mon Sep 17 00:00:00 2001 From: amar jandu Date: Thu, 7 May 2020 09:56:55 -0700 Subject: [PATCH 1/2] move dss-tests away from dss-prod --- test/integration/dss/test_dss_api.py | 4 +++- test/integration/dss/test_dss_api_retry.py | 6 +++++- test/integration/dss/test_dss_cli.py | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/test/integration/dss/test_dss_api.py b/test/integration/dss/test_dss_api.py index 12c87c9d..b3c66145 100755 --- a/test/integration/dss/test_dss_api.py +++ b/test/integration/dss/test_dss_api.py @@ -26,7 +26,9 @@ class TestDssApi(unittest.TestCase): @classmethod def setUpClass(cls): - cls.client = hca.dss.DSSClient() + # Explicitly set to dss-integration rather than what the local config is set to. + # Ensures no bundles are uploaded to dss-prod from operators machine. + cls.client = hca.dss.DSSClient(swagger_url="https://dss.integration.data.humancellatlas.org/v1/swagger.json") def test_set_host(self): with tempfile.TemporaryDirectory() as home: diff --git a/test/integration/dss/test_dss_api_retry.py b/test/integration/dss/test_dss_api_retry.py index 9123febd..53c3e3f4 100755 --- a/test/integration/dss/test_dss_api_retry.py +++ b/test/integration/dss/test_dss_api_retry.py @@ -26,6 +26,10 @@ class TestDssApiRetry(unittest.TestCase): @classmethod def setUpClass(cls): + # Explicitly set to dss-integration rather than what the local config is set to. + # Ensures no bundles are uploaded to dss-prod from operators machine. + cls.client = hca.dss.DSSClient(swagger_url="https://dss.integration.data.humancellatlas.org/v1/swagger.json") + with tempfile.TemporaryDirectory() as src_dir: bundle_path = os.path.join(src_dir, "bundle") os.makedirs(bundle_path) @@ -49,7 +53,7 @@ def test_get_retry(self): Test that GET methods are retried. We instruct the server to fake a 504 with some probability, and we should retry until successful. """ - client = hca.dss.DSSClient() + client = self.client file_uuid = str(uuid.uuid4()) creator_uid = client.config.get("creator_uid", 0) version = datetime.utcnow().strftime("%Y-%m-%dT%H%M%S.%fZ") diff --git a/test/integration/dss/test_dss_cli.py b/test/integration/dss/test_dss_cli.py index b662f777..1cbbc080 100755 --- a/test/integration/dss/test_dss_cli.py +++ b/test/integration/dss/test_dss_cli.py @@ -24,6 +24,24 @@ class TestDssCLI(unittest.TestCase): + @classmethod + def setUpClass(cls): + """ + These tests rely on a logged in env, assert that the stage is not dss-prod + """ + # the dss-api endpoint 'get-bundles-all' provides the stage within the response + args = ["dss", "get-bundles-all", "--replica", "aws", + "--per-page", "10", "--no-paginate"] + with CapturingIO('stdout') as stdout: + hca.cli.main(args) + result = json.loads(stdout.captured()) + try: + assert("https://dss.data.humancellatlas.org" not in result["dss_api"]) + except AssertionError: + print('\nPlease change the DSS swagger endpoint in the HCA config file away from `dss-prod`\n' + 'For more information see: `https://github.com/HumanCellAtlas/dcp-cli#development`') + exit(1) + def test_post_search_cli(self): query = json.dumps({}) replica = "aws" From 1ab2575f051cf2916cff82ef51e91ff086f5e589 Mon Sep 17 00:00:00 2001 From: amar jandu Date: Mon, 11 May 2020 09:00:57 -0700 Subject: [PATCH 2/2] fixup! move dss-tests away from dss-prod --- test/integration/dss/test_dss_cli.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/test/integration/dss/test_dss_cli.py b/test/integration/dss/test_dss_cli.py index 1cbbc080..d6ee0529 100755 --- a/test/integration/dss/test_dss_cli.py +++ b/test/integration/dss/test_dss_cli.py @@ -27,20 +27,12 @@ class TestDssCLI(unittest.TestCase): @classmethod def setUpClass(cls): """ - These tests rely on a logged in env, assert that the stage is not dss-prod + These tests rely on a logged in env, ensure that the current stage is not dss-prod """ - # the dss-api endpoint 'get-bundles-all' provides the stage within the response - args = ["dss", "get-bundles-all", "--replica", "aws", - "--per-page", "10", "--no-paginate"] - with CapturingIO('stdout') as stdout: - hca.cli.main(args) - result = json.loads(stdout.captured()) - try: - assert("https://dss.data.humancellatlas.org" not in result["dss_api"]) - except AssertionError: - print('\nPlease change the DSS swagger endpoint in the HCA config file away from `dss-prod`\n' - 'For more information see: `https://github.com/HumanCellAtlas/dcp-cli#development`') - exit(1) + config = hca.get_config() + if "https://dss.data.humancellatlas.org" in config['DSSClient']['swagger_url']: + raise ValueError('Please change the DSS swagger endpoint in the HCA config file away from `dss-prod`\n' + 'For more information see: `https://github.com/HumanCellAtlas/dcp-cli#development`') def test_post_search_cli(self): query = json.dumps({})