Skip to content

Force re-computation with event stream bulk create#1578

Open
AlanCoding wants to merge 2 commits into
ansible:mainfrom
AlanCoding:bulk_event_streams
Open

Force re-computation with event stream bulk create#1578
AlanCoding wants to merge 2 commits into
ansible:mainfrom
AlanCoding:bulk_event_streams

Conversation

@AlanCoding
Copy link
Copy Markdown
Member

@AlanCoding AlanCoding commented Jun 3, 2026

Hit a failure in

ansible/django-ansible-base#970

And I can explain what's happening, and why it's basically passing accidentally now.

DAB RBAC is a signals-based library. If you bulk_create objects, organization permissions will not be properly rebuilt, this is expected. The fixture involved does exactly this, and the test expects that lists show event streams correctly.

This happens to work now, because later on in the process, a credential is created. The signals that fire due to the credential creation happen to re-build role evaluations related to the previously-created event stream objects. This is because the signals are overly-broad. The DAB PR 970 narrows the scope of what those signals touch, which is a good thing, but incompatible with how this test was functioning.

Confirmed locally, after applying this change, the failing tests pass even with the DAB patch.

Summary by CodeRabbit

  • Tests
    • Updated integration test setup to refresh permission caches after creating event streams. This ensures RBAC state is consistent following test data creation, improving reliability and stability of permission-related tests and reducing intermittent failures.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 32f59de7-d746-4629-ba89-6abf63668614

📥 Commits

Reviewing files that changed from the base of the PR and between f26d37a and 7741d5a.

📒 Files selected for processing (1)
  • tests/integration/conftest.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration/conftest.py

📝 Walkthrough

Walkthrough

The default_event_streams fixture in tests/integration/conftest.py now captures the bulk_create result, resolves the default organization's ContentType, queries related ObjectRole entries, conditionally invokes compute_object_role_permissions(...) to refresh RBAC caches, and returns the created event streams.

Changes

RBAC cache maintenance in test fixture

Layer / File(s) Summary
RBAC cache refresh in event streams fixture
tests/integration/conftest.py
The default_event_streams fixture assigns the bulk_create result to a local variable and adds post-creation logic to refresh RBAC permission caching. It queries the organization's ContentType and related ObjectRole entries, conditionally calls compute_object_role_permissions to synchronize permission caches, and returns the created event streams.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Force re-computation with event stream bulk create' clearly and concisely summarizes the main change: addressing RBAC permission re-computation when bulk creating event streams.
Description check ✅ Passed The description adequately explains the problem (bulk_create not triggering signals), the root cause (overly-broad signals in DAB), the solution (force re-computation), and includes verification evidence. All mandatory aspects are covered.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.32%. Comparing base (72944af) to head (7741d5a).

@@           Coverage Diff           @@
##             main    #1578   +/-   ##
=======================================
  Coverage   92.32%   92.32%           
=======================================
  Files         244      244           
  Lines       11214    11214           
=======================================
  Hits        10353    10353           
  Misses        861      861           
Flag Coverage Δ
unit-int-tests-3.11 92.32% <ø> (ø)
unit-int-tests-3.12 92.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlanCoding AlanCoding force-pushed the bulk_event_streams branch from 8a9b0c9 to f26d37a Compare June 3, 2026 13:36
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

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