From 5218f07f152108ec29c71494d75f0de7a2ffabe7 Mon Sep 17 00:00:00 2001 From: Brendan Bergen Date: Wed, 4 Sep 2024 11:30:31 -0600 Subject: [PATCH] Fix slow tests in /pkg/frontend (#3810) * Clarifying etcd cert renew test - Updated the test to make it clear it is passing because timeout is being reached - Updated the timeout from 10s -> 0s to pass faster * Fix slow changefeed tests --- .../admin_openshiftcluster_etcdcertificaterenew_test.go | 6 ++++-- pkg/frontend/changefeed_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/frontend/admin_openshiftcluster_etcdcertificaterenew_test.go b/pkg/frontend/admin_openshiftcluster_etcdcertificaterenew_test.go index bf34abd72aa..2d702694882 100644 --- a/pkg/frontend/admin_openshiftcluster_etcdcertificaterenew_test.go +++ b/pkg/frontend/admin_openshiftcluster_etcdcertificaterenew_test.go @@ -613,11 +613,13 @@ func TestAdminEtcdCertificateRecovery(t *testing.T) { mocks func(*test, *mock_adminactions.MockKubeActions) wantStatusCode int wantError string + timeout int } for _, tt := range []*test{ { - name: "etcd secrets recovery", + name: "etcd secrets recovery fails on timeout", + timeout: 0, resourceID: fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/Microsoft.RedHatOpenShift/openShiftClusters/resourceName", mockSubID), version: &configv1.ClusterVersion{ Status: configv1.ClusterVersionStatus{ @@ -793,7 +795,7 @@ func TestAdminEtcdCertificateRecovery(t *testing.T) { log := logrus.NewEntry(logrus.New()) - err = f._postAdminOpenShiftClusterEtcdCertificateRenew(ctx, strings.ToLower(tt.resourceID), log, 10*time.Second) + err = f._postAdminOpenShiftClusterEtcdCertificateRenew(ctx, strings.ToLower(tt.resourceID), log, time.Duration(tt.timeout)*time.Second) utilerror.AssertErrorMessage(t, err, tt.wantError) }) } diff --git a/pkg/frontend/changefeed_test.go b/pkg/frontend/changefeed_test.go index 6e572d8cd86..710b2af9773 100644 --- a/pkg/frontend/changefeed_test.go +++ b/pkg/frontend/changefeed_test.go @@ -175,7 +175,7 @@ func TestUpdateFromIteratorOcpVersions(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { - ticker := time.NewTicker(1) + ticker := time.NewTicker(20 * time.Millisecond) ctx, cancel := context.WithCancel(context.TODO()) frontend := frontend{ @@ -185,7 +185,7 @@ func TestUpdateFromIteratorOcpVersions(t *testing.T) { fakeIterator := cosmosdb.NewFakeOpenShiftVersionDocumentIterator(tt.docsInIterator, 0) go frontend.updateFromIteratorOcpVersions(ctx, ticker, fakeIterator) - time.Sleep(time.Second) + time.Sleep(10 * time.Millisecond) cancel() if !reflect.DeepEqual(frontend.enabledOcpVersions, tt.wantVersions) { @@ -517,7 +517,7 @@ func TestUpdateFromIteratorRoleSets(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { - ticker := time.NewTicker(1) + ticker := time.NewTicker(20 * time.Millisecond) ctx, cancel := context.WithCancel(context.TODO()) frontend := frontend{ @@ -527,7 +527,7 @@ func TestUpdateFromIteratorRoleSets(t *testing.T) { fakeIterator := cosmosdb.NewFakePlatformWorkloadIdentityRoleSetDocumentIterator(tt.docsInIterator, 0) go frontend.updateFromIteratorRoleSets(ctx, ticker, fakeIterator) - time.Sleep(time.Second) + time.Sleep(10 * time.Millisecond) cancel() if !reflect.DeepEqual(frontend.availablePlatformWorkloadIdentityRoleSets, tt.wantRoleSets) {