Skip to content

Commit d749b3a

Browse files
authored
Merge pull request #790 from oasisprotocol/ptrus/feature/e2e-regression-tests
feat: E2E regression tests
2 parents b1158ea + 153e7e3 commit d749b3a

File tree

123 files changed

+121462
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+121462
-423
lines changed

.github/workflows/ci-test.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,49 @@ jobs:
172172
173173
- name: Upload to codecov.io
174174
uses: codecov/codecov-action@v5.5.1
175+
176+
test-e2e-regression:
177+
strategy:
178+
matrix:
179+
suite:
180+
- mainnet_sapphire_2025_09
181+
runs-on: ubuntu-latest
182+
services:
183+
postgres:
184+
image: postgres
185+
env:
186+
POSTGRES_HOST: 127.0.0.1
187+
POSTGRES_PORT: 5432
188+
POSTGRES_DB: postgres
189+
POSTGRES_USER: postgres
190+
POSTGRES_PASSWORD: postgres
191+
ports:
192+
- 5432:5432
193+
steps:
194+
- name: Checkout code
195+
uses: actions/checkout@v5
196+
197+
- name: Set up Go
198+
uses: actions/setup-go@v6
199+
with:
200+
go-version: "1.25.x"
201+
202+
- name: Build Go
203+
run: make oasis-web3-gateway
204+
205+
- name: Block access to external Oasis nodes
206+
# External nodes should not be available in CI; we run everything from caches.
207+
# Enforce unavailability to keep tests confidently reproducible, and to catch
208+
# any bugs that might cause CI to accidentally use live external services.
209+
run: |
210+
sudo bash -c 'echo 0.0.0.0 grpc.oasis.io | tee -a /etc/hosts'
211+
212+
- name: Run e2e regression tests
213+
run: make E2E_REGRESSION_SUITES=${{ matrix.suite }} test-e2e-regression
214+
215+
- uses: actions/upload-artifact@v4
216+
with:
217+
name: Actual web3 gateway responses (${{ matrix.suite }})
218+
path: |
219+
tests/e2e_regression/${{ matrix.suite }}/actual
220+
if: failure()

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ benchmarks/benchmarks
2525
.vscode
2626

2727
dist/
28+
29+
# E2E regression test artifacts.
30+
tests/e2e_regression/*/pebble-cache/
31+
tests/e2e_regression/*/actual/

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ linters:
3939
- github.com/spf13/cobra
4040
- github.com/stretchr/testify
4141
- github.com/uptrace/bun
42+
- github.com/cockroachdb/pebble
4243
- golang.org/x/crypto
4344
- google.golang.org/grpc
4445
deny:

Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,79 @@ clean:
2121
test:
2222
@$(GO) test ./...
2323

