Skip to content
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
k8s.io/apiserver v0.18.8
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
knative.dev/hack v0.0.0-20201120192952-353db687ec5b
knative.dev/hack v0.0.0-20201125230335-c46a6498e9ed
knative.dev/pkg v0.0.0-20201125095035-9bf616d2f46a
knative.dev/reconciler-test v0.0.0-20201124190335-83a44efcdfef
sigs.k8s.io/yaml v1.2.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,9 @@ k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
knative.dev/hack v0.0.0-20201112185459-01a34c573bd8/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20201118155651-b31d3bb6bff9 h1:OgYL1cATsWTS6kztSOuQqhmYfcn6ZdpPAQQ6TKCx00I=
knative.dev/hack v0.0.0-20201118155651-b31d3bb6bff9/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20201120192952-353db687ec5b h1:Lc+AKgwhAZUD98mN++qTHeeaP6FRmS8fcwc/rXkP8G0=
knative.dev/hack v0.0.0-20201120192952-353db687ec5b/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20201125230335-c46a6498e9ed h1:DrTU+vxQrNJtySxyNovUtl4si0ozjtU/AYhYaTz34YA=
knative.dev/hack v0.0.0-20201125230335-c46a6498e9ed/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/pkg v0.0.0-20201117221452-0fccc54273ed/go.mod h1:nxlh3CUvx6WBPr1WKD96AHxFZPD2UKRDo9RUp8ILTyQ=
knative.dev/pkg v0.0.0-20201125095035-9bf616d2f46a h1:pdJpLaq50mLKrPWYSQgTH2p64Dk7Fq/xID6l0F69cVY=
knative.dev/pkg v0.0.0-20201125095035-9bf616d2f46a/go.mod h1:wXZqP8MXCxb51yNFlecA13BwG7Hk370SWDFWV4dx4ug=
Expand Down
3 changes: 2 additions & 1 deletion hack/generate-yamls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ RELEASES=(
readonly RELEASES
# Flags for all ko commands
KO_YAML_FLAGS="-P"
KO_FLAGS="${KO_FLAGS:-}"
[[ "${KO_DOCKER_REPO}" != gcr.io/* ]] && KO_YAML_FLAGS=""
readonly KO_YAML_FLAGS="${KO_YAML_FLAGS} ${KO_FLAGS} --platform=all"

if [[ -n "${TAG}" ]]; then
if [[ -n "${TAG:-}" ]]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the issue here @cardil ? just curious

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using strict bash setting of set -Eeuo pipefail that fails because of -u: fail on unset variable being dereferenced.

Bash could know if variable is unset or empty.

LABEL_YAML_CMD=(sed -e "s|eventing.knative.dev/release: devel|eventing.knative.dev/release: \"${TAG}\"|")
else
LABEL_YAML_CMD=(cat)
Expand Down
29 changes: 16 additions & 13 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

# This script includes common functions for testing setup and teardown.

# shellcheck disable=SC1090

export GO111MODULE=on

source $(dirname $0)/../vendor/knative.dev/hack/e2e-tests.sh
source "$(dirname "${BASH_SOURCE[0]}")/../vendor/knative.dev/hack/e2e-tests.sh"

# If gcloud is not available make it a no-op, not an error.
which gcloud &>/dev/null || gcloud() { echo "[ignore-gcloud $*]" 1>&2; }
Expand Down Expand Up @@ -56,14 +58,14 @@ readonly REPLICAS=3
# Should deploy a Knative Monitoring as well
readonly DEPLOY_KNATIVE_MONITORING="${DEPLOY_KNATIVE_MONITORING:-1}"

TMP_DIR=$(mktemp -d -t ci-$(date +%Y-%m-%d-%H-%M-%S)-XXXXXXXXXX)
TMP_DIR=$(mktemp -d -t "ci-$(date +%Y-%m-%d-%H-%M-%S)-XXXXXXXXXX")
readonly TMP_DIR
readonly KNATIVE_DEFAULT_NAMESPACE="knative-eventing"

# This the namespace used to install and test Knative Eventing.
export SYSTEM_NAMESPACE
SYSTEM_NAMESPACE="${SYSTEM_NAMESPACE:-"knative-eventing-"$(cat /dev/urandom \
| tr -dc 'a-z0-9' | fold -w 10 | head -n 1)}"
SYSTEM_NAMESPACE="${SYSTEM_NAMESPACE:-"knative-eventing-"$(head -c 128 < \
/dev/urandom | tr -dc 'a-z0-9' | fold -w 10 | head -n 1)}"

# Latest release. If user does not supply this as a flag, the latest
# tagged release on the current branch will be used.
Expand Down Expand Up @@ -109,14 +111,15 @@ function start_knative_eventing_monitoring() {
# All generated YAMLs will be available and pointed by the corresponding
# environment variables as set in /hack/generate-yamls.sh.
function build_knative_from_source() {
local YAML_LIST="$(mktemp)"
local FULL_OUTPUT YAML_LIST LOG_OUTPUT ENV_OUTPUT
YAML_LIST="$(mktemp)"

# Generate manifests, capture environment variables pointing to the YAML files.
local FULL_OUTPUT="$( \
source $(dirname $0)/../hack/generate-yamls.sh ${REPO_ROOT_DIR} ${YAML_LIST} ; \
FULL_OUTPUT="$( \
source "$(dirname "${BASH_SOURCE[0]}")/../hack/generate-yamls.sh" "${REPO_ROOT_DIR}" "${YAML_LIST}" ; \
set | grep _YAML=/)"
local LOG_OUTPUT="$(echo "${FULL_OUTPUT}" | grep -v _YAML=/)"
local ENV_OUTPUT="$(echo "${FULL_OUTPUT}" | grep '^[_0-9A-Z]\+_YAML=/')"
LOG_OUTPUT="$(echo "${FULL_OUTPUT}" | grep -v _YAML=/)"
ENV_OUTPUT="$(echo "${FULL_OUTPUT}" | grep '^[_0-9A-Z]\+_YAML=/')"
[[ -z "${LOG_OUTPUT}" || -z "${ENV_OUTPUT}" ]] && fail_test "Error generating manifests"
# Only import the environment variables pointing to the YAML files.
echo "${LOG_OUTPUT}"
Expand Down Expand Up @@ -198,7 +201,7 @@ function install_latest_release() {
}

function install_mt_broker() {
if [[ -z "${EVENTING_MT_CHANNEL_BROKER_YAML}" ]]; then
if [[ -z "${EVENTING_MT_CHANNEL_BROKER_YAML:-}" ]]; then
build_knative_from_source
else
echo "use exist EVENTING_MT_CHANNEL_BROKER_YAML"
Expand All @@ -214,7 +217,7 @@ function install_mt_broker() {
}

function install_sugar() {
if [[ -z "${EVENTING_SUGAR_CONTROLLER_YAML}" ]]; then
if [[ -z "${EVENTING_SUGAR_CONTROLLER_YAML:-}" ]]; then
build_knative_from_source
else
echo "use exist EVENTING_SUGAR_CONTROLLER_YAML"
Expand Down Expand Up @@ -290,7 +293,7 @@ function test_setup() {
install_test_resources || return 1

echo ">> Publish test images"
"$(dirname "$0")/upload-test-images.sh" e2e || fail_test "Error uploading test images"
"$(dirname "${BASH_SOURCE[0]}")/upload-test-images.sh" e2e || fail_test "Error uploading test images"
}

# Tear down resources used in the eventing tests.
Expand All @@ -308,7 +311,7 @@ function uninstall_test_resources() {

function install_channel_crds() {
echo "Installing In-Memory Channel CRD"
if [[ -z "${EVENTING_IN_MEMORY_CHANNEL_YAML}" ]]; then
if [[ -z "${EVENTING_IN_MEMORY_CHANNEL_YAML:-}" ]]; then
build_knative_from_source
else
echo "use exist EVENTING_SUGAR_CONTROLLER_YAML"
Expand Down
50 changes: 11 additions & 39 deletions test/e2e-upgrade-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

export GO111MODULE=on

source "$(dirname "$0")/e2e-common.sh"

readonly PROBER_READY_FILE="/tmp/prober-ready"
readonly PROBER_PIPE_FILE="/tmp/prober-signal"
# shellcheck disable=SC1090
source "$(dirname "${BASH_SOURCE[0]}")/e2e-common.sh"

# Overrides

function knative_setup {
install_latest_release || fail_test 'Installing latest release of Knative Eventing failed'
# Nothing to do at setup
true
}

function install_test_resources {
Expand All @@ -41,41 +40,14 @@ function uninstall_test_resources {
true
}

initialize $@ --skip-istio-addon

TIMEOUT=${TIMEOUT:-30m}

header "Running preupgrade tests"

go_test_e2e -tags=preupgrade -timeout="${TIMEOUT}" ./test/upgrade || fail_test

header "Starting prober test"
rm -fv ${PROBER_READY_FILE}
go_test_e2e -tags=probe -timeout="${TIMEOUT}" ./test/upgrade --pipefile="${PROBER_PIPE_FILE}" --readyfile="${PROBER_READY_FILE}" &
PROBER_PID=$!
echo "Prober PID is ${PROBER_PID}"

wait_for_file ${PROBER_READY_FILE} || fail_test

header "Performing upgrade to HEAD"
install_head || fail_test 'Installing HEAD version of eventing failed'
install_channel_crds || fail_test 'Installing HEAD channel CRDs failed'
install_mt_broker || fail_test 'Installing HEAD Broker failed'
install_sugar || fail_test 'Installing HEAD Sugar failed'

header "Running postupgrade tests"
go_test_e2e -tags=postupgrade -timeout="${TIMEOUT}" ./test/upgrade || fail_test

header "Performing downgrade to latest release"
install_latest_release || fail_test 'Installing latest release of Knative Eventing failed'

header "Running postdowngrade tests"
go_test_e2e -tags=postdowngrade -timeout="${TIMEOUT}" ./test/upgrade || fail_test
initialize "$@" --skip-istio-addon

# The prober is blocking on ${PROBER_PIPE_FILE} to know when it should exit.
echo "done" > ${PROBER_PIPE_FILE}
TIMEOUT=${TIMEOUT:-60m}

header "Waiting for prober test"
wait ${PROBER_PID} || fail_test "Prober failed"
go_test_e2e \
-tags=upgrade \
-timeout="${TIMEOUT}" \
./test/upgrade \
|| fail_test

success
8 changes: 5 additions & 3 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

# Prefer sockpuppet over markdown presubmit checks, as it will correct
# markdown issues with less human involvement.
export DISABLE_MD_LINTING=1

# shellcheck disable=SC1090

export DISABLE_MD_LINTING=1
export GO111MODULE=on

source $(dirname $0)/../vendor/knative.dev/hack/presubmit-tests.sh
source "$(dirname "${BASH_SOURCE[0]}")/../vendor/knative.dev/hack/presubmit-tests.sh"

# We use the default build, unit and integration test runners.

main $@
main "$@"
44 changes: 44 additions & 0 deletions test/upgrade/continual.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
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 upgrade

import (
"context"

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

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)
},
)
}
40 changes: 40 additions & 0 deletions test/upgrade/installation/git_head.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
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 installation

import (
pkgupgrade "knative.dev/pkg/test/upgrade"
)

func GitHead() pkgupgrade.Operation {
return pkgupgrade.NewOperation("EventingGitHead", func(c pkgupgrade.Context) {
ops := []string{
"install_head",
"install_channel_crds",
"install_mt_broker",
"install_sugar",
}
Comment on lines +25 to +30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little bit concerned about this as sometimes there may be hacky code in bash script to install it properly, eg waiting to make sure all the pods in the previous step are running before applying next. I am wondering if there is a bash function that does all these installations and we can just call the bash function instead. But for sure we can change it later if such a bash function is required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no such function. Each of those functions has appropriate waits built inside, so it isn't needed.

Current code executes them directly: https://github.com/knative/eventing/pull/4519/files#diff-1c4d417537c9878a5068005f79761334318400204068c4dfd4a7656226bfefe1L61-L64

for _, shellfunc := range ops {
c.Log.Info("Running shell function: ", shellfunc)
err := callShellFunction(shellfunc)
if err != nil {
c.T.Error(err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Fatal instead? Or I am guessing the Operation caller will call Fatal when there is an error in installation, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will break operations, yeah.

return
}
}
})
}
33 changes: 33 additions & 0 deletions test/upgrade/installation/latest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
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 installation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can just use install instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used installation as I wanted noun, packages should be nouns. install is a verb.

That's why I think installation is better one.


import (
pkgupgrade "knative.dev/pkg/test/upgrade"
)

func LatestStable() pkgupgrade.Operation {
return pkgupgrade.NewOperation("EventingLatestRelease", func(c pkgupgrade.Context) {
shellfunc := "install_latest_release"
c.Log.Info("Running shell function: ", shellfunc)
err := callShellFunction(shellfunc)
if err != nil {
c.T.Error(err)
return
}
})
}
39 changes: 39 additions & 0 deletions test/upgrade/installation/shell.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
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 installation

import (
"knative.dev/hack/shell"
)

func callShellFunction(funcName string) error {
loc, err := shell.NewProjectLocation("../../..")
if err != nil {
return err
}
exec := shell.NewExecutor(shell.ExecutorConfig{
ProjectLocation: loc,
})
fn := shell.Function{
Script: shell.Script{
Label: funcName,
ScriptPath: "test/e2e-common.sh",
},
FunctionName: funcName,
}
return exec.RunFunction(fn)
}
27 changes: 27 additions & 0 deletions test/upgrade/postdowngrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
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 upgrade

import (
pkgupgrade "knative.dev/pkg/test/upgrade"
)

func PostDowngradeTest() pkgupgrade.Operation {
return pkgupgrade.NewOperation("EventingPostDowngradeTest", func(c pkgupgrade.Context) {
runSmokeTest(c.T)
})
}
Loading