-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CFNTest doesn't delete taskcat auto bucket where it uploads the project files and templates to #652
Comments
Yeah, I confirm this for taskcat |
Law of unintended consequences. I'll look at this next week. |
Just in case you cannot wait for @andrew-glenn's fix, I slightly modified the file diff --git a/taskcat/_config.py b/taskcat/_config.py
index bdcb0e5..93a4c50 100644
--- a/taskcat/_config.py
+++ b/taskcat/_config.py
@@ -282,8 +282,7 @@ class Config:
name = bucket_objects[region.account_id].name
auto_generated = bucket_objects[region.account_id].auto_generated
else:
- name = test.s3_bucket
- auto_generated = False
+ return test.s3_bucket
bucket_region = self._get_bucket_region_for_partition(region.partition)
bucket_obj = S3BucketObj(
name=name,
@@ -299,6 +298,7 @@ class Config:
)
if new:
bucket_obj.create()
+ test.s3_bucket = bucket_obj
return bucket_obj
def _create_regional_bucket_obj(self, bucket_objects, region, test):
@@ -341,6 +341,7 @@ class Config:
)
if new:
bucket_obj.create()
+ test.s3_bucket = bucket_obj
return bucket_obj
@staticmethod |
The previous changeset will fail if you set the config parameter diff --git a/taskcat/_config.py b/taskcat/_config.py
index bdcb0e5..5f48643 100644
--- a/taskcat/_config.py
+++ b/taskcat/_config.py
@@ -281,9 +281,11 @@ class Config:
elif bucket_objects.get(region.account_id):
name = bucket_objects[region.account_id].name
auto_generated = bucket_objects[region.account_id].auto_generated
- else:
+ elif isinstance(test.s3_bucket, str):
name = test.s3_bucket
auto_generated = False
+ else:
+ return test.s3_bucket
bucket_region = self._get_bucket_region_for_partition(region.partition)
bucket_obj = S3BucketObj(
name=name,
@@ -299,6 +301,7 @@ class Config:
)
if new:
bucket_obj.create()
+ test.s3_bucket = bucket_obj
return bucket_obj
def _create_regional_bucket_obj(self, bucket_objects, region, test):
@@ -341,6 +344,7 @@ class Config:
)
if new:
bucket_obj.create()
+ test.s3_bucket = bucket_obj
return bucket_obj
@staticmethod Cheers! |
thanks for looking at this currently I use a pytest session fixture to empty and delete the bucket after I am done. So an easy enough workaround for now |
@tjtaill The CLI The difference is that you are not passing the build args. args = _build_args(enable_sig_v2, regions, GLOBAL_ARGS.profile)
config = Config.create(
project_root=project_root_path,
project_config_path=input_file_path,
args=args
# TODO: detect if input file is taskcat config or CloudFormation template
) I'm not sure what the build args do and why they make it so that auto bucket is not deleted but it might have something to do with setting default values. Another way to do what you are doing is: @pytest.fixture(scope='session')
def template_root()
return Path(__file__).parent / "../.."
def test_firehose(template_root):
input_file_path = template_root / ".taskcat.yml"
test = CFNTest.from_file(project_root=template_root, input_file=input_file_path,regions='us-east-1')
test.test_names = 'firehose'
with test as stacks:
bucket_name = find_output("BucketName", stacks)
... I'm guessing the If you are not planning on using the taskcat CLI then you will probably find https://github.com/DontShaveTheYak/cloud-radar a better fit. from pathlib import Path
from cloud_radar.cf.e2e import Stack
# Stack is a context manager that makes sure your stacks are deleted after testing.
template_path = Path("tests/templates/log_bucket/log_bucket.yaml")
params = {"BucketPrefix": "testing", "KeepBucket": "False"}
regions = ['us-west-2']
# template_path can be a string or a Path object.
# params can be optional if all your template params have default values
# regions can be optional, default region is 'us-east-1'
with Stack(template_path, params, regions) as stacks:
# Stacks will be created and returned as a list in the stacks variable.
for stack in stacks:
# stack will be an instance of Taskcat's Stack class.
# It has all the expected properties like parameters, outputs and resources
print(f"Testing {stack.name}")
... This is where the original CFNTest came from. It also has some other capabilities like unit testing (testing without deploying) but that feature is only partially implemented. |
Describe the bug
When I run
taskcat test run
it successfully deletes the auto bucket it creates for the project files and templatesWhen I run pytest using CFNTest the test successfully passes and all stacks it creates are deleted but the auto bucket for some reason doesn't get deleted not sure why the clean_up method looks like it has code to delete the the buckets
see https://github.com/aws-quickstart/taskcat/blob/main/taskcat/testing/_cfn_test.py#L158 but for some reason the bicket with all the project files and templates is still there ?
To Reproduce
Steps to reproduce the behavior:
aws cloudformation package cloudformation/tests/firehose.yaml > cloudformation/tests/firehose-packaged.yaml
pytest -k test_firehose
observe everything works and is deleted except the auto bucket created to upload the project files and templates too
Are you testing a QuickStart or Custom template?
Not sure I am guessing quickstart ?
Attach or link a copy of the template if possible (remove any sensitive info)
.taskcat.yaml
./cloudformation/tests/firehose-packaged.yaml
test_firehose.py
utils.py
Provide the parameters that you passed. (remove any sensitive info)
How did you install taskcat? (docker or pip3)
pip3
Are you using a profile, an instance role or access keys to run taskcat?
profile
Is your AWS environment configured via
aws configure
?Yes ~/.aws/config
Expected behavior
That the autobucket created to upload project files and templates to is deleted
Screenshots
If applicable, add screenshots to help explain your problem.
**Version (Please make sure you are running the latest version of taskcat)
Note: Python Version (python3 required)
3.7.7
To find versions:
Via taskcat:
taskcat -V
0.9.23Via pip3:
pip3 show taskcat
0.9.23Note: both version should match
To update taskcat run:
for docker :
docker pull taskcat/taskcat
for pip3:
pip3 install --upgrade taskcat
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: