From fb6795106da45303e8cd433b4e4aa319ae2a9699 Mon Sep 17 00:00:00 2001 From: xiangchun Fu Date: Sat, 9 Nov 2024 23:00:44 -0500 Subject: [PATCH] Add osc operator unittest Signed-off-by: xiangchun Fu --- internal/cluster/cluster_test.go | 5 +++++ internal/host/host_test.go | 2 ++ internal/host/monitor_test.go | 3 +++ internal/host/transition_test.go | 1 + internal/operators/manager_test.go | 17 +++++++++++++---- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/internal/cluster/cluster_test.go b/internal/cluster/cluster_test.go index 8a36ef8d946..e096621e40b 100644 --- a/internal/cluster/cluster_test.go +++ b/internal/cluster/cluster_test.go @@ -95,6 +95,7 @@ var _ = Describe("stateMachine", func() { {Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied)}, @@ -169,6 +170,7 @@ var _ = Describe("TestClusterMonitoring", func() { {Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied)}, @@ -764,6 +766,7 @@ var _ = Describe("lease timeout event", func() { {Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied)}, @@ -887,6 +890,7 @@ var _ = Describe("Auto assign machine CIDR", func() { {Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied)}, @@ -2596,6 +2600,7 @@ var _ = Describe("ready_state", func() { {Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied)}, diff --git a/internal/host/host_test.go b/internal/host/host_test.go index 98aa2495566..aece70576e0 100644 --- a/internal/host/host_test.go +++ b/internal/host/host_test.go @@ -2869,6 +2869,7 @@ var _ = Describe("AutoAssignRole", func() { {Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, }, nil) masterRequirements := models.ClusterHostRequirementsDetails{ CPUCores: 4, @@ -3065,6 +3066,7 @@ var _ = Describe("IsValidMasterCandidate", func() { {Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied)}, }, nil) }) diff --git a/internal/host/monitor_test.go b/internal/host/monitor_test.go index eb5d0530829..75953a6b983 100644 --- a/internal/host/monitor_test.go +++ b/internal/host/monitor_test.go @@ -93,6 +93,7 @@ var _ = Describe("monitor_disconnection", func() { {Status: api.Success, ValidationId: string(models.HostValidationIDLsoRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.HostValidationIDOscRequirementsSatisfied)}, }, nil) mockHwValidator.EXPECT().GetHostInstallationPath(gomock.Any()).Return("abc").AnyTimes() }) @@ -214,6 +215,7 @@ var _ = Describe("TestHostMonitoring - with cluster", func() { {Status: api.Success, ValidationId: string(models.HostValidationIDLsoRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.HostValidationIDOscRequirementsSatisfied)}, }, nil) mockHwValidator.EXPECT().GetHostInstallationPath(gomock.Any()).Return("abc").AnyTimes() }) @@ -370,6 +372,7 @@ var _ = Describe("HostMonitoring - with infra-env", func() { {Status: api.Success, ValidationId: string(models.HostValidationIDLsoRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied)}, {Status: api.Success, ValidationId: string(models.HostValidationIDMtvRequirementsSatisfied)}, + {Status: api.Success, ValidationId: string(models.HostValidationIDOscRequirementsSatisfied)}, }, nil) mockHwValidator.EXPECT().GetHostInstallationPath(gomock.Any()).Return("abc").AnyTimes() }) diff --git a/internal/host/transition_test.go b/internal/host/transition_test.go index b13f4717f56..5fd0dcde958 100644 --- a/internal/host/transition_test.go +++ b/internal/host/transition_test.go @@ -6539,6 +6539,7 @@ var allValidationIDs = []validationID{ AreLvmRequirementsSatisfied, AreMceRequirementsSatisfied, AreMtvRequirementsSatisfied, + AreOscRequirementsSatisfied, SufficientOrUnknownInstallationDiskSpeed, HasSufficientNetworkLatencyRequirementForRole, HasSufficientPacketLossRequirementForRole, diff --git a/internal/operators/manager_test.go b/internal/operators/manager_test.go index a3606dd4bc0..d3daa3a4302 100644 --- a/internal/operators/manager_test.go +++ b/internal/operators/manager_test.go @@ -447,7 +447,7 @@ var _ = Describe("Operators manager", func() { results, err := manager.ValidateCluster(context.TODO(), cluster) Expect(err).ToNot(HaveOccurred()) - Expect(results).To(HaveLen(12)) + Expect(results).To(HaveLen(13)) Expect(results).To(ContainElements( api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDLsoRequirementsSatisfied), Reasons: []string{"lso is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOdfRequirementsSatisfied), Reasons: []string{"odf is disabled"}}, @@ -455,6 +455,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied), Reasons: []string{"mce is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied), Reasons: []string{"node-feature-discovery is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied), Reasons: []string{"nvidia-gpu is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied), Reasons: []string{"pipelines is disabled"}}, @@ -473,7 +474,7 @@ var _ = Describe("Operators manager", func() { results, err := manager.ValidateCluster(context.TODO(), cluster) Expect(err).ToNot(HaveOccurred()) - Expect(results).To(HaveLen(12)) + Expect(results).To(HaveLen(13)) Expect(results).To(ContainElements( api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDLsoRequirementsSatisfied), Reasons: []string{}}, api.ValidationResult{Status: api.Failure, ValidationId: string(models.ClusterValidationIDOdfRequirementsSatisfied), @@ -482,6 +483,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied), Reasons: []string{"mce is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied), Reasons: []string{"node-feature-discovery is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied), Reasons: []string{"nvidia-gpu is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDPipelinesRequirementsSatisfied), Reasons: []string{"pipelines is disabled"}}, @@ -499,7 +501,7 @@ var _ = Describe("Operators manager", func() { results, err := manager.ValidateHost(context.TODO(), cluster, clusterHost) Expect(err).ToNot(HaveOccurred()) - Expect(results).To(HaveLen(12)) + Expect(results).To(HaveLen(13)) Expect(results).To(ContainElements( api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLsoRequirementsSatisfied), Reasons: []string{"lso is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDOdfRequirementsSatisfied), Reasons: []string{"odf is disabled"}}, @@ -507,6 +509,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied), Reasons: []string{"mce is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDNodeFeatureDiscoveryRequirementsSatisfied), Reasons: []string{"node-feature-discovery is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDNvidiaGpuRequirementsSatisfied), Reasons: []string{"nvidia-gpu is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDPipelinesRequirementsSatisfied), Reasons: []string{"pipelines is disabled"}}, @@ -524,7 +527,7 @@ var _ = Describe("Operators manager", func() { results, err := manager.ValidateHost(context.TODO(), cluster, clusterHost) Expect(err).ToNot(HaveOccurred()) - Expect(results).To(HaveLen(12)) + Expect(results).To(HaveLen(13)) Expect(results).To(ContainElements( api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLsoRequirementsSatisfied), Reasons: []string{}}, @@ -533,6 +536,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMceRequirementsSatisfied), Reasons: []string{"mce is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDNodeFeatureDiscoveryRequirementsSatisfied), Reasons: []string{"node-feature-discovery is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDNvidiaGpuRequirementsSatisfied), Reasons: []string{"nvidia-gpu is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDPipelinesRequirementsSatisfied), Reasons: []string{"pipelines is disabled"}}, @@ -560,6 +564,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied), Reasons: []string{"cnv is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, )) }) @@ -581,6 +586,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied), Reasons: []string{"cnv is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, )) }) @@ -602,6 +608,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied), Reasons: []string{"cnv is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, )) clusterHost = getMockHostWithDisks(int64(20), int64(30)) @@ -620,6 +627,7 @@ var _ = Describe("Operators manager", func() { api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDCnvRequirementsSatisfied), Reasons: []string{"cnv is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.HostValidationIDLvmRequirementsSatisfied), Reasons: []string{"lvm is disabled"}}, api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDMtvRequirementsSatisfied), Reasons: []string{"mtv is disabled"}}, + api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDOscRequirementsSatisfied), Reasons: []string{"osc is disabled"}}, )) }) }) @@ -664,6 +672,7 @@ var _ = Describe("Operators manager", func() { "lvm", "mce", "mtv", + "osc", "node-feature-discovery", "nvidia-gpu", "odf",