From 4b8f95f904c8029b1b59519a59f1539b95e0ed01 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 4 Nov 2024 16:34:31 +0100 Subject: [PATCH] adjust tests, port, use docker image in test --- .github/workflows/node-api.yml | 2 +- api-node/package.json | 4 ++-- api-node/scripts/run-e2e-tests.ts | 3 ++- api-node/test/utils/makeRequest.ts | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/node-api.yml b/.github/workflows/node-api.yml index 7bf63e65f..2683d57bd 100644 --- a/.github/workflows/node-api.yml +++ b/.github/workflows/node-api.yml @@ -116,7 +116,7 @@ jobs: run: yarn python-api:build - name: Build Node API working-directory: ./api-node - run: yarn build:ci + run: yarn docker:build - name: Run E2E tests working-directory: ./api-node run: yarn test:e2e:ci diff --git a/api-node/package.json b/api-node/package.json index 7d6b97fe3..baa37ee36 100644 --- a/api-node/package.json +++ b/api-node/package.json @@ -27,9 +27,9 @@ "python-api:build": "docker build -t registry-api-server ../", "python-api:start": "docker start $(docker ps -aq --filter ancestor=registry-api-server) && echo 'Flask API started successfully' || (docker run -d -p 5031:5030 registry-api-server && echo 'Flask API started successfully')", "python-api:stop": "docker stop $(docker ps -q --filter ancestor=registry-api-server)", - "docker:build": "docker build -t registry-api-nestjs-server -f Dockerfile.nestjs .", + "docker:build": "docker build -t registry-api-nestjs-server -f ../Dockerfile.nestjs ../", + "docker:start": "docker run -p 5032:5030 registry-api-nestjs-server", "docker:stop": "docker stop $(docker ps -q --filter ancestor=registry-api-nestjs-server)", - "docker:run": "docker run -p 5032:5030 registry-api-nestjs-server", "start:all": "yarn build && yarn start:dev & yarn python-api:start", "sentry:sourcemaps": "sentry-cli sourcemaps inject --org sentry --project release-registry-nestjs ./dist && sentry-cli sourcemaps upload --org sentry --project release-registry-nestjs ./dist" }, diff --git a/api-node/scripts/run-e2e-tests.ts b/api-node/scripts/run-e2e-tests.ts index 0ec15db70..d694975f8 100644 --- a/api-node/scripts/run-e2e-tests.ts +++ b/api-node/scripts/run-e2e-tests.ts @@ -5,7 +5,7 @@ import * as childProcess from 'child_process'; -const nodeApi = childProcess.spawn('yarn', ['start:prod']); +const nodeApi = childProcess.spawn('yarn', ['docker:start']); let nodeApiStarted = false; let pythonApiStarted = false; @@ -76,6 +76,7 @@ function cleanup(code: number): void { nodeApi.kill(); pythonApi.kill(); childProcess.execSync('yarn python-api:stop'); + childProcess.execSync('yarn docker:stop'); process.exit(code); } diff --git a/api-node/test/utils/makeRequest.ts b/api-node/test/utils/makeRequest.ts index f8152f575..88e9de095 100644 --- a/api-node/test/utils/makeRequest.ts +++ b/api-node/test/utils/makeRequest.ts @@ -1,8 +1,8 @@ -const PYTHON_API_PORT = 5031; -const API_NODE_PORT = 3000; +const PYTHON_API_TEST_PORT = 5031; +const NODE_API_TEST_PORT = 5032; -export const PYTHON_API_URL = `http://localhost:${PYTHON_API_PORT}`; -export const API_NODE_URL = `http://localhost:${API_NODE_PORT}`; +export const PYTHON_API_URL = `http://localhost:${PYTHON_API_TEST_PORT}`; +export const API_NODE_URL = `http://localhost:${NODE_API_TEST_PORT}`; interface ResponseParts { status: number;