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

KUBESAW-100: Refactoring toolchaincluster controller-Pair Host operator #1005

Merged
merged 8 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module github.com/codeready-toolchain/toolchain-e2e

replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20240711160323-7b00b3208eb1

require (
github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7
github.com/codeready-toolchain/api v0.0.0-20240708122235-0af5a9a178bb
github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f
github.com/davecgh/go-spew v1.1.1
github.com/fatih/color v1.12.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ 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/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=
Expand Down Expand Up @@ -183,6 +181,8 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
github.com/fbm3307/toolchain-common v0.0.0-20240711160323-7b00b3208eb1 h1:ZGBbL3NTI9dNANXy+mk2y8sBHJ2LTBVNAif1pIaOx3A=
github.com/fbm3307/toolchain-common v0.0.0-20240711160323-7b00b3208eb1/go.mod h1:8M9k7w2VSyRKSK6P08Jo2ddW3uyGgxCcSitnYa3HK9o=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
30 changes: 20 additions & 10 deletions test/e2e/toolchaincluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{}
Expand All @@ -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(
Expand All @@ -148,6 +157,7 @@ func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wa
}), wait.UntilToolchainClusterHasCondition(toolchainv1alpha1.ConditionReady),
)
require.NoError(t, err)

})
}

Expand Down
9 changes: 9 additions & 0 deletions testsupport/wait/awaitility.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Loading