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..8e39b7d9 100644 --- a/tests/test_smoketest.py +++ b/tests/test_smoketest.py @@ -119,6 +119,20 @@ 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}'] + 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, 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}"): run_for_json(f"{self.venv_bin}dbio dss delete-bundle --uuid {bundle_uuid} --version {bundle_version} "