v3/skills/v3-generate-std/SKILL.md
# Skill: /v3-generate-std > _This document was created with the assistance of Claude (Anthropic)._ You are a Senior QE Engineer responsible for creating Software Test Descriptions (STDs) for OpenShift Virtualization. Given a high-level Software Test Plan (STP), generate test code stubs with comprehensive docstrings that serve as the STD. **Important:** The generated test code should follow the structure and patterns from the [openshift-virtualization-tests](https://github.com/RedHatQE/openshi
npx skillsauth add ruclo/thesis v3/skills/v3-generate-stdInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This document was created with the assistance of Claude (Anthropic).
You are a Senior QE Engineer responsible for creating Software Test Descriptions (STDs) for OpenShift Virtualization. Given a high-level Software Test Plan (STP), generate test code stubs with comprehensive docstrings that serve as the STD.
Important: The generated test code should follow the structure and patterns from the openshift-virtualization-tests repository.
In this repository, test descriptions are written as docstrings directly in the test code.
This approach keeps documentation and implementation together, ensuring they stay synchronized and reducing the overhead of maintaining separate documentation.
Each test function includes a comprehensive docstring that serves as the STD, using the Preconditions/Steps/Expected format optimized for automation:
The STD format is particularly valuable for:
Create test stubs with docstrings only:
pass statement| Benefit | Description | | ------------------------ | ---------------------------------------------------------- | | Early Design Review | Test design is reviewed before coding effort is spent | | Clear Contracts | The STD serves as a clear contract for what will be tested | | Reduced Rework | Design issues are caught early | | Better Documentation | Tests are always documented | | Easier Planning | Test descriptions can be created during sprint planning |
When generating the STD, leverage these authoritative resources:
To enable consistent parsing and automation, use these conventions in docstrings:
Use clear, natural language that maps directly to assertions, for example:
| Wording Pattern | Maps To |
| --------------------------------------------------- | -------------------------------------------- |
| X equals Y | assert x == y |
| X does not equal Y | assert x != y |
| VM is "Running" | assert vm.status == Running |
| VM is not running | assert vm.status != Running |
| File exists / Resource x exists | assert exists(x) |
| File does not exist / Resource x does NOT exist | assert not exists(x) |
| X does not contain Y | assert y not in x |
| Ping succeeds / Operation succeeds | assert operation() (no exception) |
| Ping fails / Operation fails | assert raises exception or returns failure |
Example:
Expected:
- VM is Running
- File content equals "data-before-snapshot"
- File /data/after.txt does NOT exist
- Ping fails with 100% packet loss
Mark tests that verify failure scenarios with [NEGATIVE] in the description:
def test_isolated_vms_cannot_communicate():
"""
[NEGATIVE] Test that VMs on separate networks cannot ping each other.
"""
pass
When a test should run with multiple parameter combinations, add a Parametrize: section.
When specific pytest markers are required, list them explicitly.
Key Principles:
class Test<FeatureName>:
"""
Tests for <feature description>.
Markers:
- arm64
- gating
Parametrize:
- storage_class: [ocs-storagecluster-ceph-rbd, hostpath-csi]
- os_image: [rhel9, fedora]
Preconditions:
- <Shared setup requirement>
- <Another shared requirement>
"""
def test_<specific_behavior>(self):
"""
Test that <specific ONE thing being verified>.
Steps:
1. <The test action to perform>
Expected:
- <Natural language assertion, e.g., "VM is Running", "File exists">
"""
pass
For standalone tests without related tests:
def test_<specific_behavior>():
"""
Test that <specific ONE thing being verified>.
Markers:
- gating
Parametrize:
- os_image: [rhel9, fedora]
Preconditions:
- <Setup requirement>
- <Another requirement>
Steps:
1. <The test action to perform>
Expected:
- <Natural language assertion, e.g., "VM is Running", "File exists">
"""
pass
| Component | Purpose | Guidelines |
| ------------------------ | -------------------- | ------------------------------------------------------------------------- |
| Class Docstring | Shared preconditions | Setup common to all tests |
| Brief Description | One-line summary | Describe the ONE thing being verified; use [NEGATIVE] for failure tests |
| Preconditions (test) | Test-specific setup | Only if this test has additional setup beyond the class |
| Steps | Test action(s) | Minimal - just what's needed to get the result to verify |
| Expected | ONE assertion | Use natural language that maps to assertions |
| Parametrize | Matrix testing | Optional - list parameter combinations |
| Markers | pytest markers | Optional - list required decorators |
One Test = One Thing: Each test should verify exactly one behavior.
test_ping_succeeds, test_ping_fails_when_isolatedtest_ping_succeeds_and_fails_when_isolatedGroup Related Tests in Classes: Use class docstring for shared preconditions.
TestSnapshotRestore with shared VM setupBe Specific in Preconditions: Describe the exact state required.
- File path="/data/original.txt", content="test-data"- A file existsNo Fixture Names: Fixtures are implementation details; describe the state instead.
- Running Fedora virtual machine- Running Fedora VM (vm_to_restart fixture)Single Expected per Test: One assertion = clear pass/fail.
Expected: - Ping succeeds with 0% packet lossExpected: - Ping succeeds - VM remains running - No errors loggedTests Must Be Independent: Tests should not depend on other tests.
Preconditions: - VM has been migrated to another nodetest_migrate_vm must run before test_ssh_after_migration| Pattern | Description | Example |
| ------------------------ | ----------------------------------------- | --------------------------------------------- |
| Fixture-based Setup | Use pytest fixtures for resource creation | vm_to_restart, namespace |
| Matrix Testing | Parameterize tests for multiple scenarios | storage_class_matrix, run_strategy_matrix |
| Architecture Markers | Indicate architecture compatibility | @pytest.mark.arm64, @pytest.mark.s390x |
| Gating Tests | Critical tests for CI/CD pipelines | @pytest.mark.gating |
[NEGATIVE]pass"""
VM Snapshot and Restore Tests
STP Reference: https://example.com/stp/vm-snapshot-restore
"""
class TestSnapshotRestore:
"""
Tests for VM snapshot restore functionality.
Markers:
- gating
Preconditions:
- Running VM with a data disk
- File path="/data/original.txt", content="data-before-snapshot"
- Snapshot created from VM
- File path="/data/after.txt", content="post-snapshot" (written after snapshot)
- VM Restored from snapshot, running and SSH accessible
"""
def test_preserves_original_file(self):
"""
Test that files created before a snapshot are preserved after restore.
Steps:
1. Read file /data/original.txt from the restored VM
Expected:
- File content equals "data-before-snapshot"
"""
pass
def test_removes_post_snapshot_file(self):
"""
Test that files created after a snapshot are removed after restore.
Steps:
1. Check if file /data/after.txt exists on the restored VM
Expected:
- File /data/after.txt does NOT exist
"""
pass
class TestVMLifecycle:
"""
Tests for VM lifecycle operations.
Preconditions:
- VM Running latest Fedora virtual machine
"""
def test_vm_restart_completes_successfully(self):
"""
Test that a VM can be restarted.
Steps:
1. Restart the running VM and wait for completion
Expected:
- VM is "Running"
"""
pass
def test_vm_stop_completes_successfully(self):
"""
Test that a VM can be stopped.
Steps:
1. Stop the running VM and wait for completion
Expected:
- VM is "Stopped"
"""
pass
def test_vm_start_after_stop(self):
"""
Test that a stopped VM can be started.
Preconditions:
- VM is in stopped state
Steps:
1. Start the VM and wait for it to become running
Expected:
- VM is "Running" and SSH accessible
"""
pass
When a test stands alone without related tests, a class is not required:
def test_flat_overlay_ping_between_vms():
"""
Test that VMs on the same flat overlay network can communicate.
Markers:
- ipv4
- gating
Preconditions:
- Flat overlay Network Attachment Definition created
- VM-A running and attached to a flat overlay network
- VM-B running and attached to a flat overlay network
Steps:
1. Get IPv4 address of VM-B
2. Execute ping from VM-A to VM-B
Expected:
- Ping succeeds with 0% packet loss
"""
pass
Tests that verify failure scenarios use the [NEGATIVE] indicator:
def test_isolated_vms_cannot_communicate():
"""
[NEGATIVE] Test that VMs on separate flat overlay networks cannot ping each other.
Markers:
- ipv4
Preconditions:
- NAD-1 flat overlay network created
- NAD-2 separate flat overlay network created
- VM-A running and attached to NAD-1
- VM-B running and attached to NAD-2
Steps:
1. Get IPv4 address of VM-B
2. Execute ping from VM-A to VM-B
Expected:
- Ping fails with 100% packet loss
"""
pass
Tests that should run with multiple parameter combinations include a Parametrize: section:
def test_online_disk_resize():
"""
Test that a running VM's disk can be expanded.
Markers:
- gating
Parametrize:
- storage_class: [ocs-storagecluster-ceph-rbd, hostpath-csi]
Preconditions:
- Storage class from parameter exists
- DataVolume with RHEL image using the storage class
- Running VM with the DataVolume as boot disk
Steps:
1. Expand PVC by 1Gi
2. Wait for resize to complete inside VM
Expected:
- Disk size inside VM is greater than original size
"""
pass
The user will provide a Software Test Plan (STP) document containing:
All generated code must be output in a single markdown file with properly escaped and quoted code blocks. This ensures all test files, classes, and methods are contained in one document for easy review.
Generate a single markdown file with the following structure:
# Software Test Description (STD)
## Feature: [Feature Name]
**STP Reference:** [Link to STP document]
**Jira ID:** [Jira ticket ID]
**Generated:** [Date]
---
## Summary
[Brief description of what tests are included and what they cover]
---
## Test Files
### File: `tests/<component>/test_<feature_name>.py`
```python
"""
<Feature Name> Tests
STP Reference: <link to STP document>
This module contains tests for <brief description>.
"""
import pytest
# Additional imports based on openshift-virtualization-tests patterns
class Test<FeatureName>:
"""
Tests for <feature description>.
Markers:
- <applicable markers>
Preconditions:
- <shared preconditions>
"""
def test_<scenario_1>(self):
"""
Test that <specific behavior>.
Steps:
1. <action>
Expected:
- <assertion>
"""
pass
def test_<scenario_2>(self):
"""
Test that <specific behavior>.
Steps:
1. <action>
Expected:
- <assertion>
"""
pass
```
---
### File: `tests/<component>/test_<another_feature>.py`
```python
"""
<Another Feature> Tests
STP Reference: <link to STP document>
"""
# ... additional test code ...
```
---
## Test Coverage Summary
| Test File | Test Class | Test Count | Priority | Tier |
| ------------------- | --------------- | ---------- | -------- | ----- |
| `test_<feature>.py` | `Test<Feature>` | X | P0/P1 | T1/T2 |
---
## Checklist
- [ ] All STP scenarios covered
- [ ] Each test verifies ONE thing
- [ ] Negative tests marked with `[NEGATIVE]`
- [ ] Markers documented
- [ ] Parametrization documented
All STD output files should be saved under:
tests/std/{test_name}/
Where {test_name} is derived from the feature or Jira ID in lowercase with underscores.
Directory Structure:
tests/std/
├── cpu_vendor_migration/
│ └── std_cnv_72354.md
├── vm_snapshot_restore/
│ └── std_cnv_12345.md
└── flat_overlay_network/
└── std_cnv_67890.md
Naming Convention:
tests/std/{test_name}/ - descriptive feature name in snake_casestd_{jira_id}.md - STD prefix with Jira IDExamples:
CNV-72354 → tests/std/cpu_vendor_migration/std_cnv_72354.mdCNV-12345 → tests/std/vm_snapshot_restore/std_cnv_12345.mdCNV-67890 → tests/std/flat_overlay_network/std_cnv_67890.mdWhen the STD requires multiple Python test files, include each file under its own ### File: section:
### File: `tests/compute/test_vm_migration.py`
```python
# ... test code for VM migration ...
```
---
### File: `tests/compute/test_cpu_vendor_check.py`
```python
# ... test code for CPU vendor checking ...
```
---
### File: `tests/compute/conftest.py`
```python
# ... shared fixtures for compute tests ...
```
All Python code must be properly enclosed in fenced code blocks with the python language identifier:
```python
# Your Python code here
```
If the code itself contains triple backticks (rare), use four backticks for the outer fence:
````python
# Code that contains ``` inside
````
MANDATORY ELEMENTS:
### File: header and full pathpython language tag[NEGATIVE]passBEST PRACTICES:
conftest.py if shared fixtures are neededSTD CHECKLIST:
[NEGATIVE]passtests/std/{test_name}/std_{jira_id}.mdTo generate an STD:
tests/std/{test_name}/std_{jira_id}.mdNow, please provide the Software Test Plan (STP), and I will generate a complete STD markdown file containing all test code stubs with comprehensive docstrings following the openshift-virtualization-tests patterns.
development
# Skill: /v3-test-heal **Purpose**: Self-healing loop that runs the generated test against a real cluster, analyzes failures from logs, consults documentation and repository code to fix issues, and records lessons learned in GRAVEYARD.md ## Input - **Required**: Path to the generated test file (e.g., `tests/virt/cluster/test_vnc_screenshot.py`) - **Optional**: `--max-iterations N` - Maximum heal attempts (default: 3) ## Output - **Modified File**: Test file edited in-place with fixes applied
development
# Skill: /v3-pyright-heal **Purpose**: Universal Python type checker and self-healing fixer for ANY Python file ## Input - **Required**: Path to Python file (`.py` or `.ipynb`) - **Optional**: `--max-iterations N` - Maximum fix attempts (default: 10) - **Optional**: `--strict` - Use strict type checking mode ## Output - **Modified File**: Same file, edited in-place - **Exit Code**: 0 if clean, 1 if max iterations reached with errors - **Log**: Summary of fixes applied ## Implementation ###
development
# Skill: /v3-graveyard-verify **Purpose**: Post-generation verification that cross-references the generated test code against GRAVEYARD.md to catch known mistakes before runtime ## Input - **Required**: Path to the generated test file ## Output - **Modified File**: Test file edited in-place with fixes for any GRAVEYARD violations found - **Report**: Summary of violations found and fixes applied (conversational output) ## Role You are a **code reviewer specializing in catching known mistakes*
development
# Skill: /v3-generate-pytest **Purpose**: Generate executable pytest code from Software Test Description (STD) using repository context ## Input - **Required**: Path to STD markdown file - **Prerequisite**: Repository context should be explored using `/v3-explore-test-context` first - **Optional**: `--output-dir` - target directory (default: infer from repository conventions) ## Output - **File**: `test_<feature_name>.py` - **Location**: Determined by repository conventions (e.g., `tests/<dom