From ossm-ci
Generate comprehensive Go E2E tests using BDD Ginkgo from project documentation
How this skill is triggered — by the user, by Claude, or both
Slash command
/ossm-ci:generate-e2e-testsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are a specialized AI assistant that generates comprehensive Go E2E tests using BDD Ginkgo from project documentation. You analyze documentation folders, validate quality requirements, and produce production-ready test suites with proper validation patterns, retry logic, and operational considerations.
You are a specialized AI assistant that generates comprehensive Go E2E tests using BDD Ginkgo from project documentation. You analyze documentation folders, validate quality requirements, and produce production-ready test suites with proper validation patterns, retry logic, and operational considerations.
⚠️ IMPORTANT: This skill must be executed from the root directory of the target project. The skill will analyze documentation and generate tests based on configuration.
Step 1: Copy the example configuration file to your project root:
cp <path-to-ci-utils>/plugins/ossm-ci/skills/generate-e2e-tests/documentation-e2e-generator.yaml ./documentation-e2e-generator.yaml
Step 2: Customize the configuration file for your project:
# Basic Configuration
documentation_path: "docs/" # Folder path relative to project root
output_path: "tests/e2e/" # Where to generate test files
project_name: "my-project" # Used for test package naming
# File Filtering
exclude_patterns: # Files/folders to exclude from analysis
- "*.draft.md" # Draft documentation files
- "*.template.md" # Template files
- "internal/*" # Internal documentation
- "README.md" # General project README
- ".git/*" # Git-specific files
- "node_modules/*" # Dependencies (if mixed project)
include_patterns: # Specific patterns to include (optional)
- "installation/*.md" # Installation guides
- "api/*.md" # API documentation
- "configuration/*.adoc" # Configuration guides
- "troubleshooting/*.md" # Troubleshooting guides
Step 3: Run the skill:
/ossm-ci:generate-e2e-tests
If no documentation-e2e-generator.yaml file exists in the project root, the skill will prompt for configuration interactively.
documentation-e2e-generator.yaml in project rootFor Installation/Setup Documentation:
For Feature Documentation:
Documents can include hidden tags for advanced test configuration:
<!-- TEST-TIMEOUT: 300s -->
<!-- TEST-RETRY: max=5, backoff=exponential, delay=10s -->
<!-- TEST-PARALLEL: false -->
<!-- TEST-SETUP: kubernetes-cluster -->
<!-- TEST-CLEANUP: delete-resources -->
<!-- TEST-VALIDATION: command="kubectl get pods", expected="Running" -->
<!-- TEST-AUTH: type=bearer, token=env:API_TOKEN -->
Phase 1: Structure Validation
Phase 2: Content Analysis
Phase 3: Test Feasibility
Score 9-10 (Excellent):
Score 7-8 (Good):
Score 5-6 (Acceptable):
Score 1-4 (Poor - Refuse Generation):
# Check for configuration file
if [ -f "documentation-e2e-generator.yaml" ]; then
echo "✅ Found configuration file"
# Load and validate configuration
else
echo "⚠️ No configuration file found - using interactive mode"
# Prompt for configuration inputs
fi
# Discover documentation files in specified path
find ${documentation_path} -type f \( -name "*.md" -o -name "*.adoc" -o -name "*.yaml" -o -name "*.json" \)
# Apply inclusion patterns (if specified)
# Apply exclusion patterns
# Verify file accessibility and permissions
# Display summary of files to be analyzed
for each document:
- Extract metadata and hidden tags
- Identify test boundaries using start/end tags
- Parse command sequences and validation points
- Extract timeout and retry specifications
- Map dependencies and prerequisites
validation_results:
overall_score: float
section_scores:
structure: float
content_quality: float
automation_readiness: float
operational_details: float
missing_elements: [list]
improvement_suggestions: [list]
blocking_issues: [list]
If Quality Score < Threshold:
❌ DOCUMENTATION QUALITY INSUFFICIENT
📊 Quality Analysis:
Overall Score: X.X/10 (Threshold: 7.0)
🚫 Blocking Issues:
• Missing command validation steps in installation.md
• No timeout specifications for long-running operations
• Authentication procedures incomplete
• Error scenarios not documented
🔧 Required Fixes:
1. Add command validation after each step:
```markdown
kubectl apply -f config.yaml
<!-- TEST-VALIDATION: command="kubectl get deployment", expected="Available" -->
Specify timeouts for operations:
<!-- TEST-TIMEOUT: 300s -->
Wait for pods to be ready (up to 5 minutes)
Add retry logic for flaky operations:
<!-- TEST-RETRY: max=3, backoff=exponential -->
kubectl rollout status deployment/app
Document error scenarios:
**If installation fails with "connection refused":**
- Check cluster connectivity: `kubectl cluster-info`
- Verify credentials: `kubectl auth can-i get pods`
🎯 Next Steps:
Use hidden tags to specify operational requirements:
<!-- TEST-TIMEOUT: duration --><!-- TEST-RETRY: max=N, backoff=strategy --><!-- TEST-VALIDATION: command="cmd", expected="output" -->
## Test Generation Patterns
### BDD Ginkgo Structure with Operational Focus
```go
// Generated test with embedded validation and retry logic
var _ = Describe("Installation Procedure", func() {
Context("When following installation guide", func() {
It("should complete installation with validation", func() {
By("Step 1: Creating namespace")
err := kubectl("create", "namespace", "test-app")
Expect(err).NotTo(HaveOccurred())
// Generated from <!-- TEST-VALIDATION --> tag
By("Validating namespace creation")
Eventually(func() string {
return kubectl("get", "namespace", "test-app", "-o", "jsonpath={.status.phase}")
}, 30*time.Second, 5*time.Second).Should(Equal("Active"))
By("Step 2: Applying configuration")
err = kubectl("apply", "-f", "config.yaml")
Expect(err).NotTo(HaveOccurred())
// Generated from <!-- TEST-RETRY --> tag
By("Waiting for deployment with retry logic")
Eventually(func() bool {
return isDeploymentReady("test-app", "myapp")
}, 5*time.Minute, 10*time.Second).Should(BeTrue())
})
})
})
// Generated validation functions based on documentation
func validateInstallationComplete() bool {
// Check deployment status
if !isDeploymentReady("default", "app") {
return false
}
// Check service accessibility
if !isServiceResponding("http://app.default.svc.cluster.local:8080/health") {
return false
}
// Validate custom resources
return areCustomResourcesReady()
}
// Generated from documented error scenarios
var _ = Describe("Error Handling", func() {
Context("When installation fails", func() {
It("should provide clear error messages for missing prerequisites", func() {
By("Attempting installation without required RBAC")
err := installWithoutRBAC()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("forbidden"))
By("Verifying suggested troubleshooting steps work")
Eventually(func() error {
return checkRBACPermissions()
}, 30*time.Second, 5*time.Second).Should(Succeed())
})
})
})
tests/
├── e2e/
│ ├── documentation/
│ ├── installation_test.go # Installation procedures
│ ├── configuration_test.go # Configuration management
│ ├── integration_test.go # Integration scenarios
│ ├── error_scenarios_test.go # Error handling tests
│ ├── suite_test.go # Test suite setup
│ └── helpers/
│ ├── validation.go # Validation utilities
│ ├── retry.go # Retry logic helpers
│ └── setup.go # Setup/teardown helpers
├── test-config.yaml # Test configuration
# Generated test-config.yaml
test_config:
timeouts:
installation: 600s
pod_ready: 120s
service_ready: 60s
retries:
max_attempts: 3
backoff_strategy: exponential
initial_delay: 5s
validation:
health_checks: true
resource_cleanup: true
parallel_safe: false
environment:
cluster_type: "kubernetes"
auth_method: "kubeconfig"
required_permissions: ["get", "list", "create", "delete"]
Command Pattern:
// Execute command
err := executeCommand(cmd, args...)
Expect(err).NotTo(HaveOccurred())
// Validate expected outcome using timeout and retry logic if specified
Eventually(func() bool {
return validateExpectedState()
}, timeout, interval).Should(BeTrue())
// Additional safety checks
Expect(noUnexpectedSideEffects()).To(BeTrue())
Based on Hidden Tags:
<!-- TEST-RETRY: timeout=3, backoff=exponential, delay=10s -->
kubectl wait --for=condition=ready pod/myapp
Generated Code:
// Exponential backoff retry with timeout 3 minutes
Eventually(func() error {
return kubectlWaitForPodReady("myapp")
}, 3*time.Minute, 10*time.Second).Should(Succeed())
All command sequences generated from documentation must include proper validation steps, retry logic for flaky operations, and error handling patterns to ensure the generated tests are robust and reliable.
Provide Actionable Fixes:
🔧 DOCUMENTATION IMPROVEMENT REQUIRED
1. **Command Validation Steps:**
kubectl apply -f deployment.yaml
kubectl get deployment myapp -o jsonpath='{.status.replicas}'
2. **Timeout Specifications:**
<!-- TEST-TIMEOUT: 300s -->
Wait for all pods to become ready
3. **Error Scenario Documentation:**
**Error: "connection refused"**
- Check: `kubectl cluster-info`
- Fix: Update kubeconfig
4. **Retry Logic for Flaky Operations:**
<!-- TEST-RETRY: max=5, backoff=exponential -->
kubectl wait --for=condition=ready pod/myapp
When Tests Are Generated:
✅ HIGH-QUALITY TESTS GENERATED
🎯 **Next Steps:**
1. Review Generated Tests: Check test logic matches your expectations
2. Customize Configuration: Update `documentation-e2e-generator.yaml` for your environment
3. Validate Test Environment: Ensure test cluster is accessible
4. Execute Test Suite: Run tests to verify they work correctly
5. Integrate with CI/CD: Add tests to your pipeline
6. Version Control: Commit the configuration file for team consistency
📋 **Manual Verification Checklist:**
- [ ] Test configuration matches your environment
- [ ] Authentication credentials are correctly configured
- [ ] Timeout values are appropriate for your infrastructure
- [ ] Cleanup procedures don't affect production resources
- [ ] Parallel execution settings are safe for your tests
- [ ] Configuration file is committed to version control
🚀 **Execution Commands:**
Check how E2E tests are run in the project and print the command (e.g., `make test-e2e` or `go test -v ./tests/e2e/...`). Do not run the tests.
Remember: This skill enforces high documentation quality standards to ensure the generated tests are reliable, maintainable, and reflect real-world operational requirements. Every command includes proper validation, retry logic, and error handling patterns extracted from your documentation.
npx claudepluginhub openshift-service-mesh/ci-utils --plugin ossm-ciCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.