Skip to content

Commit

Permalink
Use docker instead of LXD to run tests with local assets (#1253)
Browse files Browse the repository at this point in the history
* Use docker instead of LXD to run tests with local assets
  • Loading branch information
sgalsaleh authored Oct 11, 2024
1 parent 6f5afe8 commit fd08366
Show file tree
Hide file tree
Showing 37 changed files with 1,881 additions and 1,508 deletions.
88 changes: 88 additions & 0 deletions .github/actions/e2e-troubleshoot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: E2E Troubleshoot
description: Troubleshoot e2e tests for embedded-cluster
inputs:
test-name:
description: 'individual test to troubleshoot'
required: true

runs:
using: composite
steps:
- name: Upload Host Support Bundle
id: upload-host-support-bundle
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test-name }}-support-bundle-host.tar.gz
path: ./e2e/support-bundle-host-*.tar.gz

- name: Upload Cluster Support Bundle
id: upload-cluster-support-bundle
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test-name }}-support-bundle-cluster.tar.gz
path: ./e2e/support-bundle-cluster.tar.gz

- name: Upload Playwright Report
id: upload-playwright-report
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test-name }}-playwright-report.tar.gz
path: ./e2e/playwright-report.tar.gz

- name: Print instructions for host support bundle
if: ${{ steps.upload-host-support-bundle.outputs.artifact-url != '' }}
run: |
echo -e "\e[1;33m┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐\e[0m"
echo -e "\e[1;33m Download the host support bundle from: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;34m ${{ steps.upload-host-support-bundle.outputs.artifact-url }} \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m└──────────────────────────────────────────────────────────────────────────────────────────────────────┘\e[0m"
shell: bash

- name: Print instructions for cluster support bundle
if: ${{ steps.upload-cluster-support-bundle.outputs.artifact-url != '' }}
run: |
echo -e "\e[1;33m┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐\e[0m"
echo -e "\e[1;33m To analyze the cluster support bundle: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 1- Download & extract the support bundle from: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;34m ${{ steps.upload-cluster-support-bundle.outputs.artifact-url }} \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 2- Install sbctl CLI from: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;34m https://github.com/replicatedhq/sbctl \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 3- From inside the extracted directory, run: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;32m sbctl serve -s . \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 4- Export the printed kubeconfig to interact with the cluster. \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m└──────────────────────────────────────────────────────────────────────────────────────────────────────┘\e[0m"
shell: bash

- name: Print instructions to view Playwright report
if: ${{ steps.upload-playwright-report.outputs.artifact-url != '' }}
run: |
echo -e "\e[1;33m┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐\e[0m"
echo -e "\e[1;33m To view the Playwright test report: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 1- Download & extract the report from: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;34m ${{ steps.upload-playwright-report.outputs.artifact-url }} \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 2- From inside the extracted directory, run: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;32m npx playwright show-report . \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m└──────────────────────────────────────────────────────────────────────────────────────────────────────┘\e[0m"
shell: bash

# - name: Setup upterm session (ssh)
# uses: lhotari/action-upterm@v1
# if: failure()
# with:
# ## If no one connects after 5 minutes, shut down server.
# wait-timeout-minutes: 5
56 changes: 5 additions & 51 deletions .github/actions/e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,7 @@ runs:
external_ids:ovn-encap-ip=127.0.0.1
- name: Free up runner disk space
if: ${{ inputs.is-large-runner == 'false' }}
shell: bash
run: |
df -h
sudo docker system prune -af
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /opt/hostedtoolcache/Python
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
df -h
uses: ./.github/actions/free-disk-space
- name: Set AppArmor mode to complain
shell: bash
run: |
Expand Down Expand Up @@ -117,44 +107,8 @@ runs:
export EXPECT_K0S_VERSION=${{ inputs.k0s-version }}
export EXPECT_K0S_VERSION_PREVIOUS=${{ inputs.k0s-version-previous }}
make e2e-test TEST_NAME=${{ inputs.test-name }}
- name: Upload Host Support Bundle
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: ${{ inputs.test-name }}-support-bundle-host.tar.gz
path: ./e2e/support-bundle-host-*.tar.gz
- name: Upload Cluster Support Bundle
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
- name: Troubleshoot
if: ${{ failure() }}
uses: ./.github/actions/e2e-troubleshoot
with:
name: ${{ inputs.test-name }}-support-bundle-cluster.tar.gz
path: ./e2e/support-bundle-cluster.tar.gz
- name: Upload Playwright Report
id: upload-playwright-report
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: ${{ inputs.test-name }}-playwright-report.tar.gz
path: ./e2e/playwright-report.tar.gz
- name: Print instructions to view Playwright report
if: ${{ ! cancelled() && steps.upload-playwright-report.outputs.artifact-url != '' }}
run: |
echo -e "\e[1;33m┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐\e[0m"
echo -e "\e[1;33m To view the Playwright test report: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 1- Download & extract the report from: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;34m ${{ steps.upload-playwright-report.outputs.artifact-url }} \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m 2- From inside the extracted directory, run: \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;32m npx playwright show-report . \e[0m"
echo -e "\e[1;33m \e[0m"
echo -e "\e[1;33m└──────────────────────────────────────────────────────────────────────────────────────────────────────┘\e[0m"
shell: bash
# - name: Setup upterm session (ssh)
# uses: lhotari/action-upterm@v1
# if: failure()
# with:
# ## If no one connects after 5 minutes, shut down server.
# wait-timeout-minutes: 5
test-name: ${{ inputs.test-name }}
46 changes: 46 additions & 0 deletions .github/actions/free-disk-space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Free Disk Space
description: Free up Github runner disk space

runs:
using: composite
steps:
- name: Free disk space
shell: bash
run: |
df -h
# Don't enable these as they take a long time to run (sometimes over 10 minutes)
# sudo docker system prune -af
# sudo rm -rf /usr/local/lib/android
sudo rm -rf \
/opt/hostedtoolcache/CodeQL \
/opt/hostedtoolcache/Python \
/opt/hostedtoolcache/PyPy \
/opt/microsoft/powershell \
/opt/ghc \
/opt/az
sudo rm -rf \
/usr/share/swift \
/usr/share/dotnet \
/usr/lib/jvm \
/usr/local/share/boost \
/usr/local/lib/heroku \
/usr/local/julia* \
/usr/local/.ghcup \
/usr/local/share/powershell \
/usr/local/bin/aliyun \
/usr/local/bin/azcopy \
/usr/local/bin/bicep \
/usr/local/bin/cpack \
/usr/local/bin/hub \
/usr/local/bin/minikube \
/usr/local/bin/packer \
/usr/local/bin/pulumi* \
/usr/local/bin/sam \
/usr/local/bin/stack \
/usr/local/bin/terraform \
/usr/local/bin/oc
df -h
110 changes: 70 additions & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,42 @@ jobs:
name: E2E docker
runs-on: ubuntu-latest
needs:
- git-sha
- build-current
- build-previous-k0s
- build-upgrade
- release-app
strategy:
fail-fast: false
matrix:
test:
- TestPreflights
- TestMaterialize
- TestHostPreflightCustomSpec
- TestHostPreflightInBuiltSpec
- TestSingleNodeInstallation
- TestSingleNodeInstallationAlmaLinux8
- TestSingleNodeInstallationDebian11
- TestSingleNodeInstallationDebian12
- TestSingleNodeInstallationCentos9Stream
- TestInstallFromReplicatedApp
- TestUpgradeFromReplicatedApp
- TestInstallWithoutEmbed
- TestUpgradeEC18FromReplicatedApp
- TestResetAndReinstall
- TestOldVersionUpgrade
- TestInstallSnapshotFromReplicatedApp
- TestMultiNodeInstallation
- TestMultiNodeHAInstallation
- TestSingleNodeDisasterRecovery
- TestSingleNodeResumeDisasterRecovery
- TestMultiNodeHADisasterRecovery
- TestSingleNodeInstallationNoopUpgrade
- TestCustomCIDR
- TestLocalArtifactMirror
- TestMultiNodeReset
- TestCollectSupportBundle
- TestUnsupportedOverrides
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -489,14 +519,40 @@ jobs:
with:
go-version-file: go.mod
cache-dependency-path: "**/*.sum"
- name: Write license file
- name: Login to DockerHub to avoid rate limiting
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Free up runner disk space
uses: ./.github/actions/free-disk-space
- name: Write license files
run: |
echo "${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE }}" | base64 --decode > e2e/license.yaml
echo "${{ secrets.STAGING_EMBEDDED_CLUSTER_SNAPSHOT_LICENSE }}" | base64 --decode > e2e/snapshot-license.yaml
- name: Run test
env:
LICENSE_PATH: license.yaml
SHORT_SHA: dev-${{ needs.git-sha.outputs.git_sha }}
LICENSE_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE_ID }}
AIRGAP_LICENSE_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_AIRGAP_LICENSE_ID }}
SNAPSHOT_LICENSE_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_SNAPSHOT_LICENSE_ID }}
AIRGAP_SNAPSHOT_LICENSE_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_AIRGAP_SNAPSHOT_LICENSE_ID }}
DR_AWS_S3_ENDPOINT: https://s3.amazonaws.com
DR_AWS_S3_REGION: us-east-1
DR_AWS_S3_BUCKET: kots-testim-snapshots
DR_AWS_S3_PREFIX: ${{ matrix.test }}-${{ github.run_id }}-${{ github.run_attempt }}
DR_AWS_S3_PREFIX_AIRGAP: ${{ matrix.test }}-${{ github.run_id }}-${{ github.run_attempt }}-airgap
DR_AWS_ACCESS_KEY_ID: ${{ secrets.TESTIM_AWS_ACCESS_KEY_ID }}
DR_AWS_SECRET_ACCESS_KEY: ${{ secrets.TESTIM_AWS_SECRET_ACCESS_KEY }}
EXPECT_K0S_VERSION: ${{ needs.build-current.outputs.k0s_version }}
EXPECT_K0S_VERSION_PREVIOUS: ${{ needs.build-previous-k0s.outputs.k0s_version }}
run: |
make e2e-test TEST_NAME=${{ matrix.test }}
- name: Troubleshoot
if: ${{ failure() }}
uses: ./.github/actions/e2e-troubleshoot
with:
test-name: '${{ matrix.test }}'

e2e:
name: E2E
Expand All @@ -511,53 +567,18 @@ jobs:
fail-fast: false
matrix:
test:
- TestSingleNodeInstallation
- TestSingleNodeInstallationAlmaLinux8
- TestSingleNodeInstallationDebian11
- TestSingleNodeInstallationDebian12
- TestSingleNodeInstallationCentos9Stream
- TestVersion
- TestHostPreflightCustomSpec
- TestHostPreflightInBuiltSpec
- TestUnsupportedOverrides
- TestCommandsRequireSudo
- TestInstallWithoutEmbed
- TestInstallFromReplicatedApp
- TestUpgradeFromReplicatedApp
- TestUpgradeEC18FromReplicatedApp
- TestResetAndReinstall
- TestResetAndReinstallAirgap
- TestCollectSupportBundle
- TestOldVersionUpgrade
- TestMaterialize
- TestLocalArtifactMirror
- TestSingleNodeAirgapUpgrade
- TestSingleNodeAirgapUpgradeFromEC18
- TestSingleNodeAirgapUpgradeCustomCIDR
- TestInstallSnapshotFromReplicatedApp
- TestSingleNodeDisasterRecovery
- TestSingleNodeDisasterRecoveryWithProxy
- TestSingleNodeResumeDisasterRecovery
- TestSingleNodeInstallationNoopUpgrade
- TestProxiedEnvironment
- TestProxiedCustomCIDR
- TestInstallWithPrivateCAs
- TestInstallWithMITMProxy
include:
- test: TestCustomCIDR
runner: embedded-cluster
- test: TestProxiedEnvironment
runner: embedded-cluster
- test: TestProxiedCustomCIDR
runner: embedded-cluster
- test: TestMultiNodeInstallation
runner: embedded-cluster
- test: TestMultiNodeReset
runner: embedded-cluster
- test: TestMultiNodeAirgapUpgrade
runner: embedded-cluster
- test: TestMultiNodeHAInstallation
runner: embedded-cluster
- test: TestMultiNodeHADisasterRecovery
runner: embedded-cluster
- test: TestMultiNodeAirgapUpgrade
runner: embedded-cluster
- test: TestMultiNodeAirgapUpgradeSameK0s
Expand Down Expand Up @@ -613,11 +634,20 @@ jobs:
- name: fail if e2e job was not successful
if: needs.e2e.result != 'success'
run: exit 1
- name: fail if e2e-docker job was not successful
if: needs.e2e-docker.result != 'success'
run: exit 1
- name: fail if sanitize job was not successful
if: needs.sanitize.result != 'success'
run: exit 1
- name: fail if tests job was not successful
- name: fail if test job was not successful
if: needs.test.result != 'success'
run: exit 1
- name: fail if check-images job was not successful
if: needs.check-images.result != 'success'
run: exit 1
- name: fail if check-operator-crds job was not successful
if: needs.check-operator-crds.result != 'success'
run: exit 1
- name: succeed if everything else passed
run: echo "Validation succeeded"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ create-node%:
--name node$* \
--hostname node$* \
--privileged \
--cgroupns=host \
--restart=unless-stopped \
-v $(K0S_DATA_DIR) \
-v $(shell pwd):/replicatedhq/embedded-cluster \
-v $(shell dirname $(shell pwd))/kots:/replicatedhq/kots \
Expand Down
Loading

0 comments on commit fd08366

Please sign in to comment.