Skip to content

Commit 69d157e

Browse files
Feat importer offline e2e (#2014)
* e2e test for importer offline * ignore database path * configure test to run on github actions * improve gitignore * stop using \t for f strings in python * adding python requirements * fail justfile in case of failure * building rpc downloader and importer offline * second parameter is not target type * waiting for stratus 3001 to be ready * second stratus executing must be with release * test don't run importer * must run importer offline in the task * dont build binaries at the beginning * missing just
1 parent 834fad7 commit 69d157e

File tree

6 files changed

+65
-7
lines changed

6 files changed

+65
-7
lines changed

.github/workflows/_setup-e2e.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
with:
5252
node-version-file: .tool-versions
5353

54+
- name: Install docker-compose
55+
run: sudo apt-get install docker-compose -y
56+
5457
- name: Install jq
5558
run: sudo apt-get install jq -y
5659

.github/workflows/e2e-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,13 @@ jobs:
116116
concurrency:
117117
group: ${{ github.workflow }}-rpc-downloader-${{ github.ref || github.run_id }}
118118
cancel-in-progress: true
119+
120+
e2e-importer-offline:
121+
name: E2E Importer Offline
122+
uses: ./.github/workflows/_setup-e2e.yml
123+
with:
124+
justfile_recipe: "e2e-importer-offline"
125+
126+
concurrency:
127+
group: ${{ github.workflow }}-importer-offline-${{ github.ref || github.run_id }}
128+
cancel-in-progress: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ node_modules/
3232
# E2E (Run With Importer)
3333
e2e_logs/
3434
temp_*-rocksdb/
35+
tests/importer-offline-database/*
3536

3637
# Build
3738
crates/*/target

justfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,45 @@ e2e-rpc-downloader:
461461
just _log "Killing PostgreSQL"
462462
docker-compose down postgres
463463

464+
# E2E Importer Offline
465+
e2e-importer-offline:
466+
mkdir -p e2e_logs
467+
468+
rm -rf data/importer-offline-database-rocksdb
469+
470+
just _log "Starting Stratus"
471+
just stratus -a 0.0.0.0:3000 > e2e_logs/e2e-importer-offline-stratus.log &
472+
just _wait_for_stratus
473+
474+
just _log "Running TestContractBalances tests"
475+
just e2e stratus automine
476+
477+
just _log "Starting PostgreSQL"
478+
docker-compose up -d postgres
479+
480+
just _log "Running rpc downloader"
481+
just rpc-downloader --external-rpc http://localhost:3000/ --external-rpc-storage postgres://postgres:123@localhost:5432/stratus --metrics-exporter-address 0.0.0.0:9001 --initial-accounts 0x70997970c51812dc3a010c7d01b50e0d17dc79c8,0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
482+
483+
just _log "Run importer-offline"
484+
just importer-offline --external-rpc-storage postgres://postgres:123@localhost:5432/stratus --rocks-path-prefix=data/importer-offline-database --metrics-exporter-address 0.0.0.0:9002
485+
486+
just _log "Stratus for importer-offline"
487+
cargo run --release --bin stratus -- --leader -a 0.0.0.0:3001 --perm-storage=rocks --rocks-path-prefix=data/importer-offline-database --metrics-exporter-address 0.0.0.0:9002 > e2e_logs/e2e-importer-offline-stratus-3001.log &
488+
just _wait_for_stratus 3001
489+
490+
just _log "Compare blocks of stratus and importer-offline"
491+
pip install -r utils/compare_block/requirements.txt
492+
python utils/compare_block/main.py http://localhost:3000 http://localhost:3001 1 --ignore timestamp --ignore type
493+
494+
just _log "Killing Stratus"
495+
killport 3000 -s sigterm
496+
497+
just _log "Killing importer-offline"
498+
killport 3001 -s sigterm
499+
500+
just _log "Killing PostgreSQL"
501+
docker-compose down postgres
502+
464503
# ------------------------------------------------------------------------------
465504
# Hive tests
466505
# ------------------------------------------------------------------------------

utils/compare_block/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def print_items(changes: list, ignore: list[str], indent: int = 0):
1010
for change in changes:
1111
field = change.path(root="", output_format="list")[0]
1212
if field not in ignore:
13-
print(f"{'\t'*indent}[bold red]{field}[/bold red]")
13+
print(f"{' ' * indent}[bold red]{field}[/bold red]")
1414
print()
1515

1616

@@ -20,11 +20,11 @@ def print_changes(changes: list, ignore: list[str], left, right, indent: int = 0
2020
if field not in ignore:
2121
if isinstance(left[field], HexBytes) and isinstance(right[field], HexBytes):
2222
print(
23-
f"{'\t'*indent}{field}:\n{'\t'*indent}\t[bold red]Left: {left[field].hex()}[/bold red]\n{'\t'*indent}\t[bold green]Right: {right[field].hex()}[/bold green]"
23+
f"{' ' * indent}{field}:\n{' ' * indent} [bold red]Left: {left[field].hex()}[/bold red]\n{' ' * indent} [bold green]Right: {right[field].hex()}[/bold green]"
2424
)
2525
else:
2626
print(
27-
f"{'\t'*indent}{field}:\n{'\t'*indent}\t[bold red]Left: {left[field]}[/bold red]\n{'\t'*indent}\t[bold green]Right: {right[field]}[/bold green]"
27+
f"{' ' * indent}{field}:\n{' ' * indent} [bold red]Left: {left[field]}[/bold red]\n{' ' * indent} [bold green]Right: {right[field]}[/bold green]"
2828
)
2929
print()
3030

@@ -38,25 +38,25 @@ def print_diff(
3838
ignore_in_item: list[str],
3939
indent: int = 0,
4040
):
41-
print(f"{'\t'*indent}[bold blue]{name} Diff:[/bold blue]")
41+
print(f"{' ' * indent}[bold blue]{name} Diff:[/bold blue]")
4242
if len(diff.get("dictionary_item_added", [])):
4343
print(
44-
f"{'\t'*indent}\t[red]The left {name} is missing the following fields:[/red]"
44+
f"{' ' * indent} [red]The left {name} is missing the following fields:[/red]"
4545
)
4646
print_items(
4747
diff["dictionary_item_added"], [*ignore, *ignore_in_item], indent + 2
4848
)
4949

5050
if len(diff.get("dictionary_item_removed", [])):
5151
print(
52-
f"{'\t'*indent}\t[red]The right {name} is missing the following fields:[/red]"
52+
f"{' ' * indent} [red]The right {name} is missing the following fields:[/red]"
5353
)
5454
print_items(
5555
diff["dictionary_item_removed"], [*ignore, *ignore_in_item], indent + 2
5656
)
5757

5858
if len(diff.get("values_changed", [])):
59-
print(f"{'\t'*indent}\t[red]The follwing values don't match:[/red]")
59+
print(f"{' ' * indent} [red]The follwing values don't match:[/red]")
6060
print_changes(diff["values_changed"], ignore, left, right, indent + 2)
6161

6262

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
deepdiff
2+
web3
3+
hexbytes
4+
typer
5+
rich

0 commit comments

Comments
 (0)