Skip to content

Commit

Permalink
chore: update integration test to support consolidated gateway (#119)
Browse files Browse the repository at this point in the history
    Because

    - we consolidated three gateways into one.

    This commit

    - update integration test to support consolidated gateway
  • Loading branch information
donch1989 committed Sep 12, 2023
1 parent 3506e55 commit 6cce71b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 5 additions & 25 deletions integration-test/const.js
Original file line number Diff line number Diff line change
@@ -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") {
Expand All @@ -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: {
Expand Down

0 comments on commit 6cce71b

Please sign in to comment.