Skip to content

Commit 857f933

Browse files
committed
test: update PubSubTopic E2E test with enforceInTransit
1 parent cdbe52a commit 857f933

10 files changed

Lines changed: 113 additions & 20 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Journal Entry - PubSubTopic MessageStoragePolicy.enforceInTransit
2+
3+
## Overview
4+
Added support for the `enforceInTransit` parameter under `messageStoragePolicy` in `PubSubTopic` to both legacy (Terraform) and direct controllers.
5+
6+
## Details
7+
- Patched the local copy of the Terraform Google Beta Provider under `third_party/` to expose `enforce_in_transit` under `message_storage_policy` in `google_pubsub_topic` and implemented the flattener and expander.
8+
- Updated KRM types in `apis/pubsub/v1beta1/topic_types.go` to add `EnforceInTransit *bool` to the `MessageStoragePolicy` struct.
9+
- Updated direct controller mapping in `pkg/controller/direct/pubsub/topic_mapper.go` to proxy the `EnforceInTransit` value to the GCP Pub/Sub API.
10+
- Updated fuzz test configuration `pkg/controller/direct/pubsub/topic_fuzzer.go` to triaging the field.
11+
- Regenerated CRDs, client code, and deepcopy implementations.
12+
- Expanded the E2E test fixture under `pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/` to verify setting and changing `enforceInTransit` during create and update.

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/_final_object.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
< generation: 3
55
---
66
> generation: 2
7-
20d18
7+
24d22
88
< resourceID: pubsubtopic-sample-${uniqueId}
9-
32c30
9+
36c34
1010
< observedGeneration: 3
1111
---
1212
> observedGeneration: 2

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/_final_object_old_controller.golden.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ metadata:
1717
namespace: ${uniqueId}
1818
spec:
1919
messageRetentionDuration: 3600s
20+
messageStoragePolicy:
21+
allowedPersistenceRegions:
22+
- us-central1
23+
enforceInTransit: false
2024
resourceID: pubsubtopic-sample-${uniqueId}
2125
schemaSettings:
2226
encoding: JSON

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/_generated_object_pubsubtopic.golden.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ metadata:
1616
namespace: ${uniqueId}
1717
spec:
1818
messageRetentionDuration: 3600s
19+
messageStoragePolicy:
20+
allowedPersistenceRegions:
21+
- us-central1
22+
enforceInTransit: false
1923
schemaSettings:
2024
encoding: JSON
2125
schemaRef:

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/_http.diff

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,52 @@
66
< PUT https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json
77
---
88
> PUT https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
9-
107a108
9+
113a114
1010
> "name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
11-
109c110
11+
115c116
1212
< "encoding": "JSON",
1313
---
1414
> "encoding": 1,
15-
132c133
15+
144c145
1616
< "encoding": "JSON",
1717
---
1818
> "encoding": 1,
19-
139c140
19+
151c152
2020
< GET https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json
2121
---
2222
> GET https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
23-
160c161
23+
178c179
2424
< "encoding": "JSON",
2525
---
2626
> "encoding": 1,
27-
167c168
28-
< PATCH https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json&updateMask=labels%2CmessageRetentionDuration
27+
185c186
28+
< PATCH https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json&updateMask=labels%2CmessageStoragePolicy%2CmessageRetentionDuration
2929
---
3030
> PATCH https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
31-
178a180
31+
201a203
3232
> "name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
33-
180c182
33+
203c205
3434
< "encoding": "JSON",
3535
---
3636
> "encoding": 1,
37-
183c185,186
37+
206c208,209
3838
< }
3939
---
4040
> },
41-
> "updateMask": "labels,messageRetentionDuration"
42-
206c209
41+
> "updateMask": "labels,messageRetentionDuration,messageStoragePolicy"
42+
234c237
4343
< "encoding": "JSON",
4444
---
4545
> "encoding": 1,
46-
213c216
46+
241c244
4747
< GET https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json
4848
---
4949
> GET https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
50-
236c239
50+
269c272
5151
< "encoding": "JSON",
5252
---
5353
> "encoding": 1,
54-
243c246
54+
276c279
5555
< DELETE https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json
5656
---
5757
> DELETE https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?%24alt=json%3Benum-encoding%3Dint

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/_http.log

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ Content-Type: application/json
105105
"label-one": "value-one",
106106
"managed-by-cnrm": "true"
107107
},
108+
"messageStoragePolicy": {
109+
"allowedPersistenceRegions": [
110+
"us-central1"
111+
],
112+
"enforceInTransit": true
113+
},
108114
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
109115
"schemaSettings": {
110116
"encoding": 1,
@@ -128,6 +134,12 @@ X-Xss-Protection: 0
128134
"label-one": "value-one",
129135
"managed-by-cnrm": "true"
130136
},
137+
"messageStoragePolicy": {
138+
"allowedPersistenceRegions": [
139+
"us-central1"
140+
],
141+
"enforceInTransit": true
142+
},
131143
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
132144
"schemaSettings": {
133145
"encoding": 1,
@@ -156,6 +168,12 @@ X-Xss-Protection: 0
156168
"label-one": "value-one",
157169
"managed-by-cnrm": "true"
158170
},
171+
"messageStoragePolicy": {
172+
"allowedPersistenceRegions": [
173+
"us-central1"
174+
],
175+
"enforceInTransit": true
176+
},
159177
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
160178
"schemaSettings": {
161179
"encoding": 1,
@@ -177,13 +195,18 @@ Content-Type: application/json
177195
"newkey": "newval"
178196
},
179197
"messageRetentionDuration": "3600s",
198+
"messageStoragePolicy": {
199+
"allowedPersistenceRegions": [
200+
"us-central1"
201+
]
202+
},
180203
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
181204
"schemaSettings": {
182205
"encoding": 1,
183206
"schema": "projects/${projectId}/schemas/pubsubschema-${uniqueId}"
184207
}
185208
},
186-
"updateMask": "labels,messageRetentionDuration"
209+
"updateMask": "labels,messageRetentionDuration,messageStoragePolicy"
187210
}
188211

