From b106e7ffe49c4abc3fa17125076134b04be81b34 Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Mon, 11 Jul 2022 08:11:47 -0700 Subject: [PATCH 1/2] test: use dynamic ports on CI Also renamed DFX_E2E_TEMP_DIR -> E2E_TEMP_DIR for a little brevity --- e2e/tests-dfx/call.bash | 2 +- e2e/tests-dfx/ping.bash | 4 ++-- e2e/tests-dfx/sign_send.bash | 2 +- e2e/utils/_.bash | 10 ++++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/e2e/tests-dfx/call.bash b/e2e/tests-dfx/call.bash index e53046b91a..b611ba7d17 100644 --- a/e2e/tests-dfx/call.bash +++ b/e2e/tests-dfx/call.bash @@ -123,7 +123,7 @@ teardown() { ID="$(dfx canister id hello)" NETWORK="http://localhost:$(cat .dfx/webserver-port)" ( - cd "$DFX_E2E_TEMP_DIR" + cd "$E2E_TEMP_DIR" mkdir "not-a-project-dir" cd "not-a-project-dir" assert_command dfx canister --network "$NETWORK" call "$ID" greet '("you")' diff --git a/e2e/tests-dfx/ping.bash b/e2e/tests-dfx/ping.bash index 8e0cfd0f70..ec0cca73cc 100644 --- a/e2e/tests-dfx/ping.bash +++ b/e2e/tests-dfx/ping.bash @@ -38,9 +38,9 @@ teardown() { dfx_start webserver_port=$(get_webserver_port) - mkdir "$DFX_E2E_TEMP_DIR/not-a-project" + mkdir "$E2E_TEMP_DIR/not-a-project" ( - cd "$DFX_E2E_TEMP_DIR/not-a-project" + cd "$E2E_TEMP_DIR/not-a-project" assert_command dfx ping http://127.0.0.1:"$webserver_port" assert_match "\"ic_api_version\"" diff --git a/e2e/tests-dfx/sign_send.bash b/e2e/tests-dfx/sign_send.bash index ce5682297e..40576ee065 100644 --- a/e2e/tests-dfx/sign_send.bash +++ b/e2e/tests-dfx/sign_send.bash @@ -41,7 +41,7 @@ teardown() { } @test "sign outside of a dfx project" { - cd "$DFX_E2E_TEMP_DIR" + cd "$E2E_TEMP_DIR" mkdir not-a-project-dir cd not-a-project-dir diff --git a/e2e/utils/_.bash b/e2e/utils/_.bash index 7d5e1f8af5..6cefef8373 100644 --- a/e2e/utils/_.bash +++ b/e2e/utils/_.bash @@ -12,7 +12,7 @@ install_asset() { standard_setup() { # We want to work from a temporary directory, different for every test. x=$(mktemp -d -t dfx-e2e-XXXXXXXX) - export DFX_E2E_TEMP_DIR="$x" + export E2E_TEMP_DIR="$x" mkdir "$x/working-dir" mkdir "$x/cache-root" @@ -28,7 +28,7 @@ standard_setup() { } standard_teardown() { - rm -rf "$DFX_E2E_TEMP_DIR" || rm -rf "$DFX_E2E_TEMP_DIR" + rm -rf "$E2E_TEMP_DIR" || rm -rf "$E2E_TEMP_DIR" } dfx_new_frontend() { @@ -91,12 +91,10 @@ dfx_patchelf() { dfx_start() { dfx_patchelf - if [ "$GITHUB_WORKSPACE" ]; then - # no need for random ports on github workflow; even using a random port we sometimes - # get 'address in use', so the hope is to avoid that by using a fixed port. + if [ "$E2E_STATIC_PORTS" ]; then FRONTEND_HOST="127.0.0.1:8000" else - # Start on random port for parallel test execution (needed on nix/hydra) + # Start on random port for parallel test execution FRONTEND_HOST="127.0.0.1:0" fi From e81877f6cb758eb384a877f7ba0a2baf0eea905f Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Mon, 11 Jul 2022 08:13:33 -0700 Subject: [PATCH 2/2] . --- e2e/utils/_.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/utils/_.bash b/e2e/utils/_.bash index 6cefef8373..b91a17661e 100644 --- a/e2e/utils/_.bash +++ b/e2e/utils/_.bash @@ -94,7 +94,7 @@ dfx_start() { if [ "$E2E_STATIC_PORTS" ]; then FRONTEND_HOST="127.0.0.1:8000" else - # Start on random port for parallel test execution + # Start on random port for parallel test execution or to coexist with a local server FRONTEND_HOST="127.0.0.1:0" fi