Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/mitchellh/go-homedir v1.1.0
github.com/openzipkin/zipkin-go v0.2.5
github.com/pelletier/go-toml v1.8.0
github.com/pelletier/go-toml/v2 v2.0.0-beta.2
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/errors v0.9.1
github.com/rickb777/date v1.13.0
github.com/robfig/cron/v3 v3.0.1
github.com/rogpeppe/fastuuid v1.2.0
github.com/stretchr/testify v1.6.1
github.com/stretchr/testify v1.7.0
github.com/tsenart/vegeta/v12 v12.8.4
github.com/wavesoftware/go-ensure v1.0.0
go.opencensus.io v0.23.0
Expand Down
8 changes: 5 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,10 @@ github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw=
github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs=
github.com/pelletier/go-toml/v2 v2.0.0-beta.2 h1:f/g66OWmYXmVnYL3UAhqpM9YuWKFR2vjYfFNSDQcHPQ=
github.com/pelletier/go-toml/v2 v2.0.0-beta.2/go.mod h1:+X+aW6gUj6Hda43TeYHVCIvYNG/jqY/8ZFXAeXXHl+Q=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
Expand Down Expand Up @@ -620,8 +621,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down
25 changes: 17 additions & 8 deletions test/lib/resources/eventing.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,16 @@ func WithDependencyAnnotationTrigger(dependencyAnnotation string) TriggerOption
}
}

