|
| 1 | +# KubeVirt VM Toolset Tests |
| 2 | + |
| 3 | +This directory contains gevals-based tests for the KubeVirt VM toolset in the Kubernetes MCP Server. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +These tests validate the VM creation and troubleshooting tools (`vm_create` and `vm_troubleshoot`) by having AI agents complete real tasks using the MCP server. |
| 8 | + |
| 9 | +## Test Structure |
| 10 | + |
| 11 | +``` |
| 12 | +tests/ |
| 13 | +├── README.md # This file |
| 14 | +├── mcp-config.yaml # MCP server configuration |
| 15 | +├── claude-code/ # Claude Code agent configuration |
| 16 | +│ ├── agent.yaml |
| 17 | +│ └── eval.yaml |
| 18 | +└── tasks/ # Test tasks |
| 19 | + ├── create-vm-basic/ # Basic VM creation test |
| 20 | + ├── create-vm-with-instancetype/ # VM with specific instancetype |
| 21 | + ├── create-vm-with-size/ # VM with size parameter |
| 22 | + ├── create-vm-ubuntu/ # Ubuntu VM creation |
| 23 | + ├── create-vm-with-performance/ # VM with performance family |
| 24 | + └── troubleshoot-vm/ # VM troubleshooting test |
| 25 | +``` |
| 26 | + |
| 27 | +## Prerequisites |
| 28 | + |
| 29 | +1. **Kubernetes cluster** with KubeVirt installed |
| 30 | + - The cluster must have KubeVirt CRDs installed |
| 31 | + - For testing, you can use a Kind cluster with KubeVirt |
| 32 | + |
| 33 | +2. **Kubernetes MCP Server** running at `http://localhost:8080/mcp` |
| 34 | + |
| 35 | + ```bash |
| 36 | + # Build and run the server |
| 37 | + cd /path/to/kubernetes-mcp-server |
| 38 | + make build |
| 39 | + ./kubernetes-mcp-server --port 8080 |
| 40 | + ``` |
| 41 | + |
| 42 | +3. **gevals binary** built from the gevals project |
| 43 | + |
| 44 | + ```bash |
| 45 | + cd /path/to/gevals |
| 46 | + go build -o gevals ./cmd/gevals |
| 47 | + ``` |
| 48 | + |
| 49 | +4. **Claude Code** installed and in PATH |
| 50 | + |
| 51 | + ```bash |
| 52 | + # Install Claude Code (if not already installed) |
| 53 | + npm install -g @anthropic/claude-code |
| 54 | + ``` |
| 55 | + |
| 56 | +5. **kubectl** configured to access your cluster |
| 57 | + |
| 58 | +## Running the Tests |
| 59 | + |
| 60 | +### Run All Tests |
| 61 | + |
| 62 | +```bash |
| 63 | +# From the gevals directory |
| 64 | +./gevals eval /path/to/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/tests/claude-code/eval.yaml |
| 65 | +``` |
| 66 | + |
| 67 | +### Run a Specific Test |
| 68 | + |
| 69 | +```bash |
| 70 | +# Run just the basic VM creation test |
| 71 | +./gevals eval /path/to/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/tests/tasks/create-vm-basic/create-vm-basic.yaml \ |
| 72 | + --agent-file /path/to/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/tests/claude-code/agent.yaml \ |
| 73 | + --mcp-config-file /path/to/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/tests/mcp-config.yaml |
| 74 | +``` |
| 75 | + |
| 76 | +## Test Descriptions |
| 77 | + |
| 78 | +### create-vm-basic |
| 79 | + |
| 80 | +**Difficulty:** Easy |
| 81 | +**Description:** Tests basic VM creation with default Fedora workload. |
| 82 | +**Key Tool:** `vm_create` |
| 83 | +**Expected Behavior:** Agent should use `vm_create` to generate a plan and then create the VM using `resources_create_or_update`. |
| 84 | + |
| 85 | +### create-vm-with-instancetype |
| 86 | + |
| 87 | +**Difficulty:** Medium |
| 88 | +**Description:** Tests VM creation with a specific instancetype (u1.medium). |
| 89 | +**Key Tool:** `vm_create` |
| 90 | +**Expected Behavior:** Agent should pass the instancetype parameter to `vm_create` and create a VM with the correct instancetype reference. |
| 91 | + |
| 92 | +### create-vm-with-size |
| 93 | + |
| 94 | +**Difficulty:** Medium |
| 95 | +**Description:** Tests VM creation using a size hint ('large'). |
| 96 | +**Key Tool:** `vm_create` |
| 97 | +**Expected Behavior:** Agent should use the size parameter which should map to an appropriate instancetype. |
| 98 | + |
| 99 | +### create-vm-ubuntu |
| 100 | + |
| 101 | +**Difficulty:** Easy |
| 102 | +**Description:** Tests VM creation with Ubuntu workload. |
| 103 | +**Key Tool:** `vm_create` |
| 104 | +**Expected Behavior:** Agent should create a VM using the Ubuntu container disk image. |
| 105 | + |
| 106 | +### create-vm-with-performance |
| 107 | + |
| 108 | +**Difficulty:** Medium |
| 109 | +**Description:** Tests VM creation with performance family ('compute-optimized') and size. |
| 110 | +**Key Tool:** `vm_create` |
| 111 | +**Expected Behavior:** Agent should combine performance and size to select an appropriate instancetype (e.g., c1.medium). |
| 112 | + |
| 113 | +### troubleshoot-vm |
| 114 | + |
| 115 | +**Difficulty:** Easy |
| 116 | +**Description:** Tests VM troubleshooting guide generation. |
| 117 | +**Key Tool:** `vm_troubleshoot` |
| 118 | +**Expected Behavior:** Agent should use `vm_troubleshoot` to generate a troubleshooting guide for the VM. |
| 119 | + |
| 120 | +## Assertions |
| 121 | + |
| 122 | +The tests validate: |
| 123 | + |
| 124 | +- **Tool Usage:** Agents must call `vm_create`, `vm_troubleshoot`, or `resources_*` tools |
| 125 | +- **Call Limits:** Between 1 and 30 tool calls (allows for exploration and creation) |
| 126 | +- **Task Success:** Verification scripts confirm VMs are created correctly |
| 127 | + |
| 128 | +## Expected Results |
| 129 | + |
| 130 | +**✅ Pass** means: |
| 131 | + |
| 132 | +- The VM tools are well-designed and discoverable |
| 133 | +- Tool descriptions are clear to AI agents |
| 134 | +- Schemas are properly structured |
| 135 | +- Implementation works correctly |
| 136 | + |
| 137 | +**❌ Fail** indicates: |
| 138 | + |
| 139 | +- Tool descriptions may need improvement |
| 140 | +- Schema complexity issues |
| 141 | +- Missing functionality |
| 142 | +- Implementation bugs |
| 143 | + |
| 144 | +## Output |
| 145 | + |
| 146 | +Results are saved to `gevals-kubevirt-vm-operations-out.json` with: |
| 147 | + |
| 148 | +- Task pass/fail status |
| 149 | +- Assertion results |
| 150 | +- Tool call history |
| 151 | +- Agent interactions |
| 152 | + |
| 153 | +## Customization |
| 154 | + |
| 155 | +### Using Different AI Agents |
| 156 | + |
| 157 | +You can create additional agent configurations (similar to the `claude-code/` directory) for testing with different AI models: |
| 158 | + |
| 159 | +```yaml |
| 160 | +# Example: openai-agent/agent.yaml |
| 161 | +kind: Agent |
| 162 | +metadata: |
| 163 | + name: "openai-agent" |
| 164 | +commands: |
| 165 | + argTemplateMcpServer: "{{ .File }}" |
| 166 | + runPrompt: |- |
| 167 | + agent-wrapper.sh {{ .McpServerFileArgs }} "{{ .Prompt }}" |
| 168 | +``` |
| 169 | +
|
| 170 | +### Adding New Tests |
| 171 | +
|
| 172 | +To add a new test task: |
| 173 | +
|
| 174 | +1. Create a new directory under `tasks/` |
| 175 | +2. Add task YAML file with prompt |
| 176 | +3. Add setup, verify, and cleanup scripts |
| 177 | +4. The test will be automatically discovered by the glob pattern in `eval.yaml` |
| 178 | + |
| 179 | +## Troubleshooting |
| 180 | + |
| 181 | +### Tests Fail to Connect to MCP Server |
| 182 | + |
| 183 | +Ensure the Kubernetes MCP Server is running: |
| 184 | + |
| 185 | +```bash |
| 186 | +curl http://localhost:8080/mcp/health |
| 187 | +``` |
| 188 | + |
| 189 | +### VirtualMachine Not Created |
| 190 | + |
| 191 | +Check if KubeVirt is installed: |
| 192 | + |
| 193 | +```bash |
| 194 | +kubectl get crds | grep kubevirt |
| 195 | +kubectl get pods -n kubevirt |
| 196 | +``` |
| 197 | + |
| 198 | +### Permission Issues |
| 199 | + |
| 200 | +Ensure your kubeconfig has permissions to: |
| 201 | + |
| 202 | +- Create namespaces |
| 203 | +- Create VirtualMachine resources |
| 204 | +- List instancetypes and preferences |
| 205 | + |
| 206 | +## Contributing |
| 207 | + |
| 208 | +When adding new tests: |
| 209 | + |
| 210 | +- Keep tasks focused on a single capability |
| 211 | +- Make verification scripts robust |
| 212 | +- Document expected behavior |
| 213 | +- Set appropriate difficulty levels |
| 214 | +- Ensure cleanup scripts remove all resources |
0 commit comments