mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-23 15:30:44 -04:00
e2e: improve upgrade test portability
This commit is contained in:
parent
5afb80c588
commit
a5c328a2a7
6 changed files with 43 additions and 6 deletions
2
.github/workflows/e2e-upgrade.yml
vendored
2
.github/workflows/e2e-upgrade.yml
vendored
|
@ -184,6 +184,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
KUBECONFIG: ${{ steps.e2e_test.outputs.kubeconfig }}
|
KUBECONFIG: ${{ steps.e2e_test.outputs.kubeconfig }}
|
||||||
run: |
|
run: |
|
||||||
|
kubectl logs -n kube-system -l "app.kubernetes.io/name=constellation-operator" --tail=-1 > node-operator.logs
|
||||||
kubectl logs -n kube-system -l "app.kubernetes.io/name=node-maintenance-operator" --tail=-1 > node-maintenance-operator.logs
|
kubectl logs -n kube-system -l "app.kubernetes.io/name=node-maintenance-operator" --tail=-1 > node-maintenance-operator.logs
|
||||||
kubectl get nodeversions.update.edgeless.systems constellation-version -o yaml > constellation-version.yaml
|
kubectl get nodeversions.update.edgeless.systems constellation-version -o yaml > constellation-version.yaml
|
||||||
|
|
||||||
|
@ -193,6 +194,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: upgrade-logs
|
name: upgrade-logs
|
||||||
path: |
|
path: |
|
||||||
|
node-operator.logs
|
||||||
node-maintenance-operator.logs
|
node-maintenance-operator.logs
|
||||||
constellation-version.yaml
|
constellation-version.yaml
|
||||||
|
|
||||||
|
|
|
@ -829,6 +829,14 @@ def go_dependencies():
|
||||||
sum = "h1:XmPu4mXICgdGnC5dXGjUGbwUD/kUmS0l5Aop3LaevBM=",
|
sum = "h1:XmPu4mXICgdGnC5dXGjUGbwUD/kUmS0l5Aop3LaevBM=",
|
||||||
version = "v0.0.0-20230317132445-9c3c1fc0106e",
|
version = "v0.0.0-20230317132445-9c3c1fc0106e",
|
||||||
)
|
)
|
||||||
|
go_repository(
|
||||||
|
name = "com_github_bazelbuild_rules_go",
|
||||||
|
build_file_generation = "on",
|
||||||
|
build_file_proto_mode = "disable_global",
|
||||||
|
importpath = "github.com/bazelbuild/rules_go",
|
||||||
|
sum = "h1:wkJLUDx59dntWMghuL8++GteoU1To6sRoKJXuyFtmf8=",
|
||||||
|
version = "v0.39.1",
|
||||||
|
)
|
||||||
|
|
||||||
go_repository(
|
go_repository(
|
||||||
name = "com_github_beeker1121_goque",
|
name = "com_github_beeker1121_goque",
|
||||||
|
|
|
@ -29,11 +29,11 @@ go_test(
|
||||||
# keep
|
# keep
|
||||||
count = 1,
|
count = 1,
|
||||||
data = [
|
data = [
|
||||||
"//cli:cli_enterprise_linux_amd64",
|
"//cli:cli_enterprise_host",
|
||||||
],
|
],
|
||||||
embed = [":upgrade"],
|
embed = [":upgrade"],
|
||||||
env = {
|
env = {
|
||||||
"PATH_CLI": "$(location //cli:cli_enterprise_linux_amd64)",
|
"PATH_CLI": "$(rlocationpath //cli:cli_enterprise_host)",
|
||||||
},
|
},
|
||||||
# keep
|
# keep
|
||||||
gotags = ["e2e"],
|
gotags = ["e2e"],
|
||||||
|
@ -48,6 +48,7 @@ go_test(
|
||||||
"//internal/versions",
|
"//internal/versions",
|
||||||
"@com_github_spf13_afero//:afero",
|
"@com_github_spf13_afero//:afero",
|
||||||
"@com_github_stretchr_testify//require",
|
"@com_github_stretchr_testify//require",
|
||||||
|
"@io_bazel_rules_go//go/runfiles:go_default_library",
|
||||||
"@io_k8s_api//core/v1:core",
|
"@io_k8s_api//core/v1:core",
|
||||||
"@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
|
"@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
|
||||||
"@io_k8s_client_go//kubernetes",
|
"@io_k8s_client_go//kubernetes",
|
||||||
|
|
|
@ -17,11 +17,13 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/bazelbuild/rules_go/go/runfiles"
|
||||||
"github.com/edgelesssys/constellation/v2/e2e/internal/kubectl"
|
"github.com/edgelesssys/constellation/v2/e2e/internal/kubectl"
|
||||||
attestationconfigfetcher "github.com/edgelesssys/constellation/v2/internal/api/attestationconfig/fetcher"
|
attestationconfigfetcher "github.com/edgelesssys/constellation/v2/internal/api/attestationconfig/fetcher"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
|
@ -68,6 +70,7 @@ func TestUpgrade(t *testing.T) {
|
||||||
|
|
||||||
require.NotEqual(*targetImage, "", "--target-image needs to be specified")
|
require.NotEqual(*targetImage, "", "--target-image needs to be specified")
|
||||||
|
|
||||||
|
log.Println("Waiting for nodes and pods to be ready.")
|
||||||
testNodesEventuallyAvailable(t, k, *wantControl, *wantWorker)
|
testNodesEventuallyAvailable(t, k, *wantControl, *wantWorker)
|
||||||
testPodsEventuallyReady(t, k, "kube-system")
|
testPodsEventuallyReady(t, k, "kube-system")
|
||||||
|
|
||||||
|
@ -75,6 +78,7 @@ func TestUpgrade(t *testing.T) {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
// Migrate config if necessary.
|
// Migrate config if necessary.
|
||||||
|
log.Println("Migrating config if needed.")
|
||||||
cmd := exec.CommandContext(context.Background(), cli, "config", "migrate", "--config", constants.ConfigFilename, "--force", "--debug")
|
cmd := exec.CommandContext(context.Background(), cli, "config", "migrate", "--config", constants.ConfigFilename, "--force", "--debug")
|
||||||
stdout, stderr, err := runCommandWithSeparateOutputs(cmd)
|
stdout, stderr, err := runCommandWithSeparateOutputs(cmd)
|
||||||
require.NoError(err, "Stdout: %s\nStderr: %s", string(stdout), string(stderr))
|
require.NoError(err, "Stdout: %s\nStderr: %s", string(stdout), string(stderr))
|
||||||
|
@ -138,16 +142,35 @@ func workingDir(workspace string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCLIPath returns the path to the CLI.
|
// getCLIPath returns the path to the CLI.
|
||||||
func getCLIPath(cliPath string) (string, error) {
|
func getCLIPath(cliPathFlag string) (string, error) {
|
||||||
pathCLI := os.Getenv("PATH_CLI")
|
pathCLI := os.Getenv("PATH_CLI")
|
||||||
|
var relCLIPath string
|
||||||
switch {
|
switch {
|
||||||
case pathCLI != "":
|
case pathCLI != "":
|
||||||
return pathCLI, nil
|
relCLIPath = pathCLI
|
||||||
case cliPath != "":
|
case cliPathFlag != "":
|
||||||
return cliPath, nil
|
relCLIPath = cliPathFlag
|
||||||
default:
|
default:
|
||||||
return "", errors.New("neither 'PATH_CLI' nor 'cli' flag set")
|
return "", errors.New("neither 'PATH_CLI' nor 'cli' flag set")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to find the CLI in the working directory
|
||||||
|
// (e.g. when running via `go test` or when specifying a path manually)
|
||||||
|
workdir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("getting working directory: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
absCLIPath := relCLIPath
|
||||||
|
if !filepath.IsAbs(relCLIPath) {
|
||||||
|
absCLIPath = filepath.Join(workdir, relCLIPath)
|
||||||
|
}
|
||||||
|
if _, err := os.Stat(absCLIPath); err == nil {
|
||||||
|
return absCLIPath, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// fall back to runfiles (e.g. when running via bazel)
|
||||||
|
return runfiles.Rlocation(pathCLI)
|
||||||
}
|
}
|
||||||
|
|
||||||
// testPodsEventuallyReady checks that:
|
// testPodsEventuallyReady checks that:
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -177,6 +177,7 @@ require (
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.18.11 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sts v1.18.11 // indirect
|
||||||
|
github.com/bazelbuild/rules_go v0.39.1
|
||||||
github.com/benbjohnson/clock v1.3.0 // indirect
|
github.com/benbjohnson/clock v1.3.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/blang/semver v3.5.1+incompatible // indirect
|
github.com/blang/semver v3.5.1+incompatible // indirect
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -295,6 +295,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.18.11/go.mod h1:BgQOMsg8av8jset59jel
|
||||||
github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8=
|
github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8=
|
||||||
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
||||||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
||||||
|
github.com/bazelbuild/rules_go v0.39.1 h1:wkJLUDx59dntWMghuL8++GteoU1To6sRoKJXuyFtmf8=
|
||||||
|
github.com/bazelbuild/rules_go v0.39.1/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU=
|
||||||
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
|
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||||
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
|
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue