Let's redo the previous bash example, but this time using run_runner.py
.
- We assume that the
conduit
binary is available in the same directory asrun_runner.py
- You'll need to be in a python virtual env that has the requirements installed:
❯ python -m venv .venv
❯ source .venv/bin/activate
❯ pip install -r requirements.txt
- Let's see
runner.py
's options:
❯ python run_runner.py --help
usage: run_runner.py [-h] [--conduit-binary CONDUIT_BINARY] [--scenario SCENARIO] [--reset-db] [--purge] [--keep-alive] [--pg-container PG_CONTAINER] [--pg-port PG_PORT]
[--pg-database PG_DATABASE] [--report-directory REPORT_DIRECTORY] [--build-generator] [--skip-runner] [--test-duration TEST_DURATION]
options:
-h, --help show this help message and exit
--conduit-binary CONDUIT_BINARY
Path to conduit binary
--scenario SCENARIO Scenario configuration file (default=HOME_DIRECTORY/go-algorand/tools/block-generator/test_config.yml)
--reset-db Reset the DB and start at round 0 (default=False)
--purge Shutdown container that has been kept alive (default=False)
--keep-alive Keep postgres container alive at end of run (default=False)
--pg-container PG_CONTAINER
Name of postgres container (default='generator-test-container')
--pg-port PG_PORT Postgres port (default=15432)
--pg-database PG_DATABASE
Postgres database (default='generator_db')
--report-directory REPORT_DIRECTORY
Report directory (default='../../tmp/OUTPUT_RUN_RUNNER_TEST')
--build-generator Build the generator binary (default=False)
--skip-runner Skip running the generator (default=False)
--test-duration TEST_DURATION
Test duration (default='30s')
- Let's run a similar scenario as above, but with:
--scenario test_config.yml
to explicitly specify the scenario config file--test-duration 30s
to explicitly specify the test duration--keep-alive
so we can inspect the database after the run--report-directory RUN_REPORT
to explicitly specify the report directory
❯ python run_runner.py --scenario test_config.yml --conduit-binary ./conduit --keep-alive --test-duration 30s --report-directory RUN_REPORT
...
Using scenario file: test_config.yml
!!! rm -rf RUN_REPORT !!!
Skipping generator build.
Starting postgres container.
Starting test runner
Keeping postgres container alive: generator-test-container
Also, not removing report directory: RUN_REPORT
- Let's inspect the report:
❯ cat RUN_REPORT/test_config.report
scenario:test_config.yml
test_duration_seconds:30
test_duration_actual_seconds:30.024180
...
- What is the docker container?
❯ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d000f2d3f3c postgres "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:15432->5432/tcp generator-test-container
- Let's enter a
psql
session insdie the docker container and query the database:
❯ docker exec -it generator-test-container psql -U algorand -d generator_db
psql (14.5 (Debian 14.5-1.pgdg110+1))
Type "help" for help.
generator_db=# \dt
List of relations
...
generator_db=# SELECT * FROM metastate;
...
generator_db=# SELECT COUNT(*) FROM txn;
count
-------
5380
(1 row)
generator_db=# SELECT COUNT(*) FROM block_header;
count
-------
539
(1 row)
...
- Let's shutdown the container:
❯ python run_runner.py --purge
...
Purging postgres container - NO OTHER ACTION TAKEN
Stopping postgres container.
❯ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES