Skip to content

Commit

Permalink
Add osc operator unittest
Browse files Browse the repository at this point in the history
Signed-off-by: xiangchun Fu <xfu@redhat.com>
  • Loading branch information
xiangchunfu committed Nov 14, 2024
1 parent 7de17e6 commit fb67951
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions internal/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
Expand Down
2 changes: 2 additions & 0 deletions internal/host/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
})

Expand Down
3 changes: 3 additions & 0 deletions internal/host/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -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()
})
Expand Down
1 change: 1 addition & 0 deletions internal/host/transition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6539,6 +6539,7 @@ var allValidationIDs = []validationID{
AreLvmRequirementsSatisfied,
AreMceRequirementsSatisfied,
AreMtvRequirementsSatisfied,
AreOscRequirementsSatisfied,
SufficientOrUnknownInstallationDiskSpeed,
HasSufficientNetworkLatencyRequirementForRole,
HasSufficientPacketLossRequirementForRole,
Expand Down
17 changes: 13 additions & 4 deletions internal/operators/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,15 @@ 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"}},
api.ValidationResult{Status: api.Success, ValidationId: string(models.ClusterValidationIDCnvRequirementsSatisfied), Reasons: []string{"cnv is disabled"}},
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"}},
Expand All @@ -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),
Expand All @@ -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"}},
Expand All @@ -499,14 +501,15 @@ 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"}},
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.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"}},
Expand All @@ -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{}},
Expand All @@ -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"}},
Expand Down Expand Up @@ -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"}},
))
})

Expand All @@ -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"}},
))
})

Expand All @@ -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))
Expand All @@ -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"}},
))
})
})
Expand Down Expand Up @@ -664,6 +672,7 @@ var _ = Describe("Operators manager", func() {
"lvm",
"mce",
"mtv",
"osc",
"node-feature-discovery",
"nvidia-gpu",
"odf",
Expand Down

0 comments on commit fb67951

Please sign in to comment.