Skip to content

Commit

Permalink
add attachedcluater e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
  • Loading branch information
LiZhenCheng9527 committed Jan 29, 2024
1 parent 4d616a0 commit 3ccc028
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: E2E
on:
pull_request:
jobs:
e2e-test:
runs-on: ubuntu-22.04
name: E2E Test
timeout-minutes: 40
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@v4
- name: Build Clusters
uses: helm/kind-action@v1.8.0
with:
version: v0.18.0
install_only: true
- name: Set Up Clusters
run: |
hack/local-dev-setup.sh
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.1
- name: Install Kubectl
uses: actions-hub/kubectl@v1.27.3
- name: Init kurator cluster
run: |
hack/e2e-test/install.sh
- name: fleet-clusters e2e test
run: |
hack/e2e-test/fleet-clusters/e2e-run.sh
76 changes: 76 additions & 0 deletions hack/e2e-test/fleet-clusters/attachedcluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"}
MAIN_KUBECONFIG=${MAIN_KUBECONFIG:-"${KUBECONFIG_PATH}/kurator-host.config"}
export KUBECONFIG=${MAIN_KUBECONFIG}

kubectl create secret generic kurator-member1 --from-file=kurator-member1.config=${KUBECONFIG_PATH}/kurator-member1.config
kubectl create secret generic kurator-member2 --from-file=kurator-member2.config=${KUBECONFIG_PATH}/kurator-member2.config

cat <<EOF | kubectl apply -f -
apiVersion: cluster.kurator.dev/v1alpha1
kind: AttachedCluster
metadata:
name: kurator-member1
namespace: default
spec:
kubeconfig:
name: kurator-member1
key: kurator-member1.config
EOF

ok=false
sleep 10
kubectl get attachedclusters.cluster.kurator.dev kurator-member1 -o yaml | grep 'ready: true' && ok=true || ok=false
if [ ${ok} = false ]; then
echo "create attachedCluster member1 resources failed"
exit 1
fi

cat <<EOF | kubectl apply -f -
apiVersion: cluster.kurator.dev/v1alpha1
kind: AttachedCluster
metadata:
name: kurator-member2
namespace: default
spec:
kubeconfig:
name: kurator-member2
key: kurator-member2.config
EOF

ok=false
sleep 5
kubectl get attachedclusters.cluster.kurator.dev kurator-member1 -o yaml | grep 'ready: true' && ok=true || ok=false
if [ ${ok} = false ]; then
echo "create attachedCluster member2 resources failed"
exit 1
fi

cat <<EOF | kubectl apply -f -
apiVersion: fleet.kurator.dev/v1alpha1
kind: Fleet
metadata:
name: quickstart
namespace: default
spec:
clusters:
# add your AttachedCluster here
- name: kurator-member1
kind: AttachedCluster
- name: kurator-member2
kind: AttachedCluster
EOF

sleep 5

ok=false
kubectl get fleet | grep 'Ready' && ok=true || ok=false
if [ ${ok} = false ]; then
echo "create Fleet resources failed"
exit 1
fi
8 changes: 8 additions & 0 deletions hack/e2e-test/fleet-clusters/e2e-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -o errexit

REPO_ROOT=$(git rev-parse --show-toplevel)
DIR="$(cd "$(dirname "$0")" && pwd)"

"$DIR"/attachedcluster.sh
25 changes: 25 additions & 0 deletions hack/e2e-test/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

# This script installs Kurator cluster-operater and fleet-manager.

KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"}
MAIN_KUBECONFIG=${MAIN_KUBECONFIG:-"${KUBECONFIG_PATH}/kurator-host.config"}
export KUBECONFIG=${MAIN_KUBECONFIG}
VERSION=${VERSION:-"0.95.27"}

sleep 5s

VERSION=${VERSION} make docker
kind load docker-image ghcr.io/kurator-dev/cluster-operator:${VERSION} --name kurator-host
kind load docker-image ghcr.io/kurator-dev/fleet-manager:${VERSION} --name kurator-host

VERSION=${VERSION} make gen-chart
cd out/charts
helm install --create-namespace kurator-cluster-operator cluster-operator-${VERSION}.tgz -n kurator-system
helm install --create-namespace kurator-fleet-manager fleet-manager-${VERSION}.tgz -n kurator-system

echo "install kurator successful"

0 comments on commit 3ccc028

Please sign in to comment.