[pull] master from chaos-mesh:master #397
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 workflow defines the e2e test related jobs. | |
name: E2E Test | |
on: | |
workflow_dispatch: {} | |
pull_request: | |
branches: | |
- master | |
- release-* | |
permissions: read-all | |
jobs: | |
changed-files: | |
runs-on: ubuntu-20.04 | |
outputs: | |
only_changed: ${{ steps.filter.outputs.only_changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Get changed files | |
uses: tj-actions/changed-files@v41 | |
id: filter | |
with: | |
# Not available for frontend code for now. | |
files: | | |
.gitignore | |
**.md | |
.github/ISSUE_TEMPLATE/* | |
.github/pull_request_template.md | |
ui/** | |
.github/workflows/checklink.yaml | |
.github/checklink_config.json | |
.github/workflows/ci.yml | |
.github/workflows/ci_skip.yml | |
.github/workflows/codecov_unittest.yaml | |
.github/workflows/integration_test.yml | |
.github/workflows/license_checker.yml | |
.github/workflows/must_update_changelog.yml | |
.github/workflows/release_helm_chart.yml | |
.github/workflows/upload_env_image.yml | |
.github/workflows/upload_image.yml | |
.github/workflows/upload_image_pr.yml | |
.github/workflows/upload_latest_files.yml | |
.github/workflows/upload_release_files.yml | |
- name: Show outputs | |
run: echo "${{ toJSON(steps.filter.outputs) }}" | |
build-image: | |
needs: changed-files | |
if: needs.changed-files.outputs.only_changed == 'false' | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: checkout codes | |
uses: actions/checkout@v4 | |
- name: Build Chaos Mesh Build Env | |
if: ${{ github.event.pull_request }} | |
env: | |
IMAGE_BUILD_ENV_BUILD: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild-build-env-image') }} | |
run: | | |
if [ "${IMAGE_BUILD_ENV_BUILD}" = "true" ] ; then | |
export IMAGE_BUILD_ENV_BUILD=1; | |
else | |
export IMAGE_BUILD_ENV_BUILD=0; | |
fi | |
make image-build-env | |
- name: Build Chaos Mesh Dev Env | |
if: ${{ github.event.pull_request }} | |
env: | |
IMAGE_DEV_ENV_BUILD: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild-dev-env-image') }} | |
run: | | |
if [ "${IMAGE_DEV_ENV_BUILD}" = "true" ] ; then | |
export IMAGE_DEV_ENV_BUILD=1; | |
else | |
export IMAGE_DEV_ENV_BUILD=0; | |
fi | |
make image-dev-env | |
# once the https://github.com/actions/cache/pull/498 gets merged, | |
# we can switch to the official cache action | |
- name: Restore build cache | |
id: cache | |
uses: martijnhols/actions-cache/restore@main | |
with: | |
path: cache | |
# don't worry about the branch, the github cache | |
# is only accessible in the same branch (or a pull_request | |
# whose target is the branch) | |
key: e2e-image-build-cache-${{ runner.os }} | |
- name: Build e2e images | |
env: | |
DOCKER_CACHE: 1 | |
DOCKER_CACHE_DIR: ${{ github.workspace }}/cache | |
GO_BUILD_CACHE: ${{ github.workspace }}/cache | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
run: | | |
docker buildx create --use --name chaos-mesh-builder | |
make -j4 image e2e-image | |
- name: save docker images | |
run: | | |
mkdir -p ./output/saved-images | |
docker image save ghcr.io/chaos-mesh/chaos-dashboard:latest > ./output/saved-images/chaos-dashboard.tgz | |
docker image save ghcr.io/chaos-mesh/chaos-daemon:latest > ./output/saved-images/chaos-daemon.tgz | |
docker image save ghcr.io/chaos-mesh/chaos-mesh:latest > ./output/saved-images/chaos-mesh.tgz | |
docker image save ghcr.io/chaos-mesh/e2e-helper:latest > ./output/saved-images/e2e-helper.tgz | |
- name: upload saved images | |
uses: actions/upload-artifact@v4 | |
with: | |
name: saved-images | |
path: ./output/saved-images | |
retention-days: 7 | |
build-e2e-binary: | |
needs: changed-files | |
if: needs.changed-files.outputs.only_changed == 'false' | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: checkout codes | |
uses: actions/checkout@v4 | |
- name: Restore build cache | |
id: cache | |
uses: martijnhols/actions-cache/restore@main | |
with: | |
path: cache | |
key: e2e-binary-build-cache-${{ runner.os }} | |
- name: build e2e binary | |
env: | |
DOCKER_CACHE: 1 | |
DOCKER_CACHE_DIR: ${{ github.workspace }}/cache | |
GO_BUILD_CACHE: ${{ github.workspace }}/cache | |
run: | | |
make e2e-build | |
- name: upload e2e binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: e2e-binary | |
path: ./e2e-test/image/e2e/bin | |
retention-days: 7 | |
e2e-test-matrix: | |
needs: | |
- build-image | |
- build-e2e-binary | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
kubernetes-version: | |
- v1.26.13 | |
- v1.27.10 | |
- v1.28.6 | |
focus: | |
- "[Graceful-Shutdown] [IOChaos]" | |
- "[Graceful-Shutdown] [HTTPChaos]" | |
- "[Basic] [PodChaos]" | |
- "[Basic] [TimeChaos]" | |
- "[Basic] [IOChaos]" | |
- "[Basic] [HTTPChaos]" | |
- "[Basic] [Sidecar Config]" | |
- "[Basic] [NetworkChaos]" | |
- "[Basic] [DNSChaos]" | |
- "[Basic] [StressChaos]" | |
steps: | |
- name: checkout codes | |
uses: actions/checkout@v4 | |
- name: download saved images | |
uses: actions/download-artifact@v4 | |
with: | |
name: saved-images | |
path: ./output/saved-images | |
- name: download e2e binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: e2e-binary | |
path: ./output/e2e-binary | |
- name: move e2e binary | |
run: | | |
mkdir -p ./e2e-test/image/e2e/bin | |
mv ./output/e2e-binary/ginkgo ./e2e-test/image/e2e/bin/ginkgo | |
mv ./output/e2e-binary/e2e.test ./e2e-test/image/e2e/bin/e2e.test | |
chmod +x ./e2e-test/image/e2e/bin/ginkgo | |
chmod +x ./e2e-test/image/e2e/bin/e2e.test | |
- name: Setup minikube | |
uses: medyagh/setup-minikube@latest | |
with: | |
minikube-version: 1.32.0 | |
kubernetes-version: ${{ matrix.kubernetes-version }} | |
- name: load image into minikube | |
run: | | |
minikube image load ./output/saved-images/chaos-dashboard.tgz | |
minikube image load ./output/saved-images/chaos-daemon.tgz | |
minikube image load ./output/saved-images/chaos-mesh.tgz | |
minikube image load ./output/saved-images/e2e-helper.tgz | |
- name: Restrict access to kubeconfig # https://github.com/helm/helm/issues/9115 | |
run: chmod 600 ~/.kube/config | |
- name: Setup Helm | |
uses: azure/setup-helm@v3 | |
- name: Install Chaos Mesh | |
# Set DOCKER_API_VERSION to 1.41 to bypass https://github.com/chaos-mesh/chaos-mesh/pull/4154#issuecomment-1704442551. | |
run: | | |
helm install --wait --create-namespace chaos-mesh helm/chaos-mesh --namespace=chaos-mesh --set images.tag=latest --set chaosDaemon.env.DOCKER_API_VERSION=1.41 | |
- name: e2e tests | |
env: | |
FOCUS: ${{ matrix.focus }} | |
run: | | |
# because ginkgo -focus accepts the regex expression, we should use escape to represent the squared brackets and dash | |
export ESCAPED_FOCUS=$(echo $FOCUS | sed -e 's/\[/\\\[/g' | sed -e 's/\]/\\\]/g' | sed -e 's/\-/\\\-/g') | |
KUBECONFIG=~/.kube/config ./e2e-test/image/e2e/bin/ginkgo -focus="${ESCAPED_FOCUS}" ./e2e-test/image/e2e/bin/e2e.test -- --e2e-image ghcr.io/chaos-mesh/e2e-helper:latest | |
- name: post run - extract profile info from kubernetes | |
if: always() | |
env: | |
PROFILE_DIRECTORY: ./output/chaos-mesh-profile | |
run: | | |
kubectl cluster-info dump --all-namespaces --output-directory $PROFILE_DIRECTORY/manifests -o yaml | |
kubectl get endpoints -A -o yaml > $PROFILE_DIRECTORY/manifests/endpoints.yaml | |
kubectl get secrets -A -o yaml > $PROFILE_DIRECTORY/manifests/secrets.yaml | |
kubectl get configmaps -A -o yaml > $PROFILE_DIRECTORY/manifests/configmaps.yaml | |
- name: post run - upload Chaos Mesh profile info | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: profiling-${{ matrix.focus }}-k8s-${{ matrix.kubernetes-version }} | |
path: ./output/chaos-mesh-profile | |
retention-days: 7 | |
- name: post run - upload junit test reports | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-junit-reports-${{ matrix.focus }}-k8s-${{ matrix.kubernetes-version }} | |
path: "**/*.xml" | |
retention-days: 7 | |
pass: | |
needs: | |
- e2e-test-matrix | |
name: E2E Test Passed | |
runs-on: ubuntu-20.04 | |
steps: | |
- run: echo "🎉 E2E Test Passed!" |