Skip to content

B2.4: Validate analytics with deterministic C13 fixtures - #1051

Open
thomas-pham101 wants to merge 9 commits into
mainfrom
EB/TP/B2.4-Analytics-Fixture-Validation
Open

thomas-pham101 wants to merge 9 commits into
mainfrom
EB/TP/B2.4-Analytics-Fixture-Validation

Conversation

@thomas-pham101

Copy link
Copy Markdown
Collaborator

Summary

Implements Sprint 2 B2.4 by reusing the C13 deterministic fixture generator
to verify known analytics totals and the latest B2 filter behaviour.

Changes

  • Added deterministic analytics fixture integration tests
  • Reused the C13 fixture generator instead of introducing a second fixture path
  • Updated B2.4 tests for the latest insights.py collection architecture
  • Added isolated test collections for analytics verification
  • Added deterministic coverage for:
    • baseline overview totals
    • species aggregation
    • species filtering
    • sensorId filtering
    • date-range filtering
    • combined species + sensor filtering
  • Added developer documentation for C13 and B2.4

Deterministic Dataset

12 detections:

  • Sus Scrofa: 4
  • Dingo: 4
  • Crimson Rosella: 4

Sensors:

  • Sensor 2: 6
  • Sensor 3: 6

Expected baseline analytics:

  • detections: 12
  • unique species: 3
  • sensors with detections: 2
  • species totals: 4 / 4 / 4

Filter Validation

Known deterministic expectations include:

  • species=Sus Scrofa → 4 detections
  • sensorId=2 → 6 detections
  • date range 2026-09-03 to 2026-09-06 → 4 detections
  • species=Dingo + sensorId=3 → 2 detections

Database Isolation

Tests use dedicated collections inside EchoNet:

  • _b2_4_test_events
  • _b2_4_test_microphones
  • _b2_4_test_nodes

Normal Project Echo collections are not modified.

Validation

Combined C13 + B2.4 regression suite:

26 passed

This includes:

  • 15 C13 generator tests
  • 11 B2.4 analytics fixture tests

Dependency

This PR depends on C13:

EB/TP/C13-Seed-Fixture-Generator

Once C13 is merged into main, this PR can be retargeted to main.

@Maneesh-Kumar-Maddini

Copy link
Copy Markdown
Collaborator

The deterministic analytics tests cover the intended totals and filter combinations, but this PR currently targets the fixture-generator branch rather than main. Please wait for #1047 to be completed and merged, then retarget this PR to main. Confirm that the remaining diff contains only the intended analytics validation and rerun the combined fixture and analytics suite, including collection isolation. Approval remains pending completion of that dependency and verification.

@thomas-pham101
thomas-pham101 changed the base branch from EB/TP/C13-Seed-Fixture-Generator to main September 20, 2026 23:31
@thomas-pham101

Copy link
Copy Markdown
Collaborator Author

Hi Maneesh, C13 #1047 has now been merged into main and I’ve completed the final B2.4 reconciliation and validation.

The remaining diff is limited to the intended B2.4 analytics fixture validation and documentation.

Verification completed:

+) B2.4 analytics fixture suite: 11 passed
+) Combined C13 + B2.4 regression suite: 30 passed
+) C13 generator coverage: 19 tests
+) B2.4 analytics coverage: 11 tests
+) B2.4 uses the current C13 events fixture contract
+) Tests use isolated b2_4_test* collections, leaving the normal Project Echo collections untouched

The analytics integration tests were run against the local MongoDB instance using --noconftest, because the shared test configuration patches PyMongo with mongomock, which does not support the $type aggregation expression used by the current analytics pipeline.

Could you please re-review the latest changes when you have a chance? Thank you.

@Maneesh-Kumar-Maddini Maneesh-Kumar-Maddini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, Thomas. I confirmed that #1047 is merged, this PR now targets main, and the remaining diff is limited to the intended analytics tests and documentation.

Two test-isolation issues remain:

  1. The fixture patches MongoDB collections but leaves the normal Redis cache active. I reproduced an existing cached total of 99 overriding the expected fixture total of 12. Please isolate or bypass the cache so these tests reliably exercise their own fixture data and cannot read or overwrite normal application cache entries.

  2. Under the standard backend mongomock configuration, the new suite produces 3 passed and 8 failed because $type is unsupported. The documented --noconftest command explains your real-MongoDB run, but the integration tests still enter the normal mocked backend suite and fail. Please separate or explicitly gate the real-MongoDB tests while retaining a supported integration-test command.

Please rerun the isolated analytics suite and combined C13 regression after these corrections. Approval remains pending.

@thomas-pham101

Copy link
Copy Markdown
Collaborator Author

Hi Maneesh, I’ve addressed both remaining B2.4 test-isolation issues.

The analytics integration fixture now bypasses the normal Redis insights cache by patching insights.get_json to return None and insights.set_json to a no-op, so cached application values can no longer override the deterministic fixture results.

I also explicitly gated the real-MongoDB analytics tests when the normal Backend mongomock configuration is active. The full integration suite remains available through the documented --noconftest real-MongoDB command.

Validation after the corrections:

+) Normal mocked B2.4 collection: 3 passed, 8 skipped
+) Real-MongoDB B2.4 analytics suite: 11 passed
+) Combined C13 + B2.4 regression: 30 passed
+) Redis cache bypass: PASS
+) git diff --check: PASS

Could you please re-review the latest changes when you have a chance? Thank you.

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