-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration test framework (#15)
- Loading branch information
Showing
3,610 changed files
with
1,089,845 additions
and
29 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: 2022 "SAP SE or an SAP affiliate company and Gardener contributors" | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
import utils | ||
import yaml | ||
import json | ||
import model.container_registry | ||
import oci.auth as oa | ||
|
||
from util import ctx | ||
from subprocess import run | ||
|
||
project_root = os.environ["PROJECT_ROOT"] | ||
target_cluster = os.environ["TARGET_CLUSTER"] | ||
target_cluster_provider = os.environ["TARGET_CLUSTER_PROVIDER"] | ||
laas_version = os.environ["LAAS_VERSION"] | ||
laas_repository = os.environ["LAAS_REPOSITORY"] | ||
repo_ctx_base_url = os.environ["REPO_CTX_BASE_URL"] | ||
repo_auth_url = os.environ["REPO_AUTH_URL"] | ||
|
||
factory = ctx().cfg_factory() | ||
print(f"Getting kubeconfig for {target_cluster}") | ||
landscape_kubeconfig = factory.kubernetes(target_cluster) | ||
|
||
print(f"Getting credentials for {repo_ctx_base_url}") | ||
cr_conf = model.container_registry.find_config(repo_ctx_base_url, oa.Privileges.READONLY) | ||
|
||
with utils.TempFileAuto(prefix="landscape_kubeconfig_") as kubeconfig_temp_file, utils.TempFileAuto(prefix="registry_auth_", suffix=".json") as registry_temp_file: | ||
kubeconfig_temp_file.write(yaml.safe_dump(landscape_kubeconfig.kubeconfig())) | ||
landscape_kubeconfig_path = kubeconfig_temp_file.switch() | ||
|
||
auth = utils.base64_encode_to_string(cr_conf.credentials().username() + ":" + cr_conf.credentials().passwd()) | ||
auths = { | ||
"auths": { | ||
repo_auth_url: { | ||
"auth": auth | ||
} | ||
} | ||
} | ||
|
||
registry_temp_file.write(json.dumps(auths)) | ||
registry_secrets_path = registry_temp_file.switch() | ||
|
||
command = ["go", "run", "./pkg/main.go", | ||
"--kubeconfig", landscape_kubeconfig_path, | ||
"--provider-type", target_cluster_provider, | ||
"--laas-version", laas_version, | ||
"--laas-repository", laas_repository, | ||
"--registry-secrets", registry_secrets_path] | ||
|
||
print(f"Running integration test with command: {' '.join(command)}") | ||
|
||
mod_path = os.path.join(project_root, "integration-test") | ||
run = run(command, cwd=mod_path) | ||
|
||
if run.returncode != 0: | ||
raise EnvironmentError("Integration test exited with errors") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# SPDX-FileCopyrightText: 2022 "SAP SE or an SAP affiliate company and Gardener contributors" | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import tempfile | ||
import base64 | ||
|
||
|
||
class TempFileAuto(object): | ||
def __init__(self, prefix=None, mode='w+', suffix=".yaml"): | ||
self.file_obj = tempfile.NamedTemporaryFile(mode=mode, prefix=prefix, suffix=suffix, delete=False) | ||
self.name = self.file_obj.name | ||
def __enter__(self): | ||
return self | ||
def write(self, b): | ||
self.file_obj.write(b) | ||
def writelines(self, lines): | ||
self.file_obj.writelines(lines) | ||
def switch(self): | ||
self.file_obj.close() | ||
return self.file_obj.name | ||
def __exit__(self, type, value, traceback): | ||
if not self.file_obj.closed: | ||
self.file_obj.close() | ||
os.remove(self.file_obj.name) | ||
return False | ||
|
||
def base64_encode_to_string(value): | ||
value = value.rstrip() | ||
if isinstance(value, str): | ||
value = value.encode('utf-8') | ||
return base64.b64encode(value).decode('utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
module github.com/gardener/landscaper-service/test/integration | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/gardener/component-spec/bindings-go v0.0.53 | ||
github.com/gardener/landscaper-service v0.0.0-00010101000000-000000000000 | ||
github.com/gardener/landscaper/apis v0.23.0 | ||
github.com/gardener/landscaper/controller-utils v0.23.0 | ||
github.com/gardener/landscapercli v0.16.1-0.20220408051006-1a25c3c0b246 | ||
github.com/go-logr/logr v0.4.0 | ||
k8s.io/api v0.22.2 | ||
k8s.io/apimachinery v0.22.2 | ||
k8s.io/client-go v0.22.2 | ||
sigs.k8s.io/controller-runtime v0.10.3 | ||
) | ||
|
||
require ( | ||
github.com/Microsoft/go-winio v0.5.0 // indirect | ||
github.com/Microsoft/hcsshim v0.8.23 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.1 // indirect | ||
github.com/containerd/containerd v1.5.10 // indirect | ||
github.com/containerd/continuity v0.2.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/docker/cli v20.10.7+incompatible // indirect | ||
github.com/docker/distribution v2.7.1+incompatible // indirect | ||
github.com/docker/docker v17.12.0-ce-rc1.0.20200618181300-9dc6525e6118+incompatible // indirect | ||
github.com/docker/docker-credential-helpers v0.6.3 // indirect | ||
github.com/docker/go-units v0.4.0 // indirect | ||
github.com/evanphx/json-patch v4.11.0+incompatible // indirect | ||
github.com/fsnotify/fsnotify v1.4.9 // indirect | ||
github.com/gardener/component-cli v0.36.0 // indirect | ||
github.com/gardener/landscaper v0.21.0 // indirect | ||
github.com/ghodss/yaml v1.0.0 // indirect | ||
github.com/go-logr/zapr v0.4.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/go-cmp v0.5.6 // indirect | ||
github.com/google/go-containerregistry v0.5.0 // indirect | ||
github.com/google/gofuzz v1.1.0 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/googleapis/gnostic v0.5.5 // indirect | ||
github.com/imdario/mergo v0.3.12 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.11 // indirect | ||
github.com/klauspost/compress v1.13.6 // indirect | ||
github.com/mandelsoft/filepath v0.0.0-20200909114706-3df73d378d55 // indirect | ||
github.com/mandelsoft/spiff v1.6.1 // indirect | ||
github.com/mandelsoft/vfs v0.0.0-20210530103237-5249dc39ce91 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/moby/locker v1.0.1 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.1 // indirect | ||
github.com/opencontainers/distribution-spec v1.0.0-rc1 // indirect | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/opencontainers/image-spec v1.0.2 // indirect | ||
github.com/opencontainers/runc v1.0.2 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/prometheus/client_golang v1.11.0 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.26.0 // indirect | ||
github.com/prometheus/procfs v0.6.0 // indirect | ||
github.com/sirupsen/logrus v1.8.1 // indirect | ||
github.com/spf13/cobra v1.2.1 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect | ||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect | ||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect | ||
go.uber.org/atomic v1.7.0 // indirect | ||
go.uber.org/multierr v1.6.0 // indirect | ||
go.uber.org/zap v1.19.1 // indirect | ||
golang.org/x/net v0.0.0-20211005215030-d2e5035098b3 // indirect | ||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect | ||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect | ||
golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef // indirect | ||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect | ||
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e // indirect | ||
google.golang.org/grpc v1.41.0 // indirect | ||
google.golang.org/protobuf v1.27.1 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
k8s.io/component-base v0.22.2 // indirect | ||
k8s.io/klog/v2 v2.9.0 // indirect | ||
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect | ||
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect | ||
sigs.k8s.io/yaml v1.2.0 // indirect | ||
) | ||
|
||
replace github.com/gardener/landscaper-service => ../ |
Oops, something went wrong.