diff --git a/go.mod b/go.mod index 85d847d7a..e14ef938c 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/codeready-toolchain/toolchain-e2e require ( - github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7 - github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f + github.com/codeready-toolchain/api v0.0.0-20240708122235-0af5a9a178bb + github.com/codeready-toolchain/toolchain-common v0.0.0-20240716065433-8604fe46b96a github.com/davecgh/go-spew v1.1.1 github.com/fatih/color v1.12.0 github.com/ghodss/yaml v1.0.0 diff --git a/go.sum b/go.sum index 0f60b233f..309b78791 100644 --- a/go.sum +++ b/go.sum @@ -123,10 +123,10 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7 h1:o5JLcHCVS1BlZevw2mh1mH+iKwn9fLUrT1Ek8NFjvPY= -github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f h1:2qfRfyh7wfEnnfxrUtQeQrvhzWlkBCN0B/UXv1YUMiA= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f/go.mod h1:cyHrUfvBYEtsf+FbqQYmR9y0AQi9QAVtM3SUWLA5bd4= +github.com/codeready-toolchain/api v0.0.0-20240708122235-0af5a9a178bb h1:Wc9CMsv0ODZv9dM5qF3OI0mFDO95YNIXV/8oRvoz8aE= +github.com/codeready-toolchain/api v0.0.0-20240708122235-0af5a9a178bb/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240716065433-8604fe46b96a h1:HcaJtZCLfYkWZCxIa3iTvq3zgn711JGqPLkunBTfGSc= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240716065433-8604fe46b96a/go.mod h1:8M9k7w2VSyRKSK6P08Jo2ddW3uyGgxCcSitnYa3HK9o= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= diff --git a/test/e2e/toolchaincluster_test.go b/test/e2e/toolchaincluster_test.go index 6b77905a4..907f91410 100644 --- a/test/e2e/toolchaincluster_test.go +++ b/test/e2e/toolchaincluster_test.go @@ -24,13 +24,13 @@ func TestToolchainClusterE2E(t *testing.T) { memberAwait := awaitilities.Member1() memberAwait.WaitForToolchainClusterResources(t) - verifyToolchainCluster(t, hostAwait.Awaitility, memberAwait.Awaitility) - verifyToolchainCluster(t, memberAwait.Awaitility, hostAwait.Awaitility) + verifyToolchainCluster(t, hostAwait.Awaitility, memberAwait.Awaitility, true) + verifyToolchainCluster(t, memberAwait.Awaitility, hostAwait.Awaitility, false) } // verifyToolchainCluster verifies existence and correct conditions of ToolchainCluster CRD // in the target cluster type operator -func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wait.Awaitility) { +func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wait.Awaitility, singleCondition bool) { // given current, ok, err := await.GetToolchainCluster(t, otherAwait.Namespace, toolchainv1alpha1.ConditionReady) require.NoError(t, err) @@ -103,7 +103,7 @@ func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wa require.NoError(t, err) }) - t.Run(fmt.Sprintf("create new ToolchainCluster based on '%s' with incorrect data and expect to be offline", current.Name), func(t *testing.T) { + t.Run(fmt.Sprintf("create new ToolchainCluster based on '%s' with incorrect data and expect to be Not Ready", current.Name), func(t *testing.T) { // given name := generateNewName("new-offline-", current.Name) secretCopy := &corev1.Secret{} @@ -126,13 +126,22 @@ func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wa // wait for toolchaincontroller to reconcile time.Sleep(1 * time.Second) - // then the ToolchainCluster should be offline - require.NoError(t, err) - _, err = await.WaitForToolchainCluster(t, - wait.UntilToolchainClusterHasName(toolchainCluster.Name), - wait.UntilToolchainClusterHasCondition(toolchainv1alpha1.ToolchainClusterOffline), - ) + // then the ToolchainCluster should be Not Ready require.NoError(t, err) + if singleCondition { + _, err = await.WaitForToolchainCluster(t, + wait.UntilToolchainClusterHasName(toolchainCluster.Name), + wait.UntilToolchainClusterHasConditionFalseStatusAndReason(toolchainv1alpha1.ConditionReady, toolchainv1alpha1.ToolchainClusterClusterNotReachableReason), + ) + require.NoError(t, err) + } else { + // then the ToolchainCluster should be offline + _, err = await.WaitForToolchainCluster(t, + wait.UntilToolchainClusterHasName(toolchainCluster.Name), + wait.UntilToolchainClusterHasCondition(toolchainv1alpha1.ToolchainClusterOffline), + ) + require.NoError(t, err) + } // other ToolchainCluster should be ready, too _, err = await.WaitForToolchainCluster(t, wait.UntilToolchainClusterHasLabels( @@ -148,6 +157,7 @@ func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wa }), wait.UntilToolchainClusterHasCondition(toolchainv1alpha1.ConditionReady), ) require.NoError(t, err) + }) } diff --git a/testsupport/wait/awaitility.go b/testsupport/wait/awaitility.go index e209bbfb3..2c3d80b9a 100644 --- a/testsupport/wait/awaitility.go +++ b/testsupport/wait/awaitility.go @@ -539,6 +539,15 @@ func UntilToolchainClusterHasCondition(expected toolchainv1alpha1.ConditionType) } } +// UntilToolchainClusterHasCondition checks if ToolchainCluster has the given condition and False Status +func UntilToolchainClusterHasConditionFalseStatusAndReason(expected toolchainv1alpha1.ConditionType, reason string) ToolchainClusterWaitCriterion { + return ToolchainClusterWaitCriterion{ + Match: func(actual *toolchainv1alpha1.ToolchainCluster) bool { + return cd.IsFalseWithReason(actual.Status.Conditions, expected, reason) + }, + } +} + // UntilToolchainClusterHasLabels checks if ToolchainCluster has the given labels func UntilToolchainClusterHasLabels(expected client.MatchingLabels) ToolchainClusterWaitCriterion { return ToolchainClusterWaitCriterion{