Skip to content

Commit

Permalink
Refactor how we determine TEST_LIGHTSPEED_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Apr 19, 2024
1 parent ac9f30f commit 6b37c99
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ gnalawad
groovylint
haaaad
hbenl
hostnames
hostvars
hotfixes
iam
Expand Down
11 changes: 11 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ export HOSTNAME="${HOSTNAME:-${HOST:-$(hostname)}}"
# for build and testing purposes.
export VIRTUAL_ENV="${HOME}/.local/share/virtualenvs/vsa"

# determine which TEST_LIGHTSPEED_URL value to use, as on macos we need a
# different value than on linux due to how ipv4/ipv6 hostnames are resolved.

if [[ "$OSTYPE" == "darwin"* ]]; then
TEST_LIGHTSPEED_URL='http://127.0.0.1:3000'
else
TEST_LIGHTSPEED_URL='http://ip6-localhost:3000'
fi
export TEST_LIGHTSPEED_URL


# Activate virtualenv (creates it if needed)
layout python
source_up 2>/dev/null || true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ jobs:
#
# Once the axios library starts supporting URLs that contain ipv6 addresses, we will be able to use
# http://[::1]:3000 both on Linux and MacOS to get rid of the following conditional statement.
TEST_LIGHTSPEED_URL: "${{ contains(matrix.name, 'macos') && 'http://127.0.0.1:3000' || 'http://ip6-localhost:3000' }}"
# TEST_LIGHTSPEED_URL: "${{ contains(matrix.name, 'macos') && 'http://127.0.0.1:3000' || 'http://ip6-localhost:3000' }}"

# Set environment variables using matrix properties.
SKIP_PODMAN: "${{ matrix.env.SKIP_PODMAN || '0' }}"
Expand Down
3 changes: 2 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ tasks:
- tools/dirty.sh
interactive: true
test-e2e:
desc: Run e2e tests {{.XVFB}}
cmds:
- task: package
- $VIRTUAL_ENV/bin/python3 --version
Expand Down Expand Up @@ -175,6 +174,8 @@ tasks:
- ./tools/package.sh
- src/**/*
- test/**/*
- package/*/src
- package/*/test
generates:
- "*.vsix"
cmds:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@
"_test-ui": "extest get-vscode -c ${CODE_VERSION} -s out/test-resources && extest get-chromedriver -c ${CODE_VERSION} -s out/test-resources && extest install-vsix -f ansible-*.vsix -e out/ext -s out/test-resources && extest install-from-marketplace redhat.vscode-yaml ms-python.python -e out/ext -s out/test-resources && extest run-tests -s out/test-resources -e out/ext --code_settings test/testFixtures/settings.json out/client/test/ui-test/allTestsSuite.js",
"test-ui-current": "CODE_VERSION='max' yarn _test-ui",
"test-ui-oldest": "CODE_VERSION='min' yarn _test-ui",
"test-ui-with-mock-lightspeed-server": "TEST_LIGHTSPEED_URL='http://127.0.0.1:3000' ./tools/run-ui-test-with-mock-lightspeed-server.sh",
"test-ui-with-mock-lightspeed-server": "./tools/run-ui-test-with-mock-lightspeed-server.sh",
"vscode-prepublish": "yarn run webpack",
"watch": "tsc -b -w",
"watch-server": "tsc -p ../ansible-language-server --outDir out/server -w",
Expand All @@ -859,7 +859,7 @@
"mock-lightspeed-server": "DEBUG='express:*' node ./out/client/test/mockLightspeedServer/server.js 2> out/log/express.log",
"kill-mock-lightspeed-server": "pkill -f mockLightspeedServer/server.js",
"_coverage-all": "./tools/coverage-all.sh",
"coverage-all": "TEST_LIGHTSPEED_URL='http://127.0.0.1:3000' yarn _coverage-all",
"coverage-all": "yarn _coverage-all",
"als-compile": "yarn workspace @ansible/ansible-language-server compile"
},
"version": "24.4.0",
Expand Down
10 changes: 2 additions & 8 deletions tools/coverage-all.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash

# If TEST_LIGHTSPEED_URL is not defined, set a URL with the ipv6 callback hostname,
# which is available in the GitHub Actions Linux environment.
if [[ -z "${TEST_LIGHTSPEED_URL}" ]]; then
TEST_LIGHTSPEED_URL="http://ip6-localhost:3000"
fi

# Start the mock Lightspeed server and run e2e tests with code coverage enabled.
npx start-server-and-test \
"TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn mock-lightspeed-server" \
"yarn mock-lightspeed-server" \
"${TEST_LIGHTSPEED_URL}" \
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn coverage-e2e"
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy yarn coverage-e2e"
10 changes: 2 additions & 8 deletions tools/run-ui-test-with-mock-lightspeed-server.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash

# If TEST_LIGHTSPEED_URL is not defined, set a URL with the ipv6 callback hostname,
# which is available in the GitHub Actions Linux environment.
if [[ -z "${TEST_LIGHTSPEED_URL}" ]]; then
TEST_LIGHTSPEED_URL="http://ip6-localhost:3000"
fi

# Start the mock Lightspeed server and run UI tests with the new VS Code
npx start-server-and-test \
"TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn mock-lightspeed-server" \
"yarn mock-lightspeed-server" \
"${TEST_LIGHTSPEED_URL}" \
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn test-ui-current"
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy yarn test-ui-current"

0 comments on commit 6b37c99

Please sign in to comment.