Skip to content

Commit

Permalink
Implement smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmironov-wallarm committed Apr 25, 2024
1 parent e061e40 commit d0e4dcc
Show file tree
Hide file tree
Showing 7 changed files with 644 additions and 13 deletions.
92 changes: 83 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'cmd/**'
- 'go.*'
- 'Dockerfile'
- 'test/**'
- '!helm/Chart.yaml'
- '!helm/README.md'
- '!helm/test/**'
Expand All @@ -26,28 +27,27 @@ jobs:
fail-fast: false
matrix:
include:
- PLATFORM: amd64
- ARCH: amd64
RUNNER: self-hosted-amd64-1cpu
- PLATFORM: aarch64
- ARCH: arm64
RUNNER: self-hosted-arm64-1cpu
outputs:
helm_args: ${{ steps.compute_helm_args.outputs.helm_args }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build
run: |
IMAGE="wallarm/sidecar-controller"
make build TAG=${GITHUB_SHA} IMAGE=${IMAGE} PLATFORMS=linux/${{ matrix.PLATFORM }} BUILDX_ARGS=--load
mkdir artifacts
docker save -o artifacts/docker-image-${{ matrix.PLATFORM }}.tar ${IMAGE}:${GITHUB_SHA}
make build TAG=1.0.0-dev IMAGE=${IMAGE} PLATFORMS=linux/${{ matrix.ARCH }} BUILDX_ARGS=--load
docker save -o sidecar-${{ matrix.ARCH }}.tar ${IMAGE}:1.0.0-dev
- name: Save artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docker-artifact
path: artifacts/docker-image-${{ matrix.PLATFORM }}.tar
name: sidecar-${{ matrix.ARCH }}.tar
path: sidecar-${{ matrix.ARCH }}.tar
retention-days: 1

- name: Compute Helm arguments
Expand All @@ -56,6 +56,7 @@ jobs:
run: |
HELM_ARGS="--set controller.image.tag=${GITHUB_SHA}"
echo "helm_args=${HELM_ARGS}" >> $GITHUB_OUTPUT
test:
name: Test
needs: build
Expand All @@ -71,3 +72,76 @@ jobs:
run_ct: true
helm_args: ${{ needs.build.outputs.helm_args }}
load_artifact: true

smoke-test:
name: Smoke
runs-on: ${{ matrix.RUNNER }}
needs: build
strategy:
fail-fast: false
matrix:
k8s: [v1.23.13, v1.27.1]
ARCH: [amd64, arm64]
INJECTION_STRATEGY: [single, split]
include:
- ARCH: amd64
RUNNER: self-hosted-amd64-2cpu
- ARCH: arm64
RUNNER: self-hosted-arm64-2cpu
env:
KIND_CLUSTER_NAME: kind-${{ matrix.k8s }}
KUBECONFIG: $HOME/.kube/kind-config-${{ matrix.k8s }}
steps:
- name: Import secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c # v3.0.0
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: |
kv-gitlab-ci/data/github/ingress api_token ;
kv-gitlab-ci/data/github/ingress api_host ;
kv-gitlab-ci/data/github/ingress api_preset ;
kv-gitlab-ci/data/github/ingress user_token ;
kv-gitlab-ci/data/github/ingress webhook_uuid ;
kv-gitlab-ci/data/github/ingress webhook_api_key ;
kv-gitlab-ci/data/github/shared/allure allure_token ;
kv-gitlab-ci/data/github/shared/smoke-tests-registry-creds token_name ;
kv-gitlab-ci/data/github/shared/smoke-tests-registry-creds token_secret ;
- name: Checkout
uses: actions/checkout@v4

- name: Load cache
uses: actions/download-artifact@v4
with:
name: sidecar-${{ matrix.ARCH }}.tar

- name: Load images
run: docker load -i sidecar-${{ matrix.ARCH }}.tar

- name: Create cluster
run: kind create cluster --image=kindest/node:${{ matrix.k8s }}

- name: Run smoke tests
env:
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_HOST: ${{ steps.secrets.outputs.api_host }}
WALLARM_API_PRESET: ${{ steps.secrets.outputs.api_preset }}
USER_TOKEN: ${{ steps.secrets.outputs.user_token }}
SMOKE_REGISTRY_TOKEN: ${{ steps.secrets.outputs.token_name }}
SMOKE_REGISTRY_SECRET: ${{ steps.secrets.outputs.token_secret }}
WEBHOOK_API_KEY: ${{ steps.secrets.outputs.webhook_api_key }}
WEBHOOK_UUID: ${{ steps.secrets.outputs.webhook_uuid }}
ALLURE_UPLOAD_REPORT: true
ALLURE_GENERATE_REPORT: true
ALLURE_TOKEN: ${{ steps.secrets.outputs.allure_token }}
ALLURE_ENVIRONMENT_K8S: ${{ matrix.k8s }}
ALLURE_ENVIRONMENT_ARCH: ${{ matrix.ARCH }}
run: |
make kind-smoke-test
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ jobs:
PLATFORM: [ amd64 ]
RUNNER: [ self-hosted-amd64-1cpu ]
include:
- { kubeVersion: 1.19.16, PLATFORM: aarch64, RUNNER: self-hosted-arm64-1cpu }
- { kubeVersion: 1.25.3, PLATFORM: aarch64, RUNNER: self-hosted-arm64-1cpu }
- { kubeVersion: 1.19.16, PLATFORM: arm64, RUNNER: self-hosted-arm64-1cpu }
- { kubeVersion: 1.25.3, PLATFORM: arm64, RUNNER: self-hosted-arm64-1cpu }
steps:
- name: Import secrets
uses: hashicorp/vault-action@130d1f5f4fe645bb6c83e4225c04d64cfb62de6e # v2.5.0
Expand Down
1 change: 1 addition & 0 deletions AIO_BASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.10.2-rc1
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ifndef CI
PLATFORMS?=linux/amd64
BUILDX_ARGS?=--load
else
PLATFORMS?=linux/amd64,linux/aarch64
PLATFORMS?=linux/amd64,linux/arm64
BUILDX_ARGS?=--push
endif

Expand All @@ -18,6 +18,8 @@ IMAGE ?= wallarm/sidecar-controller
CONTROLLER_IMAGE = $(IMAGE):$(TAG)
COMMIT_SHA ?= git-$(shell git rev-parse --short HEAD)
ALPINE_VERSION = 3.18
INJECTION_STRATEGY ?= single
REGISTRY ?= wallarm

### Contribution routines
###
Expand Down Expand Up @@ -116,7 +118,7 @@ setup_buildx:
--use

build: setup_buildx
@docker buildx build \
docker buildx build \
--file Dockerfile \
--platform=$(PLATFORMS) \
--build-arg ALPINE_VERSION="$(ALPINE_VERSION)" \
Expand All @@ -132,6 +134,17 @@ dive:

.PHONY: build push rmi dive

### Test
###

.PHONY: smoke-test
smoke-test: ## Run smoke tests (expects access to a working Kubernetes cluster).
@test/smoke/run-smoke-suite.sh

.PHONY: kind-smoke-test
kind-smoke-test: ## Run smoke tests using kind.
@test/smoke/run.sh

### Cluster routines
###
TARBALL := .tmp.image.tar
Expand Down
Loading

0 comments on commit d0e4dcc

Please sign in to comment.