Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/cluster/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var _ = Describe("update_cluster_state", func() {
})
AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ var _ = Describe("processMirrorRegistryConfig", func() {

Expect(err.Error()).To(Equal("failed to load value of registries.conf into toml tree; incorrectly formatted toml: (6, 13): cannot have two dots in one float"))
})

AfterEach(func() {
mockCtrl.Finish()
})
})

var _ = Describe("cluster reconcile", func() {
Expand Down Expand Up @@ -5398,6 +5402,10 @@ var _ = Describe("unbindAgents", func() {
err = c.Get(ctx, types.NamespacedName{Name: "test-agent2", Namespace: testNamespace}, agent)
Expect(k8serrors.IsNotFound(err)).To(BeTrue())
})

AfterEach(func() {
mockCtrl.Finish()
})
})

var _ = Describe("day2 cluster", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ var _ = Describe("container_image_availability_cmd", func() {

AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})
})

Expand Down Expand Up @@ -173,4 +174,8 @@ var _ = Describe("get images", func() {
Expect(images[0]).To(ContainSubstring("registry.mirror.example.com"))
Expect(images[0]).NotTo(ContainSubstring("quay.io"))
})

AfterEach(func() {
ctrl.Finish()
})
})
1 change: 1 addition & 0 deletions internal/host/hostcommands/disk_performance_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ var _ = Describe("disk_performance", func() {
common.DeleteTestDB(db, dbName)
stepReply = nil
stepErr = nil
ctrl.Finish()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ var _ = Describe("domainNameResolution", func() {
It("Missing cluster name", func() {
cluster = common.Cluster{Cluster: models.Cluster{ID: &clusterID, BaseDNSDomain: baseDNSDomain}}
Expect(db.Create(&cluster).Error).ShouldNot(HaveOccurred())
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&models.ReleaseImage{URL: swag.String("quay.io/release")}, nil)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling for the error covered by this spec happens before GetReleaseImage is called

stepReply, stepErr = dCmd.GetSteps(ctx, &host)
Expect(stepReply).To(BeNil())
Expect(stepErr).To(HaveOccurred())
Expand All @@ -90,7 +89,6 @@ var _ = Describe("domainNameResolution", func() {
It("Missing domain base name", func() {
cluster = common.Cluster{Cluster: models.Cluster{ID: &clusterID, Name: name}}
Expect(db.Create(&cluster).Error).ShouldNot(HaveOccurred())
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&models.ReleaseImage{URL: swag.String("quay.io/release")}, nil)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling for the error covered by this spec happens before GetReleaseImage is called

stepReply, stepErr = dCmd.GetSteps(ctx, &host)
Expect(stepReply).To(BeNil())
Expect(stepErr).To(HaveOccurred())
Expand All @@ -100,5 +98,6 @@ var _ = Describe("domainNameResolution", func() {
common.DeleteTestDB(db, dbName)
stepReply = nil
stepErr = nil
ctrl.Finish()
})
})
1 change: 1 addition & 0 deletions internal/host/hostutil/update_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@ var _ = Describe("update_host_state", func() {

AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})
})
3 changes: 1 addition & 2 deletions internal/host/refresh_status_preprocessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ var _ = Describe("Cluster Refresh Status Preprocessor", func() {
},
}, nil)
mockOperatorManager = operators.NewMockAPI(ctrl)
mockOperatorManager.EXPECT().ValidateHost(gomock.Any(), gomock.Any(), gomock.Any())
mockProviderRegistry = registry.NewMockProviderRegistry(ctrl)
mockS3WrapperAPI = s3wrapper.NewMockAPI(ctrl)
mockVersions = versions.NewMockHandler(ctrl)
mockOperatorManager.EXPECT().ValidateCluster(ctx, gomock.Any())
db, dbName = common.PrepareTestDB()
validatorConfig := &hardware.ValidatorCfg{}
disabledHostValidations := make(map[string]struct{})
Expand All @@ -82,6 +80,7 @@ var _ = Describe("Cluster Refresh Status Preprocessor", func() {

AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})

createHost := func() models.Host {
Expand Down
5 changes: 5 additions & 0 deletions internal/installercache/installercache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ var _ = Describe("release event", func() {
).Times(1)
Expect(r.Cleanup(ctx)).To(Succeed())
})

AfterEach(func() {
ctrl.Finish()
})
})

var _ = Describe("installer cache", func() {
Expand Down Expand Up @@ -103,6 +107,7 @@ var _ = Describe("installer cache", func() {

AfterEach(func() {
os.RemoveAll(cacheDir)
ctrl.Finish()
})

expectEventsSent := func() {
Expand Down
1 change: 1 addition & 0 deletions internal/metrics/directory_usage_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var _ = Describe("Collection on scrape", func() {

AfterEach(func() {
server.Close()
ctrl.Finish()
})

var expectMetricValue = func(metric string, value string) {
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ var _ = Describe("Test GetSupportedProvidersByHosts", func() {
Expect(err).ToNot(BeNil())
Expect(len(platforms)).Should(Equal(0))
})

AfterEach(func() {
ctrl.Finish()
})
})

var _ = Describe("IsHostSupported", func() {
Expand Down Expand Up @@ -471,6 +475,10 @@ var _ = Describe("Test AddPlatformToInstallConfig", func() {
Expect(string(cfg.Platform.External.CloudControllerManager)).To(Equal(cloudControllerManager))
})
})

AfterEach(func() {
ctrl.Finish()
})
})

var _ = Describe("Test SetPlatformUsages", func() {
Expand Down Expand Up @@ -520,6 +528,10 @@ var _ = Describe("Test SetPlatformUsages", func() {
Expect(err).To(BeNil())
})
})

AfterEach(func() {
ctrl.Finish()
})
})

func createHost(isMaster bool, state string, inventory string) *models.Host {
Expand Down
5 changes: 5 additions & 0 deletions internal/spoke_k8s_client/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ var _ = Describe("Factory", func() {
mockSystemInfo = system.NewMockSystemInfo(controller)
})

AfterEach(func() {
controller.Finish()
})

It("Can't be created without a logger", func() {
client, err := NewFactory(nil, nil, mockSystemInfo)
Expect(err).To(MatchError("logger is mandatory"))
Expand All @@ -112,6 +116,7 @@ var _ = Describe("Factory", func() {
"Fails if secret doesn't contain a valid kubeconfig",
func(data map[string][]byte, matcher OmegaMatcher) {
controller = gomock.NewController(GinkgoT())
defer controller.Finish()
mockSystemInfo = system.NewMockSystemInfo(controller)

// Create the secret:
Expand Down
9 changes: 9 additions & 0 deletions internal/stream/notification_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ var _ = Describe("Close", func() {
writer = stream.NewMockStreamWriter(ctrl)
})

AfterEach(func() {
ctrl.Finish()
})

It("should close the writer when closing", func() {
writer.EXPECT().Close().Times(1)
notificationStream := stream.NewNotificationStream(writer, logger, metadata)
Expand Down Expand Up @@ -69,6 +73,11 @@ var _ = Describe("Notify", func() {
clusterID = strfmt.UUID(uuid.New().String())

})

AfterEach(func() {
ctrl.Finish()
})

It("succeeds when underlying writer is empty", func() {
event := &common.Event{}
var emptyWriter stream.StreamWriter
Expand Down
4 changes: 4 additions & 0 deletions internal/uploader/auth_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ var _ = Describe("getPullSecret", func() {
pullSecretWithEmptyAuthFormat = `{"auths":{"%s":{"auth":"","email":"r@empty.com"}}}` // #nosec
})

AfterEach(func() {
ctrl.Finish()
})

It("successfully gets a pull secret when the OCM pull secret is present", func() {
OCMPullSecret := fmt.Sprintf(pullSecretFormat, openshiftTokenKey, OCMPullSecretToken)
data := map[string][]byte{corev1.DockerConfigJsonKey: []byte(OCMPullSecret)}
Expand Down
11 changes: 3 additions & 8 deletions internal/uploader/events_uploader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var _ = Describe("setHeaders", func() {
})
AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})

It("correctly sets the request header with a valid auth token", func() {
Expand Down Expand Up @@ -192,6 +193,7 @@ var _ = Describe("prepareFiles", func() {

AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})

It("successfully prepares all files", func() {
Expand Down Expand Up @@ -377,6 +379,7 @@ var _ = Describe("UploadEvents", func() {
})
AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})
It("successfully uploads event data", func() {
event := models.Event{
Expand Down Expand Up @@ -419,20 +422,12 @@ var _ = Describe("UploadEvents", func() {
})
It("fails to uploads event data when malformed pullsecret", func() {
createOCMPullSecretWithEmptyToken(*mockK8sClient)
mockEvents.EXPECT().V2GetEvents(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling for the error covered by this spec happens before V2GetEvents is called

ctx, common.GetDefaultV2GetEventsParams(&clusterID, nil, nil, models.EventCategoryMetrics, models.EventCategoryUser)).
Return(&common.V2GetEventsResponse{}, nil).Times(1)

cluster := createTestObjects(db, &clusterID, &hostID, &infraEnvID)
err := uploader.UploadEvents(ctx, cluster, mockEvents)
Expect(err.Error()).To(MatchRegexp(`.*failed to get pull secrets to upload event data for cluster.*`))
})
It("fails to uploads event data when pullsecret not found", func() {
createOCMPullSecretNotFound(*mockK8sClient)
mockEvents.EXPECT().V2GetEvents(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling for the error covered by this spec happens before V2GetEvents is called

ctx, common.GetDefaultV2GetEventsParams(&clusterID, nil, nil, models.EventCategoryMetrics, models.EventCategoryUser)).
Return(&common.V2GetEventsResponse{}, nil).Times(1)

cluster := createTestObjects(db, &clusterID, &hostID, &infraEnvID)
err := uploader.UploadEvents(ctx, cluster, mockEvents)
Expect(err.Error()).To(MatchRegexp(`.*failed to get pull secrets to upload event data for cluster.*`))
Expand Down
1 change: 1 addition & 0 deletions internal/usage/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var _ = Describe("Feature Usage", func() {

AfterEach(func() {
common.DeleteTestDB(db, dbName)
ctrl.Finish()
})

readUsages := func() map[string]models.Usage {
Expand Down
4 changes: 4 additions & 0 deletions pkg/kafka/json_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var _ = Describe("Write", func() {
}
})

AfterEach(func() {
ctrl.Finish()
})

It("should succeed when writing encodable message", func() {
key := []byte("my-key")
value := map[string]interface{}{
Expand Down
1 change: 1 addition & 0 deletions pkg/s3wrapper/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var _ = Describe("s3filesystem", func() {
}
})
AfterEach(func() {
ctrl.Finish()
err := os.RemoveAll(baseDir)
Expect(err).Should(BeNil())
})
Expand Down