mirror of https://github.com/linkerd/linkerd2.git
Add integration test for upgrading from edge (#4557)
This adds an integration test for upgrading from the latest edge to the current build. Closes #4471 Signed-off-by: Kevin Leimkuhler kevin@kleimkuhler.com
This commit is contained in:
parent
d10ed2aa5e
commit
b0765c4361
|
@ -68,7 +68,7 @@ jobs:
|
|||
kind_integration_tests:
|
||||
strategy:
|
||||
matrix:
|
||||
integration_test: [deep, upgrade, helm, helm_upgrade, uninstall, custom_domain, external_issuer]
|
||||
integration_test: [deep, upgrade_stable, upgrade_edge, helm, helm_upgrade, uninstall, custom_domain, external_issuer]
|
||||
needs: [docker_build]
|
||||
name: Integration tests (${{ matrix.integration_test }})
|
||||
runs-on: ubuntu-18.04
|
||||
|
|
|
@ -78,7 +78,7 @@ jobs:
|
|||
kind_integration_tests:
|
||||
strategy:
|
||||
matrix:
|
||||
integration_test: [deep, upgrade, helm, helm_upgrade, uninstall, custom_domain, external_issuer]
|
||||
integration_test: [deep, upgrade_stable, upgrade_edge, helm, helm_upgrade, uninstall, custom_domain, external_issuer]
|
||||
needs: [docker_build]
|
||||
name: Integration tests (${{ matrix.integration_test }})
|
||||
runs-on: ubuntu-18.04
|
||||
|
|
|
@ -7,9 +7,13 @@
|
|||
# proper messages
|
||||
set +e
|
||||
|
||||
# Returns the latest stable verson
|
||||
latest_stable() {
|
||||
curl -s https://versioncheck.linkerd.io/version.json | grep -o "stable-[0-9]*.[0-9]*.[0-9]*"
|
||||
edge_install_url="https://run.linkerd.io/install-edge"
|
||||
stable_install_url="https://run.linkerd.io/install"
|
||||
|
||||
# Returns the latest version for the release channel
|
||||
# $1: release channel to check
|
||||
latest_release_channel() {
|
||||
curl -s https://versioncheck.linkerd.io/version.json | grep -o "$1-[0-9]*.[0-9]*.[0-9]*"
|
||||
}
|
||||
|
||||
# init_test_run parses input params, initializes global vars, and checks for
|
||||
|
@ -38,21 +42,33 @@ init_test_run() {
|
|||
|
||||
# These 3 functions are the primary entrypoints into running integration tests.
|
||||
# They each expect a fresh Kubernetes cluster:
|
||||
# 1. upgrade_integration_tests
|
||||
# 2. helm_upgrade_integration_tests
|
||||
# 3. helm_integration_tests
|
||||
# 4. uninstall_integration_tests
|
||||
# 5. custom_domain_integration_tests
|
||||
# 6. external_issuer_integration_tests
|
||||
# 1. upgrade_stable_integration_tests
|
||||
# 2. upgrade_edge_integration_tests
|
||||
# 3. helm_upgrade_integration_tests
|
||||
# 4. helm_integration_tests
|
||||
# 5. uninstall_integration_tests
|
||||
# 6. custom_domain_integration_tests
|
||||
# 7. external_issuer_integration_tests
|
||||
|
||||
upgrade_integration_tests() {
|
||||
upgrade_stable_integration_tests() {
|
||||
# run upgrade test:
|
||||
# 1. install latest stable
|
||||
# 2. upgrade to HEAD
|
||||
# 3. if failed, exit script to avoid leaving behind stale resources which will
|
||||
# fail subsequent tests. `cleanup` is not called if this test failed so that
|
||||
# there is a chance to debug the problem
|
||||
run_upgrade_test "$linkerd_namespace"-upgrade
|
||||
run_upgrade_test "stable" "$stable_install_url"
|
||||
cleanup
|
||||
}
|
||||
|
||||
upgrade_edge_integration_tests() {
|
||||
# run upgrade test:
|
||||
# 1. install latest edge
|
||||
# 2. upgrade to HEAD
|
||||
# 3. if failed, exit script to avoid leaving behind stale resources which will
|
||||
# fail subsequent tests. `cleanup` is not called if this test failed so that
|
||||
# there is a chance to debug the problem
|
||||
run_upgrade_test "edge" "$edge_install_url"
|
||||
cleanup
|
||||
}
|
||||
|
||||
|
@ -158,50 +174,56 @@ run_test(){
|
|||
GO111MODULE=on go test --failfast --mod=readonly "$filename" --linkerd="$linkerd_path" --k8s-context="$k8s_context" --integration-tests "$@" || exit 1
|
||||
}
|
||||
|
||||
# Install the latest stable release.
|
||||
# $1 - namespace to use for the stable release
|
||||
install_stable() {
|
||||
# Install a specific Linkerd version.
|
||||
# $1 - URL to use to download specific Linkerd version
|
||||
# $2 - namespace to use for the version
|
||||
# $3 - Linkerd version
|
||||
install_version() {
|
||||
tmp=$(mktemp -d -t l5dbin.XXX)
|
||||
|
||||
curl -s https://run.linkerd.io/install | HOME=$tmp sh > /dev/null 2>&1
|
||||
local install_url=$1
|
||||
curl -s "$install_url" | HOME=$tmp sh > /dev/null 2>&1
|
||||
|
||||
local linkerd_path=$tmp/.linkerd2/bin/linkerd
|
||||
local stable_namespace=$1
|
||||
local test_app_namespace=$stable_namespace-upgrade-test
|
||||
local upgrade_namespace=$2
|
||||
local test_app_namespace=$upgrade_namespace-upgrade-test
|
||||
|
||||
(
|
||||
set -x
|
||||
"$linkerd_path" install --linkerd-namespace="$stable_namespace" | kubectl --context="$k8s_context" apply -f - 2>&1
|
||||
"$linkerd_path" install --linkerd-namespace="$upgrade_namespace" | kubectl --context="$k8s_context" apply -f - 2>&1
|
||||
)
|
||||
exit_on_err 'install_stable() - installing stable failed'
|
||||
exit_on_err "install_version() - installing $3 failed"
|
||||
|
||||
(
|
||||
set -x
|
||||
"$linkerd_path" check --linkerd-namespace="$stable_namespace" 2>&1
|
||||
"$linkerd_path" check --linkerd-namespace="$upgrade_namespace" 2>&1
|
||||
)
|
||||
exit_on_err 'install_stable() - linkerd check failed'
|
||||
exit_on_err 'install_version() - linkerd check failed'
|
||||
|
||||
#Now we need to install the app that will be used to verify that upgrade does not break anything
|
||||
kubectl --context="$k8s_context" create namespace "$test_app_namespace" > /dev/null 2>&1
|
||||
kubectl --context="$k8s_context" label namespaces "$test_app_namespace" 'linkerd.io/is-test-data-plane'='true' > /dev/null 2>&1
|
||||
(
|
||||
set -x
|
||||
"$linkerd_path" inject --linkerd-namespace="$stable_namespace" "$test_directory/testdata/upgrade_test.yaml" | kubectl --context="$k8s_context" apply --namespace="$test_app_namespace" -f - 2>&1
|
||||
"$linkerd_path" inject --linkerd-namespace="$upgrade_namespace" "$test_directory/testdata/upgrade_test.yaml" | kubectl --context="$k8s_context" apply --namespace="$test_app_namespace" -f - 2>&1
|
||||
)
|
||||
exit_on_err 'install_stable() - linkerd inject failed'
|
||||
exit_on_err 'install_version() - linkerd inject failed'
|
||||
}
|
||||
|
||||
# Run the upgrade test by upgrading the most-recent stable release to the HEAD of
|
||||
# this branch.
|
||||
# $1 - namespace to use for the stable release
|
||||
run_upgrade_test() {
|
||||
local stable_namespace
|
||||
local stable_version
|
||||
stable_namespace=$1
|
||||
stable_version=$(latest_stable)
|
||||
local release_channel
|
||||
local upgrade_version
|
||||
local upgrade_namespace
|
||||
|
||||
install_stable "$stable_namespace"
|
||||
run_test "$test_directory/install_test.go" --upgrade-from-version="$stable_version" --linkerd-namespace="$stable_namespace"
|
||||
release_channel=$1
|
||||
upgrade_version=$(latest_release_channel "$release_channel")
|
||||
upgrade_namespace="$linkerd_namespace"-upgrade-"$release_channel"
|
||||
|
||||
install_version "$2" "$upgrade_namespace" "$upgrade_version"
|
||||
run_test "$test_directory/install_test.go" --upgrade-from-version="$upgrade_version" --linkerd-namespace="$upgrade_namespace"
|
||||
}
|
||||
|
||||
setup_helm() {
|
||||
|
|
16
bin/test-run
16
bin/test-run
|
@ -1,12 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script executes the full suite of integration tests, in series:
|
||||
# 1. upgrade_integration_tests
|
||||
# 2. helm_integration_tests
|
||||
# 3. helm_upgrade_integration_tests
|
||||
# 4. uninstall_integration_tests
|
||||
# 5. deep_integration_tests
|
||||
# 6. external_issuer_integration_tests
|
||||
# 1. upgrade_stable_integration_tests
|
||||
# 2. upgrade_edge_integration_tests
|
||||
# 3. helm_integration_tests
|
||||
# 4. helm_upgrade_integration_tests
|
||||
# 5. uninstall_integration_tests
|
||||
# 6. deep_integration_tests
|
||||
# 7. external_issuer_integration_tests
|
||||
|
||||
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
|
||||
|
||||
|
@ -18,7 +19,8 @@ init_test_run "$@"
|
|||
printf '==================RUNNING ALL TESTS==================\n'
|
||||
printf 'Testing Linkerd version [%s] namespace [%s] k8s-context [%s]\n' "$linkerd_version" "$linkerd_namespace" "$k8s_context"
|
||||
|
||||
upgrade_integration_tests
|
||||
upgrade_stable_integration_tests
|
||||
upgrade_edge_integration_tests
|
||||
helm_integration_tests
|
||||
helm_upgrade_integration_tests
|
||||
uninstall_integration_tests
|
||||
|
|
|
@ -247,20 +247,29 @@ func TestInstallOrUpgradeCli(t *testing.T) {
|
|||
|
||||
// test `linkerd upgrade --from-manifests`
|
||||
if TestHelper.UpgradeFromVersion() != "" {
|
||||
manifests, err := TestHelper.Kubectl("",
|
||||
"--namespace", TestHelper.GetLinkerdNamespace(),
|
||||
"get", "configmaps/"+k8s.ConfigConfigMapName, "secrets/"+k8s.IdentityIssuerSecretName,
|
||||
"-oyaml",
|
||||
)
|
||||
resources := []string{}
|
||||
resources = append(resources, "configmaps/"+k8s.ConfigConfigMapName, "secrets/"+k8s.IdentityIssuerSecretName)
|
||||
|
||||
// If `linkerd-config-addons` exists, add it to the resources to get
|
||||
_, err := TestHelper.Kubectl("", "--namespace", TestHelper.GetLinkerdNamespace(), "get", "configmaps/"+k8s.AddOnsConfigMapName)
|
||||
if err == nil {
|
||||
resources = append(resources, "configmaps/"+k8s.AddOnsConfigMapName)
|
||||
}
|
||||
|
||||
args := append([]string{"--namespace", TestHelper.GetLinkerdNamespace(), "get"}, resources...)
|
||||
args = append(args, "-oyaml")
|
||||
|
||||
manifests, err := TestHelper.Kubectl("", args...)
|
||||
if err != nil {
|
||||
testutil.AnnotatedFatalf(t, "'kubectl get' command failed",
|
||||
"'kubectl get' command failed with %s\n%s", err, out)
|
||||
"'kubectl get' command failed with %s\n%s\n%s", err, manifests, args)
|
||||
}
|
||||
|
||||
exec = append(exec, "--from-manifests", "-")
|
||||
upgradeFromManifests, stderr, err := TestHelper.PipeToLinkerdRun(manifests, exec...)
|
||||
if err != nil {
|
||||
testutil.AnnotatedFatalf(t, "'linkerd upgrade --from-manifests' command failed",
|
||||
"'linkerd upgrade --from-manifests' command failed with %s\n%s\n%s", err, stderr, upgradeFromManifests)
|
||||
"'linkerd upgrade --from-manifests' command failed with %s\n%s\n%s\n%s", err, stderr, upgradeFromManifests, manifests)
|
||||
}
|
||||
|
||||
if out != upgradeFromManifests {
|
||||
|
|
Loading…
Reference in New Issue