diff --git a/test/e2e/autoscaling_test.go b/test/e2e/autoscaling_test.go index 7c22a2a659..94acc02b88 100644 --- a/test/e2e/autoscaling_test.go +++ b/test/e2e/autoscaling_test.go @@ -21,14 +21,13 @@ import ( func TestAutoscaling(t *testing.T) { t.Parallel() - g := NewWithT(t) ctx, cancel := context.WithCancel(testContext) defer cancel() clusterOpts := globalOpts.DefaultClusterOptions(t) - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { // Get the newly created NodePool nodepools := &hyperv1.NodePoolList{} if err := mgtClient.List(ctx, nodepools, crclient.InNamespace(hostedCluster.Namespace)); err != nil { diff --git a/test/e2e/chaos_test.go b/test/e2e/chaos_test.go index ca2707f24a..7d2183a681 100644 --- a/test/e2e/chaos_test.go +++ b/test/e2e/chaos_test.go @@ -38,7 +38,7 @@ func TestHAEtcdChaos(t *testing.T) { clusterOpts.ControlPlaneAvailabilityPolicy = string(hyperv1.HighlyAvailable) clusterOpts.NodePoolReplicas = 0 - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { t.Run("SingleMemberRecovery", testSingleMemberRecovery(ctx, mgtClient, hostedCluster)) t.Run("KillRandomMembers", testKillRandomMembers(ctx, mgtClient, hostedCluster)) t.Run("KillAllMembers", testKillAllMembers(ctx, mgtClient, hostedCluster)) diff --git a/test/e2e/control_plane_upgrade_test.go b/test/e2e/control_plane_upgrade_test.go index 662bd016ff..1cfef2ed7a 100644 --- a/test/e2e/control_plane_upgrade_test.go +++ b/test/e2e/control_plane_upgrade_test.go @@ -15,7 +15,6 @@ import ( func TestUpgradeControlPlane(t *testing.T) { t.Parallel() - g := NewWithT(t) ctx, cancel := context.WithCancel(testContext) defer cancel() @@ -26,7 +25,7 @@ func TestUpgradeControlPlane(t *testing.T) { clusterOpts.ReleaseImage = globalOpts.PreviousReleaseImage clusterOpts.ControlPlaneAvailabilityPolicy = string(hyperv1.HighlyAvailable) - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { // Sanity check the cluster by waiting for the nodes to report ready t.Logf("Waiting for guest client to become available") guestClient := e2eutil.WaitForGuestClient(t, ctx, mgtClient, hostedCluster) diff --git a/test/e2e/create_cluster_test.go b/test/e2e/create_cluster_test.go index 6660a54253..df1a78da4a 100644 --- a/test/e2e/create_cluster_test.go +++ b/test/e2e/create_cluster_test.go @@ -48,7 +48,6 @@ func TestCreateClusterCustomConfig(t *testing.T) { t.Skip("test only supported on platform AWS") } t.Parallel() - g := NewWithT(t) ctx, cancel := context.WithCancel(testContext) defer cancel() @@ -57,12 +56,14 @@ func TestCreateClusterCustomConfig(t *testing.T) { // find kms key ARN using alias kmsKeyArn, err := e2eutil.GetKMSKeyArn(clusterOpts.AWSPlatform.AWSCredentialsFile, clusterOpts.AWSPlatform.Region, globalOpts.configurableClusterOptions.AWSKmsKeyAlias) - g.Expect(err).NotTo(HaveOccurred(), "failed to retrieve kms key arn") - g.Expect(kmsKeyArn).NotTo(BeNil(), "failed to retrieve kms key arn") + if err != nil || kmsKeyArn == nil { + t.Fatal("failed to retrieve kms key arn") + } clusterOpts.AWSPlatform.EtcdKMSKeyARN = *kmsKeyArn - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + g.Expect(hostedCluster.Spec.SecretEncryption.KMS.AWS.ActiveKey.ARN).To(Equal(*kmsKeyArn)) g.Expect(hostedCluster.Spec.SecretEncryption.KMS.AWS.Auth.AWSKMSRoleARN).ToNot(BeEmpty()) @@ -81,7 +82,7 @@ func TestNoneCreateCluster(t *testing.T) { clusterOpts := globalOpts.DefaultClusterOptions(t) - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { // Wait for the rollout to be reported complete t.Logf("Waiting for cluster rollout. Image: %s", globalOpts.LatestReleaseImage) // Since the None platform has no workers, CVO will not have expectations set, @@ -121,7 +122,7 @@ func TestCreateClusterPrivate(t *testing.T) { clusterOpts.ControlPlaneAvailabilityPolicy = string(hyperv1.SingleReplica) clusterOpts.AWSPlatform.EndpointAccess = string(hyperv1.Private) - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { // Private -> publicAndPrivate t.Run("SwitchFromPrivateToPublic", testSwitchFromPrivateToPublic(ctx, mgtClient, hostedCluster, &clusterOpts)) // publicAndPrivate -> Private diff --git a/test/e2e/nodepool_test.go b/test/e2e/nodepool_test.go index feab4b8a5d..553ebafc94 100644 --- a/test/e2e/nodepool_test.go +++ b/test/e2e/nodepool_test.go @@ -34,7 +34,6 @@ type NodePoolTestCase struct { func TestNodePool(t *testing.T) { t.Parallel() - g := NewWithT(t) ctx, cancel := context.WithCancel(testContext) defer cancel() @@ -44,7 +43,7 @@ func TestNodePool(t *testing.T) { // We set replicas to 0 in order to allow the inner tests to // create their own NodePools with the proper replicas clusterOpts.NodePoolReplicas = 0 - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { hostedClusterClient := e2eutil.WaitForGuestClient(t, ctx, mgtClient, hostedCluster) // Get the newly created defautlt NodePool diff --git a/test/e2e/olm_test.go b/test/e2e/olm_test.go index 2e9189e5de..9852345f9a 100644 --- a/test/e2e/olm_test.go +++ b/test/e2e/olm_test.go @@ -38,14 +38,12 @@ func TestOLM(t *testing.T) { t.SkipNow() t.Parallel() - g := NewWithT(t) - ctx, cancel := context.WithCancel(testContext) defer cancel() // Create a cluster clusterOpts := globalOpts.DefaultClusterOptions(t) - e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { + e2eutil.NewHypershiftTest(t, ctx, func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) { // Get guest client t.Logf("Waiting for guest client to become available") guestClient := e2eutil.WaitForGuestClient(t, ctx, mgtClient, hostedCluster) diff --git a/test/e2e/util/hypershift_framework.go b/test/e2e/util/hypershift_framework.go index bd30c382c4..ccc3fad1b7 100644 --- a/test/e2e/util/hypershift_framework.go +++ b/test/e2e/util/hypershift_framework.go @@ -18,7 +18,7 @@ import ( . "github.com/onsi/gomega" ) -type hypershiftTestFunc func(t *testing.T, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) +type hypershiftTestFunc func(t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) type hypershiftTest struct { *testing.T ctx context.Context @@ -72,7 +72,7 @@ func (h *hypershiftTest) Execute(opts *core.CreateOptions, platform hyperv1.Plat if h.test != nil && !h.Failed() { h.Run("Main", func(t *testing.T) { - h.test(t, h.client, hostedCluster) + h.test(t, NewWithT(t), h.client, hostedCluster) }) } }