Skip to content

Issue 6753 - Port ticket 48266 test#7393

Open
mirielka wants to merge 1 commit into389ds:mainfrom
mirielka:48266
Open

Issue 6753 - Port ticket 48266 test#7393
mirielka wants to merge 1 commit into389ds:mainfrom
mirielka:48266

Conversation

@mirielka
Copy link
Copy Markdown
Contributor

@mirielka mirielka commented Apr 9, 2026

Description:
Port ticket 48266 test into dirsrvtests/tests/suites/fractional/fractional_test.py using lib389 API.

Relates: #6753
Author: Lenka Doudova
Assisted by: Cursor
Reviewer: ???

Summary by Sourcery

Port the ticket 48266 fractional replication test into the main fractional test suite using the lib389 API and two-supplier topology_m2 fixtures.

Tests:

  • Add new two-supplier fractional replication setup fixture configuring agreements, fractional attributes, and logging for topology_m2.
  • Add tests verifying basic replication, non-fractional attribute replication, and CSN evaluation/skip behavior under fractional replication using staging user accounts.
  • Remove the legacy ticket48266_test.py test file now that its coverage is provided in the fractional test suite.

@mirielka mirielka marked this pull request as draft April 9, 2026 13:35
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The helper functions _fractional_m2_get_first_not_replicated_csn and _fractional_m2_get_last_not_replicated_csn duplicate almost all of their logic; consider extracting a single parameterized helper that takes the account index and returns the CSN to reduce repetition and make future changes less error-prone.
  • _fractional_m2_count_full_session rereads the entire error log file on each invocation; if these tests run frequently or on large logs, it may be worth tracking the last-read position (via tell/seek) or iterating only from the end to avoid repeated full scans.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The helper functions `_fractional_m2_get_first_not_replicated_csn` and `_fractional_m2_get_last_not_replicated_csn` duplicate almost all of their logic; consider extracting a single parameterized helper that takes the account index and returns the CSN to reduce repetition and make future changes less error-prone.
- `_fractional_m2_count_full_session` rereads the entire error log file on each invocation; if these tests run frequently or on large logs, it may be worth tracking the last-read position (via `tell`/`seek`) or iterating only from the end to avoid repeated full scans.

## Individual Comments

### Comment 1
<location path="dirsrvtests/tests/suites/fractional/fractional_test.py" line_range="548-557" />
<code_context>
+@pytest.mark.tier2
</code_context>
<issue_to_address>
**issue (testing):** Strengthen assertions and timeouts in `test_fractional_m2_csn_evaluation_count` to avoid flaky or misleading behavior

The polling loops (`while current_no_more_update == no_more_update_cnt`) exit after `max_loop` iterations without asserting that any progress occurred. If `current_no_more_update` never increases, the test still proceeds and `assert not found_skip` can pass simply because replication/log scanning never completed. To make this test robust against regressions in ticket 48266, please:

- Add assertions after each loop that verify progress (e.g., `current_no_more_update > no_more_update_cnt` or another concrete indicator such as session count or presence of the dummy update CSN), rather than only logging.
- Optionally add an explicit overall timeout with a clear failure message when replication does not progress, instead of allowing the test to “succeed” with incomplete conditions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/389ds-389-ds-base-7393
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@mirielka mirielka marked this pull request as ready for review April 9, 2026 13:53
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The helper functions _fractional_m2_get_first_not_replicated_csn and _fractional_m2_get_last_not_replicated_csn duplicate almost all of their logic; consider extracting a single CSN helper that takes the target DN or UID index as a parameter to reduce repetition and keep them in sync.
  • In fractional_m2_setup, UserAccounts(supplier1, DEFAULT_SUFFIX) is instantiated on each loop iteration and the finalizer deletes all users under the suffix; you could instantiate UserAccounts once and track/delete only the created test entries to avoid impacting unrelated users.
  • The fixture fractional_m2_setup already ensures and tests replication after restart, and test_fractional_m2_replication repeats the same ensure_agreement/test_replication calls; consider relying on the fixture setup to avoid redundant replication checks.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The helper functions `_fractional_m2_get_first_not_replicated_csn` and `_fractional_m2_get_last_not_replicated_csn` duplicate almost all of their logic; consider extracting a single CSN helper that takes the target DN or UID index as a parameter to reduce repetition and keep them in sync.
- In `fractional_m2_setup`, `UserAccounts(supplier1, DEFAULT_SUFFIX)` is instantiated on each loop iteration and the finalizer deletes all users under the suffix; you could instantiate `UserAccounts` once and track/delete only the created test entries to avoid impacting unrelated users.
- The fixture `fractional_m2_setup` already ensures and tests replication after restart, and `test_fractional_m2_replication` repeats the same `ensure_agreement`/`test_replication` calls; consider relying on the fixture setup to avoid redundant replication checks.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
@mirielka mirielka marked this pull request as draft April 20, 2026 11:47
@mirielka mirielka force-pushed the 48266 branch 2 times, most recently from f4eb6f5 to 6b26dfe Compare April 23, 2026 08:26
@mirielka mirielka marked this pull request as ready for review April 23, 2026 08:27
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In test_fractional_m2_csn_evaluation_count, the last wait loop (while current_no_more_update == no_more_update_cnt:) never updates current_no_more_update inside the loop as the previous two loops do, so it will always break only on max_loop and then use a stale value afterward; this should be refactored to refresh current_no_more_update each iteration or share a common helper for this wait pattern.
  • The repeated patterns for waiting on replication sessions to complete (three similar while loops with max_loop, cnt, time.sleep(5), and _fractional_m2_count_full_session) could be extracted into a small helper function to make test_fractional_m2_csn_evaluation_count easier to read and less error-prone.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_fractional_m2_csn_evaluation_count`, the last wait loop (`while current_no_more_update == no_more_update_cnt:`) never updates `current_no_more_update` inside the loop as the previous two loops do, so it will always break only on `max_loop` and then use a stale value afterward; this should be refactored to refresh `current_no_more_update` each iteration or share a common helper for this wait pattern.
- The repeated patterns for waiting on replication sessions to complete (three similar `while` loops with `max_loop`, `cnt`, `time.sleep(5)`, and `_fractional_m2_count_full_session`) could be extracted into a small helper function to make `test_fractional_m2_csn_evaluation_count` easier to read and less error-prone.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Comment thread dirsrvtests/tests/suites/fractional/fractional_test.py Outdated
Description:
Port ticket 48266 test into dirsrvtests/tests/suites/fractional/fractional_test.py using lib389 API.

Relates: 389ds#6753
Author: Lenka Doudova
Assisted by: Cursor
Reviewer: @droideck (Thanks!)
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