Skip to content

Commit

Permalink
tests: Create test scenario for force-set-field powertool
Browse files Browse the repository at this point in the history
Changing the location of a StorageBucket is a good example usage.
  • Loading branch information
justinsb authored and maqiuyujoyce committed May 24, 2024
1 parent 27d9dba commit 12a1e42
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


StorageBucket ${projectID}/storagebucket-${uniqueId}:
spec:
location: US -> EU


applying changes
305 changes: 305 additions & 0 deletions tests/e2e/testdata/scenarios/powertool_set_bucket_location/_http00.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
GET https://storage.googleapis.com/storage/v1/b/storagebucket-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
X-Goog-Api-Client: gl-go/1.22.0 gdcl/0.160.0

404 Not Found
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json; charset=UTF-8
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: UploadServer
Vary: Origin
Vary: X-Origin

{
"error": {
"code": 404,
"errors": [
{
"domain": "global",
"message": "The specified bucket does not exist.",
"reason": "notFound"
}
],
"message": "The specified bucket does not exist."
}
}

---

POST https://storage.googleapis.com/storage/v1/b?alt=json&prettyPrint=false&project=${projectId}
Content-Type: application/json
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
X-Goog-Api-Client: gl-go/1.22.0 gdcl/0.160.0

{
"iamConfiguration": {
"uniformBucketLevelAccess": {
"enabled": false
}
},
"labels": {
"label-one": "value-one",
"managed-by-cnrm": "true"
},
"lifecycle": {
"rule": [
{
"action": {
"type": "Delete"
},
"condition": {
"age": 7
}
}
]
},
"name": "storagebucket-${uniqueId}",
"storageClass": "STANDARD",
"versioning": {
"enabled": false
}
}

200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json; charset=UTF-8
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: UploadServer
Vary: Origin
Vary: X-Origin

{
"etag": "abcdef0123A=",
"iamConfiguration": {
"bucketPolicyOnly": {
"enabled": false
},
"publicAccessPrevention": "inherited",
"uniformBucketLevelAccess": {
"enabled": false
}
},
"id": "000000000000000000000",
"kind": "storage#bucket",
"labels": {
"label-one": "value-one",
"managed-by-cnrm": "true"
},
"lifecycle": {
"rule": [
{
"action": {
"type": "Delete"
},
"condition": {
"age": 7
}
}
]
},
"location": "US",
"locationType": "multi-region",
"metageneration": "1",
"name": "storagebucket-${uniqueId}",
"projectNumber": "${projectNumber}",
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/storagebucket-${uniqueId}",
"softDeletePolicy": {
"effectiveTime": "2024-04-01T12:34:56.123456Z",
"retentionDurationSeconds": "604800"
},
"storageClass": "STANDARD",
"timeCreated": "2024-04-01T12:34:56.123456Z",
"updated": "2024-04-01T12:34:56.123456Z",
"versioning": {
"enabled": false
}
}

---

GET https://storage.googleapis.com/storage/v1/b/storagebucket-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
X-Goog-Api-Client: gl-go/1.22.0 gdcl/0.160.0

200 OK
Cache-Control: private, max-age=0, must-revalidate, no-transform
Content-Type: application/json; charset=UTF-8
Expires: {now+0m}
Server: UploadServer
Vary: Origin
Vary: X-Origin

{
"etag": "abcdef0123A=",
"iamConfiguration": {
"bucketPolicyOnly": {
"enabled": false
},
"publicAccessPrevention": "inherited",
"uniformBucketLevelAccess": {
"enabled": false
}
},
"id": "000000000000000000000",
"kind": "storage#bucket",
"labels": {
"label-one": "value-one",
"managed-by-cnrm": "true"
},
"lifecycle": {
"rule": [
{
"action": {
"type": "Delete"
},
"condition": {
"age": 7
}
}
]
},
"location": "US",
"locationType": "multi-region",
"metageneration": "1",
"name": "storagebucket-${uniqueId}",
"projectNumber": "${projectNumber}",
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/storagebucket-${uniqueId}",
"softDeletePolicy": {
"effectiveTime": "2024-04-01T12:34:56.123456Z",
"retentionDurationSeconds": "604800"
},
"storageClass": "STANDARD",
"timeCreated": "2024-04-01T12:34:56.123456Z",
"updated": "2024-04-01T12:34:56.123456Z",
"versioning": {
"enabled": false
}
}

---

GET https://storage.googleapis.com/storage/v1/b/storagebucket-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
X-Goog-Api-Client: gl-go/1.22.0 gdcl/0.160.0

200 OK
Cache-Control: private, max-age=0, must-revalidate, no-transform
Content-Type: application/json; charset=UTF-8
Expires: {now+0m}
Server: UploadServer
Vary: Origin
Vary: X-Origin

{
"etag": "abcdef0123A=",
"iamConfiguration": {
"bucketPolicyOnly": {
"enabled": false
},
"publicAccessPrevention": "inherited",
"uniformBucketLevelAccess": {
"enabled": false
}
},
"id": "000000000000000000000",
"kind": "storage#bucket",
"labels": {
"label-one": "value-one",
"managed-by-cnrm": "true"
},
"lifecycle": {
"rule": [
{
"action": {
"type": "Delete"
},
"condition": {
"age": 7
}
}
]
},
"location": "US",
"locationType": "multi-region",
"metageneration": "1",
"name": "storagebucket-${uniqueId}",
"projectNumber": "${projectNumber}",
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/storagebucket-${uniqueId}",
"softDeletePolicy": {
"effectiveTime": "2024-04-01T12:34:56.123456Z",
"retentionDurationSeconds": "604800"
},
"storageClass": "STANDARD",
"timeCreated": "2024-04-01T12:34:56.123456Z",
"updated": "2024-04-01T12:34:56.123456Z",
"versioning": {
"enabled": false
}
}

---

GET https://storage.googleapis.com/storage/v1/b/storagebucket-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
X-Goog-Api-Client: gl-go/1.22.0 gdcl/0.160.0

200 OK
Cache-Control: private, max-age=0, must-revalidate, no-transform
Content-Type: application/json; charset=UTF-8
Expires: {now+0m}
Server: UploadServer
Vary: Origin
Vary: X-Origin

{
"etag": "abcdef0123A=",
"iamConfiguration": {
"bucketPolicyOnly": {
"enabled": false
},
"publicAccessPrevention": "inherited",
"uniformBucketLevelAccess": {
"enabled": false
}
},
"id": "000000000000000000000",
"kind": "storage#bucket",
"labels": {
"label-one": "value-one",
"managed-by-cnrm": "true"
},
"lifecycle": {
"rule": [
{
"action": {
"type": "Delete"
},
"condition": {
"age": 7
}
}
]
},
"location": "US",
"locationType": "multi-region",
"metageneration": "1",
"name": "storagebucket-${uniqueId}",
"projectNumber": "${projectNumber}",
"rpo": "DEFAULT",
"selfLink": "https://www.googleapis.com/storage/v1/b/storagebucket-${uniqueId}",
"softDeletePolicy": {
"effectiveTime": "2024-04-01T12:34:56.123456Z",
"retentionDurationSeconds": "604800"
},
"storageClass": "STANDARD",
"timeCreated": "2024-04-01T12:34:56.123456Z",
"updated": "2024-04-01T12:34:56.123456Z",
"versioning": {
"enabled": false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: storage.cnrm.cloud.google.com/v1beta1
kind: StorageBucket
metadata:
annotations:
cnrm.cloud.google.com/management-conflict-prevention-policy: none
cnrm.cloud.google.com/project-id: ${projectId}
cnrm.cloud.google.com/state-into-spec: merge
finalizers:
- cnrm.cloud.google.com/finalizer
- cnrm.cloud.google.com/deletion-defender
generation: 2
labels:
label-one: value-one
name: storagebucket-${uniqueId}
namespace: ${projectId}
spec:
lifecycleRule:
- action:
type: Delete
condition:
age: 7
withState: ANY
location: US
publicAccessPrevention: inherited
resourceID: storagebucket-${uniqueId}
storageClass: STANDARD
versioning:
enabled: false
status:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: The resource is up to date
reason: UpToDate
status: "True"
type: Ready
observedGeneration: 2
selfLink: https://www.googleapis.com/storage/v1/b/storagebucket-${uniqueId}
url: gs://storagebucket-${uniqueId}
Loading

0 comments on commit 12a1e42

Please sign in to comment.