Skip to content

Commit 2a3596c

Browse files
authored
Merge branch 'master' into test-pairing
2 parents a73a916 + 46dedf0 commit 2a3596c

8 files changed

Lines changed: 57 additions & 40 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/codeready-toolchain/toolchain-e2e
22

33
require (
44
github.com/codeready-toolchain/api v0.0.0-20250131222557-beba5463f429
5-
github.com/codeready-toolchain/toolchain-common v0.0.0-20250131223755-a9c24d874b32
5+
github.com/codeready-toolchain/toolchain-common v0.0.0-20250225125153-139ef30bbd6d
66
github.com/davecgh/go-spew v1.1.1
77
github.com/fatih/color v1.15.0
88
github.com/ghodss/yaml v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
131131
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
132132
github.com/codeready-toolchain/api v0.0.0-20250131222557-beba5463f429 h1:I7xzHRmstvzucH9NqF54xvsM/yYuWOp/G5+BUr5j4tY=
133133
github.com/codeready-toolchain/api v0.0.0-20250131222557-beba5463f429/go.mod h1:gPwicZPTmRm1PF75ysEYXaYKdXoFgwgCggTJd1oYmOs=
134-
github.com/codeready-toolchain/toolchain-common v0.0.0-20250131223755-a9c24d874b32 h1:mX8aMYw9yPCSZuRNeZwShOPQDl0aTKV9FcEfb1Sdhiw=
135-
github.com/codeready-toolchain/toolchain-common v0.0.0-20250131223755-a9c24d874b32/go.mod h1:/PeschEEyTZIAsXQxIf83Fl8kOpSOHDfR5yyanz+bSA=
134+
github.com/codeready-toolchain/toolchain-common v0.0.0-20250225125153-139ef30bbd6d h1:iEUmJ9XB7Q6BUWG76ocuECZBPIY2wDxQhAXTAW3CM8g=
135+
github.com/codeready-toolchain/toolchain-common v0.0.0-20250225125153-139ef30bbd6d/go.mod h1:/PeschEEyTZIAsXQxIf83Fl8kOpSOHDfR5yyanz+bSA=
136136
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
137137
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
138138
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=

test/e2e/parallel/nstemplatetier_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestUpdateNSTemplateTier(t *testing.T) {
129129
verifyResourceUpdatesForSpaces(t, hostAwait, memberAwait, spaces, chocolateTier)
130130

131131
t.Log("updating tiers")
132-
// when updating the "cheesecakeTier" tier with the "advanced" template refs for namespace resources
132+
// when updating the "cheesecakeTier" tier with the "advanced" template refs for namespace resources and spaceroles
133133
cheesecakeTier = tiers.UpdateCustomNSTemplateTier(t, hostAwait, cheesecakeTier, tiers.WithNamespaceResources(t, advancedTier), tiers.WithSpaceRoles(t, advancedTier))
134134
// and when updating the "cookie" tier with the "baseextendedidling" template refs for both namespace resources and cluster-wide resources
135135
cookieTier = tiers.UpdateCustomNSTemplateTier(t, hostAwait, cookieTier, tiers.WithNamespaceResources(t, baseextendedidlingTier), tiers.WithClusterResources(t, baseextendedidlingTier))
@@ -290,7 +290,6 @@ func TestFeatureToggles(t *testing.T) {
290290
tiers.WithSpaceRoles(t, base1nsTier))
291291
_, err := hostAwait.WaitForNSTemplateTier(t, tier.Name)
292292
require.NoError(t, err)
293-
294293
// when
295294

296295
// Now let's create a Space
@@ -432,9 +431,13 @@ func TestTierTemplateRevision(t *testing.T) {
432431
updatedTTRs, err := hostAwait.WaitForTTRs(t, customTier.Name, wait.GreaterOrEqual(len(ttrs)+1))
433432
require.NoError(t, err)
434433
// get the updated nstemplatetier
435-
updatedCustomTier, err := hostAwait.WaitForNSTemplateTier(t, customTier.Name)
436-
newTTR, found := updatedCustomTier.Status.Revisions[updatedCustomTier.Spec.ClusterResources.TemplateRef]
437-
require.True(t, found)
434+
updatedCustomTier, err := wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.NSTemplateTier{}).
435+
WithNameMatching(customTier.Name, func(actual *toolchainv1alpha1.NSTemplateTier) bool {
436+
newTTR, found := actual.Status.Revisions[actual.Spec.ClusterResources.TemplateRef]
437+
return found && newTTR != "" && newTTR != ttrToBeModified
438+
})
439+
newTTR := updatedCustomTier.Status.Revisions[updatedCustomTier.Spec.ClusterResources.TemplateRef]
440+
438441
// check that it has the updated crq
439442
checkThatTTRContainsCRQ(t, newTTR, updatedTTRs, updatedCRQ)
440443

@@ -493,6 +496,7 @@ func TestTierTemplateRevision(t *testing.T) {
493496
wait.HasStatusTierTemplateRevisions(tiers.GetTemplateRefs(t, hostAwait, "updatingtier").Flatten()))
494497
require.NoError(t, err)
495498
updatingTier.NSTemplateTier = tier
499+
revisionsBeforeUpdate := updatingTier.Status.Revisions
496500
// and we update the tier with the "advanced" template refs for namespace and space role resources
497501
tiers.UpdateCustomNSTemplateTier(t, hostAwait, updatingTier, tiers.WithNamespaceResources(t, advancedTier), tiers.WithSpaceRoles(t, advancedTier))
498502

@@ -511,7 +515,7 @@ func TestTierTemplateRevision(t *testing.T) {
511515
wait.HasStatusTierTemplateRevisions(expectedRefs))
512516
require.NoError(t, err)
513517
// revisions values should be different compared to the previous ones
514-
assert.NotEqual(t, updatingTier.Status.Revisions, updatedTier.Status.Revisions)
518+
assert.NotEqual(t, revisionsBeforeUpdate, updatedTier.Status.Revisions)
515519
})
516520

