Commit 914f7a8
Add Local Provider Testing Support for Migration E2E Tests & improve integration tests (#47)
* feat: add comprehensive e2e tests
* fix: preserve schedule and match blocks with dynamic refs in device posture migration
This commit fixes two critical drift issues in the zero_trust_device_posture_rule v4 to v5 migration:
1. Schedule field drift (affected 14 resources)
- Removed logic that deleted schedule = "5m" from state
- The v5 provider returns this value from API, so removing it caused drift
- Now preserved in state to match v5 API behavior
2. Match blocks with dynamic references (affected 5+ resources)
- Fixed MergeAttributeAndBlocksToObjectArray to preserve dynamic references
- Previously, match blocks with each.value.platform or var.platform were completely removed
- Added extractTokensFromBlock helper to preserve HCL tokens (variables, interpolations, functions)
- Now correctly transforms match blocks to arrays while preserving dynamic expressions
Additional changes:
- Added 3 unit tests for match blocks with dynamic references
- Updated integration testdata to include preserved schedule and match arrays
- Added E2E test Step 4 to verify stable state after v5 apply
- E2E script now exits with error if ongoing drift is detected
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(e2e): add local provider support and update test expectations
Add ability to test migrations with locally built provider binary, and
update test data to reflect current provider behavior.
Changes:
- Add --provider flag to run-e2e-tests script for local provider testing
- Verifies provider binary exists before running tests
- Creates .terraformrc-tf-migrate with dev_overrides automatically
- Applies dev overrides only to v5 tests (v4 uses registry provider)
- Update zero_trust_gateway_policy migration logic for v5 schema changes
- Update test expectations for logpull_retention, zero_trust_gateway_policy,
and zero_trust_list to match current provider output
The --provider flag enables rapid iteration when fixing provider issues:
./scripts/run-e2e-tests --provider /path/to/cloudflare-terraform-next
This allows testing provider fixes during migration without waiting for
provider releases, while keeping v4 tests using stable registry versions.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3505881 commit 914f7a8
File tree
22 files changed
+4480
-1415
lines changed- integration/v4_to_v5/testdata
- logpull_retention
- expected
- input
- zero_trust_device_posture_rule
- expected
- input
- zero_trust_gateway_policy
- expected
- input
- zero_trust_list
- expected
- input
- internal
- resources
- zero_trust_device_posture_rule
- zero_trust_gateway_policy
- transform/hcl
- scripts
22 files changed
+4480
-1415
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
Lines changed: 7 additions & 206 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 2 | + | |
12 | 3 | | |
13 | 4 | | |
14 | 5 | | |
15 | 6 | | |
16 | 7 | | |
17 | 8 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
165 | 12 | | |
166 | 13 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
173 | 17 | | |
174 | 18 | | |
175 | 19 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
0 commit comments