Skip to content

Commit 2f94e31

Browse files
authored
More API spec tests (#64)
1 parent 47f82c2 commit 2f94e31

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ go run cmd/httpserver/main.go
3939

4040
### Using Docker
4141

42-
See instructions on using Docker to run the full stack at [`docs/devenv-setup.md`](./docs/devenv-setup.md)
42+
- See instructions on using Docker to run the full stack at [`docs/devenv-setup.md`](./docs/devenv-setup.md)
43+
- Also check out the [`docker-compose.yaml`](../docker/docker-compose.yaml) file, which sets up the BuilderHub, a mock proxy, and a Postgres database.
44+
- Finally, there's an e2e api spec test suite you can run: [`./scripts/ci/integration-test.sh`](./scripts/ci/integration-test.sh)
4345

4446
### Example requests
4547

scripts/ci/e2e-test.hurl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ POST http://localhost:8081/api/admin/v1/builders
3737
}
3838
HTTP 200
3939

40-
# [Admin API] Create (and enable) a new builder configuration
40+
# [Admin API] Create an empty builder configuration
4141
POST http://localhost:8081/api/admin/v1/builders/configuration/test_builder
42+
{
43+
}
44+
HTTP 200
45+
46+
# [Admin API] Create the actual builder configuration which is stored in secrets
47+
POST http://localhost:8081/api/admin/v1/builders/secrets/test_builder
4248
{
4349
"rbuilder": {
4450
"extra_data": "FooBar"
@@ -67,16 +73,15 @@ HTTP 200
6773
jsonpath "$.[0].ip" == "1.2.3.4"
6874
jsonpath "$.[0].name" == "test_builder"
6975

70-
# [Builder API] Verify that the builder can get it's configuration (NOT WORKING, TODO)
71-
#GET http://localhost:8888/api/l1-builder/v1/configuration
72-
#HTTP 200
73-
#[Asserts]
74-
#jsonpath "$.[0].dns_name" == "foobar-v1.a.b.c"
75-
#jsonpath "$.[0].rbuilder.extra_data" == "FooBar"
76-
7776
#
7877
# BUILDER APIs (via proxy)
7978
#
79+
# [Builder API] Get own configuration
80+
GET http://localhost:8888/api/l1-builder/v1/configuration
81+
HTTP 200
82+
[Asserts]
83+
jsonpath "$.rbuilder.extra_data" == "FooBar"
84+
8085
# [Builder API] Get the list of peers
8186
GET http://localhost:8888/api/l1-builder/v1/builders
8287
HTTP 200

scripts/ci/integration-test.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,35 @@ SCRIPT_DIR=$(dirname "$0")
55
cd "$SCRIPT_DIR/../.."
66

77
# Build the Docker images
8+
echo "Building Docker images..."
89
docker compose -f docker/docker-compose.yaml build
910

1011
# Start the Docker containers
12+
echo "Starting Docker containers..."
1113
docker compose -f docker/docker-compose.yaml up -d
1214

1315
# Waiting for the service to be ready
1416
echo "Waiting for containers to be ready..."
1517
printf 'GET http://localhost:8888/\nHTTP 404' | hurl --retry 60 > /dev/null;
1618

19+
# Waiting 10 more seconds to ensure everything is up
20+
echo "Waiting for additional 10 seconds..."
21+
sleep 10
22+
1723
# Run the tests
1824
echo "Running integration tests..."
25+
26+
# Enable failing for this command
27+
set +e
1928
hurl --test scripts/ci/e2e-test.hurl
20-
echo "Integration tests completed successfully."
29+
set -e
30+
31+
# Cleanup after tests
32+
if [ $? -ne 0 ]; then
33+
echo "Integration tests failed ❌ - see above for details."
34+
docker compose -f docker/docker-compose.yaml down -v
35+
exit 1
36+
fi
2137

22-
# Stop and remove the Docker containers
38+
echo "Integration tests completed successfully ✅"
2339
docker compose -f docker/docker-compose.yaml down -v

0 commit comments

Comments
 (0)