Skip to content

E2e testing second phase test both kagenti-operators - #423

Merged
pdettori merged 39 commits into
rossoctl:mainfrom
Ladas:e2e_testing_second_phase
Dec 2, 2025
Merged

pdettori merged 39 commits into
rossoctl:mainfrom
Ladas:e2e_testing_second_phase

Conversation

@Ladas

@Ladas Ladas commented Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Enables parallel testing of both Platform Operator and Kagenti Operator in CI, with feature-driven test execution and shared deployment scripts.

Key Changes

🧪 Feature-Based Test Infrastructure

  • Tests now use @pytest.mark.requires_features() decorator tied to deployment config YAML
  • Auto-skip tests based on enabled features (platformOperator, kagentiOperator, toolhive, etc.)
  • Reorganized tests into common/, platform_operator/, and kagenti_operator/ directories
  • Config-driven execution: KAGENTI_CONFIG_FILE determines which tests run

📦 Extracted & Shared CI Scripts

  • Common deployment logic moved from inline workflow steps to reusable scripts in .github/scripts/
  • Organized by deployment wave (05-free-disk, 10-setup-deps, 20-secrets, 40-wait, 50-60 ollama, 70-dockerhost)
  • Shared infrastructure scripts used by both workflows (platform setup, ollama, dependencies)
  • Operator-specific deployment steps in separate directories (platform-operator/, kagenti-operator/)
  • Cross-platform compatibility (macOS/Linux) via helper libraries (env-detect.sh, logging.sh, k8s-utils.sh)

🔄 Dual Operator CI Workflows

  • kind-e2e-platform-operator.yaml - Required check
    • Deploys weather components via Component CRDs
  • kind-e2e-kagenti-operator.yaml - Required check
    • Builds images via AgentBuild CRs (Tekton pipelines)
    • Deploys weather-tool via Toolhive MCPServer
    • Deploys weather-service via Agent CR
  • Workflows share common setup scripts but differ in agent/tool deployment approach
  • PRs must pass both operator tests to merge

🛠 Kagenti Operator Support

  • Added Toolhive CRDs & Operator integration via Ansible installer
  • Deploy weather-tool via Toolhive MCPServer, weather-service via Agent CR
  • Pipeline template ConfigMaps for Tekton build orchestration
  • Fixed cross-namespace reference issues and build execution flow

Dependencies

Related issue(s)

Partially Fixes #309

@Ladas
Ladas marked this pull request as draft November 24, 2025 14:41
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch 4 times, most recently from c7269bd to 59c1c2c Compare November 24, 2025 15:23
@Ladas
Ladas marked this pull request as ready for review November 24, 2025 17:15
@Ladas
Ladas marked this pull request as draft November 24, 2025 17:15
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch 13 times, most recently from 506362a to 4ff386c Compare November 25, 2025 09:51
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch 4 times, most recently from 22b4a65 to fe41618 Compare November 25, 2025 15:06
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch 2 times, most recently from 255477e to e02dd0d Compare November 26, 2025 07:53
Ladas and others added 8 commits November 27, 2025 08:45
- Remove operator_mode fixture, treat operators as features
- Add pytest_collection_modifyitems hook for collection-time test skipping
- Replace runtime pytest.skip() with @pytest.mark.requires_features decorator
- Use positive conditions: tests declare required features instead of exclusions
- Tests properly skip based on config at collection time (verified locally)

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Signed-off-by: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Add verbose output and list files modified by hooks when they fail.
This will help identify which files need formatting.

Signed-off-by: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Use ruff v0.4.7 (matching pre-commit hook) to format test files.
Fixes formatting issues detected by CI.

Signed-off-by: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Mark all weather agent tests with @pytest.mark.requires_features(["kagenti_operator"])
to prevent them from running in platform operator CI where the weather-service deployment
doesn't exist.

Signed-off-by: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Reorganizes E2E tests into operator-specific and common directories
with automatic test skipping based on YAML config feature flags.

## Changes

### Test Restructuring
- Move common tests to `tests/e2e/common/`:
  - `test_platform_health.py` - platform-agnostic health checks
  - `test_keycloak.py` - Keycloak deployment tests
  - `test_agent_conversation.py` - A2A protocol conversation tests
- Create `tests/e2e/platform_operator/`:
  - `conftest.py` - service name fixtures for platform operator
  - `test_weather_agent.py` - platform operator service tests
- Update `tests/e2e/kagenti_operator/`:
  - Fix feature markers to use camelCase (kagentiOperator)
- Remove old `test_deployment_health.py` (tests moved to new structure)

### Feature Detection Enhancement
- Update `conftest.py` to extract ALL features from config layers:
  - Top-level flags (gatewayApi, certManager, tekton, etc.)
  - Chart-level enabled flags
  - Component-level enabled flags
- Use camelCase feature names matching YAML config:
  - `platformOperator` instead of `platform_operator`
  - `kagentiOperator` instead of `kagenti_operator`

### CI Workflow Updates
- Platform operator workflow:
  - Set `KAGENTI_CONFIG_FILE=deployments/envs/dev_values.yaml`
  - Run `pytest tests/e2e/common tests/e2e/platform_operator`
- Kagenti operator workflow:
  - Run `pytest tests/e2e/common tests/e2e/kagenti_operator`

## Benefits
- Tests automatically skip based on enabled features
- No manual pytest markers needed for operator selection
- Service names adapt to operator mode via fixtures
- Easier to add new operator-specific tests
- CI workflows are clearer and more maintainable

Fixes platform operator CI running kagenti_operator tests incorrectly.

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Create reusable shell scripts following sync wave numbering pattern (10, 20, 30...)
to enable identical deployment steps in both CI and local environments.

Scripts created:
- lib/: Shared utilities (env-detect, logging, k8s-utils)
- common/: Steps used by both operators (wave 10-99)
- kagenti-operator/: Kagenti Operator specific steps (wave 30, 41-43, 71-74, 90)
- platform-operator/: Platform Operator specific steps (wave 30, 71-72, 90)

All scripts extract exact logic from current CI workflows, maintaining
compatibility while enabling:
- Local debugging of individual deployment steps
- Reusable deployment logic across environments
- Clear separation between operator-specific and common steps

Next step: Update CI workflows to call these scripts instead of inline bash.

Relates to rossoctl#423

Signed-off-by: Ladislav Smola <[email protected]>
Adds resilient retry logic to handle rate limiting (429) and server
errors (5xx) when downloading Ollama components.

## Changes

### 50-install-ollama.sh
- Add retry loop with exponential backoff (5s * retry_count)
- Download install script to temp file first
- Capture HTTP status codes to detect 429 and 5xx errors
- Retry up to 5 times with increasing wait times (5s, 10s, 15s, 20s, 25s)
- Clean up temp file on exit

### 60-pull-ollama-model.sh
- Add retry loop for model pull failures
- Retry up to 3 times with exponential backoff (10s, 20s, 30s)
- Maintain existing timeout per attempt (300s)

## Benefits
- CI no longer fails on transient rate limiting
- Automatic recovery from temporary server issues
- Clear logging of retry attempts
- Exponential backoff prevents overwhelming the server

Fixes CI failure from:
https://github.com/kagenti/kagenti/actions/runs/19728276893/job/56523746999

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch from 4c69f9b to 7f48fb4 Compare November 27, 2025 07:46
Ladas and others added 2 commits November 27, 2025 08:58
Fixes sporadic CI failures where Ollama process exists but is not
responsive, leading to "cat: /tmp/ollama.log: No such file or directory"
errors.

## Root Cause Analysis

The previous script had a race condition:
1. Ollama install script may start systemd service automatically
2. pgrep finds running process and skips startup block
3. curl check fails because Ollama isn't responsive yet
4. Script tries to cat /tmp/ollama.log which was never created
5. Immediate failure without useful debugging info

## Changes

### Improved Process Management
- Stop systemd service if active (prevents interference)
- Track whether we started Ollama or found it running
- Use timestamped log files to avoid conflicts
- Only cat log file if we created it and it exists

### Better Error Handling
- Always wait for Ollama to be responsive (not just when we start it)
- Check both new and existing Ollama processes
- Provide detailed debugging on failure:
  - Process information (pgrep -a)
  - Port status (netstat on 11434)
  - Version information (ollama --version)

### Enhanced Logging
- Log progress every 10 seconds during wait
- Clear messages for each stage
- Distinguish between "already running" and "starting new"

## Benefits
- No more "file not found" errors on log files
- Better visibility into Ollama startup issues
- Handles both fresh installs and existing processes
- Detailed diagnostics for debugging sporadic failures

Fixes CI failure from:
rossoctl#423

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Consolidates CI setup steps into reusable shell scripts and renames
workflows for clarity, eliminating duplication across workflows.

## Changes

### New Scripts

**05-free-disk-space.sh**
- Frees up disk space in CI environments
- Removes unnecessary packages (dotnet, android, ghc, CodeQL)
- Cleans Docker cache and unused images
- Only runs in CI mode (skips on local)
- Shows disk usage before/after cleanup

### Updated Scripts

**10-setup-dependencies.sh**
- Clarified scope: Python and Ansible dependencies only
- Better logging for each installation step
- Quieter apt-get output (-qq flag)

### Workflow Changes

**Renamed Files:**
- `pr-kind-deployment-platform-operator.yaml` → `kind-e2e-platform-operator.yaml`
- `pr-kind-deployment-kagenti-operator.yaml` → `kind-e2e-kagenti-operator.yaml`

**Renamed Workflow/Job Names:**
- Platform Operator:
  - Workflow: "Kind PR Test"
  - Job: "e2e (Dev, Platform Operator)"
- Kagenti Operator:
  - Workflow: "Kind PR Test (Informational)"
  - Job: "e2e (Dev, Kagenti Operator)"

**Display in GitHub:**
- Before: "PR Kind Deployment Test (Platform Operator) / deploy-on-kind"
- After: "Kind PR Test / e2e (Dev, Platform Operator)"

**Streamlined Steps:**
Both workflows now use:
```yaml
- Set up Python (actions/setup-python@v6)
- Install kubectl (azure/setup-kubectl@v4)
- Install Helm (azure/setup-helm@v4)
- Set up Docker Buildx (docker/setup-buildx-action@v3)
- Free up disk space (bash script)
- Setup dependencies (bash script)
- [existing deployment steps...]
```

**Removed Steps:**
- Install uv (moved to 10-setup-dependencies.sh)
- Install jq (moved to 10-setup-dependencies.sh)
- Free up disk space inline code (moved to 05-free-disk-space.sh)
- Install Ansible inline code (moved to 10-setup-dependencies.sh)

## Benefits

✅ **Reduced duplication**: Common setup in reusable scripts
✅ **Clearer names**: Workflow names match their purpose
✅ **Consistency**: Both workflows use identical setup steps
✅ **Portability**: Shell scripts work locally and in CI
✅ **Testability**: Can run scripts independently for debugging
✅ **Maintainability**: One place to update dependencies
✅ **CI-aware**: Scripts detect CI mode and adjust behavior

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch 2 times, most recently from 5808f30 to e46ccd9 Compare November 27, 2025 08:59
- Revert unrelated changes to kagenti/ui/tests/conftest.py
- Simplify kagenti/tests/conftest.py to only register requires_features marker
  to avoid pytest 'Unknown mark' warnings
- Remove unused fixtures that belong in e2e/conftest.py

Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch from e46ccd9 to 4bf9066 Compare November 27, 2025 09:06
…ation

Enhances Keycloak tests to provide better diagnostics and validate
actual functionality, not just deployment status.

## Changes

### Fixed Error Handling
**test_keycloak_deployment_ready:**
- Capture errors from both deployment and statefulset checks
- Report both errors when Keycloak is not found
- No more silent `pass` on exceptions

Before:
```python
except ApiException:
    pass  # Try statefulset
```

After:
```python
except ApiException as e:
    deployment_error = str(e)
# ...later
pytest.fail(f"Deployment error: {deployment_error}\nStatefulSet error: {statefulset_error}")
```

### Added Authentication Test
**test_keycloak_admin_login** (new):
- Tests actual Keycloak functionality, not just pod status
- Authenticates with admin credentials via OAuth
- Obtains and validates access token
- Configurable via environment variables:
  - `KEYCLOAK_ADMIN_USER` (default: admin)
  - `KEYCLOAK_ADMIN_PASSWORD` (default: admin)
  - `KEYCLOAK_URL` (default: http://keycloak.keycloak.svc.cluster.local:8080)

### Test Coverage
- ✅ Namespace exists
- ✅ Deployment/StatefulSet is ready
- ✅ Admin authentication works (new)
- ✅ OAuth token can be obtained (new)

## Benefits

✅ Better error diagnostics when Keycloak is misconfigured
✅ Validates Keycloak is actually functional, not just running
✅ Catches authentication/configuration issues early
✅ Provides clear failure messages with both deployment and statefulset errors

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch from ca91881 to 7166cf8 Compare November 27, 2025 09:46
Instead of reading credentials from environment variables, use shared
pytest fixtures that read from Kubernetes secrets. This approach:

✅ No extra env vars needed
✅ Single source of truth (actual cluster secret)
✅ More realistic - uses same credentials as deployed system
✅ Reusable fixtures for other tests requiring auth

## Changes

### conftest.py - Added Shared Fixtures

`keycloak_admin_credentials`:
- Reads from keycloak-initial-admin secret in keycloak namespace
- Returns {username, password} dict
- Skips test if secret not found

`keycloak_token`:
- Uses keycloak_admin_credentials to authenticate
- Connects to port-forwarded Keycloak (localhost:8081)
- Returns OAuth token dict with access_token, token_type, etc.
- Skips test if authentication fails

### test_keycloak.py - Simplified Test

Before:
- Read credentials from env vars (KEYCLOAK_ADMIN_USER, KEYCLOAK_ADMIN_PASSWORD)
- Async httpx client to call Keycloak API
- Complex error handling

After:
- Use keycloak_token fixture
- Verify token structure
- Much simpler - fixture handles all auth logic

## Benefits

These fixtures can now be reused by other tests that need to:
- Authenticate to agents with Keycloak tokens
- Test protected API endpoints
- Verify RBAC/authorization

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch from a22baf5 to f1fcce2 Compare November 27, 2025 10:22
Research findings indicate these secrets are not used:
- AgentBuilds run in tenant namespaces (team1, team2), not kagenti-system
- Code verification: secrets loaded from agentBuild.Namespace
- No code references kagenti-system/{github-token,ghcr,openai,quay}-secret

Removed secrets:
- github-token-secret (kagenti-system)
- ghcr-secret (kagenti-system)
- openai-secret (kagenti-system)
- quay-registry-secret (kagenti-system)

Tenant namespace secrets remain active in agent-namespaces.yaml.

If CI passes, this confirms secrets were unused and can be permanently removed.
If CI fails, we'll investigate what actually uses them.

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch 2 times, most recently from d7228c0 to d760c9f Compare November 27, 2025 11:11
CI testing confirmed these secrets are completely unused.

Removed:
- Entire file: charts/kagenti/templates/kagenti-system-secrets.yaml
  - github-token-secret (kagenti-system) ❌
  - ghcr-secret (kagenti-system) ❌
  - openai-secret (kagenti-system) ❌
  - quay-registry-secret (kagenti-system) ❌

- From CI script (.github/scripts/common/20-create-secrets.sh):
  - quayUser, quayToken variables ❌

Research findings:
- AgentBuilds run in tenant namespaces (team1, team2), not kagenti-system
- Secrets loaded from agentBuild.Namespace (verified in controller code)
- No code references to kagenti-system build secrets
- Quay.io registry not used anywhere in samples or CI

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the e2e_testing_second_phase branch from d760c9f to bbb474f Compare November 27, 2025 11:14
Problem:
- The GNU 'timeout' command is not available on macOS
- Local testing scripts failed on macOS with 'timeout: command not found'
- This prevented local testing workflows from working on macOS
- Wave 72-73 deployment had logic issues causing deadlocks

Solution:
1. Cross-platform timeout support:
   - Added run_with_timeout() function to k8s-utils.sh
   - Auto-detects OS and uses appropriate timeout mechanism:
     * Linux: Native 'timeout' command
     * macOS: Perl-based timeout fallback using alarm
   - Updated all scripts using timeout to use the new function

2. Fixed Wave 72-73 deployment logic:
   - Wave 72: Only wait for deployment to exist (not be ready yet)
   - Wave 73: Patch both Deployment AND StatefulSet for /tmp volume
   - Wave 73: Increased timeout to 300s for StatefulSet creation
   - Wave 73: Wait for both pods and deployment to be ready after patching

Impact:
- Local testing now works on both macOS and Linux
- CI (Linux) continues to work with native timeout
- Deployment flow no longer deadlocks waiting for unpatchable pods
- All timeout operations are now cross-platform compatible

Files modified:
- .github/scripts/lib/k8s-utils.sh (new run_with_timeout function)
- .github/scripts/common/60-pull-ollama-model.sh (Ollama model pull)
- .github/scripts/kagenti-operator/71-build-weather-tool.sh (AgentBuild wait)
- .github/scripts/kagenti-operator/72-deploy-weather-tool.sh (deployment logic)
- .github/scripts/kagenti-operator/73-patch-weather-tool.sh (patching logic)
- .github/scripts/kagenti-operator/74-deploy-weather-agent.sh (agent wait)
- .github/scripts/platform-operator/72-wait-deployments.sh (deployment waits)

Tested:
- ✅ macOS local deployment completes successfully
- ✅ All timeout operations work on macOS
- ✅ Wave 60 (Ollama) passes
- ✅ Wave 72-73 (weather-tool) deployment and patching works
- ✅ Local tests passing

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

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas marked this pull request as ready for review November 27, 2025 14:49
@Ladas Ladas changed the title E2e testing second phase E2e testing second phase test both kagenti-operators Nov 27, 2025

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @Ladas this is a great addition to the project ! I see all tests running successfully, so this looks good to me !

@pdettori
pdettori merged commit dfa2b38 into rossoctl:main Dec 2, 2025
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.

epic: Full Coverage End-to-End Testing

2 participants