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

Flags to configure eventing upgrade tests forwarder (ksvc) #3899

Merged
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
20 changes: 20 additions & 0 deletions test/upgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,23 @@ Diagram below describe the setup:
+--------+ +---------+ |
(default) +----------+
```

#### Probe test configuration

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):

```
$ export E2E_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
variable prefix (using
[kelseyhightower/envconfig](https://github.com/kelseyhightower/envconfig#usage)
usage).
11 changes: 8 additions & 3 deletions test/upgrade/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"testing"
"time"

"github.com/kelseyhightower/envconfig"
"github.com/wavesoftware/go-ensure"
"go.uber.org/zap"
testlib "knative.dev/eventing/test/lib"
Expand Down Expand Up @@ -63,8 +64,8 @@ type ServingConfig struct {
}

func NewConfig(namespace string) *Config {
return &Config{
Namespace: namespace,
config := &Config{
Namespace: "",
Interval: Interval,
FinishedSleep: 5 * time.Second,
FailOnErrors: true,
Expand All @@ -73,6 +74,10 @@ func NewConfig(namespace string) *Config {
ScaleToZero: true,
},
}
err := envconfig.Process("e2e_upgrade_tests", config)
ensure.NoError(err)
config.Namespace = namespace
return config
}

// RunEventProber starts a single Prober of the given domain.
Expand Down Expand Up @@ -151,7 +156,7 @@ func (p *prober) remove() {
if p.config.Serving.Use {
p.removeForwarder()
}
p.client.Tracker.Clean(true)
ensure.NoError(p.client.Tracker.Clean(true))
}

func newProber(log *zap.SugaredLogger, client *testlib.Client, config *Config) Prober {
Expand Down
60 changes: 60 additions & 0 deletions test/upgrade/prober/prober_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2020 The Knative Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package prober

import (
"fmt"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

type envValue uint

const (
EnvFalse envValue = iota
EnvTrue
EnvUnset
)

func TestNewConfig(t *testing.T) {
envname := "E2E_UPGRADE_TESTS_SERVING_USE"
suite := []struct {
env envValue
out bool
}{
{EnvFalse, false},
{EnvTrue, true},
{EnvUnset, false},
}
for _, s := range suite {
t.Run(fmt.Sprintf("env=%v,out=%t", s.env, s.out), func(t *testing.T) {
if s.env != EnvUnset {
val := "false"
if s.env == EnvTrue {
val = "true"
}
assert.NoError(t, os.Setenv(envname, val))
defer func() { assert.NoError(t, os.Unsetenv(envname)) }()
}
config := NewConfig("test-ns")

assert.Equal(t, s.out, config.Serving.Use)
assert.True(t, config.Serving.ScaleToZero)
})
}
}