From 43d24995c3ddfd0ad8e73b4611faf3119be9dfdc Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Wed, 10 Apr 2024 21:59:36 +0100 Subject: [PATCH] Cleanup security group created by e2e test --- test/e2e/shared/openstack.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/e2e/shared/openstack.go b/test/e2e/shared/openstack.go index 2fd5f95d56..e7e3ff73d1 100644 --- a/test/e2e/shared/openstack.go +++ b/test/e2e/shared/openstack.go @@ -494,10 +494,16 @@ func CreateOpenStackSecurityGroup(e2eCtx *E2EContext, securityGroupName, descrip Description: description, } - _, err = groups.Create(networkClient, createOpts).Extract() + group, err := groups.Create(networkClient, createOpts).Extract() if err != nil { return err } + // Ensure the group is deleted after the test + DeferCleanup(func() error { + By(fmt.Sprintf("Deleting test security group %s(%s)", group.Name, group.ID)) + return groups.Delete(networkClient, group.ID).ExtractErr() + }) + return nil }