Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: SANDBOX-816 refactor WaitForDeployments #1062

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion make/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ execute-tests:
@echo "Status of ToolchainStatus"
-oc get ToolchainStatus -n ${HOST_NS} -o yaml
@echo "Starting test $(shell date)"
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -v -timeout=90m -failfast || \
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} SECOND_MEMBER_MODE=${SECOND_MEMBER_MODE} go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -v -timeout=90m -failfast || \
($(MAKE) print-logs HOST_NS=${HOST_NS} MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} && exit 1)

.PHONY: print-logs
Expand Down
34 changes: 26 additions & 8 deletions testsupport/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func waitForOperators(t *testing.T) {
registrationServiceNs := os.Getenv(wait.RegistrationServiceVar)
t.Logf("Host Operator namespace: %s", hostNs)
t.Logf("Member1 Operator namespace: %s", memberNs)
t.Logf("Member2 Operator namespace: %s", memberNs2)
if IsSecondMemberMode(t) {
t.Logf("Member2 Operator namespace: %s", memberNs2)
}
t.Logf("Registration Service namespace: %s", registrationServiceNs)

apiConfig, err := clientcmd.NewDefaultClientConfigLoadingRules().Load()
Expand Down Expand Up @@ -97,14 +99,15 @@ func waitForOperators(t *testing.T) {
// wait for member operators to be ready
initMemberAwait = getMemberAwaitility(t, initHostAwait, kubeconfig, memberNs)

initMember2Await = getMemberAwaitility(t, initHostAwait, kubeconfig, memberNs2)

_, err = initMemberAwait.WaitForToolchainClusterWithCondition(t, initHostAwait.Namespace, toolchainv1alpha1.ConditionReady)
require.NoError(t, err)

_, err = initMember2Await.WaitForToolchainClusterWithCondition(t, initHostAwait.Namespace, toolchainv1alpha1.ConditionReady)
require.NoError(t, err)
if IsSecondMemberMode(t) {
initMember2Await = getMemberAwaitility(t, initHostAwait, kubeconfig, memberNs2)

_, err = initMember2Await.WaitForToolchainClusterWithCondition(t, initHostAwait.Namespace, toolchainv1alpha1.ConditionReady)
require.NoError(t, err)
}
t.Log("all operators are ready and in running state")
}

Expand Down Expand Up @@ -209,13 +212,17 @@ func WaitForDeployments(t *testing.T) wait.Awaitilities {
// Also verify the autoscaling buffer in both members
webhookImage := initMemberAwait.GetContainerEnv(t, "MEMBER_OPERATOR_WEBHOOK_IMAGE")
require.NotEmpty(t, webhookImage, "The value of the env var MEMBER_OPERATOR_WEBHOOK_IMAGE wasn't found in the deployment of the member operator.")
err = initMember2Await.WaitUntilWebhookDeleted(t) // webhook on member2 should be deleted
require.NoError(t, err)
if IsSecondMemberMode(t) {
err = initMember2Await.WaitUntilWebhookDeleted(t) // webhook on member2 should be deleted
require.NoError(t, err)
}
initMemberAwait.WaitForMemberWebhooks(t, webhookImage)

// wait for autoscaler buffer apps
initMemberAwait.WaitForAutoscalingBufferApp(t)
initMember2Await.WaitForAutoscalingBufferApp(t)
if IsSecondMemberMode(t) {
initMember2Await.WaitForAutoscalingBufferApp(t)
}

// check that the tier exists, and all its namespace other cluster-scoped resource revisions
// are different from `000000a` which is the value specified in the initial manifest (used for base tier)
Expand All @@ -228,6 +235,10 @@ func WaitForDeployments(t *testing.T) wait.Awaitilities {
require.NoError(t, err)
})

if !IsSecondMemberMode(t) {
return wait.NewAwaitilities(initHostAwait, initMemberAwait)
}

return wait.NewAwaitilities(initHostAwait, initMemberAwait, initMember2Await)
}

Expand Down Expand Up @@ -263,3 +274,10 @@ func schemeWithAllAPIs(t *testing.T) *runtime.Scheme {
require.NoError(t, builder.AddToScheme(s))
return s
}

func IsSecondMemberMode(t *testing.T) bool {
secondMemberMode := os.Getenv(wait.SecondMemberModeVar)
rsoaresd marked this conversation as resolved.
Show resolved Hide resolved
require.NotEmpty(t, secondMemberMode)

return secondMemberMode == "true"
}
1 change: 1 addition & 0 deletions testsupport/wait/awaitility.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
DefaultTimeout = time.Second * 120
MemberNsVar = "MEMBER_NS"
MemberNsVar2 = "MEMBER_NS_2"
SecondMemberModeVar = "SECOND_MEMBER_MODE"
HostNsVar = "HOST_NS"
RegistrationServiceVar = "REGISTRATION_SERVICE_NS"
ToolchainClusterConditionTimeout = 180 * time.Second
Expand Down
Loading