Skip to content

Commit f7ee5cd

Browse files
Add E2E self-test step: real tunnel + browser session via raw WebDriver
1 parent 4b0eefd commit f7ee5cd

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

.buildkite/e2e-test.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# End-to-end self-test: drives a real TestingBot browser session through the
3+
# tunnel to a web server that only exists on this agent, proving the full
4+
# tunnel + status-update + annotation flow.
5+
set -euo pipefail
6+
7+
workdir="$(mktemp -d)"
8+
cat >"${workdir}/index.html" <<'HTML'
9+
<!DOCTYPE html>
10+
<html><head><title>Buildkite E2E OK</title></head>
11+
<body><h1>Served from the Buildkite agent, reached through the TestingBot tunnel</h1></body></html>
12+
HTML
13+
(cd "${workdir}" && exec python3 -m http.server 8123) >/dev/null 2>&1 &
14+
server_pid=$!
15+
trap 'kill "${server_pid}" 2>/dev/null || true; rm -rf "${workdir}"' EXIT
16+
17+
payload="$(jq -n \
18+
--arg key "${TESTINGBOT_KEY}" \
19+
--arg secret "${TESTINGBOT_SECRET}" \
20+
--arg build "${TESTINGBOT_BUILD}" \
21+
'{capabilities: {alwaysMatch: {browserName: "chrome",
22+
"tb:options": {key: $key, secret: $secret, build: $build, name: "plugin e2e — tunnel to localhost"}}}}')"
23+
24+
echo "--- Creating TestingBot browser session"
25+
resp="$(curl -fsS -X POST "https://hub.testingbot.com/wd/hub/session" \
26+
-H "Content-Type: application/json" -d "${payload}")"
27+
sid="$(echo "${resp}" | jq -r '.value.sessionId')"
28+
echo "session: ${sid}"
29+
echo "${sid}" >>"${TESTINGBOT_SESSIONS_FILE}"
30+
31+
echo "--- Navigating remote browser to http://localhost:8123 (through the tunnel)"
32+
curl -fsS -X POST "https://hub.testingbot.com/wd/hub/session/${sid}/url" \
33+
-H "Content-Type: application/json" -d '{"url": "http://localhost:8123/"}' >/dev/null
34+
sleep 2
35+
title="$(curl -fsS "https://hub.testingbot.com/wd/hub/session/${sid}/title" | jq -r '.value')"
36+
echo "page title seen by remote browser: ${title}"
37+
38+
curl -fsS -X DELETE "https://hub.testingbot.com/wd/hub/session/${sid}" >/dev/null
39+
40+
[[ "${title}" == "Buildkite E2E OK" ]]

.buildkite/pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ steps:
1515
plugins:
1616
- docker-compose#v5.4.1:
1717
run: tests
18+
19+
- wait
20+
21+
- label: ":chrome: E2E (real tunnel + browser session)"
22+
command: .buildkite/e2e-test.sh
23+
plugins:
24+
- ${BUILDKITE_PULL_REQUEST_REPO:-$BUILDKITE_REPO}#${BUILDKITE_COMMIT}: ~

0 commit comments

Comments
 (0)