517521
}

test/e2e/parallel/proxy_test.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -759,24 +759,22 @@ func runWatcher(t *testing.T, awaitilities wait.Awaitilities) *sync.WaitGroup {
759759
waitForWatcher.Add(1)
760760
// run the watch in a goroutine because it will take 40 seconds until the call is terminated
761761
go func() {
762-
t.Run("running the watcher", func(t *testing.T) {
763-
defer waitForWatcher.Done()
764-
withTimeout, cancelFunc := context.WithTimeout(context.Background(), contextTimeout)
765-
defer cancelFunc()
766-
767-
started := time.Now()
768-
t.Log("starting the watch call")
769-
_, err := watcherClient.RESTClient().Get().
770-
AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/configmaps", tenantNsName(watchUser.compliantUsername))).
771-
Param("resourceVersion", list.GetResourceVersion()).
772-
Param("watch", "true").
773-
Do(withTimeout).
774-
Get()
775-
t.Logf("stopping the watch after %s", time.Since(started))
776-
777-
require.EqualError(t, err, "unexpected error when reading response body. Please retry. Original error: context deadline exceeded", "The call should be terminated by the context timeout")
778-
assert.NotContains(t, err.Error(), "unexpected EOF", "If it contains 'unexpected EOF' then the call was terminated on the server side, which is not expected.")
779-
})
762+
defer waitForWatcher.Done()
763+
withTimeout, cancelFunc := context.WithTimeout(context.Background(), contextTimeout)
764+
defer cancelFunc()
765+
766+
started := time.Now()
767+
t.Log("starting the watch call")
768+
_, err := watcherClient.RESTClient().Get().
769+
AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/configmaps", tenantNsName(watchUser.compliantUsername))).
770+
Param("resourceVersion", list.GetResourceVersion()).
771+
Param("watch", "true").
772+
Do(withTimeout).
773+
Get()
774+
t.Logf("stopping the watch after %s", time.Since(started))
775+
776+
require.EqualError(t, err, "unexpected error when reading response body. Please retry. Original error: context deadline exceeded", "The call should be terminated by the context timeout") // nolint:testifylint
777+
assert.NotContains(t, err.Error(), "unexpected EOF", "If it contains 'unexpected EOF' then the call was terminated on the server side, which is not expected.")
780778
}()
781779
return &waitForWatcher
782780
}

