Skip to content

Conversation

@tamas-jozsa
Copy link
Collaborator

@tamas-jozsa tamas-jozsa commented Dec 29, 2025

./scripts/run-e2e-tests.sh --resources load_balancer,load_balancer_pool --apply-exemptions

Building binaries...
go build -v -o bin/tf-migrate ./cmd/tf-migrate
go build -v -o bin/e2e-runner ./cmd/e2e-runner

Targeting specific resources: load_balancer,load_balancer_pool
Target arguments: -target=module.load_balancer -target=module.load_balancer_pool


========================================
E2E Migration Test
========================================

Step 0: Initializing test resources
Running tests with:
  User:       [email protected]
  Account ID: 394f312589f47dc33bc80a5a5f12f35f
  Zone ID:    63a1772ec2bacdee371d3119f58c3300
  Domain:     tamas.terraform.cfapi.net
  Provider:   Registry (latest)

Running init script...

========================================
Syncing Test Resources
========================================

Filtering to specific resources: load_balancer, load_balancer_pool
Syncing resource files from testdata...
  ✓ load_balancer/load_balancer.tf (from load_balancer_e2e.tf)
  ✓ load_balancer/versions.tf
  ✓ load_balancer_pool/load_balancer_pool.tf (from load_balancer_pool_e2e.tf)
  ✓ load_balancer_pool/versions.tf

  Total: 4 files synced

Configuring terraform variables...


✓ Saved configuration
    Account ID: 394f312589f47dc33bc80a5a5f12f35f
    Zone ID: 63a1772ec2bacdee371d3119f58c3300
    Domain: tamas.terraform.cfapi.net
    File: v4/terraform.tfvars

Updating main.tf with module references...
  ↻ Updated main.tf with 2 module references


========================================
✓ Sync Complete!
========================================

Summary:
  - Terraform v4 configs: /Users/tjozsa/cf-repos/sdks/migration-work/agent-c/tf-migrate/e2e/tf/v4
  - Modules: 2
  - Files synced: 4

Configuring remote backend...
✓ Backend configured

  ✓ Provider installation preserved
  ✓ Backend already configured

Next steps:
  cd tf/v4 && terraform apply

Note: Configuration is automatically loaded from terraform.tfvars
      State is managed remotely in R2

✓ Test resources initialized

Step 1: Testing v4 configurations
Running terraform init in v4/...
Found local state file, backing up and using remote state...
✓ Terraform init successful (remote state loaded from R2)
Running terraform plan in v4/...
✓ Terraform plan successful
  Plan: 4 to add, 0 to change, 0 to destroy.

Detailed changes:

  # module.load_balancer.cloudflare_load_balancer.e2e_adaptive_routing will be created
  + resource "cloudflare_load_balancer" "e2e_adaptive_routing" {
      + created_on       = (known after apply)
      + default_pool_ids = [
          + "9a0dc8c79b9366f7c557bdd146fc1a6c",
        ]
      + enabled          = true
      + fallback_pool_id = "45f881500624f525a69b6eb345b29d31"
      + id               = (known after apply)
      + modified_on      = (known after apply)
      + name             = "cftftest-e2e-adaptive-lb.tamas.terraform.cfapi.net"
      + proxied          = false
      + session_affinity = "none"
      + steering_policy  = "off"
      + ttl              = 30
      + zone_id          = "63a1772ec2bacdee371d3119f58c3300"

  # module.load_balancer.cloudflare_load_balancer.e2e_all_attributes will be created
  + resource "cloudflare_load_balancer" "e2e_all_attributes" {
      + created_on           = (known after apply)
      + default_pool_ids     = [
          + "9a0dc8c79b9366f7c557bdd146fc1a6c",
        ]
      + enabled              = true
      + fallback_pool_id     = "45f881500624f525a69b6eb345b29d31"
      + id                   = (known after apply)
      + modified_on          = (known after apply)
      + name                 = "cftftest-e2e-all-attrs-lb.tamas.terraform.cfapi.net"
      + proxied              = false
      + session_affinity     = "cookie"
      + session_affinity_ttl = 3600
      + steering_policy      = "random"
      + ttl                  = 30
      + zone_id              = "63a1772ec2bacdee371d3119f58c3300"

  # module.load_balancer.cloudflare_load_balancer.e2e_location_strategy will be created
  + resource "cloudflare_load_balancer" "e2e_location_strategy" {
      + created_on       = (known after apply)
      + default_pool_ids = [
          + "9a0dc8c79b9366f7c557bdd146fc1a6c",
        ]
      + enabled          = true
      + fallback_pool_id = "45f881500624f525a69b6eb345b29d31"
      + id               = (known after apply)
      + modified_on      = (known after apply)
      + name             = "cftftest-e2e-location-lb.tamas.terraform.cfapi.net"
      + proxied          = false
      + session_affinity = "none"
      + steering_policy  = "off"
      + ttl              = 30
      + zone_id          = "63a1772ec2bacdee371d3119f58c3300"

  # module.load_balancer.cloudflare_load_balancer.e2e_random_steering will be created
  + resource "cloudflare_load_balancer" "e2e_random_steering" {
      + created_on       = (known after apply)
      + default_pool_ids = [
          + "9a0dc8c79b9366f7c557bdd146fc1a6c",
        ]
      + enabled          = true
      + fallback_pool_id = "45f881500624f525a69b6eb345b29d31"
      + id               = (known after apply)
      + modified_on      = (known after apply)
      + name             = "cftftest-e2e-random-lb.tamas.terraform.cfapi.net"
      + proxied          = false
      + session_affinity = "none"
      + steering_policy  = "random"
      + ttl              = 30
      + zone_id          = "63a1772ec2bacdee371d3119f58c3300"


Running terraform apply in v4/...
✓ Terraform apply successful
  Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
Syncing state from remote...
✓ Local state file synced from R2
Capturing v4 state...
✓ Saved v4 state to tmp/v4-state.json


Step 2: Running migration
Running ./scripts/migrate...
Building tf-migrate binary...
✓ Binary built successfully

========================================
Running v4 to v5 Migration
========================================

Preparing output directory...
  ✓ Preserved v5 provider installation (.terraform/)
  ✓ Preserved v5 dependency lock file (.terraform.lock.hcl)
Copying only targeted resources: load_balancer,load_balancer_pool
    ✓ Copied root file: provider.tf
    ✓ Copied root file: terraform.tfvars
    ✓ Copied root file: terraform.tfstate

    ✓ Copied module: load_balancer
    ✓ Copied module: load_balancer_pool
Creating filtered main.tf...
✓ Copied targeted resources to migrated-v4_to_v5/
✓ Updated provider.tf to use ~> 5.0 and removed backend config
Filtering state file to only include targeted resources...
✓ Filtered state to 11 resources from targeted modules

Migrating all files (including modules and state)...
Cloudflare Terraform Provider Migration Tool
============================================

Configuration directory: /Users/tjozsa/cf-repos/sdks/migration-work/agent-c/tf-migrate/e2e/migrated-v4_to_v5
Output directory: in-place
✓ Using Cloudflare API credentials (API key + email)

Found 6 configuration files to migrate
[1/6] Processing load_balancer.tf... ✓
[2/6] Processing versions.tf... ✓
[3/6] Processing load_balancer_pool.tf... ✓
[4/6] Processing versions.tf... ✓
[5/6] Processing main.tf... ✓
[6/6] Processing provider.tf... ✓

Applying cross-file reference updates (16 updates across 6 files)...
✓ Updated cross-file references (16 updates applied)

Processing state file: terraform.tfstate... ✓
✓ Migration complete (includes state and cross-module reference updates)


========================================
✓ Migration Complete!
========================================

Results:
  Input (v4):  /Users/tjozsa/cf-repos/sdks/migration-work/agent-c/tf-migrate/e2e/tf/v4
  Output (v5): /Users/tjozsa/cf-repos/sdks/migration-work/agent-c/tf-migrate/e2e/migrated-v4_to_v5

Next steps:
  cd /Users/tjozsa/cf-repos/sdks/migration-work/agent-c/tf-migrate/e2e/migrated-v4_to_v5
  terraform init
  terraform plan

✓ Migration successful

Step 3: Testing v5 configurations
Running terraform init in migrated-v4_to_v5/...
Cleaning v5 .terraform directory for fresh init...
✓ Terraform init successful
Running terraform plan in v5/...
✓ Terraform plan shows only computed value refreshes (ignored with --apply-exemptions)

Drift exemptions applied:
  - computed_value_refreshes: 42 change(s) exempted
Running terraform apply in v5/...
✓ Terraform apply successful
Capturing v5 state...
✓ Saved v5 state to tmp/v5-state.json

Step 4: Verifying stable state (v5 plan after apply)
Running terraform plan again to check for ongoing drift...
✓ No ongoing drift detected - migration achieved stable state!


========================================
Drift Report
========================================

✓ Exempted changes in v5 plan (before apply):
The following changes were detected but exempted by drift exemption rules:
  + disabled_at = (known after apply) [exempted: computed_value_refreshes] (×6)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 2 more
  - header      = {} -> null [exempted: computed_value_refreshes] (×6)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 2 more
  + port        = (known after apply) [exempted: computed_value_refreshes] (×6)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 2 more
  + notification_filter = (known after apply) [exempted: computed_value_refreshes] (×5)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 2 more
  + origin_steering     = (known after apply) [exempted: computed_value_refreshes] (×5)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 2 more
  + disabled_at         = (known after apply) [exempted: computed_value_refreshes] (×5)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 2 more
  + load_shedding       = (known after apply) [exempted: computed_value_refreshes] (×4)
    Resources: module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic, module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback, module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic
    ... and 1 more
  module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_basic:
    ~ modified_on         = "2025-12-29T15:55:47.560168Z" -> (known after apply) [exempted: computed_value_refreshes]
  module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_fallback:
    ~ modified_on         = "2025-12-29T15:55:47.648289Z" -> (known after apply) [exempted: computed_value_refreshes]
  module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_multi:
    ~ modified_on         = "2025-12-29T15:55:47.559022Z" -> (known after apply) [exempted: computed_value_refreshes]
  module.load_balancer.cloudflare_load_balancer_pool.lb_e2e_basic:
    ~ modified_on         = "2025-12-29T15:55:47.602155Z" -> (known after apply) [exempted: computed_value_refreshes]
  module.load_balancer_pool.cloudflare_load_balancer_pool.e2e_shedding:
    ~ modified_on         = "2025-12-29T15:55:47.57014Z" -> (known after apply) [exempted: computed_value_refreshes]



========================================
✓ E2E Test Complete!
========================================

Summary:

  Step 1: v4 terraform apply
    Status: ✓ SUCCESS

  Step 2: Migration (v4 → v5)
    Status: ✓ SUCCESS

  Step 3: v5 plan (before apply)
    Status: ⚠ Changes detected but all exempted
    Result: 0 real changes (42 exempted)
    Terraform: Plan: 0 to add, 5 to change, 0 to destroy.

  Step 4: v5 terraform apply
    Status: ✓ SUCCESS

  Step 5: v5 plan (after apply)
    Status: ✓ SUCCESS - Stable state achieved
    Result: No changes detected

Logs saved to:
  1 feat(load_balancer): v4 to v5 migration
  - /Users/tjozsa/cf-repos/sdks/migration-work/agent-c/tf-migrate/e2e/tmp

@tamas-jozsa tamas-jozsa force-pushed the load_balancer branch 4 times, most recently from 9e609f1 to 4092db9 Compare December 29, 2025 16:53
echo "Coverage Report:"
go tool cover -func=coverage.out
- name: Run unit tests
run: make test-unit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@tamas-jozsa tamas-jozsa merged commit 71f661f into main Dec 30, 2025
7 of 9 checks passed
@tamas-jozsa tamas-jozsa deleted the load_balancer branch December 30, 2025 06:50
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