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

Randomize test run order #822

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- run: make install version
- run: make unit-tests
- run: make integration-tests
- run: make integration-tests PYTEST_ARGS="--random-order"

- name: Archive logs
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ filelock
pytest
pytest-xdist[psutil]
pytest-timeout
pytest-random-order
psutil
requests
hypothesis
Expand Down
5 changes: 4 additions & 1 deletion requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ pyrepl==0.9.0
# via fancycompleter
pytest==7.4.4
# via
# -r requirements-dev.in
# -r requirements/requirements-dev.in
# pytest-random-order
# pytest-timeout
# pytest-xdist
pytest-random-order==1.1.1
# via -r requirements/requirements-dev.in
pytest-timeout==2.2.0
# via -r requirements-dev.in
pytest-xdist[psutil]==3.6.1
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_rest_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ async def test_subscription(rest_async_client, admin_client, producer, trail):
data = res.json()
assert "topics" in data and len(data["topics"]) == 0, f"expecting {data} to be empty"
# one pattern sub will get all 3
prefix = f"{hash(random.random())}"
# use bool(trail) to make topic prefix distinct as there has been collision when
# test order is randomized.
prefix = f"test_subscription_{bool(trail)}{hash(random.random())}"
pattern_topics = [new_topic(admin_client, prefix=f"{prefix}{i}") for i in range(3)]
await wait_for_topics(rest_async_client, topic_names=pattern_topics, timeout=20, sleep=1)
res = await rest_async_client.post(sub_path, json={"topic_pattern": f"{prefix}.*"}, headers=REST_HEADERS["json"])
Expand Down
8 changes: 1 addition & 7 deletions tests/unit/test_schema_registry_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@


async def test_forward_when_not_ready():
with patch("karapace.schema_registry_apis.aiohttp.ClientSession") as client_session_class, patch(
"karapace.schema_registry_apis.KarapaceSchemaRegistry"
) as schema_registry_class:
client_session = Mock()
client_session_class.return_value = client_session

with patch("karapace.schema_registry_apis.KarapaceSchemaRegistry") as schema_registry_class:
schema_reader_mock = Mock()
ready_property_mock = PropertyMock(return_value=False)
schema_registry = Mock()
Expand All @@ -34,7 +29,6 @@ async def test_forward_when_not_ready():
close_func = Mock()
close_func.return_value = close_future_result
schema_registry.close = close_func
client_session.close = close_func

controller = KarapaceSchemaRegistryController(config=set_config_defaults(DEFAULTS))
mock_forward_func_future = asyncio.Future()
Expand Down
Loading