def clean_resources(ctx, user, test_id, logdir, config_file): # pylint: disable=too-many-arguments,too-many-branches add_file_logger() params = dict() if config_file or logdir: if not logdir: logdir = Setup.base_logdir() if logdir and not test_id: test_id = (search_test_id_in_latest(logdir), ) if not logdir or not all(test_id): click.echo(clean_resources.get_help(ctx)) return # need to pass SCTConfigration verification, # but not affect on result os.environ['SCT_CLUSTER_BACKEND'] = "aws" if config_file: os.environ['SCT_CONFIG_FILES'] = str(list(config_file)) config = SCTConfiguration() for _test_id in test_id: params['TestId'] = _test_id clean_resources_according_post_behavior(params, config, logdir) else: if not (user or test_id): click.echo(clean_resources.get_help(ctx)) return if user: params['RunByUser'] = user if test_id: for _test_id in test_id: params['TestId'] = _test_id clean_cloud_resources(params) click.echo('cleaned instances for {}'.format(params)) else: clean_cloud_resources(params) click.echo('cleaned instances for {}'.format(params))
def test_tags_testid_and_runbyuser_with_other(self): params = {"RunByUser": "******", "TestId": "1111", "NodeType": "monitor"} res = clean_cloud_resources(params) self.assertTrue(res)
def test_tags_testid_and_runbyuser(self): params = {"RunByUser": "******", "TestId": "1111"} res = clean_cloud_resources(params) self.assertTrue(res)
def test_tag_runbyuser_only(self): params = {"TestId": "1111"} res = clean_cloud_resources(params) self.assertTrue(res)
def test_tag_testid_only(self): params = {"RunByUser": "******"} res = clean_cloud_resources(params) self.assertTrue(res)
def test_other_tags_and_no_testid_and_runbyuser(self): params = {"NodeType": "scylla-db"} res = clean_cloud_resources(params) self.assertFalse(res)
def test_no_tag_testid_and_runbyuser(self): params = {} res = clean_cloud_resources(params) self.assertFalse(res)