From d33f4278686a96e296896d3cb7d110fed8fa732f Mon Sep 17 00:00:00 2001 From: Amulyam24 Date: Tue, 1 Feb 2022 12:37:52 +0530 Subject: [PATCH] Add smoke tests Signed-off-by: Amulyam24 --- Dockerfile | 2 +- Makefile | 10 +++++++-- go.mod | 6 +++--- go.sum | 8 +++---- scripts/ci-smoke-test.sh | 26 +++++++++++++++++++++++ test/e2e/config/ibmcloud-e2e-powervs.yaml | 12 +++++------ test/e2e/data/shared/metadata.yaml | 3 +++ test/e2e/suite_test.go | 4 ++++ 8 files changed, 55 insertions(+), 16 deletions(-) create mode 100755 scripts/ci-smoke-test.sh diff --git a/Dockerfile b/Dockerfile index 45a39b98f..f15aa3bb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ COPY go.mod go.mod COPY go.sum go.sum # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer -ENV GOPROXY https://goproxy.io,direct +ENV GOPROXY https://proxy.golang.org,direct RUN go mod download # Copy the go source diff --git a/Makefile b/Makefile index 73c54a610..a8529be13 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ CORE_MANIFEST_FILE := infrastructure-components CORE_CONFIG_DIR := config/default CORE_NAMESPACE := capi-ibmcloud-system +PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) GOBIN=$(shell go env GOPATH)/bin @@ -168,9 +169,9 @@ ARTIFACTS ?= $(REPO_ROOT)/_artifacts SKIP_CLEANUP ?= false SKIP_CREATE_MGMT_CLUSTER ?= false -#Run the end-to-end tests +# Run the end-to-end tests .PHONY: test-e2e -test-e2e: $(KUBECTL) $(GINKGO) $(ENVSUBST) set-flavor e2e-image +test-e2e: $(KUBECTL) $(GINKGO) $(KUSTOMIZE) $(ENVSUBST) set-flavor e2e-image $(ENVSUBST) < $(E2E_CONF_FILE) > $(E2E_CONF_FILE_ENVSUBST) $(GINKGO) $(GINKGO_ARGS) ./test/e2e -- \ -e2e.artifacts-folder="$(ARTIFACTS)" \ @@ -179,6 +180,11 @@ test-e2e: $(KUBECTL) $(GINKGO) $(ENVSUBST) set-flavor e2e-image -e2e.use-existing-cluster=$(SKIP_CREATE_MGMT_CLUSTER) \ -e2e.flavor="$(E2E_FLAVOR)" +# Basic checks for deploying kind cluster and required providers +.PHONY: test-sanity +test-sanity: + GINKGO_FOCUS="Run Sanity tests" $(MAKE) test-e2e + ## -------------------------------------- ## Docker ## -------------------------------------- diff --git a/go.mod b/go.mod index c25c49ff0..908e6ec4d 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( k8s.io/client-go v0.23.0 k8s.io/klog/v2 v2.30.0 k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b - sigs.k8s.io/cluster-api v1.1.0-rc.0 - sigs.k8s.io/cluster-api/test v1.1.0-rc.0 + sigs.k8s.io/cluster-api v1.1.0 + sigs.k8s.io/cluster-api/test v1.1.0 sigs.k8s.io/controller-runtime v0.11.0 ) @@ -138,4 +138,4 @@ require ( sigs.k8s.io/yaml v1.3.0 // indirect ) -replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.1.0-rc.0 +replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.1.0 diff --git a/go.sum b/go.sum index b171811bb..27e497ee1 100644 --- a/go.sum +++ b/go.sum @@ -1807,10 +1807,10 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.25/go.mod h1:Mlj9PNLmG9bZ6BHFwFKDo5afkpWyUISkb9Me0GnK66I= -sigs.k8s.io/cluster-api v1.1.0-rc.0 h1:YLNabhJpbfuujnJUsR2wONBy+GU5ji9RrZb2SokG4vQ= -sigs.k8s.io/cluster-api v1.1.0-rc.0/go.mod h1:aSxmmNwDjmg9rDaL0RhRELpGX9uSTTwLF02AMtk/XGY= -sigs.k8s.io/cluster-api/test v1.1.0-rc.0 h1:U0HK82eHJJq1H3uMSf26BOOGu8ioIXuGNIoUAhvISpE= -sigs.k8s.io/cluster-api/test v1.1.0-rc.0/go.mod h1:ct7zQrWXsYIAhL/lMLFPfCAqGLDBTEzx+AtwIXpI45o= +sigs.k8s.io/cluster-api v1.1.0 h1:zJJzIUezEveYK3Ljmk/jku+DYd96RP5bZ181l2W9gVg= +sigs.k8s.io/cluster-api v1.1.0/go.mod h1:aSxmmNwDjmg9rDaL0RhRELpGX9uSTTwLF02AMtk/XGY= +sigs.k8s.io/cluster-api/test v1.1.0 h1:eBVFCWxu9/fb/By02uFjOreG9GAd9eax9uZKsCXP58s= +sigs.k8s.io/cluster-api/test v1.1.0/go.mod h1:ct7zQrWXsYIAhL/lMLFPfCAqGLDBTEzx+AtwIXpI45o= sigs.k8s.io/controller-runtime v0.11.0 h1:DqO+c8mywcZLFJWILq4iktoECTyn30Bkj0CwgqMpZWQ= sigs.k8s.io/controller-runtime v0.11.0/go.mod h1:KKwLiTooNGu+JmLZGn9Sl3Gjmfj66eMbCQznLP5zcqA= sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s= diff --git a/scripts/ci-smoke-test.sh b/scripts/ci-smoke-test.sh new file mode 100755 index 000000000..ace4738ea --- /dev/null +++ b/scripts/ci-smoke-test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright 2022 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=$(dirname "${BASH_SOURCE[0]}")/.. +# shellcheck source=../hack/ensure-go.sh +source "${REPO_ROOT}/hack/ensure-go.sh" + +echo "**** Running basic checks by deploying the required CAPI providers on a kind cluster ***" +cd "${REPO_ROOT}" && make test-sanity diff --git a/test/e2e/config/ibmcloud-e2e-powervs.yaml b/test/e2e/config/ibmcloud-e2e-powervs.yaml index 9f76cb362..30b31ac7a 100644 --- a/test/e2e/config/ibmcloud-e2e-powervs.yaml +++ b/test/e2e/config/ibmcloud-e2e-powervs.yaml @@ -9,24 +9,24 @@ providers: - name: cluster-api type: CoreProvider versions: - - name: v1.0.2 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.2/core-components.yaml + - name: v1.1.0 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.1.0/core-components.yaml type: url files: - sourcePath: "${PWD}/test/e2e/data/shared/metadata.yaml" - name: kubeadm type: BootstrapProvider versions: - - name: v1.0.2 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.2/bootstrap-components.yaml + - name: v1.1.0 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.1.0/bootstrap-components.yaml type: url files: - sourcePath: "${PWD}/test/e2e/data/shared/metadata.yaml" - name: kubeadm type: ControlPlaneProvider versions: - - name: v1.0.2 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.2/control-plane-components.yaml + - name: v1.1.0 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.1.0/control-plane-components.yaml type: url files: - sourcePath: "${PWD}/test/e2e/data/shared/metadata.yaml" diff --git a/test/e2e/data/shared/metadata.yaml b/test/e2e/data/shared/metadata.yaml index 061e29b05..4b1b982e8 100644 --- a/test/e2e/data/shared/metadata.yaml +++ b/test/e2e/data/shared/metadata.yaml @@ -5,6 +5,9 @@ # update this file only when a new major or minor version is released apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3 releaseSeries: + - major: 1 + minor: 1 + contract: v1beta1 - major: 1 minor: 0 contract: v1beta1 diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 183b087f6..f9b0dc2f8 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -223,6 +223,10 @@ func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config * }, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...) } +var _ = Describe("Run Sanity tests", func() { + // TO DO- Add additional testcases for sanity checks +}) + func tearDown(bootstrapClusterProvider bootstrap.ClusterProvider, bootstrapClusterProxy framework.ClusterProxy) { if bootstrapClusterProxy != nil { bootstrapClusterProxy.Dispose(context.TODO())