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

Allow to specify target cluster architecture for tests #3128

Merged
merged 1 commit into from
Aug 25, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ go test -v -count=1 -tags=e2e -timeout=20m ./test
go test -v -count=1 -tags=e2e -timeout=20m ./test --kubeconfig ~/special/kubeconfig --cluster myspecialcluster
```

If tests are applied to the cluster with hardware architecture different to the base one
(for instance `go test` starts on amd64 architecture and `--kubeconfig` points to s390x Kubernetes cluster),
use `TEST_RUNTIME_ARCH` environment variable to specify the target hardware architecture(amd64, s390x, ppc64le, arm, arm64, etc)

You can also use
[all of flags defined in `knative/pkg/test`](https://github.com/knative/pkg/tree/master/test#flags).

Expand Down
17 changes: 14 additions & 3 deletions test/multiarch_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package test

import (
"os"
"runtime"
"testing"
)
Expand All @@ -33,10 +34,20 @@ const (
Registry
)

// return architecture of the cluster where test suites will be executed.
// default value is similar to build architecture, TEST_RUNTIME_ARCH is used when test target cluster has another architecture
func getTestArch() string {
val, ok := os.LookupEnv("TEST_RUNTIME_ARCH")
if ok {
return val
}
return runtime.GOARCH
dlorenc marked this conversation as resolved.
Show resolved Hide resolved
}

func initImageNames() map[int]string {
mapping := make(map[int]string)

switch arch := runtime.GOARCH; arch {
switch getTestArch() {
case "s390x":
mapping[BusyboxSha] = "busybox@sha256:4f47c01fa91355af2865ac10fef5bf6ec9c7f42ad2321377c21e844427972977"
mapping[Registry] = "ibmcom/registry:2.6.2.5"
Expand All @@ -51,7 +62,7 @@ func initImageNames() map[int]string {
func initExcludedTests() map[string]bool {
mapping := make(map[string]bool)
tests := []string{}
switch arch := runtime.GOARCH; arch {
switch getTestArch() {
case "s390x":
//examples
tests = []string{
Expand Down Expand Up @@ -131,6 +142,6 @@ func GetTestImage(image int) string {
// check if test name is in the excluded list and skip it
func SkipIfExcluded(t *testing.T) {
if excludedTests[t.Name()] {
t.Skipf("skip for %s architecture", runtime.GOARCH)
t.Skipf("skip for %s architecture", getTestArch())
}
}