From agentic-starter-kits-skills
Add integration deployment tests (health-check on OpenShift) to an agent in the agentic-starter-kits repo. Creates conftest.py, test_deployment.py, __init__.py, adds test-integration Makefile target, and updates the CI workflow matrix. Use when implementing integration tests, deployment tests, or health-check tests for a new agent.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agentic-starter-kits-skills:add-integration-tests <agent_path> [JIRA-KEY]<agent_path> [JIRA-KEY]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
End-to-end workflow for adding integration deployment tests to any standard agent in the agentic-starter-kits repo. Produces per-agent pytest integration tests that build on OpenShift, deploy via Helm, validate the `/health` endpoint, and tear down.
End-to-end workflow for adding integration deployment tests to any standard agent in the agentic-starter-kits repo. Produces per-agent pytest integration tests that build on OpenShift, deploy via Helm, validate the /health endpoint, and tear down.
The agent's source code (src/, main.py, tool definitions, Dockerfile) is out of scope for this workflow. Integration tests observe the agent as-is.
If you discover a bug or deficiency in the agent (e.g., broken health endpoint, missing Makefile targets, build failures):
Adding NEW test-only artifacts under the agent directory IS in scope: tests/integration/.
Arguments: $ARGUMENTS
Parse the arguments to determine:
agents/ (e.g., google/adk, llamaindex/websearch_agent)If no agent path is provided, ask the user which agent to add integration tests to.
If a Jira key is provided: Fetch the ticket to extract scope, acceptance criteria, and parent epic for context.
If no ticket is provided: Ask the user for the Jira ticket key or confirm that no ticket tracking is needed.
Validate prerequisites:
AGENTS.md exists)agents/<agent_path>/main.py, agent.yaml, and MakefileGather these facts:
agent.yaml — extract the name fieldagent.yaml env.required section AND .env.example. Classify as:
BASE_URL, MODEL_ID (and API_KEY which is always optional). This is the majority pattern (react_agent, crewai/websearch_agent, human_in_the_loop)EMBEDDING_MODEL, VECTOR_STORE_ID for RAG agents). Follow the agentic_rag pattern with extended _write_env_file()tests/integration/test_deployment.py already exists. If yes, stop and inform the user — no work neededtest-integration, build-openshift, deploy, undeploy targets exist. If build-openshift is missing, stop — the agent cannot be built on-clusteragents/langgraph/react_agent/tests/integration/test_deployment.pyagents/langgraph/agentic_rag/tests/integration/conftest.py (for the _write_env_file pattern with extra env vars)agents/<framework>/<agent_name>/tests/integration/
__init__.py
conftest.py
test_deployment.py
If tests/integration/ already exists: inspect existing files before creating anything. Preserve any agent-specific customizations.
Empty file.
Two-line shared fixture re-export (majority pattern from 3 of 4 existing agents):
# Re-export shared integration fixtures so pytest discovers them.
from integration.conftest import cluster_auth, repo_root # noqa: F401
Follow the canonical pattern from existing agents. The file contains all per-agent logic:
from __future__ import annotations, stdlib (logging, os), pytest, then integration.utils imports (MakeTargetError, RouteNotFoundError, get_route, health_check, load_agent_name, run_make)INTERNAL_REGISTRY constant: "image-registry.openshift-image-registry.svc:5000"agent_dir fixture (module scope): returns repo_root / "agents" / "<framework>" / "<agent_name>"agent_name fixture (module scope): returns load_agent_name(agent_dir)_write_env_file() function: validates required env vars, writes .env file. For simple agents, check ("BASE_URL", "MODEL_ID"). For complex agents, add agent-specific required varsdeployed_agent fixture (module scope): orchestrates build-openshift (600s timeout) → deploy (300s timeout) → get route → yield URL → undeploy (120s timeout) → cleanup .envtest_health_endpoint: marked @pytest.mark.integration, calls health_check(f"{deployed_agent}/health", retries=12, backoff=5.0), asserts status == "healthy" and agent_initialized is TrueSimple agent _write_env_file (react_agent, crewai, hitl pattern):
def _write_env_file(agent_dir, container_image):
missing = [v for v in ("BASE_URL", "MODEL_ID") if v not in os.environ]
if missing:
pytest.fail(
f"Missing required env vars: {', '.join(missing)}. "
"Set them in the CI workflow or export locally."
)
env_path = agent_dir / ".env"
env_path.write_text(
f"API_KEY={os.environ.get('API_KEY', 'not-needed')}\n"
f"BASE_URL={os.environ['BASE_URL']}\n"
f"MODEL_ID={os.environ['MODEL_ID']}\n"
f"CONTAINER_IMAGE={container_image}\n"
)
return env_path
Complex agent _write_env_file (agentic_rag pattern — adapt per agent's env vars):
_REQUIRED_ENV = ("BASE_URL", "MODEL_ID", "<AGENT_SPECIFIC_VAR_1>", "<AGENT_SPECIFIC_VAR_2>")
def _write_env_file(agent_dir, container_image):
missing = [v for v in _REQUIRED_ENV if v not in os.environ]
if missing:
pytest.fail(
f"Missing required env vars: {', '.join(missing)}. "
"Set them in the CI workflow or export locally."
)
env_path = agent_dir / ".env"
env_path.write_text(
f"API_KEY={os.environ.get('API_KEY', 'not-needed')}\n"
f"BASE_URL={os.environ['BASE_URL']}\n"
f"MODEL_ID={os.environ['MODEL_ID']}\n"
f"CONTAINER_IMAGE={container_image}\n"
f"<AGENT_SPECIFIC_VAR_1>={os.environ['<AGENT_SPECIFIC_VAR_1>']}\n"
# ... additional vars as needed
)
return env_path
Simple agents (react_agent, crewai, hitl): single except (MakeTargetError, RouteNotFoundError) block.
Complex agents (agentic_rag): nested try/except with additional except Exception catch for unexpected errors. Use this when the agent has extra deployment complexity.
If test-integration target does NOT exist in the agent's Makefile:
test-integration to the .PHONY declarationtest target:test-integration: ## Run integration deployment test
PYTHONPATH=$$(git rev-parse --show-toplevel)/tests \
uv run --extra dev python -m pytest tests/integration/test_deployment.py \
-v --tb=long --junitxml=results.xml
Also ensure the existing test target ignores the integration directory:
test: ## Run unit tests
uv run --extra dev python -m pytest tests/ --ignore=tests/integration --ignore=tests/behavioral $(PYTEST_ARGS)
If the test target does not already have --ignore=tests/integration, add it.
Add a matrix entry to .github/workflows/agent-deployment-test.yaml under strategy.matrix.agent:
- { name: <framework>-<agent-slug>, dir: agents/<framework>/<agent_name> }
Where <agent-slug> is a kebab-case name derived from the agent name (e.g., websearch-agent, adk-agent).
If the agent needs extra env vars beyond API_KEY, BASE_URL, MODEL_ID:
env: block, sourced from ${{ vars.VAR_NAME }} or ${{ secrets.VAR_NAME }} as appropriateinclude: entry in the matrix for agent-specific env varsFrom the agent directory:
PYTHONPATH=$(git rev-parse --show-toplevel)/tests \
uv run --extra dev python -m pytest tests/integration/test_deployment.py --collect-only -q
Must show 1 test collected, no import errors.
Check cluster access:
oc whoami
If logged in and in ci-testing namespace, run:
make test-integration
This builds the agent image on-cluster, deploys via Helm, health-checks, and tears down. All steps must succeed.
If no cluster access: skip this step. Document that live testing was not performed. Test collection (5a) is sufficient for the PR.
Verify the new test files match the established pattern:
conftest.py re-exports cluster_auth and repo_root from integration.conftesttest_deployment.py has the same structure as existing agents: INTERNAL_REGISTRY, agent_dir, agent_name, _write_env_file, deployed_agent, test_health_endpoint_write_env_file validates the correct required env vars for this agentdeployed_agent fixture follows the standard build → deploy → yield → undeploy → cleanup flowConfirm the workflow file has valid YAML syntax after editing. The matrix entry must follow the format: { name: <slug>, dir: agents/<path> }.
tests/integration/__init__.py createdtests/integration/conftest.py created with shared fixture re-exportstests/integration/test_deployment.py created with health check testtest-integration Makefile target presenttest Makefile target ignores tests/integration/npx claudepluginhub red-hat-data-services/agentic-starter-kits-skills --plugin agentic-starter-kits-skillsProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.