Skip to content

Commit

Permalink
Simplify the context handling and remove the storage of contexts.
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Dec 10, 2023
1 parent f21c612 commit c114059
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions e2e/cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ func TestMain(m *testing.M) {
}

// Delete the NATS CR.
ctx := context.TODO()
err = Retry(attempts, interval, func() error {
errDel := k8sClient.Delete(ctx, NATSCR())
errDel := k8sClient.Delete(context.TODO(), NATSCR())
// If it is gone already, that's fine too.
if k8serrors.IsNotFound(errDel) {
return nil
Expand All @@ -80,10 +79,9 @@ func TestMain(m *testing.M) {
func Test_NoPodsExists(t *testing.T) {
t.Parallel()

ctx := context.TODO()
err := Retry(attempts, interval, func() error {
// Try to get the Pods.
pods, podErr := clientSet.CoreV1().Pods(NamespaceName).List(ctx, PodListOpts())
pods, podErr := clientSet.CoreV1().Pods(NamespaceName).List(context.TODO(), PodListOpts())
if podErr != nil {
return podErr
}
Expand All @@ -101,10 +99,9 @@ func Test_NoPodsExists(t *testing.T) {
func Test_NoPVCsExists(t *testing.T) {
t.Parallel()

ctx := context.TODO()
err := Retry(attempts, interval, func() error {
// Try to get the PVCs.
pvcs, pvcErr := clientSet.CoreV1().PersistentVolumeClaims(NamespaceName).List(ctx, PVCListOpts())
pvcs, pvcErr := clientSet.CoreV1().PersistentVolumeClaims(NamespaceName).List(context.TODO(), PVCListOpts())
if pvcErr != nil {
return pvcErr
}
Expand All @@ -122,10 +119,9 @@ func Test_NoPVCsExists(t *testing.T) {
func Test_NoSTSExists(t *testing.T) {
t.Parallel()

ctx := context.TODO()
err := Retry(attempts, interval, func() error {
// Try to get the STS.
_, stsErr := clientSet.AppsV1().StatefulSets(NamespaceName).Get(ctx, STSName, v1.GetOptions{})
_, stsErr := clientSet.AppsV1().StatefulSets(NamespaceName).Get(context.TODO(), STSName, v1.GetOptions{})
// This is what we want here.
if k8serrors.IsNotFound(stsErr) {
return nil
Expand All @@ -143,9 +139,8 @@ func Test_NoSTSExists(t *testing.T) {
func Test_NoNATSSecretExists(t *testing.T) {
t.Parallel()

ctx := context.TODO()
err := Retry(attempts, interval, func() error {
_, secErr := clientSet.CoreV1().Secrets(NamespaceName).Get(ctx, SecretName, v1.GetOptions{})
_, secErr := clientSet.CoreV1().Secrets(NamespaceName).Get(context.TODO(), SecretName, v1.GetOptions{})
// This is what we want here.
if k8serrors.IsNotFound(secErr) {
return nil
Expand All @@ -163,9 +158,8 @@ func Test_NoNATSSecretExists(t *testing.T) {
func Test_NoNATSCRExists(t *testing.T) {
t.Parallel()

ctx := context.TODO()
err := Retry(attempts, interval, func() error {
_, crErr := getNATSCR(ctx, CRName, NamespaceName)
_, crErr := getNATSCR(context.TODO(), CRName, NamespaceName)
// This is what we want here.
if k8serrors.IsNotFound(crErr) {
return nil
Expand Down

0 comments on commit c114059

Please sign in to comment.