| name | test-operator |
| description | Comprehensive testing, linting, and quality assurance for openstack-k8s-operators operators with Go best practices |
| argument-hint | <quick | standard | full | focus "pattern" | security | coverage> |
| user-invocable | true |
| allowed-tools | ["Bash","Read","Grep","Glob","TaskCreate","TaskUpdate"] |
| context | fork |
Test Operator - Quality Assurance & Testing
This skill provides comprehensive testing, linting, and quality assurance workflows for openstack-k8s-operators operators, following Go and Kubernetes operator best practices.
Testing Workflow
When testing an operator, I will systematically:
- Code Formatting: Ensure consistent code style with
go fmt
- Static Analysis: Run
go vet to catch common mistakes
- Linting: Execute golangci-lint with comprehensive checks
- Unit Tests: Run Ginkgo test suites with proper coverage
- Security Scanning: Check for vulnerabilities and security issues
- CRD Validation: Verify Custom Resource Definition schemas
- Operator-Specific Checks: Run operator-lint for controller patterns
Available Make Targets
Based on the openstack-k8s-operators operator Makefile conventions:
Core Testing
make test
make gotest
make test GINKGO_ARGS="--focus 'pattern'"
Code Formatting
make fmt
make gofmt
make tidy
Static Analysis
make vet
make govet
make operator-lint
Linting (Multiple Levels)
make golangci
make golangci-lint
make golint
Code Generation & Validation
make manifests
make generate
make crd-schema-check
Comprehensive Quality Check
I will run a complete quality check workflow:
Level 1: Quick Checks (Fast Feedback)
make fmt - Format code
make vet - Static analysis
- Quick syntax validation
Level 2: Standard Checks (Pre-commit)
make gofmt - Format validation
make govet - Enhanced static analysis
make golangci - Standard linting
make tidy - Dependency check
Level 3: Comprehensive Checks (Pre-PR)
make golangci-lint - Full linting with auto-fix
make operator-lint - Operator-specific patterns
make test - Full test suite
make crd-schema-check - Schema validation
Level 4: Security & Advanced (CI/CD)
- Security scanning (gosec, staticcheck)
- Vulnerability detection (govulncheck)
- Code complexity analysis (gocyclo)
- Test coverage analysis
Ginkgo Testing Patterns
Basic Test Execution
make test
make test GINKGO_ARGS="-v --trace"
make test GINKGO_ARGS="--focus 'Glance controller'"
make test GINKGO_ARGS="--procs 4"
make test GINKGO_ARGS="--randomize-all"
Advanced Ginkgo Usage
make test GINKGO_ARGS="--focus 'initializes the status fields'"
make test GINKGO_ARGS="--skip 'webhook validation'"
make test GINKGO_ARGS="--dry-run --focus 'pattern'"
make test GINKGO_ARGS="--cover --coverprofile=coverage.out"
make test GINKGO_ARGS="-v --trace --output-interceptor-mode=none"
Golangci-lint Configuration
The skill recognizes common golangci-lint checks:
Enabled Linters (Recommended)
- errcheck: Check for unchecked errors
- gosimple: Simplify code
- govet: Report suspicious constructs
- ineffassign: Detect ineffectual assignments
- staticcheck: Static analysis checks
- unused: Find unused code
- typecheck: Type-checking errors
- gocritic: Comprehensive Go linter
- gofmt: Check code formatting
- goimports: Check import formatting
Security & Quality Linters
- gosec: Security issues detection
- revive: Fast, extensible linter
- stylecheck: Style consistency
- unconvert: Remove unnecessary type conversions
- misspell: Spelling errors
- dupl: Code duplication detection
- gocyclo: Cyclomatic complexity
Operator-Specific Checks
- operator-lint: Kubernetes operator patterns
- Custom rules for controller-runtime
- Finalizer usage validation
- Status condition patterns
Security Scanning
I will run security-focused tools:
go install github.com/securego/gosec/v2/cmd/gosec@latest
gosec -fmt=json -out=results.json ./...
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
go list -json -m all | nancy sleuth
Test Coverage Analysis
Generate and analyze test coverage:
make test GINKGO_ARGS="--cover --coverprofile=coverage.out"
go tool cover -html=coverage.out
go tool cover -func=coverage.out
go test -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out | grep total
CI/CD Integration Checks
For continuous integration workflows:
make fmt && make vet && make golangci
make manifests && make generate && git diff --exit-code
make fmt vet golangci test crd-schema-check
git diff --exit-code api/ config/
Automated Test Workflows
Quick Test Loop (Development)
- Make code changes
make fmt - Format
make vet - Quick validation
make test GINKGO_ARGS="--focus 'MyTest'" - Focused test
- Iterate
Pre-Commit Workflow
make fmt - Format code
make tidy - Clean dependencies
make vet - Static analysis
make golangci - Linting
make test - Run tests
- Stage and commit changes
Pre-PR Workflow
make manifests generate - Regenerate code
- Check for uncommitted changes
make golangci-lint - Full lint with fixes
make operator-lint - Operator checks
make test - Full test suite
make crd-schema-check - Schema validation
- Generate coverage report
Common Issues Detected
Code Quality
- Unchecked errors
- Unused variables and imports
- Inefficient code patterns
- Type conversion issues
- Code duplication
Operator-Specific
- Missing finalizer handling
- Incorrect status condition usage
- Improper error wrapping
- Missing owner references
- Webhook validation issues
Security
- SQL injection vulnerabilities
- Hardcoded credentials
- Insecure random number generation
- Path traversal risks
- Known CVE dependencies
Testing
- Failing test cases
- Flaky tests (randomization issues)
- Missing test coverage
- Slow test execution
- Race conditions
Usage Examples
Quick Test Mode
/test-operator quick
Standard Test Mode
/test-operator standard
Full Test Mode
/test-operator full
Focused Test
/test-operator focus "initializes the status fields"
Lint Only
/test-operator lint
Security Scan
/test-operator security
Integration with Other Skills
- debug-operator: Use test failures to guide debugging
- code-style: Enforce style before testing
- feature: Include tests in feature planning
- debug-operator: Parse test output for log patterns
Best Practices
- Run tests frequently during development
- Fix linting issues before committing
- Maintain test coverage above 80%
- Use focused tests for rapid iteration
- Run full suite before creating PRs
- Keep dependencies updated and secure
- Follow operator-lint recommendations
- Validate CRD changes with schema checker
Reporting
I will provide:
- Test execution summary
- Failing test details with line numbers
- Linting issues categorized by severity
- Security vulnerabilities found
- Coverage statistics
- Actionable recommendations
Simply invoke /test-operator to run comprehensive testing and quality checks with detailed reporting and recommendations.