Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest integration tests #3038

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open

Add pytest integration tests #3038

wants to merge 31 commits into from

Conversation

darwintree
Copy link
Contributor

@darwintree darwintree commented Jan 10, 2025

#2944

What is done

This pull request adds new integration written in pytest to simplify test , especially rpc test setup. The legacy python tests still exists.

Code Organization

  • integration_tests/conflux/*: test framework helper code refactored from tests/conflux/* (simply code import path)
  • integratioin_tests/test_framework/* test framework setup code refactored from tests/integration_tests/test_framework/*
    • tests/integration_tests/test_framework/test_framework.py was changed a lot in order to adapt the pytest test process. The original test entry main() is removed and its code is break down and moved into __init__ and teardown function. The teardown function will be called by pytest framework
  • integration_tests/tests/*: new version integration tests. In */conftest.py, pytest fixtures are setup so they can be directly used by tests

How Parallel Testing Works

The pytest-xdist plugin enables tests running on different CPUs and in the tests we are using --dist loadscope to specify tests are distributed in modules (whereas each .py file). And in pytest fixtures, the fixture scope is set as scope="module". This means that tests within a module will be distributed to different CPUs and fixtures will be setup when the module tests starts and will be tear down after the module tests.

How Tests can be Migrated or Used

Check integration_tests/readme.md.

What all Tests be Migrated to the New One

I think no, at least not all, as there is not a must for the migration.

However, rpc tests can be migrated to the new test framework as there is a plan to add more rpc tests under the new test framework. And migration would make it easier to review and check if any edge case were missed


This change is Reviewable

darwintree and others added 30 commits December 10, 2024 16:08
test: add get_block_by_epoch_number_errors test
chore: change util to module, and reuse epoch errors
tests: add example for framework ussage
add integration test doc and espace debug trace rpc tests
refactor: remove asyncore dependency in pytest branch
chore: enable new integration tests in script
@darwintree darwintree requested a review from ChenxingLi January 10, 2025 09:41
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.

3 participants