Skip to content

fix(e2e): delete s3 buckets in After Call #3962

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

Merged
merged 2 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion features/elastictranscoder/elastictranscoder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Feature: Elastic Transcoder
And I pause the pipeline
And I read the pipeline
Then the pipeline status should be "Paused"
And I delete the bucket

@error
Scenario: Error handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ After({ tags: "@elastictranscoder" }, async function () {
await this.service.deletePipeline({ Id: this.pipelineId });
this.pipelineId = undefined;
}
if (this.bucket) {
await this.s3.deleteBucket({ Bucket: this.bucket });
this.bucket = undefined;
}
});

Given("I create an Elastic Transcoder pipeline with name prefix {string}", async function (prefix) {
Expand Down
4 changes: 0 additions & 4 deletions features/extra/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ Given("I create a bucket", function (callback) {
});
});

When("I delete the bucket", function (callback) {
this.request("s3", "deleteBucket", { Bucket: this.bucket }, callback);
});

Then("the bucket should exist", function (next) {
this.waitForBucketExists(this.s3, { Bucket: this.bucket }, next);
});
Expand Down
7 changes: 0 additions & 7 deletions features/s3/buckets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ Feature: Working with Buckets
Given I am using the S3 "us-east-1" region
When I create a bucket
Then the bucket should exist
Then I delete the bucket
# Then the bucket should not exist

Scenario: CRUD buckets using a regional endpoint
Given I am using the S3 "us-west-2" region
When I create a bucket
Then the bucket should exist
Then I delete the bucket
# Then the bucket should not exist

@cors
Expand All @@ -26,7 +24,6 @@ Feature: Working with Buckets
Then the AllowedHeader value should equal "*"
Then the ExposeHeader value should equal "x-amz-server-side-encryption"
Then the MaxAgeSeconds value should equal 5000
Then I delete the bucket

@lifecycle
Scenario: Bucket lifecycles
Expand All @@ -35,15 +32,13 @@ Feature: Working with Buckets
And I get the transition lifecycle configuration on the bucket
Then the lifecycle configuration should have transition days of 0
And the lifecycle configuration should have transition storage class of "GLACIER"
Then I delete the bucket

@tagging
Scenario: Bucket Tagging
When I create a bucket
And I put a bucket tag with key "KEY" and value "VALUE"
And I get the bucket tagging
Then the first tag in the tag set should have key and value "KEY", "VALUE"
Then I delete the bucket

Scenario: Access bucket following 307 redirects
Given I am using the S3 "us-east-1" region with signatureVersion "s3"
Expand All @@ -55,7 +50,6 @@ Feature: Working with Buckets
Scenario: Working with bucket names that contain '.'
When I create a bucket with a DNS compatible name that contains a dot
Then the bucket should exist
Then I delete the bucket
# Then the bucket should not exist

@path-style
Expand All @@ -67,7 +61,6 @@ Feature: Working with Buckets
Then the bucket name should be in the request path
And the bucket name should not be in the request host
Then I delete the object "hello" from the bucket
Then I delete the bucket

# Known bug: https://github.com/aws/aws-sdk-js-v3/issues/1802
# Scenario: Follow 307 redirect on new buckets
Expand Down
14 changes: 11 additions & 3 deletions features/s3/step_definitions/buckets.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const { Before, Given, Then, When } = require("@cucumber/cucumber");
const { After, Before, Given, Then, When } = require("@cucumber/cucumber");

Before({ tags: "@buckets" }, function (scenario, callback) {
Before({ tags: "@buckets" }, function () {
const { S3 } = require("../../../clients/client-s3");
this.S3 = S3;
callback();
});

After({ tags: "@buckets" }, function (callback) {
if (this.bucket) {
this.request("s3", "deleteBucket", { Bucket: this.bucket }, callback);
this.bucket = undefined;
} else {
callback();
}
});

Given("I am using the S3 {string} region", function (region, callback) {
Expand Down