Skip to content
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

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

Merged
merged 2 commits into from
Sep 16, 2022
Merged

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Sep 15, 2022

Issue

Refs: #3948

Description

Move S3 buckets deletion in After call.

The shared integration test buckets are cleaned up in global AfterAll call

const filePath = path.resolve("integ.buckets.json");
try {
if (!fs.existsSync(filePath)) return Promise.resolve();
deleteFixtures();
const cache = JSON.parse(fs.readFileSync(filePath));

Testing

elastictranscoder

Success case
$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'

$ yarn run cucumber-js --fail-fast -t @elastictranscoder
yarn run v1.22.19
$ /local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/.bin/cucumber-js --fail-fast -t @elastictranscoder
................

2 scenarios (2 passed)
10 steps (10 passed)
0m01.828s (executing steps: 0m01.784s)
Done in 2.64s.

$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'
Failure case
$ git diff
diff --git a/features/elastictranscoder/step_definitions/elastictranscoder.js b/features/elastictranscoder/step_definitions/elastictranscoder.js
index 3383484a29..b04713795e 100644
--- a/features/elastictranscoder/step_definitions/elastictranscoder.js
+++ b/features/elastictranscoder/step_definitions/elastictranscoder.js
@@ -48,7 +48,7 @@ Given("I create an Elastic Transcoder pipeline with name prefix {string}", async
 });
 
 Given("I list pipelines", async function () {
-  this.data = await this.service.listPipelines({});
+  // this.data = await this.service.listPipelines({});
 });
 
 Then("the list should contain the pipeline", function () {

$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'

$ yarn run cucumber-js --fail-fast -t @elastictranscoder                                      
yarn run v1.22.19
$ /local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/.bin/cucumber-js --fail-fast -t @elastictranscoder
......F---(node:36722) [DEP0094] DeprecationWarning: assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.
(Use `node --trace-deprecation ...` to show where the warning was created)
.-----

Failures:

1) Scenario: Pipeline CRUD # features/elastictranscoder/elastictranscoder.feature:8
   ✔ Before # features/elastictranscoder/step_definitions/elastictranscoder.js:3
   ✔ Before # features/extra/hooks.js:15
   ✔ Given I create an IAM role with name prefix "aws-sdk-js" # features/iam/step_definitions/iam.js:38
   ✔ And I create a bucket # features/extra/hooks.js:38
   ✔ And I create an Elastic Transcoder pipeline with name prefix "aws-sdk-js" # features/elastictranscoder/step_definitions/elastictranscoder.js:27
   ✔ And I list pipelines # features/elastictranscoder/step_definitions/elastictranscoder.js:50
   ✖ Then the list should contain the pipeline # features/elastictranscoder/step_definitions/elastictranscoder.js:54
       AssertionError [ERR_ASSERTION]: undefined does not contain [Function (anonymous)]
           at Function.assertContains [as contains] (/local/home/trivikr/workspace/aws-sdk-js-v3/features/extra/assertions.js:18:10)
           at Object.<anonymous> (/local/home/trivikr/workspace/aws-sdk-js-v3/features/elastictranscoder/step_definitions/elastictranscoder.js:56:15)
   - And I pause the pipeline # features/elastictranscoder/step_definitions/elastictranscoder.js:61
   - And I read the pipeline # features/elastictranscoder/step_definitions/elastictranscoder.js:68
   - Then the pipeline status should be "Paused" # features/elastictranscoder/step_definitions/elastictranscoder.js:72
   ✔ After # features/elastictranscoder/step_definitions/elastictranscoder.js:12

2 scenarios (1 failed, 1 skipped)
10 steps (1 failed, 5 skipped, 4 passed)
0m01.750s (executing steps: 0m01.707s)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'

s3

Success case
$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'

$ yarn run cucumber-js --fail-fast -t @buckets
yarn run v1.22.19
$ /local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/.bin/cucumber-js --fail-fast -t @buckets
.............................................................................

8 scenarios (8 passed)
37 steps (37 passed)
0m08.872s (executing steps: 0m08.796s)

$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'
Failure case
$ git diff
diff --git a/features/s3/buckets.feature b/features/s3/buckets.feature
index c4389d0001..e82785b61d 100644
--- a/features/s3/buckets.feature
+++ b/features/s3/buckets.feature
@@ -20,7 +20,7 @@ Feature: Working with Buckets
     And I put a bucket CORS configuration
     And I get the bucket CORS configuration
     Then the AllowedMethods list should inclue "DELETE POST PUT"
-    Then the AllowedOrigin value should equal "http://example.com"
+    Then the AllowedOrigin value should equal "http://amazon.com"
     Then the AllowedHeader value should equal "*"
     Then the ExposeHeader value should equal "x-amz-server-side-encryption"
     Then the MaxAgeSeconds value should equal 5000
     
$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'

$ yarn run cucumber-js --fail-fast -t @buckets                                                
yarn run v1.22.19
$ /local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/.bin/cucumber-js --fail-fast -t @buckets
........................F---.------------------------------------------------

Failures:

1) Scenario: Bucket CORS # features/s3/buckets.feature:18
   ✔ Before # features/extra/hooks.js:15
   ✔ Before # features/s3/step_definitions/buckets.js:3
   ✔ Before # features/s3/step_definitions/hooks.js:3
   ✔ Before # features/s3/step_definitions/proxy.js:5
   ✔ When I create a bucket # features/extra/hooks.js:38
   ✔ And I put a bucket CORS configuration # features/s3/step_definitions/buckets.js:121
   ✔ And I get the bucket CORS configuration # features/s3/step_definitions/buckets.js:139
   ✔ Then the AllowedMethods list should inclue "DELETE POST PUT" # features/s3/step_definitions/buckets.js:150
   ✖ Then the AllowedOrigin value should equal "http://amazon.com" # features/s3/step_definitions/buckets.js:155
       AssertionError [ERR_ASSERTION]: 'http://example.com' == 'http://amazon.com'
           + expected - actual
       
           -http://example.com
           +http://amazon.com
       
           at Object.<anonymous> (/local/home/trivikr/workspace/aws-sdk-js-v3/features/s3/step_definitions/buckets.js:156:15)
   - Then the AllowedHeader value should equal "*" # features/s3/step_definitions/buckets.js:160
   - Then the ExposeHeader value should equal "x-amz-server-side-encryption" # features/s3/step_definitions/buckets.js:165
   - Then the MaxAgeSeconds value should equal 5000 # features/s3/step_definitions/buckets.js:170
   ✔ After # features/s3/step_definitions/buckets.js:8

8 scenarios (1 failed, 5 skipped, 2 passed)
37 steps (1 failed, 26 skipped, 10 passed)
0m02.897s (executing steps: 0m02.825s)

$ aws s3api list-buckets | jq '.Buckets[].Name | select(startswith("aws-sdk-js-integration"))'

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr marked this pull request as ready for review September 16, 2022 00:13
@trivikr trivikr requested a review from a team as a code owner September 16, 2022 00:13
@trivikr trivikr merged commit 5c92d80 into aws:main Sep 16, 2022
@trivikr trivikr deleted the s3-delete-after branch September 16, 2022 04:08
@github-actions
Copy link

github-actions bot commented Oct 1, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants