-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2884 from fabriziopandini/e2e-quickstart
✨introduce test E2E
- Loading branch information
Showing
29 changed files
with
2,045 additions
and
22 deletions.
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,60 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2018 The Kubernetes 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. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
cd "${REPO_ROOT}" || exit 1 | ||
|
||
# shellcheck source=./hack/ensure-go.sh | ||
source "${REPO_ROOT}/hack/ensure-go.sh" | ||
# shellcheck source=./hack/ensure-kubectl.sh | ||
source "${REPO_ROOT}/hack/ensure-kubectl.sh" | ||
# shellcheck source=./hack/ensure-kustomize.sh | ||
source "${REPO_ROOT}/hack/ensure-kustomize.sh" | ||
|
||
# Configure provider images generation; | ||
# please ensure the generated image name matches image names used in the E2E_CONF_FILE | ||
export REGISTRY=gcr.io/k8s-staging-cluster-api | ||
export TAG=ci | ||
export ARCH=amd64 | ||
export PULL_POLICY=IfNotPresent | ||
|
||
## Rebuild all Cluster API provider images | ||
make docker-build | ||
|
||
## Rebuild CAPD provider images | ||
make -C test/infrastructure/docker docker-build | ||
|
||
## Pulling cert manager images so we can pre-load in kind nodes | ||
docker pull quay.io/jetstack/cert-manager-cainjector:v0.11.0 | ||
docker pull quay.io/jetstack/cert-manager-webhook:v0.11.0 | ||
docker pull quay.io/jetstack/cert-manager-controller:v0.11.0 | ||
|
||
# Configure e2e tests | ||
export GINKGO_FOCUS= | ||
export GINKGO_NODES=2 | ||
export GINKGO_NOCOLOR=true | ||
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/docker-ci.yaml" | ||
export ARTIFACTS="${ARTIFACTS:-${REPO_ROOT}/_artifacts}" | ||
export SKIP_RESOURCE_CLEANUP=false | ||
export USE_EXISTING_CLUSTER=false | ||
|
||
# Run e2e tests | ||
mkdir -p "$ARTIFACTS" | ||
make -C test/e2e/ run |
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,65 @@ | ||
# Copyright 2020 The Kubernetes 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. | ||
|
||
# If you update this file, please follow: | ||
# https://suva.sh/posts/well-documented-makefiles/ | ||
|
||
# Use GOPROXY environment variable if set | ||
|
||
.DEFAULT_GOAL:=help | ||
|
||
GOPROXY := $(shell go env GOPROXY) | ||
ifeq ($(GOPROXY),) | ||
GOPROXY := https://proxy.golang.org | ||
endif | ||
export GOPROXY | ||
|
||
REPO_ROOT := $(shell git rev-parse --show-toplevel) | ||
|
||
help: ## Display this help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
## -------------------------------------- | ||
## Binaries | ||
## -------------------------------------- | ||
|
||
TOOLS_DIR := $(REPO_ROOT)/hack/tools | ||
BIN_DIR := bin | ||
TOOLS_BIN_DIR := $(TOOLS_DIR)/$(BIN_DIR) | ||
GINKGO := $(TOOLS_BIN_DIR)/ginkgo | ||
|
||
.PHONY: ginkgo | ||
ginkgo: | ||
cd $(TOOLS_DIR) && go build -tags=tools -o $(BIN_DIR)/ginkgo github.com/onsi/ginkgo/ginkgo | ||
|
||
## -------------------------------------- | ||
## Testing | ||
## -------------------------------------- | ||
|
||
TEST_E2E_DIR := $(REPO_ROOT)/test/e2e | ||
|
||
GINKGO_FOCUS ?= | ||
GINKGO_NODES ?= 1 | ||
E2E_CONF_FILE ?= ${REPO_ROOT}/test/e2e/config/docker-dev.yaml | ||
ARTIFACTS ?= ${REPO_ROOT}/_artifacts | ||
SKIP_RESOURCE_CLEANUP ?= false | ||
USE_EXISTING_CLUSTER ?= false | ||
GINKGO_NOCOLOR ?= false | ||
|
||
.PHONY: run | ||
run: ginkgo ## Run the end-to-end tests | ||
cd $(TEST_E2E_DIR); $(GINKGO) -v -trace -tags=e2e -focus=$(GINKGO_FOCUS) -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) . -- \ | ||
-e2e.artifacts-folder="$(ARTIFACTS)" \ | ||
-e2e.config="$(E2E_CONF_FILE)" \ | ||
-e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) -e2e.use-existing-cluster=$(USE_EXISTING_CLUSTER) |
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,71 @@ | ||
/* | ||
Copyright 2020 The Kubernetes 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 e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path/filepath" | ||
|
||
. "github.com/onsi/ginkgo" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" | ||
"sigs.k8s.io/cluster-api/test/framework" | ||
"sigs.k8s.io/cluster-api/util" | ||
) | ||
|
||
func Byf(format string, a ...interface{}) { | ||
By(fmt.Sprintf(format, a...)) | ||
} | ||
|
||
func setupSpecNamespace(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, artifactFolder string) (*corev1.Namespace, context.CancelFunc) { | ||
Byf("Creating a namespace for hosting the %q test spec", specName) | ||
namespace, cancelWatches := framework.CreateNamespaceAndWatchEvents(ctx, framework.CreateNamespaceAndWatchEventsInput{ | ||
Creator: clusterProxy.GetClient(), | ||
ClientSet: clusterProxy.GetClientSet(), | ||
Name: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), | ||
LogFolder: filepath.Join(artifactFolder, "clusters", clusterProxy.GetName()), | ||
}) | ||
|
||
return namespace, cancelWatches | ||
} | ||
|
||
func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterProxy framework.ClusterProxy, artifactFolder string, namespace *corev1.Namespace, cancelWatches context.CancelFunc, cluster *clusterv1.Cluster, intervalsGetter func(spec, key string) []interface{}, skipCleanup bool) { | ||
Byf("Dumping all the Cluster API resources in the %q namespace", namespace.Name) | ||
// Dump all Cluster API related resources to artifacts before deleting them. | ||
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{ | ||
Lister: clusterProxy.GetClient(), | ||
Namespace: namespace.Name, | ||
LogPath: filepath.Join(artifactFolder, "clusters", clusterProxy.GetName(), "resources"), | ||
}) | ||
|
||
if !skipCleanup { | ||
Byf("Deleting cluster %s/%s", cluster.Namespace, cluster.Name) | ||
framework.DeleteClusterAndWait(ctx, framework.DeleteClusterAndWaitInput{ | ||
Client: clusterProxy.GetClient(), | ||
Cluster: cluster, | ||
}, intervalsGetter(specName, "wait-delete-cluster")...) | ||
|
||
Byf("Deleting namespace used for hosting the %q test spec", specName) | ||
framework.DeleteNamespace(ctx, framework.DeleteNamespaceInput{ | ||
Deleter: clusterProxy.GetClient(), | ||
Name: namespace.Name, | ||
}) | ||
} | ||
cancelWatches() | ||
} |
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,77 @@ | ||
--- | ||
# CI E2E test test configuration scenario using locally build images and manifests for: | ||
# - cluster-api | ||
# - bootstrap kubeadm | ||
# - control-plane kubeadm | ||
# - docker | ||
|
||
# For creating local dev images run ./scripts/ci-e2e.sh | ||
|
||
images: | ||
# Use local dev images built source tree; | ||
- name: gcr.io/k8s-staging-cluster-api/cluster-api-controller-amd64:ci | ||
loadBehavior: mustLoad | ||
- name: gcr.io/k8s-staging-cluster-api/kubeadm-bootstrap-controller-amd64:ci | ||
loadBehavior: mustLoad | ||
- name: gcr.io/k8s-staging-cluster-api/kubeadm-control-plane-controller-amd64:ci | ||
loadBehavior: mustLoad | ||
- name: gcr.io/k8s-staging-cluster-api/capd-manager-amd64:ci | ||
loadBehavior: mustLoad | ||
- name: quay.io/jetstack/cert-manager-cainjector:v0.11.0 | ||
loadBehavior: tryLoad | ||
- name: quay.io/jetstack/cert-manager-webhook:v0.11.0 | ||
loadBehavior: tryLoad | ||
- name: quay.io/jetstack/cert-manager-controller:v0.11.0 | ||
loadBehavior: tryLoad | ||
|
||
providers: | ||
|
||
- name: cluster-api | ||
type: CoreProvider | ||
versions: | ||
- name: v0.3.0 | ||
# Use manifest from source files | ||
value: ../../../config | ||
|
||
- name: kubeadm | ||
type: BootstrapProvider | ||
versions: | ||
- name: v0.3.0 | ||
# Use manifest from source files | ||
value: ../../../bootstrap/kubeadm/config | ||
|
||
- name: kubeadm | ||
type: ControlPlaneProvider | ||
versions: | ||
- name: v0.3.0 | ||
# Use manifest from source files | ||
value: ../../../controlplane/kubeadm/config | ||
|
||
- name: docker | ||
type: InfrastructureProvider | ||
versions: | ||
- name: v0.3.0 | ||
# Use manifest from source files | ||
value: ../../../test/infrastructure/docker/config | ||
files: | ||
# Add a metadata for docker provider | ||
- sourcePath: "../data/infrastructure-docker/metadata.yaml" | ||
# Add a cluster template | ||
- sourcePath: "../data/infrastructure-docker/cluster-template-ci.yaml" | ||
targetName: "cluster-template.yaml" | ||
|
||
variables: | ||
KUBERNETES_VERSION: "v1.17.0" | ||
DOCKER_SERVICE_DOMAIN: "cluster.local" | ||
DOCKER_SERVICE_CIDRS: "10.128.0.0/12" | ||
# IMPORTANT! This values should match the one used by the CNI provider | ||
DOCKER_POD_CIDRS: "192.168.0.0/16" | ||
CNI: "./data/cni/kindnet/kindnet.yaml" | ||
|
||
intervals: | ||
default/wait-controllers: ["3m", "10s"] | ||
default/wait-cluster: ["3m", "10s"] | ||
default/wait-control-plane: ["3m", "10s"] | ||
default/wait-worker-nodes: ["3m", "10s"] | ||
default/wait-delete-cluster: ["3m", "10s"] | ||
default/wait-machine-upgrade: ["15m", "1m"] |
Oops, something went wrong.