189212
200 OK
@@ -204,6 +227,11 @@ X-Xss-Protection: 0
204227
"newkey": "newval"
205228
},
206229
"messageRetentionDuration": "3600s",
230+
"messageStoragePolicy": {
231+
"allowedPersistenceRegions": [
232+
"us-central1"
233+
]
234+
},
207235
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
208236
"schemaSettings": {
209237
"encoding": 1,
@@ -234,6 +262,11 @@ X-Xss-Protection: 0
234262
"newkey": "newval"
235263
},
236264
"messageRetentionDuration": "3600s",
265+
"messageStoragePolicy": {
266+
"allowedPersistenceRegions": [
267+
"us-central1"
268+
]
269+
},
237270
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
238271
"schemaSettings": {
239272
"encoding": 1,

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/_http_old_controller.log

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ Content-Type: application/json
105105
"label-one": "value-one",
106106
"managed-by-cnrm": "true"
107107
},
108+
"messageStoragePolicy": {
109+
"allowedPersistenceRegions": [
110+
"us-central1"
111+
],
112+
"enforceInTransit": true
113+
},
108114
"schemaSettings": {
109115
"encoding": "JSON",
110116
"schema": "projects/${projectId}/schemas/pubsubschema-${uniqueId}"
@@ -127,6 +133,12 @@ X-Xss-Protection: 0
127133
"label-one": "value-one",
128134
"managed-by-cnrm": "true"
129135
},
136+
"messageStoragePolicy": {
137+
"allowedPersistenceRegions": [
138+
"us-central1"
139+
],
140+
"enforceInTransit": true
141+
},
130142
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
131143
"schemaSettings": {
132144
"encoding": "JSON",
@@ -155,6 +167,12 @@ X-Xss-Protection: 0
155167
"label-one": "value-one",
156168
"managed-by-cnrm": "true"
157169
},
170+
"messageStoragePolicy": {
171+
"allowedPersistenceRegions": [
172+
"us-central1"
173+
],
174+
"enforceInTransit": true
175+
},
158176
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
159177
"schemaSettings": {
160178
"encoding": "JSON",
@@ -164,7 +182,7 @@ X-Xss-Protection: 0
164182

165183
---
166184

167-
PATCH https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json&updateMask=labels%2CmessageRetentionDuration
185+
PATCH https://pubsub.googleapis.com/v1/projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}?alt=json&updateMask=labels%2CmessageStoragePolicy%2CmessageRetentionDuration
168186
Content-Type: application/json
169187

170188
{
@@ -176,6 +194,11 @@ Content-Type: application/json
176194
"newkey": "newval"
177195
},
178196
"messageRetentionDuration": "3600s",
197+
"messageStoragePolicy": {
198+
"allowedPersistenceRegions": [
199+
"us-central1"
200+
]
201+
},
179202
"schemaSettings": {
180203
"encoding": "JSON",
181204
"schema": "projects/${projectId}/schemas/pubsubschema-${uniqueId}"
@@ -201,6 +224,11 @@ X-Xss-Protection: 0
201224
"newkey": "newval"
202225
},
203226
"messageRetentionDuration": "3600s",
227+
"messageStoragePolicy": {
228+
"allowedPersistenceRegions": [
229+
"us-central1"
230+
]
231+
},
204232
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
205233
"schemaSettings": {
206234
"encoding": "JSON",
@@ -231,6 +259,11 @@ X-Xss-Protection: 0
231259
"newkey": "newval"
232260
},
233261
"messageRetentionDuration": "3600s",
262+
"messageStoragePolicy": {
263+
"allowedPersistenceRegions": [
264+
"us-central1"
265+
]
266+
},
234267
"name": "projects/${projectId}/topics/pubsubtopic-sample-${uniqueId}",
235268
"schemaSettings": {
236269
"encoding": "JSON",

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/create.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ spec:
2525
schemaRef:
2626
name: pubsubschema-${uniqueId}
2727
encoding: JSON
28+
messageStoragePolicy:
29+
allowedPersistenceRegions:
30+
- us-central1
31+
enforceInTransit: true

pkg/test/resourcefixture/testdata/basic/pubsub/v1beta1/pubsubtopic/pubsubtopic/update.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ spec:
2727
name: pubsubschema-${uniqueId}
2828
encoding: JSON
2929
messageRetentionDuration: 3600s
30+
messageStoragePolicy:
31+
allowedPersistenceRegions:
32+
- us-central1
33+
enforceInTransit: false

tests/apichecks/testdata/exceptions/missingfields.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3187,7 +3187,6 @@
31873187
[missing_field] crd=privatecacertificatetemplates.privateca.cnrm.cloud.google.com version=v1beta1: field ".spec.projectRef" is not set; neither 'external' nor 'name' are set
31883188
[missing_field] crd=projects.resourcemanager.cnrm.cloud.google.com version=v1beta1: field ".spec.billingAccountRef" is not set; neither 'external' nor 'name' are set
31893189
[missing_field] crd=pubsubtopics.pubsub.cnrm.cloud.google.com version=v1beta1: field ".spec.kmsKeyRef" is not set; neither 'external' nor 'name' are set
3190-
[missing_field] crd=pubsubtopics.pubsub.cnrm.cloud.google.com version=v1beta1: field ".spec.messageStoragePolicy.allowedPersistenceRegions[]" is not set in unstructured objects
31913190
[missing_field] crd=recaptchaenterprisekeys.recaptchaenterprise.cnrm.cloud.google.com version=v1beta1: field ".spec.wafSettings.wafFeature" is not set in unstructured objects
31923191
[missing_field] crd=recaptchaenterprisekeys.recaptchaenterprise.cnrm.cloud.google.com version=v1beta1: field ".spec.wafSettings.wafService" is not set in unstructured objects
31933192
[missing_field] crd=redisinstances.redis.cnrm.cloud.google.com version=v1beta1: field ".spec.alternativeLocationId" is not set in unstructured objects

0 commit comments

Comments
 (0)