Skip to content

Commit

Permalink
test: kubeapi-aws
Browse files Browse the repository at this point in the history
  • Loading branch information
danielerez committed Oct 9, 2024
1 parent 83696d2 commit 61c10d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ifeq ($(VERBOSE), true)
endif

GOTEST_FLAGS = --format=$(GO_TEST_FORMAT) $(GOTEST_PUBLISH_FLAGS) -- -count=1 -cover -coverprofile=$(REPORTS)/$(TEST_SCENARIO)_coverage.out
GINKGO_FLAGS = -ginkgo.focus="$(FOCUS)" -ginkgo.v -ginkgo.skip="$(SKIP)" -ginkgo.v -ginkgo.reportFile=./junit_$(TEST_SCENARIO)_test.xml
GINKGO_FLAGS = -ginkgo.failFast -ginkgo.focus="$(FOCUS)" -ginkgo.v -ginkgo.skip="$(SKIP)" -ginkgo.v -ginkgo.reportFile=./junit_$(TEST_SCENARIO)_test.xml

COVER_PROFILE := $(or ${COVER_PROFILE},$(REPORTS)/unit_coverage.out)
GINKGO_REPORTFILE := $(or $(GINKGO_REPORTFILE), ./junit_unit_test.xml)
Expand Down
73 changes: 9 additions & 64 deletions subsystem/kubeapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ func checkPlatformStatus(ctx context.Context, key types.NamespacedName, specPlat
ExpectWithOffset(1, aci.Status.UserManagedNetworking).To(Equal(umn))
}