// WithSubscriberServiceRefForTrigger returns an option that adds a Subscriber Knative Service Ref for the given v1 Trigger.
// WithSubscriberServiceRefForTrigger returns an option that adds a Subscriber Knative Service Ref for the given v1beta1 Trigger.
func WithSubscriberServiceRefForTrigger(name string) TriggerOption {
return func(t *eventingv1.Trigger) {
if name != "" {
t.Spec.Subscriber = duckv1.Destination{
Ref: KnativeRefForService(name, t.Namespace),
}
return WithSubscriberDestination(func(t *eventingv1.Trigger) duckv1.Destination {
return duckv1.Destination{
Ref: KnativeRefForService(name, t.Namespace),
}
}
})
}

// WithSubscriberURIForTrigger returns an option that adds a Subscriber URI for the given v1 Trigger.
// WithSubscriberURIForTrigger returns an option that adds a Subscriber URI for the given v1beta1 Trigger.
func WithSubscriberURIForTrigger(uri string) TriggerOption {
apisURI, _ := apis.ParseURL(uri)
return func(t *eventingv1.Trigger) {
Expand All @@ -259,6 +257,17 @@ func WithSubscriberURIForTrigger(uri string) TriggerOption {
}
}

// WithSubscriberDestination returns an option that adds a Subscriber for given
// duckv1.Destination.
func WithSubscriberDestination(destFactory func(t *eventingv1.Trigger) duckv1.Destination) TriggerOption {
return func(t *eventingv1.Trigger) {
dest := destFactory(t)
if dest.Ref != nil || dest.URI != nil {
t.Spec.Subscriber = dest
}
}
}

// WithBroker returns an option that adds a broker for the given Trigger.
func WithBroker(name string) TriggerOption {
return func(trigger *eventingv1.Trigger) {
Expand Down
2 changes: 1 addition & 1 deletion test/test_images/wathola-forwarder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

func TestForwarderMain(t *testing.T) {
port := freeport.GetPort()
config.Instance.LogLevel = zapcore.DebugLevel
config.Instance.LogLevel = zapcore.DebugLevel.String()
config.Instance.Forwarder.Port = port
go main()
time.Sleep(time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion test/test_images/wathola-receiver/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

func TestReceiverMain(t *testing.T) {
port := freeport.GetPort()
config.Instance.LogLevel = zapcore.DebugLevel
config.Instance.LogLevel = zapcore.DebugLevel.String()
config.Instance.Receiver.Port = port
go main()
time.Sleep(time.Millisecond)
Expand Down
74 changes: 42 additions & 32 deletions test/upgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Running these tests on every commit will ensure that we don’t introduce any
non-upgradeable changes, so every commit should be releasable.

This is inspired by kubernetes
[upgrade testing](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/e2e-tests.md#version-skewed-and-upgrade-testing).
[upgrade testing](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/e2e-tests.md#version-skewed-and-upgrade-testing)
.

These tests are a pretty big hammer in that they cover more than just version
changes, but it’s one of the only ways to make sure we don’t accidentally make
Expand All @@ -26,15 +27,19 @@ At a high level, we want to do this:
1. Run any post-install jobs that apply for the release to be.
1. Test those resources, verify that we didn’t break anything.

To achieve that, we just have three separate build tags:
To achieve that, we created an upgrade framework (knative.dev/pkg/test/upgrade).
This framework will enforce running upgrade tests in specific order and supports
continual verification of system under test. In case of Eventing it is:

1. Install the latest release from GitHub.
1. Run the `preupgrade` tests in this directory.
1. Install at HEAD (`ko apply -f config/`).
1. Run the post-install job. For v0.15 we need to migrate storage versions.
1. Run the `postupgrade` tests in this directory.
1. Run the `preupgrade` smoke tests.
1. Start `continual` tests that will propagate events in the background, while
upgrading and downgrading.
1. Install at HEAD (`ko apply -f config/`) and run the post-install jobs.
1. Run the `postupgrade` smoke tests.
1. Install the latest release from GitHub.
1. Run the `postdowngrade` tests in this directory.
1. Run the `postdowngrade` smoke tests.
1. Stop and verify `continual` tests, checking if every event propagated well.

## Tests

Expand All @@ -52,42 +57,47 @@ In order to verify that we don't have data-plane unavailability during our
control-plane outages (when we're upgrading the knative/eventing installation),
we run a prober test that continually sends events to a service during the
entire upgrade/downgrade process. When the upgrade completes, we make sure that
all of those events propagated just once.

To achieve that a [wathola tool](test/upgrade/prober/wathola) was prepared. It
consists of 4 components: _sender_, _forwarder_, _receiver_, and _fetcher_.
_Sender_ is the usual Kubernetes deployment that publishes events to the default
`broker` with given interval. When it terminates (by either `SIGTERM`, or
all of those events propagated at least once.

To achieve that
a [wathola tool](https://pkg.go.dev/knative.dev/eventing/test/upgrade/prober/wathola)
was prepared. It consists of 4 components: _sender_, _forwarder_, _receiver_,
and _fetcher_. _Sender_ is the usual Kubernetes deployment that publishes events
to the System Under Tests (SUT). By default, SUT is a default `broker`
with two triggers for each type of events being sent. _Sender_ will send events
with given interval. When it terminates (by either `SIGTERM`, or
`SIGINT`), a `finished` event is generated. _Forwarder_ is a knative serving
service that scales up from zero to receive the sent events and forward them to
given target which is the _receiver_ in our case. _Receiver_ is an ordinary
deployment that collects events from multiple forwarders and has an endpoint
`/report` that can be polled to get the status of received events. To fetch the
report from within the cluster _fetcher_ comes in. It's a simple one time job,
that will fetch the report from _receiver_ and print it on stdout as JSON. That
enables the test client to download _fetcher_ logs and parse the JSON to get the
final report.
deployment that collects events from multiple forwarders and has an
endpoint `/report` that can be polled to get the status of received events. To
fetch the report from within the cluster _fetcher_ comes in. It's a simple one
time job, that will fetch the report from _receiver_ and print it on stdout as
JSON. That enables the test client to download _fetcher_ logs and parse the JSON
to get the final report.

Diagram below describe the setup:

```
K8s cluster | Test machine
|
(deploym.) (ksvc) (deploym.) |
(deployment) (ksvc) (deployment) |
+--------+ +-----------+ +----------+ | +------------+
| | | ++ | | | | |
| Sender | +-->| Forwarder ||----->+ Receiver | | + TestProber |
| | | | || | |<---+ | | |
+---+----+ | +------------| +----------+ | | +------------+
| | +-----------+ | |
| | | |
| | +---------+ |
| +--+-----+ +---------+ | | |
+-----> | | +-+ + Fetcher | |
| Broker | < - > | Trigger | | | | |
| | | | | +---------+ |
+--------+ +---------+ | (job) |
(default) +----------+ |
| ```````|````````````````````````````` | |
| ` | ` +---------+ |
| ` +--+-----+ +---------+ ` | | |
+-----> | | +-+ ` | Fetcher | |
` | Broker | < - > | Trigger | | ` | | |
` | | | | | ` +---------+ |
` +--------+ +---------+ | ` (job) |
` (default) +----------+ ` |
` (SUT) `
`````````````````````````````````````
```

#### Probe test configuration
Expand All @@ -96,16 +106,16 @@ Probe test behavior can be influenced from outside without modifying its source
code. That can be beneficial if one would like to run upgrade tests in different
context. One such example might be running Eventing upgrade tests in place that
have Serving and Eventing both installed. In such environment one can set
environment variable `E2E_UPGRADE_TESTS_SERVING_USE` to enable usage of ksvc
forwarder (which is disabled by default):
environment variable `EVENTING_UPGRADE_TESTS_SERVING_USE` to enable usage of
ksvc forwarder (which is disabled by default):

```
$ export E2E_UPGRADE_TESTS_SERVING_USE=true
$ export EVENTING_UPGRADE_TESTS_SERVING_USE=true
```

Any option, apart from namespace, in
[`knative.dev/eventing/test/upgrade/prober.Config`](https://github.com/knative/eventing/blob/022e281/test/upgrade/prober/prober.go#L52-L63)
struct can be influenced, by using `E2E_UPGRADE_TESTS_XXXXX` environmental
struct can be influenced, by using `EVENTING_UPGRADE_TESTS_XXXXX` environmental
variable prefix (using
[kelseyhightower/envconfig](https://github.com/kelseyhightower/envconfig#usage)
usage).
22 changes: 3 additions & 19 deletions test/upgrade/continual.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,12 @@ limitations under the License.
package upgrade

import (
"context"

testlib "knative.dev/eventing/test/lib"
"knative.dev/eventing/test/upgrade/prober"
pkgupgrade "knative.dev/pkg/test/upgrade"
)

// ContinualTest will perform a continual validation of Eventing SUT.
func ContinualTest() pkgupgrade.BackgroundOperation {
ctx := context.Background()
var client *testlib.Client
var probe prober.Prober
return pkgupgrade.NewBackgroundVerification("EventingContinualTest",
func(c pkgupgrade.Context) {
// setup
client = testlib.Setup(c.T, false)
config := prober.NewConfig(client.Namespace)
probe = prober.RunEventProber(ctx, c.Log, client, config)
},
func(c pkgupgrade.Context) {
// verify
defer testlib.TearDown(client)
prober.AssertEventProber(ctx, c.T, probe)
},
)
return prober.NewContinualVerification("EventingContinualTest",
prober.ContinualVerificationOptions{})
}
6 changes: 3 additions & 3 deletions test/upgrade/prober/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# logLevel = 5 # DEBUG(5)
# logLevel = 'DEBUG'
[sender]
address = '{{- .BrokerURL -}}'
address = '{{- .Endpoint -}}'
interval = {{ .Config.Interval.Nanoseconds }}
[forwarder]
target = 'http://wathola-receiver.{{- .Config.Namespace -}}.svc.cluster.local'
target = 'http://wathola-receiver.{{- .Namespace -}}.svc.cluster.local'
Loading