Skip to content

Commit

Permalink
Fix slow tests in /pkg/frontend (#3810)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SudoBrendan authored and edisonLcardenas committed Sep 16, 2024
1 parent 5fdeb3b commit 5218f07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
})
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/frontend/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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) {
Expand Down Expand Up @@ -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{
Expand All @@ -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) {
Expand Down

0 comments on commit 5218f07

Please sign in to comment.