func checkAgentClusterInstallCondition(ctx context.Context, key types.NamespacedName, conditionType hivev1.ClusterInstallConditionType, reason string) {
func checkAgentClusterInstallCondition(ctx context.Context, key types.NamespacedName, conditionType string, reason string) {
Eventually(func() string {
condition := controllers.FindStatusCondition(getAgentClusterInstallCRD(ctx, kubeClient, key).Status.Conditions, conditionType)
if condition != nil {
Expand All @@ -706,7 +706,7 @@ func checkAgentClusterInstallCondition(ctx context.Context, key types.Namespaced
}, "2m", "2s").Should(Equal(reason))
}

func checkAgentClusterInstallConditionConsistency(ctx context.Context, key types.NamespacedName, conditionType hivev1.ClusterInstallConditionType, reason string) {
func checkAgentClusterInstallConditionConsistency(ctx context.Context, key types.NamespacedName, conditionType string, reason string) {
Consistently(func() string {
condition := controllers.FindStatusCondition(getAgentClusterInstallCRD(ctx, kubeClient, key).Status.Conditions, conditionType)
if condition != nil {
Expand Down Expand Up @@ -3419,33 +3419,7 @@ var _ = Describe("[kube-api]cluster installation", func() {

checkAgentCondition(ctx, host.ID.String(), v1beta1.SpecSyncedCondition, v1beta1.BackendErrorReason)
})
It("deploy clusterDeployment and infraEnv and with an invalid NMState config YAML", func() {
var (
NMStateLabelName = "someName"
NMStateLabelValue = "someValue"
nicPrimary = "eth0"
nicSecondary = "eth1"
macPrimary = "09:23:0f:d8:92:AA"
macSecondary = "09:23:0f:d8:92:AB"
)
nmstateConfigSpec := getDefaultNMStateConfigSpec(nicPrimary, nicSecondary, macPrimary, macSecondary, "foo: bar")
deployNMStateConfigCRD(ctx, kubeClient, "nmstate2", NMStateLabelName, NMStateLabelValue, nmstateConfigSpec)
deployClusterDeploymentCRD(ctx, kubeClient, clusterDeploymentSpec)
deployAgentClusterInstallCRD(ctx, kubeClient, aciSpec, clusterDeploymentSpec.ClusterInstallRef.Name)
installkey := types.NamespacedName{
Namespace: Options.Namespace,
Name: clusterDeploymentSpec.ClusterInstallRef.Name,
}
checkAgentClusterInstallCondition(ctx, installkey, hiveext.ClusterRequirementsMetCondition, hiveext.ClusterNotReadyReason)
infraEnvSpec.NMStateConfigLabelSelector = metav1.LabelSelector{MatchLabels: map[string]string{NMStateLabelName: NMStateLabelValue}}
deployInfraEnvCRD(ctx, kubeClient, infraNsName.Name, infraEnvSpec)
infraEnvKubeName := types.NamespacedName{
Namespace: Options.Namespace,
Name: infraNsName.Name,
}
// InfraEnv Reconcile takes longer, since it needs to generate the image.
checkInfraEnvCondition(ctx, infraEnvKubeName, v1beta1.ImageCreatedCondition, "Invalid YAML")
})

It("ensure StaticNetworkConfig is empty after NMStateConfig deletion", func() {
var (
NMStateLabelName = "someName"
Expand Down Expand Up @@ -5084,16 +5058,14 @@ spec:
}, "2m", "2s").Should(Equal(1))

By("Add skip-spoke-cleanup annotiaion")
Eventually(func() error {
agent := getClusterDeploymentAgents(ctx, kubeClient, clusterKey).Items[0]
annotations := agent.GetAnnotations()
annotations[controllers.AgentSkipSpokeCleanupAnnotation] = "true"
agent.SetAnnotations(annotations)
return kubeClient.Update(ctx, &agent)
}, "2m", "2s").Should(BeNil())
agent := getClusterDeploymentAgents(ctx, kubeClient, clusterKey).Items[0]
annotations := agent.GetAnnotations()
annotations[controllers.AgentSkipSpokeCleanupAnnotation] = "true"
agent.SetAnnotations(annotations)
Expect(kubeClient.Update(ctx, &agent)).To(BeNil())

By("Delete agent CR and validate")
agent := getClusterDeploymentAgents(ctx, kubeClient, clusterKey).Items[0]
agent = getClusterDeploymentAgents(ctx, kubeClient, clusterKey).Items[0]
Expect(kubeClient.Delete(ctx, &agent)).To(BeNil())
Eventually(func() int {
return len(getClusterDeploymentAgents(ctx, kubeClient, clusterKey).Items)
Expand Down Expand Up @@ -5288,33 +5260,6 @@ spec:
hiveext.ClusterSpecSyncedCondition)
Expect(condition.Message).To(ContainSubstring("User Managed Networking cannot be set with API VIP"))
})

It("updating infraenv OSImageVersion updates the image URL", func() {
infraEnvSpec.ClusterRef = nil
infraEnvSpec.OSImageVersion = "4.14"
deployInfraEnvCRD(ctx, kubeClient, infraNsName.Name, infraEnvSpec)

var url string
Eventually(func() string {
url = getInfraEnvCRD(ctx, kubeClient, infraNsName).Status.ISODownloadURL
return url
}, "15s", "1s").Should(Not(BeEmpty()))

Eventually(func() error {
infraEnv := getInfraEnvCRD(ctx, kubeClient, infraNsName)
infraEnv.Spec.OSImageVersion = "4.16"
return kubeClient.Update(ctx, infraEnv)
}, "1m", "20s").Should(BeNil())

var newURL string
Eventually(func() string {
newURL = getInfraEnvCRD(ctx, kubeClient, infraNsName).Status.ISODownloadURL
return newURL
}, "15s", "1s").Should(Not(Equal(url)))

updatedInfraEnv := getInfraEnvFromDBByKubeKey(ctx, db, infraNsName, waitForReconcileTimeout)
Expect(updatedInfraEnv.OpenshiftVersion).To(Equal("4.16"))
})
})

var _ = Describe("bmac reconcile flow", func() {
Expand Down

0 comments on commit 61c10d8

Please sign in to comment.