Skip to content

[DRAFT] UnitTest based tests#7906

Open
cjen1-msft wants to merge 6 commits into
microsoft:mainfrom
cjen1-msft:unittest-2
Open

[DRAFT] UnitTest based tests#7906
cjen1-msft wants to merge 6 commits into
microsoft:mainfrom
cjen1-msft:unittest-2

Conversation

@cjen1-msft
Copy link
Copy Markdown
Contributor

@cjen1-msft cjen1-msft commented May 20, 2026

Several changes to make this work:

  • Pass cli args as config file and path to that file as an environment variable.
  • test files need to start with test_*

The atom in UnitTest is a TestCase.
So here I've mapped the suite to a single TestCase.
If down the line we still want to separate out different tests to different runners, we can do so by adding them to suites.

Selectors for single tests work:

   PYTHONPATH=tests:python/src \
   CCF_TEST_CONFIG=build/test_config.json \
   python -m unittest test_e2e_operations.BackupSnapshotDownload.test_backup_snapshot_fetch -v

I'm enthuastically open to suggestions and bikeshedding on this as it will be quite a large change and we need to ensure we are careful and correct in how we do it.

There is none of the reworks to the config, or deduplication or concurrent runners or anything like that, this is solely focused on showing how we could go about using unittest to improve the UX and improve the UX of our testing.
It does however pave the way to future improvements such as:

  • Better config management
  • Efficiency (deduplication and more concurrency)

@cjen1-msft cjen1-msft requested a review from a team as a code owner May 20, 2026 18:04
Copilot AI review requested due to automatic review settings May 20, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR proposes an initial integration of Python’s unittest framework into CCF’s end-to-end (e2e) test infrastructure by introducing a NetworkTestCase base class and a CMake/JSON-driven configuration mechanism, plus wiring a new ctest entry to run unittest discovery.

Changes:

  • Add NetworkTestCase (unittest.TestCase) that starts a CCF network once per test class and records failures to skip subsequent tests in the same class.
  • Add CCF_TEST_CONFIG-driven JSON defaults loading in e2e_args.cli_args(), and generate a build-time test_config.json via CMake.
  • Add a new e2e_unittests ctest target running python -m unittest discover, and add a first example test file tests/test_e2e_operations.py.

Custom instructions used:

  • .github/copilot-instructions.md
  • .github/instructions/reviewing.instructions.md

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_e2e_operations.py Adds first unittest-based wrapper class for existing e2e_operations tests
tests/infra/network.py Introduces NetworkTestCase to run e2e tests under unittest
tests/infra/e2e_args.py Loads config defaults from CCF_TEST_CONFIG / test_config.json, adds argv override
python/src/ccf/ledger.py Fixes file handle lifetime in SimpleBuffer.from_file
CMakeLists.txt Generates test_config.json, adds e2e_unittests ctest entry, refactors constitution args list
cmake/test_config.json.in New template for JSON test configuration
cmake/common.cmake Removes duplicated NODE_TICK_MS selection (now set in top-level CMake)

Comment thread tests/test_e2e_operations.py
Comment thread CMakeLists.txt
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