Skip to content

Refactor sync test#137

Open
OlufemiAdeOlusile wants to merge 31 commits into
mainfrom
sync-refactor
Open

Refactor sync test#137
OlufemiAdeOlusile wants to merge 31 commits into
mainfrom
sync-refactor

Conversation

@OlufemiAdeOlusile

@OlufemiAdeOlusile OlufemiAdeOlusile commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Refactors node sync test configuration to make Genesis mode the default, aligning with IOG's current defaults. Fixes broken Preview/Preprod tests caused by hardcoded Mainnet peer snapshot.

Changes

  • Removed hardcoded Mainnet peer snapshot file (sync_tests/data/peersnapshotfile.json)
  • Added remove_json_keys() helper and disable_genesis_mode() function
  • Added normalize_peer_snapshot() to convert IOG's domain keys to address
  • Downloads environment-specific peer snapshot from IOG automatically
  • Replaced --use-genesis-mode flag with --disable-genesis-mode

Genesis mode (default)

python sync_tests/tests/node_sync_test.py -e preview -r1 master -t1 my_test

Praos mode (fallback)

python sync_tests/tests/node_sync_test.py -e preview -r1 master -t1 my_test --disable-genesis-mode

Breaking Changes

  • -g / --use-genesis-mode flag removed
  • Genesis mode now ON by default (previously OFF)

…lt, aligning with IOG's current defaults. Fixes broken Preview/Preprod tests caused by hardcoded Mainnet peer snapshot.

## Changes

- Removed hardcoded Mainnet peer snapshot file (`sync_tests/data/peersnapshotfile.json`)
- Added `remove_json_keys()` helper and `disable_genesis_mode()` function
- Added `normalize_peer_snapshot()` to convert IOG's `domain` keys to `address`
- Downloads environment-specific peer snapshot from IOG automatically
- Replaced `--use-genesis-mode` flag with `--disable-genesis-mode`

## Usage

# Genesis mode (default)
python sync_tests/tests/node_sync_test.py -e preview -r1 master -t1 my_test

# Praos mode (fallback)
python sync_tests/tests/node_sync_test.py -e preview -r1 master -t1 my_test --disable-genesis-mode

## Breaking Changes

- `-g` / `--use-genesis-mode` flag removed
- Genesis mode now ON by default (previously OFF)
Move export_env_var, make_tarfile, write_json_to_file, manage_directory,
get_file_sha256_sum, and print_last_n_lines from db_sync.py to helpers.py
to eliminate code duplication.

Update all call sites in db_sync.py to use helpers functions.
- Add `LOGGER = logging.getLogger(__name__)`
- Replace `logging.info()` with `LOGGER.info()`
- Replace `logging.error()` with `LOGGER.error()`
- Remove `logging.basicConfig()` call
- Remove `sh_colors` class
- Remove `print_color_log()` function
- Replace calls with `helpers.print_message()` or `LOGGER`
- Create `DbSyncTip` dataclass
- Create `PerfStats` dataclass
- Update functions to return dataclasses instead of tuples
- Update callers to use dataclass fields
- Replace global variables with DbSyncConfig dataclass. All functions now
- accept config parameter instead of relying on globals. Updated all test
- files to create and pass config explicitly. Matches node_sync_test.py
- patterns for better maintainability and thread-safety.
@OlufemiAdeOlusile OlufemiAdeOlusile marked this pull request as draft January 16, 2026 08:17
- Replace all os.chdir() calls with subprocess cwd parameter and absolute paths derived from DbSyncConfig.
Extract helper functions from wait_for_db_to_sync() to improve
maintainability:
- _check_for_rollback() - rollback detection
- _log_sync_progress() - progress logging
- _collect_perf_stats() - stats collection

Also fixes all linting issues and mypy type errors.
- Split db_sync.py into postgres.py, artifacts.py, charts.py, and snapshots.py for better separation of concerns.
- Updated aws_db.py to use DbSyncConfig instead of global variables. All functions re-exported from db_sync.py
for backward compatibility.
- Add wait_for_shelley_era() function to optimize db-sync start time.
- Instead of waiting for full node sync or starting immediately, the test
- now waits for the node to reach Shelley era before starting db-sync.
@OlufemiAdeOlusile OlufemiAdeOlusile marked this pull request as ready for review January 27, 2026 11:46
Comment thread sync_tests/tests/node_sync_test.py

@saratomaz saratomaz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sync_tests/tests/node_sync_test.py was removed and it's used by buildkite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants