Skip to content

feat(server): improve resource manager test suit debug output #2914

feat(server): improve resource manager test suit debug output

feat(server): improve resource manager test suit debug output #2914

Workflow file for this run

name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- .github/workflows/pull-request.yaml
- api/**
- cli/**
- examples/**
- server/**
- tracetesting/**
- web/**
- Dockerfile
- k8s/**
jobs:
backend-arch-graph:
name: Generate backend architecture graph
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: 'go.work'
cache: true
cache-dependency-path: go.work
- name: install graph tool
run: |
mkdir /tmp/go-arch
cd /tmp/go-arch
curl -SLO https://github.com/mathnogueira/golang-arch-viewer/archive/refs/heads/master.zip
unzip master.zip
cd golang-arch-viewer-master
make
mv dist/go-arch /tmp/go-arch/go-arch
- name: generate graph
run: |
cd server
mkdir -p ../dist/
/tmp/go-arch/go-arch ../dist/architecture.png
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: architecture-graph
path: dist/architecture.png
unit-test-cli:
name: CLI unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: 'go.work'
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd cli; make test
test-server:
name: API Server unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: 'go.work'
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd server; make test
test-web:
name: WebUI unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cmd:
- npm run lint
- npm test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- run: cd web; npm ci
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
- run: cd web; ${{ matrix.cmd }}
build-go:
name: Build go binaries (API Server and CLI)
needs: [unit-test-cli, test-server]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: 'go.work'
cache: true
cache-dependency-path: go.work
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser-pro
version: v1.17.2
args: build --single-target --clean --snapshot
env:
VERSION: pr-${{ github.event.pull_request.number }}
TRACETEST_ENV: pr
ANALYTICS_FE_KEY: ${{ secrets.ANALYTICS_FE_KEY }}
ANALYTICS_BE_KEY: ${{ secrets.ANALYTICS_BE_KEY }}
- run: echo $(go env GOOS)_$(go env GOARCH) > dist/arch.txt
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: tracetest-go
path: dist/
build-web:
name: Build WebUI resources
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache Build
id: cache-build
uses: actions/cache@v3
with:
path: web/build/
key: web-build-${{ hashFiles('web/*') }}
- run: cd web; npm ci
if: steps.cache-build.outputs.cache-hit != 'true'
- run: cd web; CI= npm run build
if: steps.cache-build.outputs.cache-hit != 'true'
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: tracetest-web
path: web/build/
build-docker:
name: Build docker image
runs-on: ubuntu-latest
needs: [build-web, build-go]
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
GORELEASER_KEY: ${{ secrets.GORELEASER_LICENSE }}
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: 'go.work'
cache: true
cache-dependency-path: go.work
- uses: actions/download-artifact@v3
with:
name: tracetest-web
path: web/build/
# release
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser-pro
version: v1.17.2
args: release --clean --skip-announce --snapshot -f .goreleaser.dev.yaml
env:
VERSION: pr-${{ github.event.pull_request.number }}
TRACETEST_ENV: pr
ANALYTICS_FE_KEY: ${{ secrets.ANALYTICS_FE_KEY }}
ANALYTICS_BE_KEY: ${{ secrets.ANALYTICS_BE_KEY }}
- run: docker push kubeshop/tracetest:pr-${{ github.event.pull_request.number }}
test-examples:
name: Test examples
needs: [build-docker]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example_dir:
- collector
- tracetest-jaeger
- tracetest-opensearch
- tracetest-tempo
- tracetest-no-tracing
- tracetest-provisioning-env
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-go
path: dist/
- name: Build example
run: |
cd examples/${{ matrix.example_dir }}
TAG=pr-${{ github.event.pull_request.number }} docker-compose up -d
docker compose logs -f > /tmp/docker-log &
- name: Run example test
run: |
find ./dist -name 'tracetest' -exec cp {} ./dist \;
chmod +x ./dist/tracetest
./scripts/wait-for-port.sh 11633
./dist/tracetest configure -g --endpoint http://localhost:11633 --analytics=false
./dist/tracetest test run -d examples/${{ matrix.example_dir }}/tests/list-tests.yaml --wait-for-result || (cat /tmp/docker-log; exit 1)
smoke-test-cli:
name: CLI smoke tests
needs: [build-docker]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_env:
- local
- docker
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-go
path: dist/
- name: Start server
run: |
cd examples/collector
TAG="pr-${{ github.event.pull_request.number }}" docker-compose up -d
docker compose logs -f > /tmp/docker-log &
- name: Run tests
run: |
find ./dist -name 'tracetest' -exec cp {} ./dist \;
chmod +x ./dist/tracetest
cd ./cli/smoketest
chmod +x ./run.bash
../../scripts/wait-for-port.sh 11633
TRACETEST_CLI="../../dist/tracetest" \
TAG="pr-${{ github.event.pull_request.number }}" \
TEST_ENV="${{ matrix.test_env }}" \
./run.bash
deploy:
name: Deploy test infra
needs: [build-docker, unit-test-cli, test-server, test-web]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ secrets.GKE_CLUSTER }}
location: ${{ secrets.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Deploy
run: |
TAG=pr-${{ github.event.pull_request.number }} \
NAME=tracetest-$TAG \
CONFIG_FILE=./k8s/tracetest.beta.yaml \
./k8s/deploy.sh
trace-testing:
needs: [deploy]
name: Tracetesting API Server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ secrets.GKE_CLUSTER }}
location: ${{ secrets.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install CLI integration version (latest main)
run: |
cd /tmp
curl -L https://github.com/kubeshop/tracetest/releases/download/nightly/tracetest_latest_linux_amd64.tar.gz | tar -xz
- name: Connecting with integration env (port-forwarding)
run: |
kubectl port-forward \
--namespace tracetest-integration \
svc/tracetest-integration 11633 &
./scripts/wait-for-port.sh 11633
- name: Connecting with PR env (port-forwarding)
run: |
kubectl port-forward \
--namespace tracetest-pr-${{ github.event.pull_request.number }} \
svc/tracetest-pr-${{ github.event.pull_request.number }} 11634:11633 &
./scripts/wait-for-port.sh 11634
- name: Run integration tests
run: |
cd tracetesting
TRACETEST_CLI="/tmp/tracetest" \
TARGET_URL="http://tracetest-pr-${{ github.event.pull_request.number }}.tracetest-pr-${{ github.event.pull_request.number }}:11633" \
./run.bash
e2e:
needs: [deploy, trace-testing]
name: WebUI End-to-end tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ secrets.GKE_CLUSTER }}
location: ${{ secrets.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Cache dependencies
id: cache-nodemodules
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: cd web/; npm ci
- name: Forward port
run: |
kubectl port-forward \
--namespace tracetest-pr-${{ github.event.pull_request.number }} \
svc/tracetest-pr-${{ github.event.pull_request.number }} 3000:11633 &
- name: Run integration tests
run: |
./scripts/wait-for-port.sh 3000 &
cd web/
npm run cy:ci
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
cleanup:
name: Cleanup test infra
runs-on: ubuntu-latest
needs: [trace-testing, e2e]
steps:
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ secrets.GKE_CLUSTER }}
location: ${{ secrets.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Uninstall tracetest
run: |
helm delete tracetest-pr-${{ github.event.pull_request.number }} \
--namespace tracetest-pr-${{ github.event.pull_request.number }}
kubectl delete ns tracetest-pr-${{ github.event.pull_request.number }}