Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain committed Nov 15, 2024
1 parent d17732a commit 7bfa43f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/e2e/tests/httproute_with_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ var EnvoyGatewayBackendTest = suite.ConformanceTest{
if err != nil {
t.Fatalf("failed to create backend %s: %v", backendIPName, err)
}
if err != nil {
t.Fatalf("failed to create backend %s: %v", backendIPName, err)
}
t.Cleanup(func() {
if err := DeleteBackend(suite.Client, types.NamespacedName{Name: backendIPName, Namespace: ns}); err != nil {
t.Fatalf("failed to delete backend %s: %v", backendIPName, err)
}
})

routeNN := types.NamespacedName{Name: "httproute-to-backend-ip", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/tests/tlsroute_with_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ var TLSRouteBackendIPTest = suite.ConformanceTest{
if err != nil {
t.Fatalf("failed to create backend %s: %v", backendIPName, err)
}
t.Cleanup(func() {
if err := DeleteBackend(suite.Client, types.NamespacedName{Name: backendIPName, Namespace: ns}); err != nil {
t.Fatalf("failed to delete backend %s: %v", backendIPName, err)
}
})
testTLSRouteWithBackend(t, suite, "tlsroute-to-backend-ip", backendIPName)
})
},
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,11 @@ func CreateBackend(c client.Client, nn types.NamespacedName, clusterIP string) e
}
return c.Create(context.TODO(), backend)
}

func DeleteBackend(c client.Client, nn types.NamespacedName) error {
backend := &egv1a1.Backend{}
if err := c.Get(context.Background(), nn, backend); err != nil {
return err
}
return c.Delete(context.Background(), backend)
}

0 comments on commit 7bfa43f

Please sign in to comment.