24+
# E2E regression testing.
25+
E2E_REGRESSION_SUITES := mainnet_sapphire_2025_09
26+
27+
compress-e2e-regression-caches:
28+
for suite in $(E2E_REGRESSION_SUITES); do \
29+
cache_dir="tests/e2e_regression/$$suite/pebble-cache"; \
30+
archive_path="tests/e2e_regression/$$suite/pebble-cache.tzst"; \
31+
echo "Compressing $$cache_dir to $$archive_path..."; \
32+
tar -cf "$$archive_path" --exclude='*.backup' -C "$$(dirname $$cache_dir)" "$$(basename $$cache_dir)" \
33+
--use-compress-program zstd; \
34+
done
35+
36+
clean-e2e-regression-caches:
37+
for suite in $(E2E_REGRESSION_SUITES); do \
38+
cache_dir="tests/e2e_regression/$$suite/pebble-cache"; \
39+
archive_path="tests/e2e_regression/$$suite/pebble-cache.tzst"; \
40+
echo "Removing $$cache_dir and $$archive_path..."; \
41+
rm -rf "$$cache_dir" "$$archive_path"; \
42+
done
43+
44+
ensure-e2e-regression-caches:
45+
for suite in $(E2E_REGRESSION_SUITES); do \
46+
cache_path="tests/e2e_regression/$$suite/pebble-cache"; \
47+
archive_path="tests/e2e_regression/$$suite/pebble-cache.tzst"; \
48+
if [ "$$FORCE" = "1" ]; then \
49+
echo "Forcing extraction of $$cache_path..."; \
50+
rm -rf "$$cache_path"; \
51+
fi; \
52+
if [ ! -d "$$cache_path" ]; then \
53+
if [ -f "$$archive_path" ]; then \
54+
echo "Extracting $$archive_path to $$cache_path..."; \
55+
mkdir -p "$$(dirname $$cache_path)"; \
56+
tar -xf "$$archive_path" -C "$$(dirname $$cache_path)" --use-compress-program unzstd; \
57+
else \
58+
echo "Archive $$archive_path not found, will run with empty cache."; \
59+
fi; \
60+
else \
61+
echo "Cache already exists for $$suite — skipping."; \
62+
fi; \
63+
done
64+
65+
# Run the e2e regression tests, assuming the environment is set up.
66+
test-e2e-regression: oasis-web3-gateway ensure-e2e-regression-caches
67+
for suite in $(E2E_REGRESSION_SUITES); do ./tests/e2e_regression/run.sh $$suite; done
68+
69+
# Accept the outputs of the e2e regression tests as the new expected outputs.
70+
accept-e2e-regression:
71+
for suite in $(E2E_REGRESSION_SUITES); do ./tests/e2e_regression/accept.sh $$suite; done
72+
73+
# Check actual vs expected results for e2e regression tests.
74+
check-e2e-regression:
75+
for suite in $(E2E_REGRESSION_SUITES); do ./tests/e2e_regression/check.sh $$suite; done
76+
77+
# Run dockerized postgres for local development.
78+
postgres:
79+
@docker ps -a --format '{{.Names}}' | grep -q oasis-web3-gateway-postgres && docker start oasis-web3-gateway-postgres || \
80+
docker run \
81+
--name oasis-web3-gateway-postgres \
82+
-p 5432:5432 \
83+
-e POSTGRES_USER=postgres \
84+
-e POSTGRES_PASSWORD=postgres \
85+
-e POSTGRES_DB=postgres \
86+
-d postgres -c log_statement=all
87+
@sleep 3 # Allow time for postgres to start accepting connections.
88+
89+
# Attach to the local DB from "make postgres".
90+
psql:
91+
@docker exec -it oasis-web3-gateway-postgres psql -U postgres postgres
92+
93+
# Stop and remove the postgres container.
94+
shutdown-postgres:
95+
@docker rm oasis-web3-gateway-postgres --force
96+
2497
# Format code.
2598
fmt:
2699
@$(ECHO) "$(CYAN)*** Running Go formatters...$(OFF)"
@@ -64,6 +137,9 @@ docker-sapphire-localnet:
64137
oasis-web3-gateway \
65138
clean \
66139
test \
140+
compress-e2e-regression-caches clean-e2e-regression-caches ensure-e2e-regression-caches \
141+
test-e2e-regression accept-e2e-regression check-e2e-regression \
142+
postgres psql shutdown-postgres \
67143
fmt \
68144
$(lint-targets) lint \
69145
release-build \

conf/config.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ import (
1616

1717
// Config contains the CLI configuration.
1818
type Config struct {
19-
RuntimeID string `koanf:"runtime_id"`
20-
NodeAddress string `koanf:"node_address"`
19+
RuntimeID string `koanf:"runtime_id"`
20+
21+
NodeAddress string `koanf:"node_address"`
22+
NodeCachePath *string `koanf:"node_cache_path"`
23+
2124
EnablePruning bool `koanf:"enable_pruning"`
2225
PruningStep uint64 `koanf:"pruning_step"`
2326
// IndexingStart. Skip indexing before this block number. Use this to avoid trying to index
2427
// blocks that the node doesn't have data for, such as by skipping them in checkpoint sync.
25-
// For sensible reasons, indexing may actually start at an even later block, such as if
26-
// this block is already indexed or the node indicates that it doesn't have this block.
27-
IndexingStart uint64 `koanf:"indexing_start"`
28+
IndexingStart uint64 `koanf:"indexing_start"`
29+
// IndexingEnd. Stop indexing after reaching this block number.
30+
IndexingEnd uint64 `koanf:"indexing_end"`
2831
IndexingDisable bool `koanf:"indexing_disable"`
2932

3033
Log *LogConfig `koanf:"log"`

0 commit comments

Comments
 (0)