Skip to content

feat(infra-monitoring): v2 statefulsets integration tests#11440

Open
nikhilmantri0902 wants to merge 1 commit into
infraM/v2_deployments_integration_testsfrom
infraM/v2_statefulsets_integration_tests
Open

feat(infra-monitoring): v2 statefulsets integration tests#11440
nikhilmantri0902 wants to merge 1 commit into
infraM/v2_deployments_integration_testsfrom
infraM/v2_statefulsets_integration_tests

Conversation

@nikhilmantri0902
Copy link
Copy Markdown
Contributor

Pull Request


📄 Summary

First end-to-end integration tests for POST /api/v2/infra_monitoring/statefulsets.

Screenshots / Screen Recordings (if applicable)

N/A — backend test addition; no UI.

Issues closed by this PR

Part of https://github.com/SigNoz/engineering-pod/issues/4980


✅ Change Type

  • 🧪 Test-only

🐛 Bug Context

N/A — not a bug fix.


🧪 Testing Strategy

53 tests across 21 functions in tests/integration/tests/inframonitoring/08_statefulsets.py + 9 JSONL datasets + 1 expected-values JSON (generated by tests/gen_statefulsets_datasets.py).

  • test_statefulsets_happy_path — shape, 11 record fields (statefulSetName, 6 float metrics, desiredPods/currentPods as int, podCountsByPhase, meta); meta carries
    k8s.statefulset.name/k8s.namespace.name/k8s.cluster.name
  • test_statefulsets_value_accuracy — exact 6 float metric values + replica counts + phase counts. Locks in Sum vs Avg split: cpu/memory = SpaceAggregationSum; cpu_request/limit +
    memory_request/limit = SpaceAggregationAvg; desired/current = latest-summed. v1/v2 parity confirmed by code reading (pkg/query-service/app/inframetrics/statefulsets.go:21-90
    pkg/modules/inframonitoring/implinframonitoring/statefulsets_constants.go:24-242)
  • test_statefulsets_missing_metrics — seed only k8s.pod.cpu.usage, other 8 of 9 required metrics flagged → records=[], total=0
  • test_statefulsets_filter_and / in / not_in / contains — each QB v5 operator
  • test_statefulsets_filter_combos ×4 — AND+IN, AND+NOT IN, AND+CONTAINS, IN+CONTAINS
  • test_statefulsets_filter_bad_attr_name, test_statefulsets_filter_bad_grammar ×2 — 400 paths
  • test_statefulsets_pod_phase_aggregation — 4 Running + 1 Pending + 2 Failed
  • test_statefulsets_desired_current_counts — desired=5, current=3, only 2 Running pods seeded. Locks in int typing + distinguishes replica counts from phase counts (separate code paths); models a
    scale-up in progress
  • test_statefulsets_base_filter_drops_non_statefulset_pods — seed 1 SS pod + 1 standalone pod (no k8s.statefulset.name) + 1 Deployment pod (k8s.deployment.name only); only the real SS row
    appears. Documents statefulSetsBaseFilterExpr (statefulsets_constants.go:10, :63-69)
  • test_statefulsets_groupby_namespacegroupBy=[k8s.namespace.name] → 2 records, statefulSetName="", meta surfaces k8s.namespace.name
  • test_statefulsets_pagination_sync — K=7, limit=3, offsets {0,3,6}: page invariants, total invariant, full partition
  • test_statefulsets_offset_beyond_total — empty records, total unchanged
  • test_statefulsets_total_invariant_across_orderby — 8 metric columns × 2 directions = 16 calls, total==K
  • test_statefulsets_orderby_correctness ×16 — 8 columns (cpu, cpu_request, cpu_limit, memory, memory_request, memory_limit, desired_pods, current_pods) × 2 directions. Exercises every
    entry in orderByToStatefulSetsQueryNames
  • test_statefulsets_orderby_by_statefulset_name ×2 — metadata-name branch (PaginateMetadataByName)
  • test_statefulsets_validation_errors ×12 — all Validate() rules including orderBy=k8s.statefulset.name + non-empty groupBy rejection
  • test_statefulsets_auth ×2 — 401 no token, 200 admin

Manual verification:

  • 53/53 statefulsets green on first run (~53 s)
  • Full inframonitoring suite: 362/362 green (39 hosts + 45 pods + 43 nodes + 37 namespaces + 44 clusters + 48 volumes + 53 deployments + 53 statefulsets, ~5 min 50 s)

⚠️ Risk & Impact Assessment

  • Blast radius: none — test-only, no product code changes
  • Potential regressions: none; CI runtime grows by ~53 s for this file
  • Rollback plan: revert — no migrations, no shared state

📝 Changelog

Field Value
Deployment Type N/A
Change Type N/A
Description N/A — internal test addition, not user-facing

📋 Checklist

  • Tests added or explicitly not required
  • Manually tested (53/53 green; full inframonitoring suite 362/362)
  • Breaking changes documented (none — test-only)
  • Backward compatibility considered (N/A — test-only)

👀 Notes for Reviewers

@github-actions github-actions Bot added the enhancement New feature or request label May 24, 2026
@nikhilmantri0902 nikhilmantri0902 added safe-to-integrate Run integration tests and removed enhancement New feature or request labels May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-integrate Run integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant