Files
openobserve/tests/api-testing
Shrinath RaoandClaude Opus 4.5 fa5155e597 test: add API tests for histogram interval validation (#10172)
### **User description**
## Summary
- Adds pytest API tests to verify the fix for PR #10168 - histogram
interval validation for multi-day factors of 24 hours
- Tests ensure weekly intervals (7 days) are not incorrectly converted
to daily intervals
- Includes helper function `_assert_histogram_interval()` for robust
validation with clear error messages

## Tests Added
| Test | Purpose |
|------|---------|
| `test_histogram_interval_weekly_preserved` | Main regression test - 7
days (604800s) preserved |
| `test_histogram_interval_multiples_of_24h_preserved` | Tests 1, 2, 7,
14, 30, 90 day intervals |
| `test_histogram_interval_factors_of_24h_preserved` | Tests 1, 2, 4, 6,
8, 12 hour intervals |
| `test_histogram_interval_invalid_adjusted_to_nearest_factor` | Tests
5h→6h, 25h→1d adjustments |
| `test_histogram_interval_with_human_readable_format` | Tests '7 day',
'1 hour' format |
| `test_histogram_interval_consistency_across_requests` | Tests cache
consistency |

## Test Plan
- [x] All 6 tests pass locally against running OpenObserve instance
- [x] Syntax validation passed

## Related PRs
- Fixes validation in: #10168

🤖 Generated with [Claude Code](https://claude.com/claude-code)


___

### **PR Type**
Tests


___

### **Description**
- Add histogram interval validation tests (weekly, multiples, factors)

- Add invalid interval adjustment and human-readable format tests

- Add consistency across requests test for histogram interval

- Introduce `_assert_histogram_interval` helper for assertions


___



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>test_search.py</strong><dd><code>Add histogram interval
tests and helper</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

tests/api-testing/tests/test_search.py

<ul><li>Add constants for seconds per hour, day, week<br> <li> Introduce
<code>_assert_histogram_interval</code> helper function<br> <li> Add
tests: weekly, multiples of 24h, factors of 24h intervals<br> <li> Add
tests: invalid adjustments, human-readable format, consistency
<br>checks</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/10172/files#diff-f3776a5bc02e67c163ed707f86b2192f47b73c641dde04b83523b95a74518141">+361/-3</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 16:52:01 +05:30
..
2025-07-31 14:31:33 +08:00
2025-07-31 14:31:33 +08:00

pytest-openobserve

This is a repo to test openobserve API endpoints.

Introduction:

The tests are running using pytest against alpha1 for now. Idea is to parametrize it for the other endpoints like production as well.

Getting Started

  • We use rye to manage the python version and environment - https://github.com/mitsuhiko/rye
  • Once installed, simply run the following steps:
    • rye sync
    • rye run pytest

TODOS:

  • Parametrize tests to run against different environments
  • Run the tests as cron-job every few hours or daily etc. for different environments
  • Send slack-notification ( use github-actions ) in case something fails on alpha1 or production endpoints.