Adding in deploy changes tests for vcluster #6
Workflow file for this 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
name: E2E Deploy Changes CI | ||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [created] | ||
pull_request: | ||
branches: | ||
- main | ||
- v* | ||
paths: | ||
- "test/deploy_changes/**" | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
env: | ||
REPOSITORY_NAME: ghcr.io/${{ github.repository }}-ci | ||
TAG_NAME: PR${{ github.event.number }} | ||
VCLUSTER_SUFFIX: vcluster | ||
VCLUSTER_NAME: vcluster | ||
VCLUSTER_NAMESPACE: vcluster | ||
jobs: | ||
use-build-and-push-syncer-image: | ||
uses: ./.github/workflows/commonActions.yml#build-and-push-syncer-image | ||
use-build-vcluster-cli: | ||
uses: ./.github/workflows/commonActions.yml#build-vcluster-cli | ||
build-tests: | ||
name: Build tests binaries | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Configure git | ||
run: git config --global url.https://[email protected]/.insteadOf https://github.com/ | ||
env: | ||
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
- name: Build e2e binary | ||
run: | | ||
cd ./test/deploy_changes | ||
go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo build --require-suite -r --mod vendor $(ls *.test | jq -R . | jq -rcs '. | join(" \\\n")') | ||
env: | ||
GOWORK: off | ||
- name: Upload test binaries to artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-binaries | ||
path: ./test/deploy_changes/*.test | ||
retention-days: 7 | ||
deploy-tests: | ||
name: Execute test suites | ||
needs: | ||
- build-and-push-syncer-image | ||
- build-vcluster-cli | ||
- build-tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- uses: azure/setup-helm@v4 | ||
name: Setup Helm | ||
with: | ||
version: "v3.11.0" | ||
- name: Set up kind k8s cluster | ||
uses: engineerd/[email protected] | ||
with: | ||
version: "v0.20.0" | ||
image: kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e | ||
- name: Testing kind cluster set-up | ||
run: | | ||
set -x | ||
kubectl cluster-info | ||
kubectl get pods -n kube-system | ||
echo "kubectl config current-context:" $(kubectl config current-context) | ||
echo "KUBECONFIG env var:" ${KUBECONFIG} | ||
- name: Download vcluster cli | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: vcluster | ||
- name: Download syncer image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: vcluster_syncer | ||
- name: Download test binaries | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: test-binaries | ||
path: ./test/deploy_changes | ||
- name: Create vcluster | ||
id: create-vcluster | ||
run: | | ||
set -x | ||
sudo apt-get install -y sed | ||
sed -i "s|REPLACE_REPOSITORY_NAME|${{ env.REPOSITORY_NAME }}|g" ./test/deploy_changes/commonValues.yaml | ||
sed -i "s|REPLACE_TAG_NAME|${{ env.TAG_NAME }}|g" ./test/deploy_changes/commonValues.yaml | ||
kind load image-archive vcluster_syncer | ||
chmod +x vcluster && sudo mv vcluster /usr/bin | ||
vcluster create ${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} \ | ||
--create-namespace \ | ||
--debug \ | ||
--connect=false \ | ||
--local-chart-dir ./chart \ | ||
-f ./test/deploy_changes/commonValues.yaml | ||
continue-on-error: true | ||
- name: Wait until vcluster is ready | ||
id: wait-until-vcluster-is-ready | ||
if: steps.create-vcluster.outcome == 'success' | ||
run: | | ||
set -x | ||
./hack/wait-for-pod.sh -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} | ||
continue-on-error: true | ||
- name: Collect deployment information in case vcluster fails to start | ||
if: steps.wait-until-vcluster-is-ready.outcome != 'success' | ||
run: | | ||
set -x | ||
kubectl get pods -o yaml -n ${{ env.VCLUSTER_NAMESPACE }} | ||
echo "======================================================================================================================" | ||
kubectl get events -n ${{ env.VCLUSTER_NAMESPACE }} --sort-by='.lastTimestamp' | ||
echo "======================================================================================================================" | ||
kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p || kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 | ||
echo "======================================================================================================================" | ||
kubectl describe pods -n ${{ env.VCLUSTER_NAMESPACE }} | ||
exit 1 | ||
# Skips NetworkPolicy tests because they require network plugin with support (e.g. Calico) | ||
- name: Execute tests | ||
id: execute-tests | ||
working-directory: ./test | ||
run: | | ||
set -x | ||
sudo chmod +x ./deploy_changes/*.test | ||
VCLUSTER_SUFFIX=${{ env.VCLUSTER_SUFFIX }} VCLUSTER_NAME=${{ env.VCLUSTER_NAME }} VCLUSTER_NAMESPACE=${{ env.VCLUSTER_NAMESPACE }} ./deploy_changes/*.test -test.v --ginkgo.v --ginkgo.skip='.*NetworkPolicy.*' --ginkgo.fail-fast | ||
if kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p >/dev/null 2>/dev/null; then | ||
echo "vCluster has restarted during testing, failing..." | ||
exit 1 | ||
fi | ||
continue-on-error: true | ||
- name: Print logs if tests fail | ||
if: steps.execute-tests.outcome == 'failure' | ||
run: | | ||
set -x | ||
kubectl get pods -o yaml -n ${{ env.VCLUSTER_NAMESPACE }} | ||
echo "======================================================================================================================" | ||
kubectl get events -n ${{ env.VCLUSTER_NAMESPACE }} --sort-by='.lastTimestamp' | ||
echo "======================================================================================================================" | ||
kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p || kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 | ||
echo "======================================================================================================================" | ||
kubectl describe pods -n ${{ env.VCLUSTER_NAMESPACE }} | ||
exit 1 | ||