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

Ensure resource cleanup and add integration test for invalid credentials #449

Merged
merged 5 commits into from
Mar 10, 2022

Conversation

EmoinLanyu
Copy link
Contributor

@EmoinLanyu EmoinLanyu commented Mar 3, 2022

How to categorize this PR?

/area usability
/kind test
/platform alicloud

What this PR does / why we need it:

This PR tests gardener/terraformer#93 and gardener/gardener#3950 by adding an integration test case for invalid credentials.
It creates an infrastructure resource but uses invalid credentials and ensures that the ERR_INFRA_UNAUTHENTICATED is correctly detected from the termination message and that the infrastructure can still be deleted afterwards (as it's a no-op).

Before this PR, the destroy logic and testing was executed as part of a cleanup action, while the destroy logic should be part of the actual test and not just cleanup. Also, this could lead to resource leakage on AliCloud and on the test-machinery cluster, because if one cleanup action fails (e.g. the destroy logic) no further cleanup actions are executed.
Now, the destroy logic is executed as a deferred function to ensure that the cleanup actions are still run, even if the test itself fails.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Ref:

Release note:


@EmoinLanyu EmoinLanyu requested review from a team as code owners March 3, 2022 06:26
@EmoinLanyu EmoinLanyu self-assigned this Mar 3, 2022
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 3, 2022
@gardener-robot gardener-robot added area/usability Usability related kind/test Test platform/alicloud Alicloud platform/infrastructure labels Mar 3, 2022
@gardener-robot
Copy link

@EmoinLanyu Thank you for your contribution.

@gardener-robot
Copy link

@EmoinLanyu You need rebase this pull request with latest master branch. Please check.

@gardener-robot gardener-robot added needs/rebase Needs git rebase needs/review Needs review size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) labels Mar 3, 2022
@EmoinLanyu
Copy link
Contributor Author

/test

@testmachinery
Copy link

testmachinery bot commented Mar 3, 2022

Testrun: e2e-wqmgf
Workflow: e2e-wqmgf-wf
Phase: Failed

+---------------------+---------------------+--------+----------+
|        NAME         |        STEP         | PHASE  | DURATION |
+---------------------+---------------------+--------+----------+
| infrastructure-test | infrastructure-test | Failed | 3m59s    |
+---------------------+---------------------+--------+----------+

@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 3, 2022
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 3, 2022
@EmoinLanyu
Copy link
Contributor Author

/test

@testmachinery
Copy link

testmachinery bot commented Mar 3, 2022

Testrun: e2e-vbx4p
Workflow: e2e-vbx4p-wf
Phase: Failed

+---------------------+---------------------+--------+----------+
|        NAME         |        STEP         | PHASE  | DURATION |
+---------------------+---------------------+--------+----------+
| infrastructure-test | infrastructure-test | Failed | 11m45s   |
+---------------------+---------------------+--------+----------+

@EmoinLanyu
Copy link
Contributor Author

/test

@testmachinery
Copy link

testmachinery bot commented Mar 3, 2022

Testrun: e2e-v7d7j
Workflow: e2e-v7d7j-wf
Phase: Succeeded

+---------------------+---------------------+-----------+----------+
|        NAME         |        STEP         |   PHASE   | DURATION |
+---------------------+---------------------+-----------+----------+
| infrastructure-test | infrastructure-test | Succeeded | 11m37s   |
+---------------------+---------------------+-----------+----------+

@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 3, 2022
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 3, 2022
@jia-jerry
Copy link
Contributor

please run make revendor

@EmoinLanyu
Copy link
Contributor Author

/squash

@gardener-robot gardener-robot added the merge/squash Should be merged via 'Squash and merge' label Mar 3, 2022
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 3, 2022
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 3, 2022
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 3, 2022
@EmoinLanyu
Copy link
Contributor Author

/test

@testmachinery
Copy link

testmachinery bot commented Mar 4, 2022

Testrun: e2e-tjcsh
Workflow: e2e-tjcsh-wf
Phase: Succeeded

+---------------------+---------------------+-----------+----------+
|        NAME         |        STEP         |   PHASE   | DURATION |
+---------------------+---------------------+-----------+----------+
| infrastructure-test | infrastructure-test | Succeeded | 11m55s   |
+---------------------+---------------------+-----------+----------+

@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 4, 2022
@@ -127,17 +131,15 @@ var _ = AfterSuite(func() {
mgrCancel()
}()

By("running cleanup actions")
framework.RunCleanupActions()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean all namespaces generated during testing are only be cleaned at the end of testing? Is it expected behavior?

@@ -535,6 +624,7 @@ func prepareVPC(ctx context.Context, clientFactory alicloudclient.ClientFactory,
vpcClient, err := clientFactory.NewVPCClient(region, *accessKeyID, *accessKeySecret)
Expect(err).NotTo(HaveOccurred())
createVpcReq := vpc.CreateCreateVpcRequest()
createVpcReq.VpcName = "provider-alicloud-infra-test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will happen if there are several testing running in parallel? will this name cause any conflict?

@EmoinLanyu
Copy link
Contributor Author

will this name cause any conflict?

No it won't. VPC name is not required to be unique. So there is no problem here.

@EmoinLanyu
Copy link
Contributor Author

Does it mean all namespaces generated during testing are only be cleaned at the end of testing? Is it expected behavior?

Yes the clean up actions are carried out at the end of the testing. The clean up actions will still be done should any tests fail.

@EmoinLanyu EmoinLanyu merged commit 9de547e into master Mar 10, 2022
@EmoinLanyu EmoinLanyu deleted the fix_infra_test branch March 10, 2022 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/usability Usability related kind/test Test merge/squash Should be merged via 'Squash and merge' needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/rebase Needs git rebase needs/review Needs review platform/alicloud Alicloud platform/infrastructure size/m Size of pull request is medium (see gardener-robot robot/bots/size.py)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants