mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
## Summary
Companion PR to o2-enterprise PR 1841 (api-testing follow-ups). All
ENT-side test/CI work lands there; this OSS PR carries the two changes
that must live on the OSS side because they touch shared code.
Both PRs live on the same-named branch (`test/api-test-followups`) so
ENT CI's cp-merge picks up this branch and sees both changes together.
## What's in this PR
### 1 — Add `pytest-xdist` dependency
Adds `pytest-xdist>=3.0` to `tests/api-testing/pyproject.toml`. Needed
by the ENT api-testing CI's `api_integration / ent_rbac` shard to run
RBAC tests in parallel (`-n 4`).
CI-verified speedup: **~70 s → 21.7 s (~69% reduction)** on the ENT RBAC
shard's 280+ tests, with zero failures.
Foundation only — no test code in this repo uses xdist yet. Available
for any future shard that wants it.
### 2 — Standardize automated-test user display name to "Automation
TestUser"
Two helper files in `tests/api-testing/helpers/workflow/pages/` had a
personal name (`"Shyam P"` / `"Shyam Panjiyar"`) hardcoded in their user
/ service-account create payloads. Those helpers are consumed by the
workflow chain (`helpers/workflow/create_objects.py` +
`edit_objects.py`), which doesn't reliably clean up its created users —
so the names persisted in the IAM users page and looked confusingly like
real teammates' accounts.
Files changed:
- `tests/api-testing/helpers/workflow/pages/user_page.py`
- `tests/api-testing/helpers/workflow/pages/serviceaccount_page.py`
Both now use:
```
first_name: "Automation"
last_name: "TestUser"
```
Convention going forward: any account named `Automation TestUser` in the
IAM users page is automatically identifiable as test-created and safe to
clean up. Email addresses still use random suffixes
(`d4m21_{random_int}`) so uniqueness isn't affected — only the display
name standardizes.
## Test plan
- [ ] CI green on this branch
- [ ] Companion ENT PR 1841 (which depends on the `pytest-xdist` dep
added here) stays green
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
import logging
|
|
import os
|
|
import random
|
|
from requests.auth import HTTPBasicAuth
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class UserPage:
|
|
Unique_value_user = f"d4m21_{random.randint(100000, 999999)}" # Class variable
|
|
|
|
def __init__(self, session, base_url, org_id):
|
|
self.session = session
|
|
self.base_url = base_url
|
|
self.org_id = org_id
|
|
|
|
def create_user_admin(self, session, base_url, user_email, user_password, org_id, email_address):
|
|
"""Create a user as admin."""
|
|
headers = {"Content-Type": "application/json", "Custom-Header": "value"}
|
|
session.auth = HTTPBasicAuth(user_email, user_password)
|
|
|
|
payload = {
|
|
"organization": org_id,
|
|
"email": email_address,
|
|
# Read from env to match the pattern in support/factories.py,
|
|
# db-testing/conftest.py, and the rum fixtures — falls back to
|
|
# the standard CI test password when no env var is set.
|
|
"password": os.getenv("ZO_ROOT_USER_PASSWORD", "Complexpass#123"),
|
|
# Standard convention: all automated-test users use the
|
|
# same display name so they're identifiable as test-created
|
|
# in the IAM users page (and safe to clean up).
|
|
"first_name": "Automation",
|
|
"last_name": "TestUser",
|
|
"role": "admin",
|
|
}
|
|
|
|
logger.debug("Payload for user creation: %s", payload)
|
|
response = session.post(f"{base_url}api/{org_id}/users", json=payload, headers=headers)
|
|
assert response.status_code == 200, f"Failed to create user as admin: {response.content.decode()}"
|
|
return response |