Skip to content

Add AliCloud parity testing and simplify template generation#35

Open
jvhoof wants to merge 1 commit intomainfrom
claude/alicloud-output-testing-MUDVm
Open

Add AliCloud parity testing and simplify template generation#35
jvhoof wants to merge 1 commit intomainfrom
claude/alicloud-output-testing-MUDVm

Conversation

@jvhoof
Copy link
Owner

@jvhoof jvhoof commented Mar 7, 2026

Summary

This PR introduces automated parity testing between TypeScript and Python implementations for AliCloud infrastructure templates, and refactors the AliCloud template generation to use simpler, more maintainable approaches.

Key Changes

New Parity Testing Workflow

  • Added .github/workflows/parity-test-alicloud.yml to automatically compare TypeScript and Python outputs for AliCloud templates
  • Workflow runs on pushes to main and pull requests affecting AliCloud-related files
  • Supports customizable VPC CIDR and subnet count via workflow dispatch inputs
  • Generates detailed comparison reports and uploads diff artifacts for debugging
  • Fails the workflow if any format differences are detected between implementations

Template Generation Simplification

  • Aliyun Shell Script (aliyun.template.sh):

    • Removed complex Python JSON parsing for VPC creation response handling
    • Replaced with simpler aliyun CLI output formatting: --output cols=VpcId rows=VpcId | tail -n 1 | tr -d ' '
    • Removed error checking logic that relied on JSON parsing
    • Simplified vSwitch creation to use pre-calculated availability zones instead of dynamic zone discovery
  • Terraform Template (terraform.template.tf):

    • Removed dynamic data "alicloud_zones" data source for zone lookup
    • Added explicit zone variables for each vSwitch (e.g., vswitch1_zone, vswitch2_zone)
    • Changed vSwitch resources to use static zone variables instead of round-robin zone selection
    • Added example Security Group resource and ingress rule for internal communication
    • Added security group ID to outputs

Python Script Updates (template_processor.py)

  • Aliyun processing: Simplified vSwitch creation to use pre-calculated zones from subnet data instead of dynamic zone discovery
  • Terraform processing:
    • Removed dynamic zone data source generation
    • Added zone variables for each vSwitch matching the pre-calculated zones
    • Updated vSwitch resource generation to reference zone variables instead of data source lookups

Configuration Updates (cloud_provider_config.py)

  • Updated AliCloud availability zones list to use standard Hangzhou zones (cn-hangzhou-a through cn-hangzhou-f) instead of the previous set

Implementation Details

  • Both TypeScript and Python implementations now use the same pre-calculated availability zones, ensuring output parity
  • The simplified approach removes runtime dependencies on dynamic zone discovery, making templates more predictable and testable
  • The parity test workflow validates that both implementations produce identical outputs for the same inputs

https://claude.ai/code/session_01FPJXHgjRWCVA2g92YWabgW

- Add parity-test-alicloud.yml GitHub Actions workflow that generates
  alicloud output (aliyun + terraform) from both TypeScript and Python
  implementations and diffs the results, mirroring the Azure/AWS pattern
- Sync Python alicloud availability zones to match TypeScript config
  (cn-hangzhou-a..f instead of cn-hangzhou-h..k)
- Rewrite process_alicloud_aliyun_template to use pre-calculated zones
  and --output cols=VSwitchId format, matching TypeScript output exactly
- Rewrite process_alicloud_terraform_template to use static vswitch zone
  variables instead of a dynamic alicloud_zones data source, matching
  TypeScript output exactly
- Update Python aliyun.template.sh to use --output cols=VpcId for VPC
  ID extraction, matching the TypeScript template
- Add security group resources and security_group_id output to Python
  terraform.template.tf to match the TypeScript template

https://claude.ai/code/session_01FPJXHgjRWCVA2g92YWabgW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants