Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura committed Jan 13, 2025
1 parent b06c739 commit 55fcd90
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 50 deletions.
19 changes: 19 additions & 0 deletions .github/scripts/setup_local_busola.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# This script returns the id of the draft release

# standard bash error handling
set -o nounset # treat unset variables as an error and exit immediately.
set -o errexit # exit immediately when a command fails.
set -E # needs to be set if we want the ERR trap
set -o pipefail # prevents errors in a pipeline from being masked

npm ci
npm run build
cp -r build backend/core-ui
cd backend
npm run build
IS_DOCKER=true npm run start:prod > busola.log &
export DOMAIN=http://localhost:3001
echo "waiting for server to be up..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' "$DOMAIN")" != "200" ]]; do sleep 5; done
21 changes: 5 additions & 16 deletions .github/workflows/pull-integration-cluster-k3d.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: PR Integration Cluster Tests

on:
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
types: [ opened, edited, synchronize, reopened, ready_for_review ]
paths:
- ".github/workflows/pull-integration-cluster-k3d.yml"
- "resources/**"
Expand Down Expand Up @@ -39,26 +39,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: setup_busola
- name: Setup Busola
shell: bash
run: |
set -e
npm ci
npm run build
cp -r build backend/core-ui
cd backend
npm run build
IS_DOCKER=true npm run start:prod > busola.log &
.github/scripts/setup-local_busola.sh
- name: run_tests
shell: bash
run: |
k3d kubeconfig get k3dCluster > tests/integration/fixtures/kubeconfig.yaml
export CYPRESS_DOMAIN=http://localhost:3001
echo "waiting for server to be up..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' "$CYPRESS_DOMAIN")" != "200" ]]; do sleep 5; done
sleep 10
export CYPRESS_DOMAIN=http://localhost:3001
cd tests/integration
npm ci && npm run "test:cluster"
- name: Uploads artifacts
Expand Down
19 changes: 4 additions & 15 deletions .github/workflows/pull-integration-namespace-k3d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: setup_busola
- name: Setup Busola
shell: bash
run: |
set -e
npm ci
npm run build
cp -r build backend/core-ui
cd backend
npm run build
IS_DOCKER=true npm run start:prod > busola.log &
- name: run_tests
.github/scripts/setup-local_busola.sh
- name: Run tests
shell: bash
run: |
k3d kubeconfig get k3dCluster > tests/integration/fixtures/kubeconfig.yaml
export CYPRESS_DOMAIN=http://localhost:3001
echo "waiting for server to be up..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' "$CYPRESS_DOMAIN")" != "200" ]]; do sleep 5; done
sleep 10
k3d kubeconfig get k3dCluster > tests/integration/fixtures/kubeconfig.yaml
cd tests/integration
npm ci && npm run "test:namespace"
- name: Uploads artifacts
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pull-kyma-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: setup_busola
- name: Setup Busola
shell: bash
run: |
./.github/scripts/setup-busola.sh | tee busola-build.log
.github/scripts/setup-local_busola.sh
env:
ENV: dev
- name: run_tests
- name: Run tests
shell: bash
run: |
k3d kubeconfig get kyma > tests/integration/fixtures/kubeconfig.yaml
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/pull-lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,14 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: setup_busola
- name: Run busola
shell: bash
run: |
set -e
npm ci
npm run build
cp -r build backend/core-ui
cd backend
npm run build
IS_DOCKER=true npm run start:prod > busola.log &
- name: run_tests
.github/scripts/setup-local_busola.sh
- name: Run lighthouse tests
shell: bash
run: |
k3d kubeconfig get k3dCluster > tests/lighthouse/fixtures/kubeconfig.yaml
export DOMAIN=http://localhost:3001
echo "waiting for server to be up..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' "$DOMAIN")" != "200" ]]; do sleep 5; done
sleep 10
cd tests/lighthouse
npm ci && npx playwright install --with-deps && npm run "test"
- name: Upload Busola logs
Expand Down
5 changes: 4 additions & 1 deletion tests/lighthouse/lighthouse.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { playAudit } from 'playwright-lighthouse';
import { chromium } from 'playwright';
import { tmpdir } from 'os';

const ADDRESS = 'http://localhost:3001';
const ADDRESS = process.env.LOCAL
? 'http://localhost:8080'
: 'http://localhost:3001';
// What to do with that

test('Busola Lighthouse audit', async () => {
const context = await chromium.launchPersistentContext(tmpdir(), {
Expand Down

0 comments on commit 55fcd90

Please sign in to comment.