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

Cleantool #234

Merged
merged 4 commits into from
Oct 1, 2024
Merged

Conversation

briantkennedy
Copy link
Member

Adds a tool to help manually clean up orphaned test resources.

Fixes #232

Move the flags out of the test file to the e2e package, and export
flag variables and parseFlagsOrDie.
Relocate and export FallbackCleanup function.
@briantkennedy
Copy link
Member Author

friendly ping @bowei @kl52752 @AwesomePatrol

Copy link
Contributor

@AwesomePatrol AwesomePatrol left a comment

Choose a reason for hiding this comment

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

Thanks for adding a simple way to clean up any leftover resources. I run it myself and it works flawlessly.

Aside from theCloud->TheCloud change, LGTM

}

func eMain() error {
//klog.InitFlags(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this comment is not needed

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

}

func main() {
if err := eMain(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

eMain doesn't seem to remove any errors. Please consider consolidating the two

Copy link
Member Author

Choose a reason for hiding this comment

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

combined with eMain

"google.golang.org/api/googleapi"
"google.golang.org/api/impersonate"
"google.golang.org/api/option"
)

var (
// theCloud is a global to be used in the e2e tests.
theCloud cloud.Cloud
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it seems it is unused

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure what action this is suggesting

Copy link
Contributor

Choose a reason for hiding this comment

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

as you reverted from TheCloud to theCloud now there is a duplicate declaration of global variable with this name. Declaration here can be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for calling this out, it's been a while, and I forgot that go build doesn't build tests for some reason =/

e2e/cleanup.go Outdated
log.Printf("FallbackCleanup: TheCloud.TcpRoutes().List(ctx, _): %v\n", err)
return
}
log.Printf("Listed %d tcproutes", len(tcprs))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this looks like a debug log I think we can get rid of it

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@@ -42,16 +42,16 @@ func TestAddresses(t *testing.T) {

t.Logf("addr1 = %s", fmt.Sprint(addr1))

t.Cleanup(func() { theCloud.Addresses().Delete(context.Background(), addr1Key) })
t.Cleanup(func() { TheCloud.Addresses().Delete(context.Background(), addr1Key) })
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider not changing the variable name. It doesn't seem needed (I run sed and the code still worked). It would make PR diff much smaller

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted to theCloud

@bowei
Copy link
Member

bowei commented Sep 27, 2024

/lgtm
/approve

* Fix a bug in resource cleanup where tcproutes and meshes were not
  being cleaned up due to sending invalid URL.
* Adjust cleanup matching to clean resources from all tests when RunID is empty.
@kl52752
Copy link
Contributor

kl52752 commented Oct 1, 2024

/lgtm

@kl52752
Copy link
Contributor

kl52752 commented Oct 1, 2024

/approve

@google-oss-prow google-oss-prow bot merged commit da81e2a into GoogleCloudPlatform:master Oct 1, 2024
3 checks passed
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AwesomePatrol, bowei, briantkennedy, kl52752

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

e2e tests orphan resources on timeout
4 participants