Skip to content

Commit

Permalink
Consolidate checksGroup.Add calls (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 authored Dec 13, 2023
1 parent 25ebca6 commit 921b754
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 161 deletions.
28 changes: 8 additions & 20 deletions cnf-certification-test/certification/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,30 @@ func LoadChecks() {
checksGroup := checksdb.NewChecksGroup(common.AffiliatedCertTestKey).
WithBeforeEachFn(beforeEachFn)

testID, tags := identifiers.GetGinkgoTestIDAndLabels(identifiers.TestHelmVersionIdentifier)
check := checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestHelmVersionIdentifier)).
WithSkipCheckFn(skipIfNoHelmChartReleasesFn).
WithCheckFn(testHelmVersion)
WithCheckFn(testHelmVersion))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorIsCertifiedIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorIsCertifiedIdentifier)).
WithSkipCheckFn(skipIfNoOperatorsFn).
WithCheckFn(func(c *checksdb.Check) error {
testAllOperatorCertified(c, &env, validator)
return nil
})

checksGroup.Add(check)
}))

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestHelmIsCertifiedIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestHelmIsCertifiedIdentifier)).
WithSkipCheckFn(skipIfNoHelmChartReleasesFn).
WithCheckFn(func(c *checksdb.Check) error {
testHelmCertified(c, &env, validator)
return nil
})
}))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestContainerIsCertifiedDigestIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestContainerIsCertifiedDigestIdentifier)).
WithSkipCheckFn(testhelper.GetNoContainersUnderTestSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testContainerCertificationStatusByDigest(c, &env, validator)
return nil
})

checksGroup.Add(check)
}))
}

func getContainersToQuery(env *provider.TestEnvironment) map[provider.ContainerImageIdentifier]bool {
Expand Down
28 changes: 8 additions & 20 deletions cnf-certification-test/observability/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,46 +50,34 @@ func LoadChecks() {
checksGroup := checksdb.NewChecksGroup(common.ObservabilityTestKey).
WithBeforeEachFn(beforeEachFn)

testID, tags := identifiers.GetGinkgoTestIDAndLabels(identifiers.TestLoggingIdentifier)
check := checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestLoggingIdentifier)).
WithSkipCheckFn(testhelper.GetNoContainersUnderTestSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testContainersLogging(c, &env)
return nil
})
}))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestCrdsStatusSubresourceIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestCrdsStatusSubresourceIdentifier)).
WithSkipCheckFn(testhelper.GetNoCrdsUnderTestSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testCrds(c, &env)
return nil
})

checksGroup.Add(check)
}))

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestTerminationMessagePolicyIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestTerminationMessagePolicyIdentifier)).
WithSkipCheckFn(testhelper.GetNoContainersUnderTestSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testTerminationMessagePolicy(c, &env)
return nil
})
}))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestPodDisruptionBudgetIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestPodDisruptionBudgetIdentifier)).
WithSkipCheckFn(testhelper.GetNoDeploymentsUnderTestSkipFn(&env), testhelper.GetNoStatefulSetsUnderTestSkipFn(&env)).
WithSkipModeAll().
WithCheckFn(func(c *checksdb.Check) error {
testPodDisruptionBudgets(c, &env)
return nil
})

checksGroup.Add(check)
}))
}

// containerHasLoggingOutput helper function to get the last line of logging output from
Expand Down
21 changes: 6 additions & 15 deletions cnf-certification-test/operator/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,26 @@ func LoadChecks() {
checksGroup := checksdb.NewChecksGroup(common.OperatorTestKey).
WithBeforeEachFn(beforeEachFn)

testID, tags := identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorInstallStatusSucceededIdentifier)
check := checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorInstallStatusSucceededIdentifier)).
WithSkipCheckFn(testhelper.GetNoOperatorsSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testOperatorInstallationPhaseSucceeded(c, &env)
return nil
})
}))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorNoPrivileges)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorNoPrivileges)).
WithSkipCheckFn(testhelper.GetNoOperatorsSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testOperatorInstallationWithoutPrivileges(c, &env)
return nil
})

checksGroup.Add(check)
}))

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorIsInstalledViaOLMIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorIsInstalledViaOLMIdentifier)).
WithSkipCheckFn(testhelper.GetNoOperatorsSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testOperatorOlmSubscription(c, &env)
return nil
})

checksGroup.Add(check)
}))
}

func testOperatorInstallationPhaseSucceeded(check *checksdb.Check, env *provider.TestEnvironment) {
Expand Down
43 changes: 12 additions & 31 deletions cnf-certification-test/performance/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,72 +80,53 @@ var (
}
)

//nolint:funlen
func LoadChecks() {
log.Debug("Loading %s checks", common.PerformanceTestKey)

checksGroup := checksdb.NewChecksGroup(common.PerformanceTestKey).
WithBeforeEachFn(beforeEachFn)

testID, tags := identifiers.GetGinkgoTestIDAndLabels(identifiers.TestExclusiveCPUPoolIdentifier)
check := checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestExclusiveCPUPoolIdentifier)).
WithSkipCheckFn(testhelper.GetNoPodsUnderTestSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testExclusiveCPUPool(c, &env)
return nil
})

checksGroup.Add(check)
}))

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestRtAppNoExecProbes)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestRtAppNoExecProbes)).
WithSkipCheckFn(skipIfNoGuaranteedPodContainersWithExclusiveCPUs).
WithCheckFn(func(c *checksdb.Check) error {
testRtAppsNoExecProbes(c, &env)
return nil
})
}))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestSharedCPUPoolSchedulingPolicy)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestSharedCPUPoolSchedulingPolicy)).
WithSkipCheckFn(skipIfNoNonGuaranteedPodContainersWithoutHostPID).
WithCheckFn(func(c *checksdb.Check) error {
testSchedulingPolicyInCPUPool(c, &env, env.GetNonGuaranteedPodContainersWithoutHostPID(), scheduling.SharedCPUScheduling)
return nil
})

checksGroup.Add(check)
}))

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestExclusiveCPUPoolSchedulingPolicy)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestExclusiveCPUPoolSchedulingPolicy)).
WithSkipCheckFn(skipIfNoGuaranteedPodContainersWithExclusiveCPUsWithoutHostPID).
WithCheckFn(func(c *checksdb.Check) error {
testSchedulingPolicyInCPUPool(c, &env, env.GetGuaranteedPodContainersWithExclusiveCPUsWithoutHostPID(), scheduling.ExclusiveCPUScheduling)
return nil
})
}))

checksGroup.Add(check)

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestIsolatedCPUPoolSchedulingPolicy)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestIsolatedCPUPoolSchedulingPolicy)).
WithSkipCheckFn(skipIfNoGuaranteedPodContainersWithIsolatedCPUsWithoutHostPID).
WithCheckFn(func(c *checksdb.Check) error {
testSchedulingPolicyInCPUPool(c, &env, env.GetGuaranteedPodContainersWithIsolatedCPUsWithoutHostPID(), scheduling.ExclusiveCPUScheduling)
return nil
})

checksGroup.Add(check)
}))

testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestLimitedUseOfExecProbesIdentifier)
check = checksdb.NewCheck(testID, tags).
checksGroup.Add(checksdb.NewCheck(identifiers.GetGinkgoTestIDAndLabels(identifiers.TestLimitedUseOfExecProbesIdentifier)).
WithSkipCheckFn(testhelper.GetNoPodsUnderTestSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testLimitedUseOfExecProbes(c, &env)
return nil
})

checksGroup.Add(check)
}))
}

//nolint:funlen
Expand Down
Loading

0 comments on commit 921b754

Please sign in to comment.