From 619ed3a4d1f1dba4fca61defe3b61b859ed930ac Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 26 Sep 2023 13:12:39 +0000 Subject: [PATCH 1/4] fix e2e browser tests --- .circleci/config.yml | 4 +- yarn-project/canary/Dockerfile | 5 +++ .../canary/scripts/docker-compose-browser.yml | 37 ++++++++++++++++++ yarn-project/end-to-end/Dockerfile | 16 +++++++- yarn-project/end-to-end/package.json | 4 +- .../docker-compose-e2e-sandbox-browser.yml | 38 +++++++++++++++++++ .../scripts/start_e2e_ci_browser.sh | 15 ++++++++ yarn-project/end-to-end/src/canary/browser.ts | 11 ++---- 8 files changed, 118 insertions(+), 12 deletions(-) create mode 100644 yarn-project/canary/scripts/docker-compose-browser.yml create mode 100644 yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml create mode 100644 yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 696bf824a8e..d4ab73d5061 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -783,7 +783,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local e2e_aztec_js_browser.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local e2e_aztec_js_browser.test.ts ./scripts/docker-compose-e2e-sandbox-browser.yml e2e-card-game: machine: @@ -972,7 +972,7 @@ jobs: - *setup_env - run: name: "Test" - command: run_script canary ./scripts/run_tests ./src/aztec_js_browser.test.ts canary ./scripts/docker-compose.yml + command: run_script canary ./scripts/run_tests ./src/aztec_js_browser.test.ts canary ./scripts/docker-compose-browser.yml run-deployment-canary-cli: machine: diff --git a/yarn-project/canary/Dockerfile b/yarn-project/canary/Dockerfile index ad2f5a1962e..dcb701b7b78 100644 --- a/yarn-project/canary/Dockerfile +++ b/yarn-project/canary/Dockerfile @@ -32,6 +32,11 @@ ENV CHROME_BIN="/usr/bin/chromium-browser" PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="tru WORKDIR /usr/src/yarn-project/aztec.js RUN yarn build:web WORKDIR /usr/src/yarn-project/canary + +# Copy browser script +RUN cp ../end-to-end/scripts/start_e2e_ci_browser.sh ./scripts/start_e2e_ci_browser.sh +RUN chmod +x scripts/start_e2e_ci_browser.sh + RUN cp ../aztec.js/dest/main.js src/web/ RUN cp ../circuits.js/resources/aztec3-circuits.wasm src/web/ ENTRYPOINT ["yarn", "test"] diff --git a/yarn-project/canary/scripts/docker-compose-browser.yml b/yarn-project/canary/scripts/docker-compose-browser.yml new file mode 100644 index 00000000000..04ab2d5c2fc --- /dev/null +++ b/yarn-project/canary/scripts/docker-compose-browser.yml @@ -0,0 +1,37 @@ +version: '3' +services: + fork: + image: ghcr.io/foundry-rs/foundry:nightly-a44aa13cfc23491ba32aaedc093e9488c1a6db43 + entrypoint: > + sh -c ' + if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" + else + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 + fi' + ports: + - '8545:8545' + + sandbox: + image: aztecprotocol/aztec-sandbox:latest + environment: + DEBUG: 'aztec:*' + ETHEREUM_HOST: http://fork:8545 + CHAIN_ID: 31337 + ARCHIVER_POLLING_INTERVAL_MS: 50 + P2P_BLOCK_CHECK_INTERVAL_MS: 50 + SEQ_TX_POLLING_INTERVAL_MS: 50 + WS_BLOCK_CHECK_INTERVAL_MS: 50 + RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 + SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} + ports: + - '8080:8080' + + canary: + image: aztecprotocol/canary:latest + environment: + ETHEREUM_HOST: http://fork:8545 + CHAIN_ID: 31337 + SANDBOX_URL: http://sandbox:8080 + command: ['./scripts/start_e2e_ci_browser.sh', './src/aztec_js_browser.test.ts'] diff --git a/yarn-project/end-to-end/Dockerfile b/yarn-project/end-to-end/Dockerfile index c8d9c644217..6aae08e77f2 100644 --- a/yarn-project/end-to-end/Dockerfile +++ b/yarn-project/end-to-end/Dockerfile @@ -18,12 +18,26 @@ RUN yarn workspaces focus --production > /dev/null # Create final, minimal size image. FROM node:18-alpine -RUN apk update && apk add --no-cache udev ttf-freefont chromium curl jq bash +RUN apk update && apk add --no-cache \ + chromium \ + chromium-chromedriver \ + nss \ + freetype \ + harfbuzz \ + ca-certificates \ + ttf-freefont + ENV CHROME_BIN="/usr/bin/chromium-browser" PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" COPY --from=builder /usr/src /usr/src + RUN rm /usr/src/yarn-project/end-to-end/src/web/aztec3-circuits.wasm RUN rm /usr/src/yarn-project/end-to-end/src/web/main.js COPY --from=builder /usr/src/circuits/cpp/build-wasm/bin/aztec3-circuits.wasm /usr/src/yarn-project/end-to-end/src/web/aztec3-circuits.wasm COPY --from=builder /usr/src/yarn-project/aztec.js/dest/main.js /usr/src/yarn-project/end-to-end/src/web/main.js + WORKDIR /usr/src/yarn-project/end-to-end + +# Will only be used by browser tests, but ensure permissions are set correctly. +RUN chmod +x scripts/start_e2e_ci_browser.sh + ENTRYPOINT ["yarn", "test"] diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 01e14a2ecb1..460eefe91f5 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -56,7 +56,7 @@ "lodash.times": "^4.3.2", "lodash.zip": "^4.2.0", "lodash.zipwith": "^4.2.0", - "puppeteer": "^20.9.0", + "puppeteer": "^21.3.4", "string-argv": "^0.3.2", "ts-jest": "^29.1.0", "ts-node": "^10.9.1", @@ -75,4 +75,4 @@ "!*.test.*" ], "types": "./dest/index.d.ts" -} +} \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml new file mode 100644 index 00000000000..a808fed8a1d --- /dev/null +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml @@ -0,0 +1,38 @@ +version: '3' +services: + fork: + image: ghcr.io/foundry-rs/foundry:nightly-a44aa13cfc23491ba32aaedc093e9488c1a6db43 + entrypoint: > + sh -c ' + if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" + else + exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 + fi' + ports: + - '8545:8545' + + sandbox: + image: sandbox + environment: + DEBUG: 'aztec:*' + ETHEREUM_HOST: http://fork:8545 + CHAIN_ID: 31337 + ARCHIVER_POLLING_INTERVAL_MS: 50 + P2P_BLOCK_CHECK_INTERVAL_MS: 50 + SEQ_TX_POLLING_INTERVAL_MS: 50 + WS_BLOCK_CHECK_INTERVAL_MS: 50 + RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 + SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} + ports: + - '8080:8080' + + end-to-end: + image: e2e + environment: + ETHEREUM_HOST: http://fork:8545 + CHAIN_ID: 31337 + SANDBOX_URL: http://sandbox:8080 + SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} + entrypoint: ['./scripts/start_e2e_ci_browser.sh', './src/e2e_aztec_js_browser.test.ts'] diff --git a/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh b/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh new file mode 100644 index 00000000000..0f96c5f4230 --- /dev/null +++ b/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +TEST=${2:-./src/e2e_aztec_js_browser.test.ts} + +apk add dbus + +# Create dbus dirs +mkdir -p /var/run/dbus + +# Change ownership and permissions if necessary +chown -R root:root /var/run/dbus +chmod -R 755 /var/run/dbus + +dbus-daemon --system --nofork & +yarn test $TEST diff --git a/yarn-project/end-to-end/src/canary/browser.ts b/yarn-project/end-to-end/src/canary/browser.ts index c4f2506b59d..c3f16ff9861 100644 --- a/yarn-project/end-to-end/src/canary/browser.ts +++ b/yarn-project/end-to-end/src/canary/browser.ts @@ -27,11 +27,11 @@ const PORT = 3000; const { SANDBOX_URL } = process.env; -// const conditionalDescribe = () => (SANDBOX_URL ? describe: describe.skip); +const conditionalDescribe = () => (SANDBOX_URL ? describe : describe.skip); const privKey = AztecJs.GrumpkinScalar.random(); export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugLogger) => - describe.skip('e2e_aztec.js_browser', () => { + conditionalDescribe()('e2e_aztec.js_browser', () => { const initialBalance = 33n; const transferAmount = 3n; @@ -56,15 +56,12 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL executablePath: process.env.CHROME_BIN, headless: 'new', args: [ - '--allow-file-access-from-files', '--no-sandbox', '--headless', - '--disable-web-security', - '--disable-features=IsolateOrigins', - '--disable-site-isolation-trials', '--disable-gpu', '--disable-dev-shm-usage', - '--disk-cache-dir=/dev/null', + '--disable-software-rasterizer', + '--remote-debugging-port=9222', ], }); page = await browser.newPage(); From 28d080e1c5d50ac890ac54ccdf0b8ff399cd71b0 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 26 Sep 2023 13:34:45 +0000 Subject: [PATCH 2/4] undo dev change + restore bash --- yarn-project/end-to-end/Dockerfile | 1 + .../end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/yarn-project/end-to-end/Dockerfile b/yarn-project/end-to-end/Dockerfile index 6aae08e77f2..00fdc7a60eb 100644 --- a/yarn-project/end-to-end/Dockerfile +++ b/yarn-project/end-to-end/Dockerfile @@ -19,6 +19,7 @@ RUN yarn workspaces focus --production > /dev/null # Create final, minimal size image. FROM node:18-alpine RUN apk update && apk add --no-cache \ + bash \ chromium \ chromium-chromedriver \ nss \ diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml index a808fed8a1d..cbee1a7bbfd 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml @@ -13,7 +13,7 @@ services: - '8545:8545' sandbox: - image: sandbox + image: aztecprotocol/aztec-sandbox:latest environment: DEBUG: 'aztec:*' ETHEREUM_HOST: http://fork:8545 @@ -29,7 +29,7 @@ services: - '8080:8080' end-to-end: - image: e2e + image: aztecprotocol/end-to-end:latest environment: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 From a4c4c19619b19f7009c4bce45da795cf92b3e726 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 26 Sep 2023 14:05:32 +0000 Subject: [PATCH 3/4] remove perm step --- yarn-project/end-to-end/Dockerfile | 3 --- yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh | 0 2 files changed, 3 deletions(-) mode change 100644 => 100755 yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh diff --git a/yarn-project/end-to-end/Dockerfile b/yarn-project/end-to-end/Dockerfile index 00fdc7a60eb..c4d69bae4a4 100644 --- a/yarn-project/end-to-end/Dockerfile +++ b/yarn-project/end-to-end/Dockerfile @@ -38,7 +38,4 @@ COPY --from=builder /usr/src/yarn-project/aztec.js/dest/main.js /usr/src/yarn-pr WORKDIR /usr/src/yarn-project/end-to-end -# Will only be used by browser tests, but ensure permissions are set correctly. -RUN chmod +x scripts/start_e2e_ci_browser.sh - ENTRYPOINT ["yarn", "test"] diff --git a/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh b/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh old mode 100644 new mode 100755 From 4c96e133a892d21587c4626670509c3a7f591dd7 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 26 Sep 2023 15:51:32 +0000 Subject: [PATCH 4/4] Fix script var typo --- yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh b/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh index 0f96c5f4230..f73db85b3fe 100755 --- a/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh +++ b/yarn-project/end-to-end/scripts/start_e2e_ci_browser.sh @@ -1,6 +1,6 @@ #!/bin/sh -TEST=${2:-./src/e2e_aztec_js_browser.test.ts} +TEST=${1:-./src/e2e_aztec_js_browser.test.ts} apk add dbus