From a1e2bd86c69d8d62bc20eb434aeae46938ee3974 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 22 Feb 2022 11:20:58 +0000 Subject: [PATCH 1/3] Prevent local port conflicts between account portal and cypress --- packages/builder/cypress.json | 5 +++-- packages/builder/cypress/setup.js | 19 +++++++++++-------- packages/builder/package.json | 7 ++++--- packages/server/scripts/likeCypress.ts | 15 +++++++++------ 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/packages/builder/cypress.json b/packages/builder/cypress.json index 0908f2c839..a0b257fc9e 100644 --- a/packages/builder/cypress.json +++ b/packages/builder/cypress.json @@ -1,9 +1,10 @@ { - "baseUrl": "http://localhost:10001/builder/", + "baseUrl": "http://localhost:41000/builder/", "video": true, "projectId": "bmbemn", "env": { - "PORT": "10001", + "PORT": "41000", + "WORKER_PORT": "42000", "JWT_SECRET": "test" } } diff --git a/packages/builder/cypress/setup.js b/packages/builder/cypress/setup.js index ca5a65c7f5..e19c931ed9 100644 --- a/packages/builder/cypress/setup.js +++ b/packages/builder/cypress/setup.js @@ -4,17 +4,17 @@ const path = require("path") const tmpdir = path.join(require("os").tmpdir(), ".budibase") // normal development system -const WORKER_PORT = "10002" -const MAIN_PORT = cypressConfig.env.PORT +const SERVER_PORT = cypressConfig.env.PORT +const WORKER_PORT = cypressConfig.env.WORKER_PORT + process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE" process.env.NODE_ENV = "cypress" process.env.ENABLE_ANALYTICS = "false" -process.env.PORT = MAIN_PORT process.env.JWT_SECRET = cypressConfig.env.JWT_SECRET process.env.COUCH_URL = `leveldb://${tmpdir}/.data/` process.env.SELF_HOSTED = 1 -process.env.WORKER_URL = "http://localhost:10002/" -process.env.APPS_URL = `http://localhost:${MAIN_PORT}/` +process.env.WORKER_URL = `http://localhost:${WORKER_PORT}/` +process.env.APPS_URL = `http://localhost:${SERVER_PORT}/` process.env.MINIO_URL = `http://localhost:4004` process.env.MINIO_ACCESS_KEY = "budibase" process.env.MINIO_SECRET_KEY = "budibase" @@ -33,11 +33,14 @@ exports.run = ( // require("dotenv").config({ path: resolve(dir, ".env") }) // don't make this a variable or top level require // it will cause environment module to be loaded prematurely - require(serverLoc) + + // override the port with the worker port temporarily process.env.PORT = WORKER_PORT require(workerLoc) - // reload main port for rest of system - process.env.PORT = MAIN_PORT + + // override the port with the server port + process.env.PORT = SERVER_PORT + require(serverLoc) } if (require.main === module) { diff --git a/packages/builder/package.json b/packages/builder/package.json index dbfbdfe0f2..2f8a30bbc5 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -14,9 +14,10 @@ "cy:run": "cypress run", "cy:open": "cypress open", "cy:run:ci": "cypress run --record", - "cy:test": "start-server-and-test cy:setup http://localhost:10001/builder cy:run", - "cy:ci": "start-server-and-test cy:setup:ci http://localhost:10001/builder cy:run", - "cy:debug": "start-server-and-test cy:setup http://localhost:10001/builder cy:open" + "cy:test": "start-server-and-test cy:setup http://localhost:41000/builder cy:run", + "cy:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:run", + "cy:debug": "start-server-and-test cy:setup http://localhost:41000/builder cy:open", + "cy:debug:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:open" }, "jest": { "globals": { diff --git a/packages/server/scripts/likeCypress.ts b/packages/server/scripts/likeCypress.ts index 2ca4933ed7..308f22eb74 100644 --- a/packages/server/scripts/likeCypress.ts +++ b/packages/server/scripts/likeCypress.ts @@ -2,14 +2,13 @@ * This script just makes it easy to re-create * * a cypress like environment for testing the backend * ******************************************************/ -const path = require("path") +import path from "path" const tmpdir = path.join(require("os").tmpdir(), ".budibase") -const MAIN_PORT = "10001" -const WORKER_PORT = "10002" +const SERVER_PORT = "41000" +const WORKER_PORT = "42000" // @ts-ignore -process.env.PORT = MAIN_PORT process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE" process.env.NODE_ENV = "cypress" process.env.ENABLE_ANALYTICS = "false" @@ -27,7 +26,11 @@ process.env.ALLOW_DEV_AUTOMATIONS = "1" // don't make this a variable or top level require // it will cause environment module to be loaded prematurely -const server = require("../src/app") + +// override the port with the worker port temporarily process.env.PORT = WORKER_PORT const worker = require("../../worker/src/index") -process.env.PORT = MAIN_PORT + +// override the port with the server port +process.env.PORT = SERVER_PORT +const server = require("../src/app") From 17d11b46ff3fab468ecfa3d913e7338a1bb147a8 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 22 Feb 2022 15:23:54 +0000 Subject: [PATCH 2/3] Update cypress commands to work in local dev --- package.json | 4 ++-- packages/builder/package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 5111ad204f..22f5963bd2 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,8 @@ "lint:fix:prettier": "prettier --write \"packages/**/*.{js,ts,svelte}\"", "lint:fix:ts": "lerna run lint:fix", "lint:fix": "yarn run lint:fix:ts && yarn run lint:fix:prettier && yarn run lint:fix:eslint", - "test:e2e": "lerna run cy:test", - "test:e2e:ci": "lerna run cy:ci", + "test:e2e": "lerna run cy:test --stream", + "test:e2e:ci": "lerna run cy:ci --stream", "build:docker": "lerna run build:docker && npm run build:docker:proxy:compose && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION && cd -", "build:docker:proxy": "docker build hosting/proxy -t proxy-service", "build:docker:proxy:compose": "lerna run generate:proxy:compose && npm run build:docker:proxy", diff --git a/packages/builder/package.json b/packages/builder/package.json index 51a2e22eec..48989794cb 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -11,11 +11,11 @@ "rollup": "rollup -c -w", "cy:setup": "ts-node ./cypress/ts/setup.ts", "cy:setup:ci": "node ./cypress/setup.js", - "cy:run": "xvfb-run cypress run --headed --browser chrome", "cy:open": "cypress open", - "cy:run:ci": "cypress run --record", + "cy:run": "cypress run", + "cy:run:ci": "xvfb-run cypress run --headed --browser chrome --record", "cy:test": "start-server-and-test cy:setup http://localhost:41000/builder cy:run", - "cy:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:run", + "cy:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:run:ci", "cy:debug": "start-server-and-test cy:setup http://localhost:41000/builder cy:open", "cy:debug:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:open" }, From eb3f192950577f287c5eb6dc2f1a032b988efcf2 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 23 Feb 2022 07:00:57 +0000 Subject: [PATCH 3/3] Change ports --- packages/builder/cypress.json | 6 +++--- packages/builder/package.json | 8 ++++---- packages/server/scripts/likeCypress.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/builder/cypress.json b/packages/builder/cypress.json index 5d101cae31..3e4d4c4d1b 100644 --- a/packages/builder/cypress.json +++ b/packages/builder/cypress.json @@ -1,10 +1,10 @@ { - "baseUrl": "http://localhost:41000", + "baseUrl": "http://localhost:4100", "video": true, "projectId": "bmbemn", "env": { - "PORT": "41000", - "WORKER_PORT": "42000", + "PORT": "4100", + "WORKER_PORT": "4200", "JWT_SECRET": "test", "HOST_IP": "" } diff --git a/packages/builder/package.json b/packages/builder/package.json index 48989794cb..270ebff8a2 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -14,10 +14,10 @@ "cy:open": "cypress open", "cy:run": "cypress run", "cy:run:ci": "xvfb-run cypress run --headed --browser chrome --record", - "cy:test": "start-server-and-test cy:setup http://localhost:41000/builder cy:run", - "cy:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:run:ci", - "cy:debug": "start-server-and-test cy:setup http://localhost:41000/builder cy:open", - "cy:debug:ci": "start-server-and-test cy:setup:ci http://localhost:41000/builder cy:open" + "cy:test": "start-server-and-test cy:setup http://localhost:4100/builder cy:run", + "cy:ci": "start-server-and-test cy:setup:ci http://localhost:4100/builder cy:run:ci", + "cy:debug": "start-server-and-test cy:setup http://localhost:4100/builder cy:open", + "cy:debug:ci": "start-server-and-test cy:setup:ci http://localhost:4100/builder cy:open" }, "jest": { "globals": { diff --git a/packages/server/scripts/likeCypress.ts b/packages/server/scripts/likeCypress.ts index 308f22eb74..5675966b68 100644 --- a/packages/server/scripts/likeCypress.ts +++ b/packages/server/scripts/likeCypress.ts @@ -5,8 +5,8 @@ import path from "path" const tmpdir = path.join(require("os").tmpdir(), ".budibase") -const SERVER_PORT = "41000" -const WORKER_PORT = "42000" +const SERVER_PORT = "4100" +const WORKER_PORT = "4200" // @ts-ignore process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"