testsupport/cleanup/clean.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,23 @@ func (c *cleanManager) clean(t *testing.T) func() {
6868
return func() {
6969
c.Lock()
7070
defer c.Unlock()
71-
var wg sync.WaitGroup
72-
for _, task := range c.cleanTasks[t] {
73-
wg.Add(1)
74-
go func(cleanTask *cleanTask) {
75-
defer wg.Done()
76-
cleanTask.clean()
77-
}(task)
71+
if !t.Failed() {
72+
var wg sync.WaitGroup
73+
for _, task := range c.cleanTasks[t] {
74+
wg.Add(1)
75+
go func(cleanTask *cleanTask) {
76+
defer wg.Done()
77+
cleanTask.clean()
78+
}(task)
79+
}
80+
wg.Wait()
81+
} else {
82+
t.Logf(
83+
"skipping object cleanup, test=%s failedTimestamp=%s",
84+
t.Name(),
85+
time.Now().Format(time.StampMilli),
86+
)
7887
}
79-
wg.Wait()
8088
c.cleanTasks[t] = nil
8189
}
8290
}

testsupport/space/space.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import (
66
"testing"
77

88
toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
9+
"github.com/codeready-toolchain/toolchain-common/pkg/hash"
910
testspace "github.com/codeready-toolchain/toolchain-common/pkg/test/space"
10-
testtier "github.com/codeready-toolchain/toolchain-common/pkg/test/tier"
1111
"github.com/codeready-toolchain/toolchain-e2e/testsupport"
1212
testsupportsb "github.com/codeready-toolchain/toolchain-e2e/testsupport/spacebinding"
1313
"github.com/codeready-toolchain/toolchain-e2e/testsupport/tiers"
1414
"github.com/codeready-toolchain/toolchain-e2e/testsupport/util"
1515
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"
16-
1716
"github.com/gofrs/uuid"
1817
"github.com/stretchr/testify/assert"
1918
"github.com/stretchr/testify/require"
@@ -123,7 +122,7 @@ func VerifyResourcesProvisionedForSpaceWithCustomTier(t *testing.T, hostAwait *w
123122
}
124123

125124
func verifyResourcesProvisionedForSpace(t *testing.T, hostAwait *wait.HostAwaitility, targetCluster *wait.MemberAwaitility, spaceName string, tier *toolchainv1alpha1.NSTemplateTier, checks tiers.TierChecks) (*toolchainv1alpha1.Space, *toolchainv1alpha1.NSTemplateSet) {
126-
hash, err := testtier.ComputeTemplateRefsHash(tier) // we can assume the JSON marshalling will always work
125+
hash, err := hash.ComputeHashForNSTemplateTier(tier)
127126
require.NoError(t, err)
128127

129128
// wait for space to be fully provisioned

testsupport/tiers/tier_setup.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ func CreateCustomNSTemplateTier(t *testing.T, hostAwait *wait.HostAwaitility, na
137137
}
138138
err := hostAwait.CreateWithCleanup(t, tier.NSTemplateTier)
139139
require.NoError(t, err)
140+
newTTier, err := hostAwait.WaitForNSTemplateTier(t, tier.Name,
141+
wait.HasStatusTierTemplateRevisions(GetTemplateRefs(t, hostAwait, tier.Name).Flatten()))
142+
require.NoError(t, err)
143+
tier.NSTemplateTier = newTTier
140144
return tier
141145
}
142146

@@ -157,6 +161,10 @@ func UpdateCustomNSTemplateTier(t *testing.T, hostAwait *wait.HostAwaitility, ti
157161
nstt.Spec = tier.NSTemplateTier.Spec
158162
})
159163
require.NoError(t, err)
164+
newTTier, err := hostAwait.WaitForNSTemplateTier(t, tier.Name,
165+
wait.HasStatusTierTemplateRevisions(GetTemplateRefs(t, hostAwait, tier.Name).Flatten()))
166+
require.NoError(t, err)
167+
tier.NSTemplateTier = newTTier
160168
return tier
161169
}
162170

testsupport/user_assertions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
corev1 "k8s.io/api/core/v1"
1212

1313
toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
14+
"github.com/codeready-toolchain/toolchain-common/pkg/hash"
1415
identitypkg "github.com/codeready-toolchain/toolchain-common/pkg/identity"
15-
testtier "github.com/codeready-toolchain/toolchain-common/pkg/test/tier"
1616
"github.com/codeready-toolchain/toolchain-e2e/testsupport/tiers"
1717
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"
1818

@@ -237,7 +237,7 @@ func VerifySpaceRelatedResources(t *testing.T, awaitilities wait.Awaitilities, u
237237

238238
tier, err := hostAwait.WaitForNSTemplateTier(t, spaceTierName)
239239
require.NoError(t, err)
240-
hash, err := testtier.ComputeTemplateRefsHash(tier) // we can assume the JSON marshalling will always work
240+
hash, err := hash.ComputeHashForNSTemplateTier(tier) // we can assume the JSON marshalling will always work
241241
require.NoError(t, err)
242242

243243
space, err := hostAwait.WaitForSpace(t, userSignup.Status.CompliantUsername,

0 commit comments

Comments
 (0)