Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:47:08 +08:00
commit 3f4757d6f3
12 changed files with 772 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{
"name": "test-gen",
"description": "OpenShift AI Test Generation System",
"version": "1.0.0",
"author": {
"name": "huangmingxia",
"email": "zhongweili@tubi.tv"
},
"commands": [
"./commands"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# test-gen
OpenShift AI Test Generation System

200
commands/README.md Normal file
View File

@@ -0,0 +1,200 @@
# Slash Commands Guide
## Available Commands
### Core Workflow Commands
| Command | Purpose | Example |
|---------|---------|---------|
| `/generate-test` | Generate test case from JIRA | `/generate-test HIVE-2883` |
| `/generate-e2e` | Generate E2E test code | `/generate-e2e HIVE-2883` |
| `/run-tests` | Execute E2E tests | `/run-tests HIVE-2883` |
| `/generate-report` | Generate comprehensive test report | `/generate-report HIVE-2883` |
| `/submit-pr` | Create pull request | `/submit-pr HIVE-2883` |
| `/full-workflow` | Execute complete workflow | `/full-workflow HIVE-2883` |
### Regeneration Commands
| Command | Purpose | Example |
|---------|---------|---------|
| `/regenerate-test` | Regenerate test case (force) | `/regenerate-test HIVE-2883` |
| `/regenerate-e2e` | Regenerate E2E code (force) | `/regenerate-e2e HIVE-2883` |
## Command vs Agent Relationship
```
┌─────────────────────┐
│ Slash Command │ ← User types this
│ /generate-test │
└──────────┬──────────┘
┌─────────────────────┐
│ Agent Config │ ← Claude reads this
│ test_case_ │
│ generation.yaml │
└──────────┬──────────┘
┌─────────────────────┐
│ Agent Execution │ ← Claude executes steps
│ Step 1, 2, 3... │
└─────────────────────┘
```
## How Slash Commands Work
### 1. User Interface Layer (Slash Command)
- **File**: `.claude/commands/generate-test.md`
- **Purpose**: User-friendly entry point
- **Contains**:
- Usage instructions
- Argument parsing
- Execution prompt
### 2. Logic Layer (Agent)
- **File**: `config/agents/test_case_generation.yaml`
- **Purpose**: Execution logic and steps
- **Contains**:
- Step-by-step tasks
- Tool configurations
- Input/output specifications
### 3. Execution Flow
```bash
# User types
/generate-test HIVE-2883
# Claude Code processes
1. Reads .claude/commands/generate-test.md
2. Extracts argument: HIVE-2883
3. Reads config/agents/test_case_generation.yaml
4. Executes each step in agent config
5. Returns results to user
```
## Creating Your Own Slash Command
### Template Structure
```markdown
# Command Title
Brief description of what this command does.
## Usage
\`\`\`
/your-command ARG1 ARG2
\`\`\`
## What this command does
1. Step 1 description
2. Step 2 description
3. ...
## Arguments
- `$1` (required): Description
- `$2` (optional): Description
## Example
\`\`\`
User: /your-command value1 value2
→ Expected behavior
→ Output description
\`\`\`
---
Execute {agent_name} agent for: **{args}**
```
### Key Components
1. **Header**: Clear command name and description
2. **Usage**: Show command syntax
3. **What it does**: High-level workflow
4. **Arguments**: Define required/optional params
5. **Example**: Show concrete usage
6. **Footer**: Execution prompt (critical!)
### The Footer Pattern
```markdown
---
Execute {agent_name} agent for: **{args}**
```
This footer tells Claude Code:
- Which agent to load (`{agent_name}`)
- What arguments to pass (`{args}`)
## Best Practices
### DO ✅
- Keep commands simple and focused
- Document all arguments clearly
- Provide concrete examples
- Link to agent configuration
- Use consistent naming patterns
### DON'T ❌
- Create commands without corresponding agents
- Mix multiple agents in one command
- Skip argument documentation
- Forget the execution footer
## Common Patterns
### Pattern 1: Simple Agent Execution
```markdown
Execute test_case_generation agent for: **{args}**
```
### Pattern 2: Conditional Execution
```markdown
Check prerequisites, then execute e2e_generation agent for: **{args}**
```
### Pattern 3: Sequential Workflow
```markdown
Execute workflow: test_case_generation → e2e_generation → test-executor for: **{args}**
```
## Troubleshooting
### Command not found
- Check file exists in `.claude/commands/`
- Verify file has `.md` extension
- Ensure file name matches command (e.g., `generate-test.md``/generate-test`)
### Command doesn't execute correctly
- Verify agent config exists
- Check execution footer format
- Ensure argument parsing is correct
### Agent not loading
- Verify agent path in `config/agents/`
- Check agent YAML is valid
- Ensure agent name in command matches file name
## Advanced: Multi-Step Commands
For complex workflows, use sequential agent calls:
```markdown
Execute complete workflow for: **{args}**
MANDATORY steps:
1. Read config/agents/workflow_orchestrator.yaml
2. Load test_case_generation agent
3. Execute all 4 phases
4. Verify outputs before proceeding
```
## Related Documentation
- Agent configurations: [config/agents/](../../config/agents/)
- Workflow guide: [prompts/workflow_guide.md](../../prompts/workflow_guide.md)
- Execution checklist: [prompts/check_list.md](../../prompts/check_list.md)

81
commands/full-workflow.md Normal file
View File

@@ -0,0 +1,81 @@
---
description: Execute complete test generation workflow (test case → E2E code → run tests)
argument-hint: [JIRA_KEY]
---
## Name
full-workflow
## Synopsis
```
/test-gen:full-workflow JIRA_KEY
```
## Description
The `full-workflow` command executes the complete test generation workflow, automating all steps from test case generation to test execution.
This command combines three agents in sequence:
1. Test case generation
2. E2E test code generation
3. Test execution and reporting
## Implementation
Executes the workflow orchestrator agent at `config/agents/workflow_orchestrator.md`
The orchestrator performs:
1. **test_case_generation** - Generates comprehensive test cases from JIRA
2. **e2e_test_generation_openshift_private** - Creates E2E test code
3. **test-executor** - Runs tests and generates report
Total execution time: ~3-4 minutes
## Return Value
- **Success**: Complete workflow outputs in `test_artifacts/{JIRA_KEY}/`
- **Failure**: Error message indicating which phase failed
## Examples
1. **Basic usage**:
```
/test-gen:full-workflow HIVE-2883
```
2. **For different component**:
```
/test-gen:full-workflow CCO-1234
```
## Arguments
- **$1** (required): JIRA issue key (e.g., HIVE-2883, CCO-1234)
## Prerequisites
- JIRA MCP configured and accessible
- GitHub CLI (`gh`) installed and authenticated
- OpenShift cluster kubeconfig available (for test execution)
- Fork of openshift-tests-private configured
## Output Structure
```
test_artifacts/{JIRA_KEY}/
├── phases/
│ ├── test_requirements_output.md
│ ├── test_strategy.md
│ └── test_case_design.md
├── test_cases/
│ └── {JIRA_KEY}_test_case.md
├── test_report.md
└── e2e_test_info.json
```
## Complete Workflow
This IS the complete workflow. For step-by-step control:
1. `/test-gen:generate-test JIRA_KEY`
2. `/test-gen:generate-e2e JIRA_KEY`
3. `/test-gen:run-tests JIRA_KEY`
4. `/test-gen:submit-pr JIRA_KEY`
## See Also
- `workflow_orchestrator.md` - Orchestrator implementation
- `/test-gen:generate-test` - Manual test case generation
- `/test-gen:generate-e2e` - Manual E2E generation
- `/test-gen:run-tests` - Manual test execution

78
commands/generate-e2e.md Normal file
View File

@@ -0,0 +1,78 @@
---
description: Generate E2E test code for openshift-tests-private repository
argument-hint: [JIRA_KEY]
---
## Name
generate-e2e
## Synopsis
```
/test-gen:generate-e2e JIRA_KEY
```
## Description
The `generate-e2e` command generates executable Ginkgo-based E2E test code for the openshift-tests-private repository based on test case specifications.
The command integrates the generated E2E code directly into your fork of openshift-tests-private and creates a feature branch for PR submission.
## Implementation
Executes the E2E test generation agent at `config/agents/e2e_test_generation_openshift_private.md`
The agent performs:
- Reads test case from: `test_artifacts/{JIRA_KEY}/test_cases/`
- Analyzes repository patterns in openshift-tests-private
- Generates Ginkgo E2E test code following repository conventions
- Creates feature branch: `ai-case-design-{JIRA_KEY}`
- Commits E2E code to the branch
Execution time: ~2-3 minutes
## Return Value
- **Success**: E2E test code generated and committed to feature branch
- **Failure**: Error message with generation or validation errors
## Examples
1. **Basic usage**:
```
/test-gen:generate-e2e HIVE-2883
```
2. **After test case generation**:
```
/test-gen:generate-test HIVE-2883
/test-gen:generate-e2e HIVE-2883
```
## Arguments
- **$1** (required): JIRA issue key (e.g., HIVE-2883, CCO-1234)
## Prerequisites
- Test case file exists in `test_artifacts/{JIRA_KEY}/test_cases/`
- Fork of openshift-tests-private configured in environment
- GitHub credentials configured (for pushing to fork)
- `/test-gen:generate-test` has been run first
## Output Structure
```
~/auto-test-case/openshift-tests-private/
└── test/extended/cluster_operator/{component}/
└── {jira_key}_test.go # Generated E2E test
test_artifacts/{JIRA_KEY}/
└── e2e_test_info.json # Metadata about generated E2E test
```
## Complete Workflow
1. `/test-gen:generate-test JIRA_KEY`
2. `/test-gen:generate-e2e JIRA_KEY` ← This command
3. `/test-gen:run-tests JIRA_KEY`
4. `/test-gen:submit-pr JIRA_KEY`
## See Also
- `e2e_test_generation_openshift_private.md` - Agent implementation
- `/test-gen:generate-test` - Previous step (required)
- `/test-gen:regenerate-e2e` - Regenerate without prerequisite checks
- `/test-gen:run-tests` - Next step in workflow
- `/test-gen:full-workflow` - Automated complete workflow

View File

@@ -0,0 +1,42 @@
---
description: Generate comprehensive test execution and coverage report
argument-hint: [JIRA_KEY]
---
## Name
generate-report
## Synopsis
```
/test-gen:generate-report JIRA_KEY
```
## Description
Generates comprehensive test report including execution results, coverage analysis, and recommendations.
## Implementation
Executes test_report_generation agent at `config/agents/test_report_generation.md`
Execution time: ~30 seconds
## Examples
1. **Generate report after tests**:
```
/test-gen:run-tests HIVE-2883
/test-gen:generate-report HIVE-2883
```
## Arguments
- **$1** (required): JIRA issue key
## Prerequisites
- Test artifacts exist
## Output
```
test_artifacts/{JIRA_KEY}/test_report.md
```
## See Also
- `/test-gen:run-tests` - Execute tests first
- `/test-gen:submit-pr` - Include report in PR

81
commands/generate-test.md Normal file
View File

@@ -0,0 +1,81 @@
---
description: Generate comprehensive test cases from JIRA issue
argument-hint: [JIRA_KEY]
---
## Name
generate-test
## Synopsis
```
/test-gen:generate-test JIRA_KEY
```
## Description
The `generate-test` command generates comprehensive test cases from a JIRA issue using systematic thinking framework.
Applies a 4-phase methodology:
1. **Requirements Analysis** - Extract and analyze JIRA requirements
2. **Test Strategy** - Define testing approach and coverage
3. **Test Case Design** - Create detailed test scenarios
4. **Validation** - Ensure completeness and quality
## Implementation
Executes the test case generation agent at `config/agents/test_case_generation.md`
The agent performs:
- Extracts requirements from JIRA via JIRA MCP
- Analyzes code changes using DeepWiki MCP (optional)
- Applies systematic thinking framework
- Generates test cases in Polarion-compatible format
- Outputs to: `test_artifacts/{JIRA_KEY}/test_cases/`
Execution time: ~90 seconds
## Return Value
- **Success**: Test cases generated in `test_artifacts/{JIRA_KEY}/`
- **Failure**: Error message with generation or validation errors
## Examples
1. **Basic usage**:
```
/test-gen:generate-test HIVE-2883
```
2. **For Cloud Credential Operator**:
```
/test-gen:generate-test CCO-1234
```
## Arguments
- **$1** (required): JIRA issue key (e.g., HIVE-2883, CCO-1234)
## Prerequisites
- JIRA MCP configured and accessible
- JIRA issue exists and is accessible
- DeepWiki MCP configured (optional, for code analysis)
## Output Structure
```
test_artifacts/{JIRA_KEY}/
├── phases/
│ ├── test_requirements_output.md # Phase 1: Requirements
│ ├── test_strategy.md # Phase 2: Strategy
│ └── test_case_design.md # Phase 3: Design
├── test_cases/
│ └── {JIRA_KEY}_test_case.md # Final test cases
└── test_coverage_matrix.md # Coverage matrix
```
## Complete Workflow
1. `/test-gen:generate-test JIRA_KEY` ← This command
2. `/test-gen:generate-e2e JIRA_KEY`
3. `/test-gen:run-tests JIRA_KEY`
4. `/test-gen:submit-pr JIRA_KEY`
## See Also
- `test_case_generation.md` - Agent implementation
- `/test-gen:regenerate-test` - Regenerate without checks
- `/test-gen:generate-e2e` - Next step in workflow
- `/test-gen:full-workflow` - Automated complete workflow

View File

@@ -0,0 +1,37 @@
---
description: Regenerate E2E test code without prerequisite checks (force regeneration)
argument-hint: [JIRA_KEY]
---
## Name
regenerate-e2e
## Synopsis
```
/test-gen:regenerate-e2e JIRA_KEY
```
## Description
Regenerates E2E test code, skipping prerequisite checks. Use when updating existing E2E tests.
## Implementation
Executes e2e_test_generation_openshift_private agent at `config/agents/e2e_test_generation_openshift_private.md` with regenerate mode.
Execution time: ~2-3 minutes
## Examples
1. **Regenerate after test case update**:
```
/test-gen:regenerate-e2e HIVE-2883
```
## Arguments
- **$1** (required): JIRA issue key
## Use Cases
- Test cases were updated
- E2E code needs improvement
## See Also
- `/test-gen:generate-e2e` - Normal generation
- `/test-gen:regenerate-test` - Regenerate test cases

View File

@@ -0,0 +1,37 @@
---
description: Regenerate test cases without prerequisite checks (force regeneration)
argument-hint: [JIRA_KEY]
---
## Name
regenerate-test
## Synopsis
```
/test-gen:regenerate-test JIRA_KEY
```
## Description
Regenerates test cases, skipping prerequisite checks. Use when updating existing test cases.
## Implementation
Executes test_case_generation agent at `config/agents/test_case_generation.md` with regenerate mode.
Execution time: ~90 seconds
## Examples
1. **Regenerate after JIRA update**:
```
/test-gen:regenerate-test HIVE-2883
```
## Arguments
- **$1** (required): JIRA issue key
## Use Cases
- JIRA issue was updated
- Test case quality needs improvement
## See Also
- `/test-gen:generate-test` - Normal generation
- `/test-gen:regenerate-e2e` - Regenerate E2E

85
commands/run-tests.md Normal file
View File

@@ -0,0 +1,85 @@
---
description: Execute E2E tests and generate comprehensive test reports
argument-hint: [JIRA_KEY]
---
## Name
run-tests
## Synopsis
```
/test-gen:run-tests JIRA_KEY
```
## Description
The `run-tests` command executes E2E tests for the specified JIRA issue and generates comprehensive test execution reports.
The command locates the generated E2E test code, executes it against the configured OpenShift cluster, and produces detailed test reports including pass/fail status, execution logs, and error analysis.
## Implementation
Executes the test executor agent at `config/agents/test-executor.md`
The agent performs:
- Locates E2E test code in openshift-tests-private fork
- Configures test environment using provided kubeconfig
- Executes tests using extended-platform-tests binary
- Captures test output and logs
- Generates comprehensive test report
- Analyzes failures and provides debugging information
Execution time: ~5-10 minutes (depends on test complexity)
## Return Value
- **Success**: Test execution report generated in `test_artifacts/{JIRA_KEY}/test_report.md`
- **Failure**: Error message with execution or environment configuration errors
## Examples
1. **Basic usage**:
```
/test-gen:run-tests HIVE-2883
```
2. **After E2E generation**:
```
/test-gen:generate-e2e HIVE-2883
/test-gen:run-tests HIVE-2883
```
3. **Complete workflow**:
```
/test-gen:generate-test HIVE-2883
/test-gen:generate-e2e HIVE-2883
/test-gen:run-tests HIVE-2883
```
## Arguments
- **$1** (required): JIRA issue key (e.g., HIVE-2883, CCO-1234)
## Prerequisites
- E2E test code exists (run `/test-gen:generate-e2e` first)
- KUBECONFIG environment variable set to valid OpenShift cluster config
- OpenShift cluster accessible and operational
- extended-platform-tests binary built (or compiled from source)
- Test environment matches expected platform (AWS, Azure, GCP, etc.)
## Output Structure
```
test_artifacts/{JIRA_KEY}/
├── test_report.md # Comprehensive test report
├── test_execution_log.txt # Raw test execution output
└── test_results.json # Structured test results
```
## Complete Workflow
1. `/test-gen:generate-test JIRA_KEY`
2. `/test-gen:generate-e2e JIRA_KEY`
3. `/test-gen:run-tests JIRA_KEY` ← This command
4. `/test-gen:submit-pr JIRA_KEY`
## See Also
- `test-executor.md` - Agent implementation
- `/test-gen:generate-e2e` - Previous step (required)
- `/test-gen:generate-report` - Generate additional reports
- `/test-gen:submit-pr` - Next step in workflow
- `/test-gen:full-workflow` - Automated complete workflow

39
commands/submit-pr.md Normal file
View File

@@ -0,0 +1,39 @@
---
description: Submit E2E test code as pull request to openshift-tests-private
argument-hint: [JIRA_KEY]
---
## Name
submit-pr
## Synopsis
```
/test-gen:submit-pr JIRA_KEY
```
## Description
The `submit-pr` command creates and submits a pull request containing the generated E2E test code to the openshift-tests-private repository.
## Implementation
Executes the PR submission agent at `config/agents/pr-submitter.md`
Execution time: ~30 seconds
## Examples
1. **Basic usage**:
```
/test-gen:submit-pr HIVE-2883
```
## Arguments
- **$1** (required): JIRA issue key
## Prerequisites
- E2E test code exists
- GitHub CLI (`gh`) installed
## Complete Workflow
1. `/test-gen:generate-test JIRA_KEY`
2. `/test-gen:generate-e2e JIRA_KEY`
3. `/test-gen:run-tests JIRA_KEY`
4. `/test-gen:submit-pr JIRA_KEY` ← This command

77
plugin.lock.json Normal file
View File

@@ -0,0 +1,77 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:huangmingxia/test-generation-assistant:plugins/test-gen",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "d77a7cadba98d2e57dfe99d8ab1c47c86e91fa8b",
"treeHash": "d2999c36919d25ad8b98be18543331568a929f070db97871a24067e575c02fca",
"generatedAt": "2025-11-28T10:17:35.597714Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "test-gen",
"description": "OpenShift AI Test Generation System",
"version": "1.0.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "bc8e3d0e0e7b832937b03a40973b7fd483ecede22e12a476921d761b8a4eb52c"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "243c615defc543451980d4ac58a7ae325946a72facf37ad7fa11488f3860006f"
},
{
"path": "commands/full-workflow.md",
"sha256": "cd3e0a05bd9053c0565f712e7feb2095d8542b8374218d701d2ae176b04732cb"
},
{
"path": "commands/run-tests.md",
"sha256": "42ab5263f64eda0de19900b4106f5eb0cfdd5987a8c45b763c31d88991eb17ca"
},
{
"path": "commands/regenerate-test.md",
"sha256": "06852bcfe4405e1a0ee8b0253b4a4130117eb680be6b8b34aecbee0eb0856ad1"
},
{
"path": "commands/generate-report.md",
"sha256": "bb92296ca62313832daa2b7a66ae893f4a86ea87dfeb658c017e074dcb683d84"
},
{
"path": "commands/generate-e2e.md",
"sha256": "5fbd83036d6bdb68f82f684931b2441e4ad98d5c907ad0da7debf9b80bec465d"
},
{
"path": "commands/regenerate-e2e.md",
"sha256": "419d8bbe4d01aafde71bc01bff3cbf207c7b4d8bf9a13e5c722327ba5d3cc03e"
},
{
"path": "commands/README.md",
"sha256": "d3655b7e451568ffd9163a54cf19158644210bd89cecb8b5c8b7e84d0406af64"
},
{
"path": "commands/submit-pr.md",
"sha256": "975a42e85c7b3257c0b333602dc350de278c0e2a5eae0c57579f231e0342b12c"
},
{
"path": "commands/generate-test.md",
"sha256": "603dbfa6c97472ee1ed8f034162e42bec1f778f3dee19bce7a77e5b27e8ef0a9"
}
],
"dirSha256": "d2999c36919d25ad8b98be18543331568a929f070db97871a24067e575c02fca"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}