From 305a873b9862e8f70c6e07adc20a69402f550516 Mon Sep 17 00:00:00 2001 From: amar jandu Date: Wed, 18 Mar 2020 22:41:08 -0700 Subject: [PATCH 1/3] added support for testing flac --- tests/infra/base_smoketest.py | 13 +++++++++++++ tests/test_smoketest.py | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/infra/base_smoketest.py b/tests/infra/base_smoketest.py index 838f7599..3396580a 100644 --- a/tests/infra/base_smoketest.py +++ b/tests/infra/base_smoketest.py @@ -73,6 +73,7 @@ class BaseSmokeTest(unittest.TestCase): } ] notification_bucket = os.environ['DSS_S3_BUCKET_TEST'] + scripts_dir = os.path.join(os.getenv('DSS_HOME'), 'scripts') @classmethod def setUpClass(cls): @@ -238,6 +239,18 @@ def _test_get_subscriptions(self, replica, requested_subscription, subscription_ list_of_subscription_uuids = [x['uuid'] for x in list_of_subscriptions if x['uuid']] self.assertIn(requested_subscription, list_of_subscription_uuids) + def add_to_flac_table(self, keys: list, groups: list): + """adds given uuid to the flac lookup table""" + return run_for_json(f'{self.scripts_dir}/dss-ops.py flac add --keys {" ".join(keys)}' + f' --groups {" ".join(groups)}') + + def cleanup_from_flac_table(self, keys: list): + self.addCleanup(run, f'{self.scripts_dir}/dss-ops.py flac remove --keys {" ".join(keys)}') + + def get_from_flac_table(self, keys: list): + """adds given uuid to the flac lookup table""" + return run_for_json(f'{self.scripts_dir}/dss-ops.py flac get --keys {" ".join(keys)}') + @staticmethod def _download_bundle(replica_name: str, bundle_uuid: str, workdir: str, venv_bin: str): with tempfile.TemporaryDirectory(prefix=f'{workdir}/') as tempdir: diff --git a/tests/test_smoketest.py b/tests/test_smoketest.py index b15bbbfd..e679eaa9 100644 --- a/tests/test_smoketest.py +++ b/tests/test_smoketest.py @@ -119,6 +119,14 @@ def smoketest(self, starting_replica, checkout_bucket, test_bucket): version=bundle_version): self._test_replay_event(replica, bundle_uuid, bundle_version) + with self.subTest(f'Testing FLAC Lookup for bundles'): + keys = [f'bundles/{bundle_uuid}.{bundle_version}'] + add_bundle = self.add_to_flac_table(keys=keys, groups=['service-account', 'dss_admin']) + self.cleanup_from_flac_table(keys=keys) + self.assertIs(True, add_bundle[0].get('inDatabase')) + for replica in self.replicas: + self._test_get_bundle(replica=replica, bundle_uuid=bundle_uuid) + for replica in self.replicas: with self.subTest(f"{starting_replica.name}: Tombstone the bundle on replica {replica}"): run_for_json(f"{self.venv_bin}dbio dss delete-bundle --uuid {bundle_uuid} --version {bundle_version} " From 92c497273d18c70cda7a9cc99a09e5c31c4a30f5 Mon Sep 17 00:00:00 2001 From: amar jandu Date: Wed, 18 Mar 2020 22:45:48 -0700 Subject: [PATCH 2/3] added get usag --- tests/test_smoketest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_smoketest.py b/tests/test_smoketest.py index e679eaa9..e51f948b 100644 --- a/tests/test_smoketest.py +++ b/tests/test_smoketest.py @@ -121,9 +121,10 @@ def smoketest(self, starting_replica, checkout_bucket, test_bucket): with self.subTest(f'Testing FLAC Lookup for bundles'): keys = [f'bundles/{bundle_uuid}.{bundle_version}'] - add_bundle = self.add_to_flac_table(keys=keys, groups=['service-account', 'dss_admin']) + self.add_to_flac_table(keys=keys, groups=['service-account', 'dss_admin']) + added_bundles = self.get_from_flac_table(keys=keys) self.cleanup_from_flac_table(keys=keys) - self.assertIs(True, add_bundle[0].get('inDatabase')) + self.assertIs(True, added_bundles[0].get('inDatabase')) for replica in self.replicas: self._test_get_bundle(replica=replica, bundle_uuid=bundle_uuid) From e6d33dbce112e4af3a3fc738b4dc13a3f0c1b93c Mon Sep 17 00:00:00 2001 From: amar jandu Date: Wed, 18 Mar 2020 22:51:55 -0700 Subject: [PATCH 3/3] need to sort out the exptected failure --- tests/test_smoketest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_smoketest.py b/tests/test_smoketest.py index e51f948b..8e39b7d9 100644 --- a/tests/test_smoketest.py +++ b/tests/test_smoketest.py @@ -127,6 +127,11 @@ def smoketest(self, starting_replica, checkout_bucket, test_bucket): self.assertIs(True, added_bundles[0].get('inDatabase')) for replica in self.replicas: self._test_get_bundle(replica=replica, bundle_uuid=bundle_uuid) + self.add_to_flac_table(keys=keys, groups=['deny']) + for replica in self.replicas: + self._test_get_bundle(replica=replica, bundle_uuid=bundle_uuid) + # This is going to cause a error in the subprocess, can this be caught because + # its expected? what would be the appropriate way to perform this? for replica in self.replicas: with self.subTest(f"{starting_replica.name}: Tombstone the bundle on replica {replica}"):