Skip to content

Commit

Permalink
Create paired upgrade tests (#8158)
Browse files Browse the repository at this point in the history
* Re-use channel.ChannelChain reconciler-test feature in upgrade tests

* Fix glob -> global

* Remove redundant feature name from test name

* Remove Setup/Verify from test name

* Use slices.Concat from Golang 1.22

* Include setupEnv and setupCtx in DurableFeature

* Remove most pointers

* Refactor and use FeatureGroupWithUpgradeTests

* Try workaround for issues/8161

* Renames

* Expose EnvOpts and make DurableFeature more configurable
  • Loading branch information
mgencur authored Sep 10, 2024
1 parent 04c42dc commit 229446d
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 127 deletions.
3 changes: 3 additions & 0 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ function install_knative_eventing() {
UNINSTALL_LIST+=( "${EVENTING_RELEASE_YAML}" )
fi

# Workaround for https://github.com/knative/eventing/issues/8161
kubectl label namespace "${SYSTEM_NAMESPACE}" bindings.knative.dev/exclude=true --overwrite

# Setup config tracing for tracing tests
local TMP_CONFIG_TRACING_CONFIG=${TMP_DIR}/${CONFIG_TRACING_CONFIG##*/}
sed "s/namespace: ${KNATIVE_DEFAULT_NAMESPACE}/namespace: ${SYSTEM_NAMESPACE}/g" "${CONFIG_TRACING_CONFIG}" > "${TMP_CONFIG_TRACING_CONFIG}"
Expand Down
28 changes: 21 additions & 7 deletions test/rekt/features/channel/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ import (

func ChannelChain(length int, createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) *feature.Feature {
f := feature.NewFeature()
sink := feature.MakeRandomK8sName("sink")
cs := feature.MakeRandomK8sName("containersource")

sink, channel := ChannelChainSetup(f, length, createSubscriberFn)

ChannelChainAssert(f, sink, channel)

return f
}

func ChannelChainSetup(f *feature.Feature, length int, createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) (sink string, channel string) {
sink = feature.MakeRandomK8sName("sink")

var channels []string
for i := 0; i < length; i++ {
Expand Down Expand Up @@ -79,13 +87,19 @@ func ChannelChain(length int, createSubscriberFn func(ref *duckv1.KReference, ur
f.Setup("subscription is ready", subscription.IsReady(sub))
}

// attach the first channel to the source
f.Requirement("install containersource", containersource.Install(cs, containersource.WithSink(channel_impl.AsDestinationRef(channels[0]))))
f.Requirement("containersource goes ready", containersource.IsReady(cs))
return sink, channels[0]
}

f.Assert("chained channels relay events", assert.OnStore(sink).MatchEvent(test.HasType("dev.knative.eventing.samples.heartbeat")).AtLeast(1))
func ChannelChainAssert(f *feature.Feature, sink, channel string) {
cs := feature.MakeRandomK8sName("containersource")
eventType := feature.MakeRandomK8sName("et")
args := "--eventType=" + eventType
f.Requirement("install containersource", containersource.Install(cs,
containersource.WithSink(channel_impl.AsDestinationRef(channel)),
containersource.WithArgs(args)))
f.Requirement("containersource goes ready", containersource.IsReady(cs))

return f
f.Assert("chained channels relay events", assert.OnStore(sink).MatchEvent(test.HasType(eventType)).AtLeast(1))
}

func DeadLetterSink(createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) *feature.Feature {
Expand Down
27 changes: 0 additions & 27 deletions test/upgrade/postdowngrade.go

This file was deleted.

14 changes: 0 additions & 14 deletions test/upgrade/postupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,10 @@ import (
pkgupgrade "knative.dev/pkg/test/upgrade"
)

func SmokePostUpgradeTest() pkgupgrade.Operation {
return pkgupgrade.NewOperation("EventingPostUpgradeTest", func(c pkgupgrade.Context) {
runSmokeTest(c.T)
})
}

func CRDPostUpgradeTest() pkgupgrade.Operation {
return pkgupgrade.NewOperation("PostUpgradeCRDTest", func(c pkgupgrade.Context) {
client := testlib.Setup(c.T, true)
defer testlib.TearDown(client)
migrate.ExpectSingleStoredVersion(c.T, client.Apiextensions.CustomResourceDefinitions(), "knative.dev")
})
}

// PostUpgradeTests is an umbrella function for grouping all Eventing post-upgrade tests.
func PostUpgradeTests() []pkgupgrade.Operation {
return []pkgupgrade.Operation{
SmokePostUpgradeTest(),
CRDPostUpgradeTest(),
}
}
27 changes: 0 additions & 27 deletions test/upgrade/preupgrade.go

This file was deleted.

39 changes: 0 additions & 39 deletions test/upgrade/smoke.go

This file was deleted.

Loading

0 comments on commit 229446d

Please sign in to comment.