From 7aa602e12498c1543c41979b385660fb68be4d0d Mon Sep 17 00:00:00 2001 From: "Roland.Ma" Date: Wed, 24 Feb 2021 06:56:23 +0000 Subject: [PATCH] e2e github action Signed-off-by: Roland.Ma --- .github/workflows/e2e-test.yml | 37 +++++++++++++++++++++ .github/workflows/kind/kind.yaml | 11 +++++++ hack/deploy-kubesphere.sh | 56 ++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 .github/workflows/e2e-test.yml create mode 100644 .github/workflows/kind/kind.yaml create mode 100755 hack/deploy-kubesphere.sh diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml new file mode 100644 index 00000000..78bb9f7e --- /dev/null +++ b/.github/workflows/e2e-test.yml @@ -0,0 +1,37 @@ +name: e2e + +on: + schedule: + # run e2e test every 4 hours + - cron: 0 */4 * * * + workflow_dispatch: +jobs: + build: + name: Test + runs-on: ubuntu-latest + env: + GO111MODULE: on + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Downloading go dependencies + run: go mod vendor + + - name: Create kind cluster + uses: helm/kind-action@v1.0.0-rc.1 + with: + config: .github/workflows/kind/kind.yaml + + - name: Deploy KubeSphere to Kind + run: KIND_CLUSTER_NAME=chart-testing hack/deploy-kubesphere.sh + + - name: Run e2e testing + run: go test ./test/e2e \ No newline at end of file diff --git a/.github/workflows/kind/kind.yaml b/.github/workflows/kind/kind.yaml new file mode 100644 index 00000000..4179d133 --- /dev/null +++ b/.github/workflows/kind/kind.yaml @@ -0,0 +1,11 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + image: kindest/node:v1.19.7 + extraMounts: + - hostPath: /etc/localtime + containerPath: /etc/localtime + extraPortMappings: + - containerPort: 30881 + hostPort: 9090 \ No newline at end of file diff --git a/hack/deploy-kubesphere.sh b/hack/deploy-kubesphere.sh new file mode 100755 index 00000000..b1d5c192 --- /dev/null +++ b/hack/deploy-kubesphere.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright 2020 The KubeSphere 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 + +function wait_for_installation_finish() { + echo "waiting for ks-installer pod ready" + kubectl -n kubesphere-system wait --timeout=180s --for=condition=Ready $(kubectl -n kubesphere-system get pod -l app=ks-install -oname) + echo "waiting for KubeSphere ready" + while IFS= read -r line; do + if [[ $line =~ "Welcome to KubeSphere" ]] + then + break + fi + done < <(timeout 900 kubectl logs -n kubesphere-system deploy/ks-installer -f) +} + +# Use kubespheredev and latest tag as default image +TAG="${TAG:-latest}" +REPO="${REPO:-kubespheredev}" + +# Use KIND_LOAD_IMAGE=y .hack/deploy-kubesphere.sh to load +# the built docker image into kind before deploying. +if [[ "${KIND_LOAD_IMAGE:-}" == "y" ]]; then + kind load docker-image "$REPO/ks-apiserver:$TAG" --name="${KIND_CLUSTER_NAME:-kind}" + kind load docker-image "$REPO/ks-controller-manager:$TAG" --name="${KIND_CLUSTER_NAME:-kind}" +fi + +# Download the latest ks-install to deploy KubeSphere +wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries 3 https://raw.githubusercontent.com/kubesphere/ks-installer/master/deploy/kubesphere-installer.yaml +wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries 3 https://raw.githubusercontent.com/kubesphere/ks-installer/master/deploy/cluster-configuration.yaml + +#TODO: override ks-apiserver and ks-controller-manager images with specific tag + +kubectl apply -f kubesphere-installer.yaml +kubectl apply -f cluster-configuration.yaml + +wait_for_installation_finish + +# Expose KubeSphere API Server +kubectl -n kubesphere-system patch svc ks-apiserver -p '{"spec":{"type":"NodePort","ports":[{"name":"ks-apiserver","port":80,"protocal":"TCP","targetPort":9090,"nodePort":30881}]}}' -- GitLab