Issue 7535 - Fix race in test_schema_update_policy_reject#7598
Conversation
Description: Removed temporary_oc2 fixture that added OC2 before the reject policy was active. Moved OC2 creation after the policy is set and supplier1 is restarted. Fixes: 389ds#7535 Reviewed by: ??? Assisted by: Claude
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider extracting the repeated cleanup logic for removing
oc2_namefrom both suppliers into a small helper function to keep the test body focused on behavior rather than teardown details. - Since
oc2_nameis used in multiple places, you might want to promote it to a module-level constant (e.g.,OC2_NAME = "OC2UpdatePolicy") to avoid hardcoding the same string in several locations and make future updates easier.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the repeated cleanup logic for removing `oc2_name` from both suppliers into a small helper function to keep the test body focused on behavior rather than teardown details.
- Since `oc2_name` is used in multiple places, you might want to promote it to a module-level constant (e.g., `OC2_NAME = "OC2UpdatePolicy"`) to avoid hardcoding the same string in several locations and make future updates easier.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
droideck
left a comment
There was a problem hiding this comment.
Thanks for putting this together, @aadhikar!
Since @mreynolds389 is assigned to #7535 and had also been looking into this, I'd leave the final review to him in case he has additional context or a preferred direction.
Besides the small cleanup/teardown comment:)
| log.info(f"Cleaning up {oc2_name}") | ||
| for s in [supplier1, supplier2]: | ||
| try: | ||
| Schema(s).remove_objectclass(oc2_name) | ||
| except (ldap.NO_SUCH_OBJECT, ValueError): | ||
| pass |
There was a problem hiding this comment.
Might worth placing it in try/finally block, IMO.
There was a problem hiding this comment.
@droideck Can you elaborate? If you mean wrapping the entire test logic in try with cleanup in finally, I can do that. If it's just the cleanup part, finally wouldn't add value since there's nothing to guard above it. Let me know what I am missing here!
There was a problem hiding this comment.
Yep, I think we need a finalizer/try/finally for the whole test clean up.
|
I don't think the problem is the test. I've been working on this the last few days and there is definitely is a race condition in DS (a bug). When it fails, the schema reject policy is set the default policy for printer-uri-oid instead of the defined one for OCPolicyUpdate. Since the policy set and the server is restarted it should be using the correct policy right away, but sometimes it still has the default policy set (I'm still working on it). So I suspect if you run this test enough times it will still fail. |
Ok so I have verified this is a testing issue. It's not a bug in DS. What's happening is that the schema replication of "OCPolicyUpdate" is happening before we set it in the rejection policy. I can not reproduce the problem using this patch. I think the CI test could be hardened a bit more, but its been passing for me with both bdb and lmdb, so Ack! |
|
My understanding is the 'setup_test_env' fixture adds 'OCUpdatePolicy' in the topology (S1 and S2). The purpose of 'temporary_oc2' is just to update the schema and allow the replication of it. So IMHO we should not care about the presence of 'OC2UpdatePolicy' only 'OCUpdatePolicy' needs to be checked. This is the one we want to reject. An option is
|
Thanks for the suggestion @tbordaz! However, as per |
I am afraid this comment is not inline with the code. Actually it looks to me that if a given attribute/objectclass in the schema is set to REPL_SCHEMA_UPDATE_REJECT_VALUE then the full update of the schema is abandoned independently if the consumer knows this attr/oc. |
@tbordaz I ran your proposed flow as a quick experiment: The reject policy is set, but S2 still got the OC. It seems the reject only fires when the consumer already has the OC in its schema. Am I missing something? |
Description: Removed temporary_oc2 fixture that added OC2 before the reject policy was active. Moved OC2 creation after the policy is set and supplier1 is restarted.
Fixes: #7535
Reviewed by: ???
Assisted by: Claude
Summary by Sourcery
Adjust schema update rejection test to create and clean up the temporary object class after the reject policy is active, ensuring replication behavior is validated correctly.
Bug Fixes:
Tests: