From 6cce71b49716bf95bc8cc821cb3d267527e89254 Mon Sep 17 00:00:00 2001 From: "Chang, Hui-Tang" Date: Tue, 12 Sep 2023 19:48:22 +0800 Subject: [PATCH] chore: update integration test to support consolidated gateway (#119) Because - we consolidated three gateways into one. This commit - update integration test to support consolidated gateway --- .github/workflows/integration-test.yml | 2 +- Makefile | 4 ++-- integration-test/const.js | 30 +++++--------------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index c446c06..1682938 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -129,4 +129,4 @@ jobs: - name: Run integration-test run: | - make integration-test API_GATEWAY_BASE_HOST=localhost API_GATEWAY_BASE_PORT=7080 + make integration-test API_GATEWAY_URL=localhost:8080 diff --git a/Makefile b/Makefile index 4278a33..cfe4830 100644 --- a/Makefile +++ b/Makefile @@ -56,10 +56,10 @@ unit-test: ## Run unit test .PHONY: integration-test integration-test: ## Run integration test @TEST_FOLDER_ABS_PATH=${PWD} k6 run \ - -e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_BASE_HOST=${API_GATEWAY_BASE_HOST} -e API_GATEWAY_BASE_PORT=${API_GATEWAY_BASE_PORT} \ + -e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_URL=${API_GATEWAY_URL} \ integration-test/grpc.js --no-usage-report --quiet @TEST_FOLDER_ABS_PATH=${PWD} k6 run \ - -e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_BASE_HOST=${API_GATEWAY_BASE_HOST} -e API_GATEWAY_BASE_PORT=${API_GATEWAY_BASE_PORT} \ + -e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_URL=${API_GATEWAY_URL} \ integration-test/rest.js --no-usage-report --quiet .PHONY: help diff --git a/integration-test/const.js b/integration-test/const.js index 623030e..b102796 100644 --- a/integration-test/const.js +++ b/integration-test/const.js @@ -1,15 +1,8 @@ import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js'; let proto -let host -let publicPort -let privatePort -if (__ENV.API_GATEWAY_BASE_HOST && !__ENV.API_GATEWAY_BASE_PORT || !__ENV.API_GATEWAY_BASE_HOST && __ENV.API_GATEWAY_BASE_PORT) { - fail("both API_GATEWAY_BASE_HOST and API_GATEWAY_BASE_PORT should be properly configured.") -} - -export const apiGatewayMode = (__ENV.API_GATEWAY_BASE_HOST && __ENV.API_GATEWAY_BASE_PORT); +export const apiGatewayMode = (__ENV.API_GATEWAY_URL !== "" && __ENV.API_GATEWAY_URL !== undefined); if (__ENV.API_GATEWAY_PROTOCOL) { if (__ENV.API_GATEWAY_PROTOCOL !== "http" && __ENV.API_GATEWAY_PROTOCOL != "https") { @@ -19,25 +12,12 @@ if (__ENV.API_GATEWAY_PROTOCOL) { } else { proto = "http" } - -if (apiGatewayMode) { - // api gateway mode - host = __ENV.API_GATEWAY_BASE_HOST - privatePort = 3084 - publicPort = __ENV.API_GATEWAY_BASE_PORT -} else { - // direct microservice mode - host = "mgmt-backend" - privatePort = 3084 - publicPort = 8084 -} - export const mgmtVersion = "v1alpha"; -export const mgmtPrivateHost = `${proto}://${host}:${privatePort}/${mgmtVersion}` -export const mgmtPublicHost = `${proto}://${host}:${publicPort}/${mgmtVersion}` +export const mgmtPrivateHost = apiGatewayMode ? "" : `http://mgmt-backend:3084/${mgmtVersion}` +export const mgmtPublicHost = apiGatewayMode ? `${proto}://${__ENV.API_GATEWAY_URL}/base/${mgmtVersion}` : `http://mgmt-backend:8084/${mgmtVersion}` -export const mgmtPrivateGRPCHost = `${host}:${privatePort}` -export const mgmtPublicGRPCHost = `${host}:${publicPort}` +export const mgmtPrivateGRPCHost = `mgmt-backend:3084` +export const mgmtPublicGRPCHost = `${__ENV.API_GATEWAY_URL}` export const restParams = { headers: {