-
Story
-
Resolution: Unresolved
-
Undefined
-
None
-
None
-
None
-
Quality / Stability / Reliability
-
False
-
-
False
-
5
-
None
-
None
-
None
Problem Statement
The WINC test suite currently uses 35+ static YAML template files in test/extended/testdata/winc/. Many of these files are near-duplicates with minor variations:
Windows Web Server variants (7 files):
- windows_web_server.yaml
- windows_web_server_no_taint.yaml
- windows_web_server_pvc.yaml
- windows_web_server_scaler.yaml
- windows_webserver_secondary_os.yaml
- windows_webserver_projected_volume.yaml
- windows_web_server_disconnected.yaml
Machineset templates (10 files):
- 5 platform-specific Windows machinesets (AWS, Azure, GCP, vSphere, Nutanix)
- 5 BYOH machinesets (being removed in WINC-1508)
Note: windows_web_server_byoh.yaml and the 5 BYOH machineset templates will be removed by WINC-1508 and are excluded from this consolidation effort.
This creates significant maintenance overhead:
- Changes to common structure must be duplicated across multiple files
- Easy to introduce inconsistencies between variants
- Difficult to understand what differentiates each template
- Hard to create new test variants
- Increases file count and repository size
Proposed Solution
Implement a Go template-based system using Go's text/template package to consolidate test templates. This will reduce file count by ~70% while maintaining full backward compatibility.
Scope: Focus on Windows web server templates (Phase 1) with optional expansion to machinesets (Phase 3), coordinating with WINC-1508 for BYOH removal.
Objectives
- Reduce Windows web server template file count from 7 to 1 consolidated template
- Improve maintainability through centralized template definitions
- Add type safety to template configuration
- Enable easier creation of new test variants
- Support both file-based and stdin-based (oc apply -f -) deployment
- Maintain backward compatibility with existing tests
- Coordinate with WINC-1508 to avoid conflicts with BYOH template removal
Proposed Approach
Phase 1: Infrastructure Setup (Windows Web Server Templates)
1. Create Consolidated Template
- Create windows_web_server_template.yaml using Go text/template syntax
- Support 7 existing Windows web server variants through configuration (excluding BYOH)
- Use conditional blocks ({{
{\{if\}}
..{{
{\{end\}}}}) for optional sections
- Support dynamic values through template variables
2. Add Type-Safe Configuration
- Create WindowsWebServerConfig struct in test/extended/winc/utils.go
- Add fields for all configuration options:
- Service inclusion
- Tolerations
- Security context
- Replica count
- PVC mounting
- Resource limits
- Node selectors
- Image pull secrets
- PowerShell version
- OS label styles
- Add NewDefaultWindowsWebServerConfig() helper function
- Import text/template package
3. Implement Template Functions
- Create createWorkloadFromTemplate() function for file-based deployment
- Create createWorkloadFromTemplateWithStdin() function for stdin-based deployment
- Handle template parsing, execution, and error checking
- Support waiting for workload readiness
4. Documentation
- Create migration guide with before/after examples
- Document all configuration options
- Provide usage examples for each template variant
- Include troubleshooting guide
Phase 2: Migration (Optional - Future Ticket)
- Update test/extended/winc/winc.go to use new template system
- Update test/extended/winc/storage.go to use new template system
- Update other test files using Windows web server templates
- Verify all tests pass in CI
- Remove old static YAML files (coordinate with WINC-1508)
Phase 3: Expansion to Machinesets (Future Ticket)
- Wait for WINC-1508 BYOH removal to complete
- Apply same pattern to remaining machineset templates (5 platforms, Windows only)
- Create per-platform consolidated templates
- Further reduce file count
Technical Design
Template System Architecture
Test Code (*.go)
↓
WindowsWebServerConfig (typed configuration)
↓
createWorkloadFromTemplate[WithStdin]()
↓
text/template.Execute()
↓
windows_web_server_template.yaml
↓
Generated YAML
↓
oc apply -f <file> OR oc apply -f -
Configuration Example
Current approach (map of strings):
createWorkload(oc, namespace, "windows_web_server_pvc.yaml", map[string]string{ "<id>": pvc, "<pvc-name>": pvc, "<windows_container_image>": image, "<node-selector>": nodeSelector, }, false, windowsWorkloads+"-"+pvc)
Proposed approach (type-safe struct):
config := NewDefaultWindowsWebServerConfig()
config.ImageName = image
config.NameSuffix = pvc
config.PVCName = pvc
config.Replicas = 3
config.AdditionalNodeSelector = nodeSelector
createWorkloadFromTemplateWithStdin(oc, namespace,
"windows_web_server_template.yaml", config, false, windowsWorkloads+"-"+pvc)
Template Consolidation Mapping
| Current Template File | Configuration in New System | Status |
|---|---|---|
| windows_web_server.yaml | Default configuration | Active |
| windows_web_server_no_taint.yaml | IncludeTolerations=false, IncludeService=false | Active |
| windows_web_server_pvc.yaml | PVCName, Replicas=3, NameSuffix | Active |
| windows_web_server_scaler.yaml | ResourceLimits="1" | Active |
| windows_webserver_secondary_os.yaml | UseNewOSLabels=true, KernelID | Active |
| windows_webserver_projected_volume.yaml | ProjectedVolume=true | Active |
| windows_web_server_disconnected.yaml | ImagePullSecrets, MultilineCommand=true | Active |
| windows_web_server_byoh.yaml | N/A - Being removed in WINC-1508 | Excluded |
Expected Benefits
- Reduced Maintenance: Common changes only need to be made once in the template
- Type Safety: Configuration validated at compile time, preventing typos in placeholder strings
- Improved Clarity: Explicit configuration shows what makes each test variant different
- Easier Testing: Create new test variants without creating new files
- Better Efficiency: Stdin mode eliminates temp file I/O overhead
- Supports OTE Migration: Cleaner codebase makes framework migration easier (WINC-1536)
- No Conflicts with BYOH Removal: Work is coordinated with WINC-1508
Implementation Tasks
Required Work (Phase 1)
- Create windows_web_server_template.yaml with Go template syntax
- Add WindowsWebServerConfig struct to utils.go
- Add text/template import to utils.go
- Implement createWorkloadFromTemplate() function
- Implement createWorkloadFromTemplateWithStdin() function
- Add NewDefaultWindowsWebServerConfig() helper function
- Create comprehensive migration guide
- Create usage examples for all 7 template variants (excluding BYOH)
- Add testing utilities
- Validate template syntax and rendering
Coordination Required
- Verify WINC-1508 status and timeline for BYOH removal
- Ensure no conflicts with BYOH template removal work
- Document that BYOH templates are excluded from this effort
Optional Follow-up Work (Future Tickets)
- Migrate existing test code to use new template system
- Remove old static YAML files (after WINC-1508 completes)
- Create machineset templates for each cloud provider (5 platforms)
- Consolidate other resource templates
Acceptance Criteria
Phase 1: Infrastructure (Core Deliverable)
- [ ] windows_web_server_template.yaml created with Go template syntax supporting 7 variants
- [ ] WindowsWebServerConfig struct implemented with all required fields
- [ ] createWorkloadFromTemplate() function implemented and tested
- [ ] createWorkloadFromTemplateWithStdin() function implemented and tested
- [ ] NewDefaultWindowsWebServerConfig() helper function created
- [ ] Template syntax validated (no parsing errors)
- [ ] Documentation created:
- Migration guide with before/after examples
- Usage examples for all template variants
- Configuration reference
- Troubleshooting guide
- [ ] Can generate YAML equivalent to all 7 original template files (excluding BYOH)
- [ ] No breaking changes to existing tests
- [ ] No conflicts with WINC-1508 BYOH removal work
Phase 2: Migration (Optional - Future Ticket)
- [ ] All test files migrated to use new template system
- [ ] All tests pass in CI
- [ ] Old static YAML files removed (coordinate timing with WINC-1508)
- [ ] Code review completed
Phase 3: Expansion (Future Ticket - After WINC-1508)
- [ ] WINC-1508 BYOH removal completed
- [ ] Machineset templates created for 5 platforms (Windows only)
- [ ] Additional resource templates consolidated
- [ ] Template best practices documented
Success Metrics
- Windows web server file count reduction: 7 files → 1 template (86% reduction)
- Potential overall reduction after Phase 3: ~29 files → ~8-10 templates (65-70% reduction)
- Zero test failures introduced by migration
- Improved code review velocity (less duplication to review)
- Easier for team members to create new test variants
- Clean coordination with WINC-1508 (no merge conflicts)
Dependencies and Related Work
Dependencies
- None - this work is independent and can proceed immediately
- However, Phase 3 (machineset consolidation) should wait for WINC-1508 to complete
Related Issues
- WINC-1536 (Epic): Stabilize and Migrate WINC Tests to OpenShift Tests Extension (OTE)
- This work supports test stabilization and cleaner codebase for OTE migration
- WINC-1508: Remove BYOH template support
- Affects 6 files: windows_web_server_byoh.yaml + 5 BYOH machineset templates
- This consolidation effort excludes BYOH templates to avoid conflicts
- Phase 3 machineset consolidation should wait for WINC-1508 completion
Coordination Plan
- Phase 1 (this ticket): Focus only on Windows web server templates (excludes BYOH)
- WINC-1508: Removes BYOH templates independently
- Phase 2 (future): Migrate code to use new templates (after both efforts stabilize)
- Phase 3 (future): Consolidate remaining machineset templates (after WINC-1508 completes)
Risks and Mitigations
Risk: Conflicts with WINC-1508 BYOH removal
Mitigation: Explicitly exclude BYOH templates from consolidation scope
Risk: Breaking existing tests during migration
Mitigation: Keep old templates until migration is complete and verified in CI
Risk: Template syntax errors
Mitigation: Validate templates before use, add unit tests for template rendering
Risk: Team unfamiliarity with Go templates
Mitigation: Provide comprehensive documentation and examples
Timeline Estimate
- Phase 1 (Infrastructure): 3-5 days
- Phase 2 (Migration): 3-5 days (future ticket, coordinate with WINC-1508)
- Phase 3 (Expansion): 5-8 days (future ticket, after WINC-1508)
Story Points
Recommended: 5 Story Points (Phase 1 only)
- Medium complexity
- Clear requirements
- Well-defined scope
- Excludes migration and expansion work
Resources
- Go text/template documentation: https://pkg.go.dev/text/template
- Existing test files: test/extended/testdata/winc/
- Existing utilities: test/extended/winc/utils.go
- Related epic: https://issues.redhat.com/browse/WINC-1536
- Related issue: https://issues.redhat.com/browse/WINC-1508
- is blocked by
-
WINC-1508 Draft: Optimize BYOH tests to use pre-provisioned nodes in Prow CI for faster execution
-
- To Do
-