From 43b17a46c3080af7ac20059ea746fe5e8a914c6d Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 15:36:29 -0600 Subject: [PATCH 01/20] add nosetests --- .github/workflows/qiita-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/qiita-ci.yml b/.github/workflows/qiita-ci.yml index ebfd92c..decb524 100644 --- a/.github/workflows/qiita-ci.yml +++ b/.github/workflows/qiita-ci.yml @@ -119,6 +119,8 @@ jobs: conda activate qiita_client export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg + nosetests --with-doctest --with-coverage --cover-package=qiita_client + - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} From 671f4c4e4fba1ebaa45e1d822282cbac46019d93 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 15:49:01 -0600 Subject: [PATCH 02/20] QIITA_CLIENT_DEBUG_LEVEL --- .github/workflows/qiita-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/qiita-ci.yml b/.github/workflows/qiita-ci.yml index decb524..635a979 100644 --- a/.github/workflows/qiita-ci.yml +++ b/.github/workflows/qiita-ci.yml @@ -119,6 +119,7 @@ jobs: conda activate qiita_client export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg + export QIITA_CLIENT_DEBUG_LEVEL=DEBUG nosetests --with-doctest --with-coverage --cover-package=qiita_client - uses: codecov/codecov-action@v3 From 80e57da72e80283749b97b6221688805aac3feb0 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 16:00:17 -0600 Subject: [PATCH 03/20] cls.rootca --- qiita_client/testing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qiita_client/testing.py b/qiita_client/testing.py index 89e7a25..375db7a 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -24,12 +24,14 @@ def setUpClass(cls): cls.client_id = '19ndkO3oMKsoChjVVWluF7QkxHRfYhTKSFbAVt8IhK7gZgDaO4' cls.client_secret = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh' 'AmmCWZuabe0O5Mp28s1') + cls.rootca = environ.get('QIITA_ROOTCA_CERT', None) qiita_port = int(environ.get('QIITA_PORT', 21174)) # do not rely on defining ca_cert for these tests. Instead append # the appropriate CA cert to certifi's pem file. cls.qclient = QiitaClient("https://localhost:%d" % qiita_port, - cls.client_id, cls.client_secret) + cls.client_id, cls.rootca) + logger.debug( 'PluginTestCase.setUpClass() token %s' % cls.qclient._token) cls.qclient.post('/apitest/reload_plugins/') From 937fdd98e46d7a452973112c98f2ae3bba4fa288 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 16:11:22 -0600 Subject: [PATCH 04/20] SERVER_CERT = %s --- qiita_client/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiita_client/plugin.py b/qiita_client/plugin.py index a0fdc53..c41ea42 100644 --- a/qiita_client/plugin.py +++ b/qiita_client/plugin.py @@ -379,5 +379,6 @@ def register_command(self, command): PUBLICATIONS = %s [oauth2] +SERVER_CERT = %s CLIENT_ID = %s CLIENT_SECRET = %s""" From cb9f78fb13dc3f16ea754aa10879b22806cff2ca Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 16:15:52 -0600 Subject: [PATCH 05/20] QIITA_SERVER_CERT=$QIITA_ROOTCA_CERT --- .github/workflows/qiita-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/qiita-ci.yml b/.github/workflows/qiita-ci.yml index 635a979..047cdff 100644 --- a/.github/workflows/qiita-ci.yml +++ b/.github/workflows/qiita-ci.yml @@ -118,6 +118,7 @@ jobs: run: | conda activate qiita_client export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt + export QIITA_SERVER_CERT=$QIITA_ROOTCA_CERT export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg export QIITA_CLIENT_DEBUG_LEVEL=DEBUG nosetests --with-doctest --with-coverage --cover-package=qiita_client From 3a38b6d1661f4e11e4553478ec6653673df99149 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 16:30:23 -0600 Subject: [PATCH 06/20] adding cls.client_secret, cls.rootca) --- qiita_client/plugin.py | 2 +- qiita_client/testing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qiita_client/plugin.py b/qiita_client/plugin.py index c41ea42..3af462e 100644 --- a/qiita_client/plugin.py +++ b/qiita_client/plugin.py @@ -250,7 +250,7 @@ def __call__(self, server_url, job_id, output_dir): # this value will prevent underlying libraries # from validating the server's cert using # certifi's pem cache. - ca_cert=environ['QIITA_ROOTCA_CERT']) + ca_cert=config.get('oauth2', 'SERVER_CERT')) if job_id == 'register': self._register(qclient) diff --git a/qiita_client/testing.py b/qiita_client/testing.py index 375db7a..5c3b322 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -30,7 +30,7 @@ def setUpClass(cls): # do not rely on defining ca_cert for these tests. Instead append # the appropriate CA cert to certifi's pem file. cls.qclient = QiitaClient("https://localhost:%d" % qiita_port, - cls.client_id, cls.rootca) + cls.client_id, cls.client_secret, cls.rootca) logger.debug( 'PluginTestCase.setUpClass() token %s' % cls.qclient._token) From fa2f65db55e96f38fb9af8d4f4ec4a22fe680294 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 12 Aug 2024 18:40:29 -0600 Subject: [PATCH 07/20] reduce sleep time --- qiita_client/qiita_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index 610097f..024875b 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -29,8 +29,8 @@ JOB_COMPLETED = False MAX_RETRIES = 3 -MIN_TIME_SLEEP = 180 -MAX_TIME_SLEEP = 360 +MIN_TIME_SLEEP = 1 +MAX_TIME_SLEEP = 3 BLANK_FILE_THRESHOLD = 100 From 4c965e96130094a16276df40c0ae0275c5fcbeb0 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 06:52:24 -0600 Subject: [PATCH 08/20] self.ca_cert --- qiita_client/qiita_client.py | 13 ++++++++++--- qiita_client/tests/test_qiita_client.py | 11 +++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index 024875b..0dde6f5 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -28,9 +28,16 @@ logger = logging.getLogger(__name__) JOB_COMPLETED = False -MAX_RETRIES = 3 -MIN_TIME_SLEEP = 1 -MAX_TIME_SLEEP = 3 +# if the log level is DEBUG we should never expect slow response so let's +# make the retries as small as posible +if logger.level == logging.DEBUG: + MAX_RETRIES = 1 + MIN_TIME_SLEEP = 1 + MAX_TIME_SLEEP = 2 +else: + MAX_RETRIES = 3 + MIN_TIME_SLEEP = 180 + MAX_TIME_SLEEP = 3 BLANK_FILE_THRESHOLD = 100 diff --git a/qiita_client/tests/test_qiita_client.py b/qiita_client/tests/test_qiita_client.py index 17184e1..02593ac 100644 --- a/qiita_client/tests/test_qiita_client.py +++ b/qiita_client/tests/test_qiita_client.py @@ -97,12 +97,15 @@ def test_format_payload_error(self): class QiitaClientTests(PluginTestCase): def setUp(self): + self.ca_cert = environ['QIITA_ROOT_CA'] self.tester = QiitaClient("https://localhost:21174", CLIENT_ID, - CLIENT_SECRET) + CLIENT_SECRET, + self.ca_cert) self.bad_tester = QiitaClient("https://localhost:21174", BAD_CLIENT_ID, - CLIENT_SECRET) + CLIENT_SECRET, + self.ca_cert) self.clean_up_files = [] # making assertRaisesRegex compatible with Python 2.7 and 3.9 @@ -118,11 +121,11 @@ def test_init(self): obs = QiitaClient("https://localhost:21174", CLIENT_ID, CLIENT_SECRET, - ca_cert=environ['QIITA_ROOT_CA']) + ca_cert=self.ca_cert) self.assertEqual(obs._server_url, "https://localhost:21174") self.assertEqual(obs._client_id, CLIENT_ID) self.assertEqual(obs._client_secret, CLIENT_SECRET) - self.assertEqual(obs._verify, environ['QIITA_ROOT_CA']) + self.assertEqual(obs._verify, self.ca_cert) def test_get(self): obs = self.tester.get("/qiita_db/artifacts/1/") From 8412f82fed4922c3dcc45016fb3085e1907704ba Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 07:01:01 -0600 Subject: [PATCH 09/20] environ.get --- qiita_client/tests/test_plugin.py | 3 ++- qiita_client/tests/test_qiita_client.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qiita_client/tests/test_plugin.py b/qiita_client/tests/test_plugin.py index 4981cfa..9ebc376 100644 --- a/qiita_client/tests/test_plugin.py +++ b/qiita_client/tests/test_plugin.py @@ -146,7 +146,8 @@ def html_generator_func(a, b, c, d): 'PLUGIN_TYPE = artifact definition\n', 'PUBLICATIONS = \n', '\n', - '[oauth2]\n'] + '[oauth2]\n', + 'SERVER_CERT = \n'] # We will test the last 2 lines independently since they're variable # in each test run self.assertEqual(conf[:-2], exp_lines) diff --git a/qiita_client/tests/test_qiita_client.py b/qiita_client/tests/test_qiita_client.py index 02593ac..bbae0bb 100644 --- a/qiita_client/tests/test_qiita_client.py +++ b/qiita_client/tests/test_qiita_client.py @@ -97,7 +97,7 @@ def test_format_payload_error(self): class QiitaClientTests(PluginTestCase): def setUp(self): - self.ca_cert = environ['QIITA_ROOT_CA'] + self.ca_cert = environ.get('QIITA_ROOT_CA', None) self.tester = QiitaClient("https://localhost:21174", CLIENT_ID, CLIENT_SECRET, From 02cb634cf1f8b569361a2e35a57ac97a7e6eef03 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 07:06:42 -0600 Subject: [PATCH 10/20] MIN_TIME_SLEEP = 0 --- qiita_client/qiita_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index 0dde6f5..0880360 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -32,7 +32,7 @@ # make the retries as small as posible if logger.level == logging.DEBUG: MAX_RETRIES = 1 - MIN_TIME_SLEEP = 1 + MIN_TIME_SLEEP = 0 MAX_TIME_SLEEP = 2 else: MAX_RETRIES = 3 From 9bb14da9e420a3cd33b5660416474bbec0a11449 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 07:24:26 -0600 Subject: [PATCH 11/20] MAX_TIME_SLEEP = 360 --- qiita_client/qiita_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index 0880360..278a91b 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -32,12 +32,12 @@ # make the retries as small as posible if logger.level == logging.DEBUG: MAX_RETRIES = 1 - MIN_TIME_SLEEP = 0 - MAX_TIME_SLEEP = 2 + MIN_TIME_SLEEP = 1 + MAX_TIME_SLEEP = 3 else: MAX_RETRIES = 3 MIN_TIME_SLEEP = 180 - MAX_TIME_SLEEP = 3 + MAX_TIME_SLEEP = 360 BLANK_FILE_THRESHOLD = 100 From b0a060c40ad2852e77ac1d4b759f39ce80394813 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 07:34:10 -0600 Subject: [PATCH 12/20] logging.CRITICAL --- qiita_client/qiita_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index 278a91b..8425f90 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -28,9 +28,9 @@ logger = logging.getLogger(__name__) JOB_COMPLETED = False -# if the log level is DEBUG we should never expect slow response so let's -# make the retries as small as posible -if logger.level == logging.DEBUG: +# if the log level is not CRITICAL, the default, then we not expect slow +# responses from the server so let's make the retries values small +if logger.level != logging.CRITICAL: MAX_RETRIES = 1 MIN_TIME_SLEEP = 1 MAX_TIME_SLEEP = 3 From 4793fd2b1d339762f4d7c3c6e81b650f5a6473b9 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 07:50:55 -0600 Subject: [PATCH 13/20] 21174 -> 8383 --- qiita_client/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_client/testing.py b/qiita_client/testing.py index 5c3b322..c6b0cec 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -25,7 +25,7 @@ def setUpClass(cls): cls.client_secret = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh' 'AmmCWZuabe0O5Mp28s1') cls.rootca = environ.get('QIITA_ROOTCA_CERT', None) - qiita_port = int(environ.get('QIITA_PORT', 21174)) + qiita_port = int(environ.get('QIITA_PORT', 8383)) # do not rely on defining ca_cert for these tests. Instead append # the appropriate CA cert to certifi's pem file. From b1fe0af5d94575409e8c833dd5eee7e33916893e Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 08:03:00 -0600 Subject: [PATCH 14/20] 21174 -> 8383 --- README.md | 2 +- qiita_client/tests/test_plugin.py | 6 +++--- qiita_client/tests/test_qiita_client.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7dfeedf..2f7eb4d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This package includes the Qiita Client utility library, a library to simplify th How to test this package? ------------------------- -In order to test the Qiita Client package, a local installation of Qiita should be running in test mode on the address `https://localhost:21174`, with the default test database created in Qiita's test suite. +In order to test the Qiita Client package, a local installation of Qiita should be running in test mode on the address `https://localhost:8383`, with the default test database created in Qiita's test suite. Also, if Qiita is running with the default server SSL certificate, you need to export the variable `QIITA_ROOTCA_CERT` in your environment, so the Qiita Client can perform secure connections against the Qiita server: ```bash diff --git a/qiita_client/tests/test_plugin.py b/qiita_client/tests/test_plugin.py index 9ebc376..7af6d1b 100644 --- a/qiita_client/tests/test_plugin.py +++ b/qiita_client/tests/test_plugin.py @@ -173,7 +173,7 @@ def html_generator_func(a, b, c, d): self.qclient.post('/apitest/reload_plugins/') # Install the current plugin - tester("https://localhost:21174", 'register', 'ignored') + tester("https://localhost:8383", 'register', 'ignored') # Check that it has been installed obs = self.qclient.get('/qiita_db/plugins/NewPlugin/1.0.0/') @@ -214,7 +214,7 @@ def func(qclient, job_id, job_params, working_dir): tester.generate_config('ls', 'echo') self.qclient.post('/apitest/reload_plugins/') - tester("https://localhost:21174", 'register', 'ignored') + tester("https://localhost:8383", 'register', 'ignored') obs = self.qclient.get('/qiita_db/plugins/NewPlugin/0.0.1/') self.assertEqual(obs['name'], 'NewPlugin') @@ -230,7 +230,7 @@ def func(qclient, job_id, job_params, working_dir): 'status': 'queued'} job_id = self.qclient.post('/apitest/processing_job/', data=data)['job'] - tester("https://localhost:21174", job_id, self.outdir) + tester("https://localhost:8383", job_id, self.outdir) status = self._wait_for_running_job(job_id) self.assertEqual(status, 'success') diff --git a/qiita_client/tests/test_qiita_client.py b/qiita_client/tests/test_qiita_client.py index bbae0bb..a31342e 100644 --- a/qiita_client/tests/test_qiita_client.py +++ b/qiita_client/tests/test_qiita_client.py @@ -98,11 +98,11 @@ def test_format_payload_error(self): class QiitaClientTests(PluginTestCase): def setUp(self): self.ca_cert = environ.get('QIITA_ROOT_CA', None) - self.tester = QiitaClient("https://localhost:21174", + self.tester = QiitaClient("https://localhost:8383", CLIENT_ID, CLIENT_SECRET, self.ca_cert) - self.bad_tester = QiitaClient("https://localhost:21174", + self.bad_tester = QiitaClient("https://localhost:8383", BAD_CLIENT_ID, CLIENT_SECRET, self.ca_cert) @@ -118,11 +118,11 @@ def tearDown(self): remove(fp) def test_init(self): - obs = QiitaClient("https://localhost:21174", + obs = QiitaClient("https://localhost:8383", CLIENT_ID, CLIENT_SECRET, ca_cert=self.ca_cert) - self.assertEqual(obs._server_url, "https://localhost:21174") + self.assertEqual(obs._server_url, "https://localhost:8383") self.assertEqual(obs._client_id, CLIENT_ID) self.assertEqual(obs._client_secret, CLIENT_SECRET) self.assertEqual(obs._verify, self.ca_cert) From 6b217781d3e4ee7b27aa1e79416cdfeb7b0e6afb Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 13 Aug 2024 09:31:22 -0600 Subject: [PATCH 15/20] raise retry times --- qiita_client/qiita_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index 8425f90..ae98c24 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -31,9 +31,9 @@ # if the log level is not CRITICAL, the default, then we not expect slow # responses from the server so let's make the retries values small if logger.level != logging.CRITICAL: - MAX_RETRIES = 1 - MIN_TIME_SLEEP = 1 - MAX_TIME_SLEEP = 3 + MAX_RETRIES = 2 + MIN_TIME_SLEEP = 3 + MAX_TIME_SLEEP = 10 else: MAX_RETRIES = 3 MIN_TIME_SLEEP = 180 From 04b0705c47bac19d8bc44dafae9b65bd938094c3 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 19 Aug 2024 08:12:20 -0600 Subject: [PATCH 16/20] environ.get(QIITA_ROOTCA_CERT) --- .github/workflows/qiita-ci.yml | 1 - qiita_client/testing.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/qiita-ci.yml b/.github/workflows/qiita-ci.yml index 047cdff..635a979 100644 --- a/.github/workflows/qiita-ci.yml +++ b/.github/workflows/qiita-ci.yml @@ -118,7 +118,6 @@ jobs: run: | conda activate qiita_client export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt - export QIITA_SERVER_CERT=$QIITA_ROOTCA_CERT export QIITA_CONFIG_FP=`pwd`/qiita-dev/qiita_core/support_files/config_test_local.cfg export QIITA_CLIENT_DEBUG_LEVEL=DEBUG nosetests --with-doctest --with-coverage --cover-package=qiita_client diff --git a/qiita_client/testing.py b/qiita_client/testing.py index c6b0cec..5c4cc3f 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -24,7 +24,7 @@ def setUpClass(cls): cls.client_id = '19ndkO3oMKsoChjVVWluF7QkxHRfYhTKSFbAVt8IhK7gZgDaO4' cls.client_secret = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh' 'AmmCWZuabe0O5Mp28s1') - cls.rootca = environ.get('QIITA_ROOTCA_CERT', None) + cls.rootca = environ.get('QIITA_ROOTCA_CERT') qiita_port = int(environ.get('QIITA_PORT', 8383)) # do not rely on defining ca_cert for these tests. Instead append From 991d9140fd9029a60f7bc4ba6e1e370f8ddcf5bb Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 19 Aug 2024 10:50:30 -0600 Subject: [PATCH 17/20] installing current version in qiita --- .github/workflows/qiita-ci.yml | 6 ++++++ qiita_client/testing.py | 6 +++--- qiita_client/tests/test_plugin.py | 7 ++++--- qiita_client/tests/test_qiita_client.py | 10 +++++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/qiita-ci.yml b/.github/workflows/qiita-ci.yml index 635a979..d09ac5e 100644 --- a/.github/workflows/qiita-ci.yml +++ b/.github/workflows/qiita-ci.yml @@ -81,6 +81,12 @@ jobs: conda activate qiita_client pip --quiet install . + # Note that the qiita conda environment has installed the qiita_client "master branch" + # but to fully test we need to install the current branch of qiita_client + conda deactivate + conda activate qiita + pip --quiet install . + - name: Starting Main Services shell: bash -l {0} run: | diff --git a/qiita_client/testing.py b/qiita_client/testing.py index 5c4cc3f..cd84b4d 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -15,6 +15,7 @@ import logging logger = logging.getLogger(__name__) +URL = "https://localhost:8383" class PluginTestCase(TestCase): @@ -25,12 +26,11 @@ def setUpClass(cls): cls.client_secret = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh' 'AmmCWZuabe0O5Mp28s1') cls.rootca = environ.get('QIITA_ROOTCA_CERT') - qiita_port = int(environ.get('QIITA_PORT', 8383)) # do not rely on defining ca_cert for these tests. Instead append # the appropriate CA cert to certifi's pem file. - cls.qclient = QiitaClient("https://localhost:%d" % qiita_port, - cls.client_id, cls.client_secret, cls.rootca) + cls.qclient = QiitaClient( + URL, cls.client_id, cls.client_secret, cls.rootca) logger.debug( 'PluginTestCase.setUpClass() token %s' % cls.qclient._token) diff --git a/qiita_client/tests/test_plugin.py b/qiita_client/tests/test_plugin.py index 7af6d1b..bce88e1 100644 --- a/qiita_client/tests/test_plugin.py +++ b/qiita_client/tests/test_plugin.py @@ -16,6 +16,7 @@ from qiita_client.testing import PluginTestCase from qiita_client import (QiitaPlugin, QiitaTypePlugin, QiitaCommand, QiitaArtifactType, ArtifactInfo) +from .testing import URL class QiitaCommandTest(TestCase): @@ -173,7 +174,7 @@ def html_generator_func(a, b, c, d): self.qclient.post('/apitest/reload_plugins/') # Install the current plugin - tester("https://localhost:8383", 'register', 'ignored') + tester(URL, 'register', 'ignored') # Check that it has been installed obs = self.qclient.get('/qiita_db/plugins/NewPlugin/1.0.0/') @@ -214,7 +215,7 @@ def func(qclient, job_id, job_params, working_dir): tester.generate_config('ls', 'echo') self.qclient.post('/apitest/reload_plugins/') - tester("https://localhost:8383", 'register', 'ignored') + tester(URL, 'register', 'ignored') obs = self.qclient.get('/qiita_db/plugins/NewPlugin/0.0.1/') self.assertEqual(obs['name'], 'NewPlugin') @@ -230,7 +231,7 @@ def func(qclient, job_id, job_params, working_dir): 'status': 'queued'} job_id = self.qclient.post('/apitest/processing_job/', data=data)['job'] - tester("https://localhost:8383", job_id, self.outdir) + tester(URL, job_id, self.outdir) status = self._wait_for_running_job(job_id) self.assertEqual(status, 'success') diff --git a/qiita_client/tests/test_qiita_client.py b/qiita_client/tests/test_qiita_client.py index a31342e..4d0efa4 100644 --- a/qiita_client/tests/test_qiita_client.py +++ b/qiita_client/tests/test_qiita_client.py @@ -97,15 +97,11 @@ def test_format_payload_error(self): class QiitaClientTests(PluginTestCase): def setUp(self): - self.ca_cert = environ.get('QIITA_ROOT_CA', None) + self.ca_cert = environ.get('QIITA_ROOT_CA') self.tester = QiitaClient("https://localhost:8383", CLIENT_ID, CLIENT_SECRET, self.ca_cert) - self.bad_tester = QiitaClient("https://localhost:8383", - BAD_CLIENT_ID, - CLIENT_SECRET, - self.ca_cert) self.clean_up_files = [] # making assertRaisesRegex compatible with Python 2.7 and 3.9 @@ -247,6 +243,10 @@ def test_update_job_step_ignore_failure(self): # confirm that update_job_step behaves as before when ignore_error # parameter absent or set to False. + self.bad_tester = QiitaClient("https://localhost:8383", + BAD_CLIENT_ID, + CLIENT_SECRET, + self.ca_cert) with self.assertRaises(BaseException): self.bad_tester.update_job_step(job_id, new_step) From 3cc5f6655d8dcea6476920b52d3187d20802fc33 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 19 Aug 2024 11:03:28 -0600 Subject: [PATCH 18/20] localhost->127.0.0.1 --- qiita_client/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_client/testing.py b/qiita_client/testing.py index cd84b4d..1b6c5ff 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -15,7 +15,7 @@ import logging logger = logging.getLogger(__name__) -URL = "https://localhost:8383" +URL = "https://127.0.0.1:8383" class PluginTestCase(TestCase): From ec6f9b56f4e9a88e507965da1eebe2f4b4ce2ec7 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 19 Aug 2024 15:34:07 -0600 Subject: [PATCH 19/20] self.ca_cert --- qiita_client/qiita_client.py | 4 ++-- qiita_client/testing.py | 6 +++--- qiita_client/tests/test_plugin.py | 2 +- qiita_client/tests/test_qiita_client.py | 17 ++++++++--------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/qiita_client/qiita_client.py b/qiita_client/qiita_client.py index ae98c24..ca7b189 100644 --- a/qiita_client/qiita_client.py +++ b/qiita_client/qiita_client.py @@ -32,8 +32,8 @@ # responses from the server so let's make the retries values small if logger.level != logging.CRITICAL: MAX_RETRIES = 2 - MIN_TIME_SLEEP = 3 - MAX_TIME_SLEEP = 10 + MIN_TIME_SLEEP = 2 + MAX_TIME_SLEEP = 5 else: MAX_RETRIES = 3 MIN_TIME_SLEEP = 180 diff --git a/qiita_client/testing.py b/qiita_client/testing.py index 1b6c5ff..da55598 100644 --- a/qiita_client/testing.py +++ b/qiita_client/testing.py @@ -15,7 +15,7 @@ import logging logger = logging.getLogger(__name__) -URL = "https://127.0.0.1:8383" +URL = "https://localhost:8383" class PluginTestCase(TestCase): @@ -25,12 +25,12 @@ def setUpClass(cls): cls.client_id = '19ndkO3oMKsoChjVVWluF7QkxHRfYhTKSFbAVt8IhK7gZgDaO4' cls.client_secret = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh' 'AmmCWZuabe0O5Mp28s1') - cls.rootca = environ.get('QIITA_ROOTCA_CERT') + cls.ca_cert = environ.get('QIITA_ROOTCA_CERT') # do not rely on defining ca_cert for these tests. Instead append # the appropriate CA cert to certifi's pem file. cls.qclient = QiitaClient( - URL, cls.client_id, cls.client_secret, cls.rootca) + URL, cls.client_id, cls.client_secret, cls.ca_cert) logger.debug( 'PluginTestCase.setUpClass() token %s' % cls.qclient._token) diff --git a/qiita_client/tests/test_plugin.py b/qiita_client/tests/test_plugin.py index bce88e1..62e20a6 100644 --- a/qiita_client/tests/test_plugin.py +++ b/qiita_client/tests/test_plugin.py @@ -16,8 +16,8 @@ from qiita_client.testing import PluginTestCase from qiita_client import (QiitaPlugin, QiitaTypePlugin, QiitaCommand, QiitaArtifactType, ArtifactInfo) -from .testing import URL +URL = 'https://localhost:21174' class QiitaCommandTest(TestCase): def setUp(self): diff --git a/qiita_client/tests/test_qiita_client.py b/qiita_client/tests/test_qiita_client.py index 4d0efa4..f713d89 100644 --- a/qiita_client/tests/test_qiita_client.py +++ b/qiita_client/tests/test_qiita_client.py @@ -15,7 +15,7 @@ from qiita_client.qiita_client import (QiitaClient, _format_payload, ArtifactInfo) -from qiita_client.testing import PluginTestCase +from qiita_client.testing import PluginTestCase, URL from qiita_client.exceptions import BadRequestError CLIENT_ID = '19ndkO3oMKsoChjVVWluF7QkxHRfYhTKSFbAVt8IhK7gZgDaO4' @@ -97,11 +97,9 @@ def test_format_payload_error(self): class QiitaClientTests(PluginTestCase): def setUp(self): - self.ca_cert = environ.get('QIITA_ROOT_CA') - self.tester = QiitaClient("https://localhost:8383", + self.tester = QiitaClient(URL, CLIENT_ID, - CLIENT_SECRET, - self.ca_cert) + CLIENT_SECRET, self.ca_cert) self.clean_up_files = [] # making assertRaisesRegex compatible with Python 2.7 and 3.9 @@ -114,11 +112,11 @@ def tearDown(self): remove(fp) def test_init(self): - obs = QiitaClient("https://localhost:8383", + obs = QiitaClient(URL, CLIENT_ID, CLIENT_SECRET, ca_cert=self.ca_cert) - self.assertEqual(obs._server_url, "https://localhost:8383") + self.assertEqual(obs._server_url, URL) self.assertEqual(obs._client_id, CLIENT_ID) self.assertEqual(obs._client_secret, CLIENT_SECRET) self.assertEqual(obs._verify, self.ca_cert) @@ -243,13 +241,14 @@ def test_update_job_step_ignore_failure(self): # confirm that update_job_step behaves as before when ignore_error # parameter absent or set to False. - self.bad_tester = QiitaClient("https://localhost:8383", + self.bad_tester = QiitaClient(URL, BAD_CLIENT_ID, CLIENT_SECRET, self.ca_cert) with self.assertRaises(BaseException): - self.bad_tester.update_job_step(job_id, new_step) + self.bad_tester.update_job_step( + job_id, new_step, ignore_error=False) with self.assertRaises(BaseException): self.bad_tester.update_job_step(job_id, From 06015101cc91af5af5e4a79a1ae78fe265485d48 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 19 Aug 2024 16:03:23 -0600 Subject: [PATCH 20/20] fix test_plugin.py --- qiita_client/tests/test_plugin.py | 7 +++---- qiita_client/tests/test_qiita_client.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/qiita_client/tests/test_plugin.py b/qiita_client/tests/test_plugin.py index 62e20a6..ab87f6b 100644 --- a/qiita_client/tests/test_plugin.py +++ b/qiita_client/tests/test_plugin.py @@ -13,11 +13,10 @@ from json import dumps from tempfile import mkdtemp -from qiita_client.testing import PluginTestCase +from qiita_client.testing import PluginTestCase, URL from qiita_client import (QiitaPlugin, QiitaTypePlugin, QiitaCommand, QiitaArtifactType, ArtifactInfo) -URL = 'https://localhost:21174' class QiitaCommandTest(TestCase): def setUp(self): @@ -169,7 +168,7 @@ def html_generator_func(a, b, c, d): validate_func, html_generator_func, atypes) # Generate the config file for the new plugin - tester.generate_config('ls', 'echo') + tester.generate_config('ls', 'echo', self.ca_cert) # Ask Qiita to reload the plugins self.qclient.post('/apitest/reload_plugins/') @@ -213,7 +212,7 @@ def func(qclient, job_id, job_params, working_dir): {'out1': 'Demultiplexed'}) tester.register_command(a_cmd) - tester.generate_config('ls', 'echo') + tester.generate_config('ls', 'echo', self.ca_cert) self.qclient.post('/apitest/reload_plugins/') tester(URL, 'register', 'ignored') diff --git a/qiita_client/tests/test_qiita_client.py b/qiita_client/tests/test_qiita_client.py index f713d89..87178b0 100644 --- a/qiita_client/tests/test_qiita_client.py +++ b/qiita_client/tests/test_qiita_client.py @@ -7,7 +7,7 @@ # ----------------------------------------------------------------------------- from unittest import TestCase, main -from os import remove, close, environ +from os import remove, close from os.path import basename, exists from tempfile import mkstemp from json import dumps