Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DE-53 implement smoke tests #149

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 84 additions & 10 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=${GITHUB_SHA} IMAGE=${IMAGE} PLATFORMS=linux/${{ matrix.ARCH }} BUILDX_ARGS=--load
docker save -o sidecar-${{ matrix.ARCH }}.tar ${IMAGE}:${GITHUB_SHA}

- 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,10 +56,11 @@ jobs:
run: |
HELM_ARGS="--set controller.image.tag=${GITHUB_SHA}"
echo "helm_args=${HELM_ARGS}" >> $GITHUB_OUTPUT

test:
name: Test
needs: build
uses: wallarm/sidecar/.github/workflows/test.yaml@DE-11 # TODO: fix, tmp, no dynamic resolving here
uses: wallarm/sidecar/.github/workflows/test.yaml@DE-53_smoke_tests # TODO: fix, tmp, no dynamic resolving here
secrets:
VAULT_URL: ${{ secrets.VAULT_URL }}
VAULT_ROLE: ${{ secrets.VAULT_ROLE }}
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]
denisqsound marked this conversation as resolved.
Show resolved Hide resolved
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 TAG=${GITHUB_SHA}
32 changes: 15 additions & 17 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ jobs:
- 1.23.13
- 1.24.7
- 1.25.3
PLATFORM: [ amd64 ]
ARCH: [ 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, ARCH: arm64, RUNNER: self-hosted-arm64-1cpu }
- { kubeVersion: 1.25.3, ARCH: arm64, RUNNER: self-hosted-arm64-1cpu }
steps:
- name: Import secrets
uses: hashicorp/vault-action@130d1f5f4fe645bb6c83e4225c04d64cfb62de6e # v2.5.0
Expand Down Expand Up @@ -164,17 +164,16 @@ jobs:
kubectl cluster-info
kubectl wait --for=condition=Ready pods --all --timeout=180s -n kube-system
echo "current-context:" $(kubectl config current-context)

- name: Restore artifact
- name: Load cache
if: ${{ inputs.load_artifact }}
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: docker-artifact
path: artifacts
name: sidecar-${{ matrix.ARCH }}.tar

- name: Load image
if: ${{ inputs.load_artifact }}
run: kind load image-archive artifacts/docker-image-${{ matrix.PLATFORM }}.tar
run: kind load image-archive sidecar-${{ matrix.ARCH }}.tar

- name: Install Helm chart
run: |
Expand All @@ -184,9 +183,9 @@ jobs:
--debug \
--timeout 5m0s \
--wait ${{ inputs.helm_args }}
kubectl wait --for=condition=Ready pods --all --timeout=5m0s
kubectl describe pod -l app.kubernetes.io/component=postanalytics
kubectl describe pod -l app.kubernetes.io/component=controller
kubectl wait --for=condition=Ready pods --all --timeout=5m0s || (
kubectl describe pod -l app.kubernetes.io/component=postanalytics &&
kubectl describe pod -l app.kubernetes.io/component=controller && exit 1)

- name: Deploy pytest
run: |
Expand Down Expand Up @@ -230,16 +229,15 @@ jobs:
kind create cluster --image kindest/node:v1.25.3
kubectl wait --for=condition=Ready pods --all --timeout=180s -n kube-system

- name: Restore artifact
- name: Load cache
if: ${{ inputs.load_artifact }}
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: docker-artifact
path: artifacts
name: sidecar-amd64.tar

- name: Load image
if: ${{ inputs.load_artifact }}
run: kind load image-archive artifacts/docker-image-amd64.tar
run: kind load image-archive sidecar-amd64.tar

- name: Run test
env:
Expand Down
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
Loading