|
1 | 1 | # StackRox MCP E2E Testing |
2 | 2 |
|
3 | | -This directory contains end-to-end tests for the StackRox MCP server using the [mcp-testing-framework](https://github.com/L-Qun/mcp-testing-framework). |
| 3 | +End-to-end tests for the StackRox MCP server using [gevals](https://github.com/genmcp/gevals). |
4 | 4 |
|
5 | 5 | ## Prerequisites |
6 | 6 |
|
7 | | -1. **OpenAI API Key**: Required for running the AI model tests |
8 | | - - Get your key from Bitwarden |
9 | | - |
10 | | -2. **StackRox API Token**: Required for connecting to StackRox Central |
11 | | - - Generate from StackRox Central UI: Integrations > API Token > Generate Token |
| 7 | +- Go 1.25+ |
| 8 | +- OpenAI API Key (for AI agent and LLM judge) |
| 9 | +- StackRox API Token |
12 | 10 |
|
13 | 11 | ## Setup |
14 | 12 |
|
15 | | -### 1. Configure Environment Variables |
16 | | - |
17 | | -Create a `.env` file with your credentials: |
| 13 | +### 1. Build gevals |
18 | 14 |
|
19 | 15 | ```bash |
20 | | -# OpenAI API key for running tests |
21 | | -OPENAI_API_KEY=sk-your-openai-key-here |
22 | | - |
23 | | -# StackRox API Token for accessing Central |
24 | | -STACKROX_API_TOKEN=your-stackrox-api-token-here |
| 16 | +cd e2e-tests |
| 17 | +./scripts/build-gevals.sh |
25 | 18 | ``` |
26 | 19 |
|
27 | | -### 2. Update Server Configuration (Optional) |
| 20 | +### 2. Configure Environment |
28 | 21 |
|
29 | | -Edit `mcp-testing-framework.yaml` if you need to change the StackRox Central URL: |
| 22 | +Create `.env` file: |
30 | 23 |
|
| 24 | +```bash |
| 25 | +OPENAI_API_KEY=sk-your-key-here |
| 26 | +STACKROX_API_TOKEN=your-token-here |
| 27 | +``` |
31 | 28 |
|
32 | 29 | ## Running Tests |
33 | 30 |
|
34 | | -From the `e2e-tests` directory, run: |
| 31 | +```bash |
| 32 | +./scripts/run-tests.sh |
| 33 | +``` |
| 34 | + |
| 35 | +Results are saved to `gevals-stackrox-mcp-e2e-out.json`. |
| 36 | + |
| 37 | +### View Results |
35 | 38 |
|
36 | 39 | ```bash |
37 | | -npx mcp-testing-framework@latest evaluate |
| 40 | +# Summary |
| 41 | +jq '.tasks[] | {name, passed}' gevals-stackrox-mcp-e2e-out.json |
| 42 | + |
| 43 | +# Tool calls |
| 44 | +jq '.tasks[].callHistory[] | {toolName, arguments}' gevals-stackrox-mcp-e2e-out.json |
38 | 45 | ``` |
39 | 46 |
|
40 | | -This will: |
41 | | -- Spawn the StackRox MCP server in stdio mode |
42 | | -- Run test cases against the configured AI models (GPT-5 and GPT-5-mini) |
43 | | -- Generate a test report in the `mcp-reports/` directory |
| 47 | +## Test Cases |
| 48 | + |
| 49 | +| Test | Description | Tool | |
| 50 | +|------|-------------|------| |
| 51 | +| `list-clusters` | List all clusters | `list_clusters` | |
| 52 | +| `cve-affecting-workloads` | CVE impact on deployments | `get_deployments_for_cve` | |
| 53 | +| `cve-affecting-clusters` | CVE impact on clusters | `get_clusters_for_cve` | |
| 54 | +| `cve-nonexistent` | Handle non-existent CVE | `get_clusters_for_cve` | |
| 55 | +| `cve-cluster-scooby` | CVE with cluster filter | `get_clusters_for_cve` | |
| 56 | +| `cve-cluster-maria` | CVE with cluster filter | `get_clusters_for_cve` | |
| 57 | +| `cve-clusters-general` | General CVE query | `get_clusters_for_cve` | |
| 58 | +| `cve-cluster-list` | CVE across clusters | `get_clusters_for_cve` | |
| 59 | + |
| 60 | +## Configuration |
| 61 | + |
| 62 | +- **`gevals/eval.yaml`**: Main test configuration, agent settings, assertions |
| 63 | +- **`gevals/mcp-config.yaml`**: MCP server configuration |
| 64 | +- **`gevals/tasks/*.yaml`**: Individual test task definitions |
44 | 65 |
|
45 | | -## Test Configuration |
| 66 | +## How It Works |
46 | 67 |
|
47 | | -The `mcp-testing-framework.yaml` file controls the test behavior: |
| 68 | +Gevals uses a proxy architecture to intercept MCP tool calls: |
48 | 69 |
|
49 | | -- **testRound**: Number of times each test runs (default: 3) |
50 | | -- **passThreshold**: Minimum success rate (0.5 = 50%) |
51 | | -- **modelsToTest**: AI models to test (currently: `gpt-5`, `gpt-5-mini`) |
52 | | -- **testCases**: 8 test scenarios covering CVE queries and cluster listing |
53 | | -- **mcpServers**: Server configuration using stdio transport |
| 70 | +1. AI agent receives task prompt |
| 71 | +2. Agent calls MCP tool |
| 72 | +3. Gevals proxy intercepts and records the call |
| 73 | +4. Call forwarded to StackRox MCP server |
| 74 | +5. Server executes and returns result |
| 75 | +6. Gevals validates assertions and response quality |
54 | 76 |
|
55 | | -## Customizing Tests |
| 77 | +## Troubleshooting |
| 78 | + |
| 79 | +**Tests fail - no tools called** |
| 80 | +- Verify StackRox Central is accessible |
| 81 | +- Check API token permissions |
| 82 | + |
| 83 | +**Build errors** |
| 84 | +```bash |
| 85 | +go mod tidy |
| 86 | +./scripts/build-gevals.sh |
| 87 | +``` |
56 | 88 |
|
57 | | -### Add More Test Cases |
| 89 | +## Further Reading |
58 | 90 |
|
59 | | -Add new test cases to `mcp-testing-framework.yaml`: |
60 | | -Use the JSON report to analyze which prompts work best with each model. |
| 91 | +- [Gevals Documentation](https://github.com/genmcp/gevals) |
| 92 | +- [StackRox MCP Server](../README.md) |
0 commit comments