diff --git a/pkg/test/utils.go b/pkg/test/utils.go index 3fbe9e216e..88065e89d9 100644 --- a/pkg/test/utils.go +++ b/pkg/test/utils.go @@ -15,9 +15,11 @@ package test import ( + "fmt" "os" "path/filepath" "regexp" + "sigs.k8s.io/yaml" "strings" "testing" @@ -140,3 +142,63 @@ func IgnoreLeadingComments(s string) string { } return strings.TrimSpace(strings.Join(out, "\n")) + "\n" } + +func CompareGoldenObject(path string, got []byte) error { + writeGoldenOutput := os.Getenv("WRITE_GOLDEN_OUTPUT") != "" + want, err := os.ReadFile(path) + if err != nil { + if writeGoldenOutput && os.IsNotExist(err) { + // Expected when creating output for the first time + if err := os.WriteFile(path, got, 0644); err != nil { + return fmt.Errorf("failed to write golden output %s: %w", path, err) + } + fmt.Printf("wrote updated golden output to %s", path) + return nil + } else { + return fmt.Errorf("failed to read golden file %q: %w", path, err) + } + } + var wantMap, gotMap map[string]interface{} + err = yaml.Unmarshal(want, &wantMap) + if err != nil { + return err + } + err = yaml.Unmarshal(got, &gotMap) + if err != nil { + return err + } + if ok, err := compareNestedFields(wantMap, gotMap); !ok { + return err + } + return nil +} + +func compareNestedFields(wantMap, gotMap map[string]interface{}) (bool, error) { + for wantKey := range wantMap { + if _, exists := gotMap[wantKey]; !exists { + err := fmt.Errorf("field %s in the golden file is missing", wantKey) + return false, err + } + } + + for gotKey := range gotMap { + if _, exists := wantMap[gotKey]; !exists { + err := fmt.Errorf("field %s does not exist in golden file", gotKey) + return false, err + } + } + + // Check nested structures recursively + for wantKey, wantVal := range wantMap { + if gotVal, exists := gotMap[wantKey]; exists { + if wantNestedMap, ok1 := wantVal.(map[string]interface{}); ok1 { + if gotNestedMap, ok2 := gotVal.(map[string]interface{}); ok2 { + if ok, err := compareNestedFields(wantNestedMap, gotNestedMap); !ok { + return false, err + } + } + } + } + } + return true, nil +} diff --git a/scripts/github-actions/ga-object-schema-test.sh b/scripts/github-actions/ga-object-schema-test.sh new file mode 100755 index 0000000000..3251a68db6 --- /dev/null +++ b/scripts/github-actions/ga-object-schema-test.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# 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. +set -o errexit +set -o nounset +set -o pipefail +REPO_ROOT="$(git rev-parse --show-toplevel)" +source ${REPO_ROOT}/scripts/shared-vars-public.sh +cd ${REPO_ROOT} +source ${REPO_ROOT}/scripts/fetch_ext_bins.sh && \ + fetch_tools && \ + setup_envs + +cd ${REPO_ROOT}/ +echo "Running mock e2e object schema tests..." +E2E_KUBE_TARGET=envtest \ + RUN_E2E=1 E2E_GCP_TARGET=mock \ + go test -test.count=1 -timeout 3600s -v ./tests/e2e -run TestKRMObject/fixtures 2>&1 \ No newline at end of file diff --git a/tests/e2e/export.go b/tests/e2e/export.go index 373fa11519..9906c18781 100644 --- a/tests/e2e/export.go +++ b/tests/e2e/export.go @@ -15,6 +15,7 @@ package e2e import ( + "k8s.io/apimachinery/pkg/types" "path/filepath" "strings" @@ -95,3 +96,13 @@ func exportResourceAsUnstructured(h *create.Harness, obj *unstructured.Unstructu } return u } + +func getKRMObject(h *create.Harness, obj *unstructured.Unstructured) (*unstructured.Unstructured, error) { + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(obj.GroupVersionKind()) + id := types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()} + if err := h.GetClient().Get(h.Ctx, id, u); err != nil { + return nil, err + } + return u, nil +} diff --git a/tests/e2e/golden/object/_apikeyskeybasic.yaml b/tests/e2e/golden/object/_apikeyskeybasic.yaml index 45bc0737de..69904e1e7f 100644 --- a/tests/e2e/golden/object/_apikeyskeybasic.yaml +++ b/tests/e2e/golden/object/_apikeyskeybasic.yaml @@ -1,17 +1,3 @@ -# 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: apikeys.cnrm.cloud.google.com/v1alpha1 kind: APIKeysKey metadata: diff --git a/tests/e2e/golden/object/_billingaccountiampolicy.yaml b/tests/e2e/golden/object/_billingaccountiampolicy.yaml index 2d55719a67..b1c83eed1a 100644 --- a/tests/e2e/golden/object/_billingaccountiampolicy.yaml +++ b/tests/e2e/golden/object/_billingaccountiampolicy.yaml @@ -1,17 +1,3 @@ -# 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: iam.cnrm.cloud.google.com/v1beta1 kind: IAMPolicy metadata: diff --git a/tests/e2e/golden/object/_billingaccountiampolicymember.yaml b/tests/e2e/golden/object/_billingaccountiampolicymember.yaml index 9f80cfd988..fbfb1fc12f 100644 --- a/tests/e2e/golden/object/_billingaccountiampolicymember.yaml +++ b/tests/e2e/golden/object/_billingaccountiampolicymember.yaml @@ -1,17 +1,3 @@ -# 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: iam.cnrm.cloud.google.com/v1beta1 kind: IAMPolicyMember metadata: diff --git a/tests/e2e/golden/object/_certificatemanagercertificatemanageddns.yaml b/tests/e2e/golden/object/_certificatemanagercertificatemanageddns.yaml index d238fb3508..fe7561a1f3 100644 --- a/tests/e2e/golden/object/_certificatemanagercertificatemanageddns.yaml +++ b/tests/e2e/golden/object/_certificatemanagercertificatemanageddns.yaml @@ -1,17 +1,3 @@ -# 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: certificatemanager.cnrm.cloud.google.com/v1beta1 kind: CertificateManagerCertificate metadata: diff --git a/tests/e2e/golden/object/_certificatemanagercertificatemap.yaml b/tests/e2e/golden/object/_certificatemanagercertificatemap.yaml index a1864de993..9319e9b256 100644 --- a/tests/e2e/golden/object/_certificatemanagercertificatemap.yaml +++ b/tests/e2e/golden/object/_certificatemanagercertificatemap.yaml @@ -1,17 +1,3 @@ -# 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: certificatemanager.cnrm.cloud.google.com/v1beta1 kind: CertificateManagerCertificateMap metadata: diff --git a/tests/e2e/golden/object/_certificatemanagercertificatemapentry.yaml b/tests/e2e/golden/object/_certificatemanagercertificatemapentry.yaml index 2234606b08..8aa10f585c 100644 --- a/tests/e2e/golden/object/_certificatemanagercertificatemapentry.yaml +++ b/tests/e2e/golden/object/_certificatemanagercertificatemapentry.yaml @@ -1,17 +1,3 @@ -# 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: certificatemanager.cnrm.cloud.google.com/v1beta1 kind: CertificateManagerCertificateMapEntry metadata: diff --git a/tests/e2e/golden/object/_certificatemanagercertificateselfmanaged.yaml b/tests/e2e/golden/object/_certificatemanagercertificateselfmanaged.yaml index bac03d399c..d30509eca8 100644 --- a/tests/e2e/golden/object/_certificatemanagercertificateselfmanaged.yaml +++ b/tests/e2e/golden/object/_certificatemanagercertificateselfmanaged.yaml @@ -1,17 +1,3 @@ -# 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: certificatemanager.cnrm.cloud.google.com/v1beta1 kind: CertificateManagerCertificate metadata: diff --git a/tests/e2e/golden/object/_certificatemanagerdnsauthorization.yaml b/tests/e2e/golden/object/_certificatemanagerdnsauthorization.yaml index ee232d733e..cb41e28cab 100644 --- a/tests/e2e/golden/object/_certificatemanagerdnsauthorization.yaml +++ b/tests/e2e/golden/object/_certificatemanagerdnsauthorization.yaml @@ -1,17 +1,3 @@ -# 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: certificatemanager.cnrm.cloud.google.com/v1beta1 kind: CertificateManagerDNSAuthorization metadata: diff --git a/tests/e2e/golden/object/_computediskfromsourcedisk.yaml b/tests/e2e/golden/object/_computediskfromsourcedisk.yaml index de8e14e424..330dea3a8c 100644 --- a/tests/e2e/golden/object/_computediskfromsourcedisk.yaml +++ b/tests/e2e/golden/object/_computediskfromsourcedisk.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeDisk metadata: diff --git a/tests/e2e/golden/object/_computenetwork.yaml b/tests/e2e/golden/object/_computenetwork.yaml index b0ecdf9d1d..a2e3942213 100644 --- a/tests/e2e/golden/object/_computenetwork.yaml +++ b/tests/e2e/golden/object/_computenetwork.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeNetwork metadata: diff --git a/tests/e2e/golden/object/_computenodegroup.yaml b/tests/e2e/golden/object/_computenodegroup.yaml index 9b69e135de..46bb83ff1e 100644 --- a/tests/e2e/golden/object/_computenodegroup.yaml +++ b/tests/e2e/golden/object/_computenodegroup.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeNodeGroup metadata: diff --git a/tests/e2e/golden/object/_computenodetemplate.yaml b/tests/e2e/golden/object/_computenodetemplate.yaml index c10ef20ba7..b03df5f659 100644 --- a/tests/e2e/golden/object/_computenodetemplate.yaml +++ b/tests/e2e/golden/object/_computenodetemplate.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeNodeTemplate metadata: diff --git a/tests/e2e/golden/object/_computesubnetwork.yaml b/tests/e2e/golden/object/_computesubnetwork.yaml index 8d84a90f7f..0c981f72d0 100644 --- a/tests/e2e/golden/object/_computesubnetwork.yaml +++ b/tests/e2e/golden/object/_computesubnetwork.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeSubnetwork metadata: diff --git a/tests/e2e/golden/object/_containerattachedcluster.yaml b/tests/e2e/golden/object/_containerattachedcluster.yaml index 11c15931ab..c7b55b9e99 100644 --- a/tests/e2e/golden/object/_containerattachedcluster.yaml +++ b/tests/e2e/golden/object/_containerattachedcluster.yaml @@ -1,17 +1,3 @@ -# 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: containerattached.cnrm.cloud.google.com/v1beta1 kind: ContainerAttachedCluster metadata: diff --git a/tests/e2e/golden/object/_edgecontainercluster.yaml b/tests/e2e/golden/object/_edgecontainercluster.yaml index 79475e2f33..991ed55dc0 100644 --- a/tests/e2e/golden/object/_edgecontainercluster.yaml +++ b/tests/e2e/golden/object/_edgecontainercluster.yaml @@ -1,17 +1,3 @@ -# 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: edgecontainer.cnrm.cloud.google.com/v1beta1 kind: EdgeContainerCluster metadata: diff --git a/tests/e2e/golden/object/_edgecontainernodepool.yaml b/tests/e2e/golden/object/_edgecontainernodepool.yaml index 896ada2aed..40295648d6 100644 --- a/tests/e2e/golden/object/_edgecontainernodepool.yaml +++ b/tests/e2e/golden/object/_edgecontainernodepool.yaml @@ -1,17 +1,3 @@ -# 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: edgecontainer.cnrm.cloud.google.com/v1beta1 kind: EdgeContainerNodePool metadata: diff --git a/tests/e2e/golden/object/_edgenetworknetwork.yaml b/tests/e2e/golden/object/_edgenetworknetwork.yaml index e130bdbaa1..479c379346 100644 --- a/tests/e2e/golden/object/_edgenetworknetwork.yaml +++ b/tests/e2e/golden/object/_edgenetworknetwork.yaml @@ -1,17 +1,3 @@ -# 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: edgenetwork.cnrm.cloud.google.com/v1beta1 kind: EdgeNetworkNetwork metadata: diff --git a/tests/e2e/golden/object/_edgenetworksubnet.yaml b/tests/e2e/golden/object/_edgenetworksubnet.yaml index 3e98f25681..eb1896fc7f 100644 --- a/tests/e2e/golden/object/_edgenetworksubnet.yaml +++ b/tests/e2e/golden/object/_edgenetworksubnet.yaml @@ -1,17 +1,3 @@ -# 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: edgenetwork.cnrm.cloud.google.com/v1beta1 kind: EdgeNetworkSubnet metadata: diff --git a/tests/e2e/golden/object/_folderid.yaml b/tests/e2e/golden/object/_folderid.yaml index 20a1bc9eeb..6bedc95679 100644 --- a/tests/e2e/golden/object/_folderid.yaml +++ b/tests/e2e/golden/object/_folderid.yaml @@ -1,17 +1,3 @@ -# 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: resourcemanager.cnrm.cloud.google.com/v1beta1 kind: Project metadata: @@ -39,5 +25,5 @@ status: reason: UpToDate status: "True" type: Ready - number: "2663254680" + number: "2691238687" observedGeneration: 3 diff --git a/tests/e2e/golden/object/_forcedestroy.yaml b/tests/e2e/golden/object/_forcedestroy.yaml index cdb550c232..9a842c78e4 100644 --- a/tests/e2e/golden/object/_forcedestroy.yaml +++ b/tests/e2e/golden/object/_forcedestroy.yaml @@ -1,17 +1,3 @@ -# 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: diff --git a/tests/e2e/golden/object/_globalcomputeaddress.yaml b/tests/e2e/golden/object/_globalcomputeaddress.yaml index a793e90d40..4f6698946d 100644 --- a/tests/e2e/golden/object/_globalcomputeaddress.yaml +++ b/tests/e2e/golden/object/_globalcomputeaddress.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeAddress metadata: diff --git a/tests/e2e/golden/object/_httpsfunction.yaml b/tests/e2e/golden/object/_httpsfunction.yaml index 4e63a26479..4edd846e88 100644 --- a/tests/e2e/golden/object/_httpsfunction.yaml +++ b/tests/e2e/golden/object/_httpsfunction.yaml @@ -1,17 +1,3 @@ -# 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: cloudfunctions.cnrm.cloud.google.com/v1beta1 kind: CloudFunctionsFunction metadata: diff --git a/tests/e2e/golden/object/_iamserviceaccount.yaml b/tests/e2e/golden/object/_iamserviceaccount.yaml index 8e7ea44937..f6ec27503e 100644 --- a/tests/e2e/golden/object/_iamserviceaccount.yaml +++ b/tests/e2e/golden/object/_iamserviceaccount.yaml @@ -1,17 +1,3 @@ -# 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: iam.cnrm.cloud.google.com/v1beta1 kind: IAMServiceAccount metadata: diff --git a/tests/e2e/golden/object/_networkservicesmesh.yaml b/tests/e2e/golden/object/_networkservicesmesh.yaml index b486036e03..990c6f0a12 100644 --- a/tests/e2e/golden/object/_networkservicesmesh.yaml +++ b/tests/e2e/golden/object/_networkservicesmesh.yaml @@ -1,17 +1,3 @@ -# 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: networkservices.cnrm.cloud.google.com/v1beta1 kind: NetworkServicesMesh metadata: diff --git a/tests/e2e/golden/object/_organizationiampolicy.yaml b/tests/e2e/golden/object/_organizationiampolicy.yaml index df263ffac5..232772acd2 100644 --- a/tests/e2e/golden/object/_organizationiampolicy.yaml +++ b/tests/e2e/golden/object/_organizationiampolicy.yaml @@ -1,17 +1,3 @@ -# 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: iam.cnrm.cloud.google.com/v1beta1 kind: IAMPolicy metadata: diff --git a/tests/e2e/golden/object/_organizationiampolicymember.yaml b/tests/e2e/golden/object/_organizationiampolicymember.yaml index b3850fda03..94652e52ec 100644 --- a/tests/e2e/golden/object/_organizationiampolicymember.yaml +++ b/tests/e2e/golden/object/_organizationiampolicymember.yaml @@ -1,17 +1,3 @@ -# 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: iam.cnrm.cloud.google.com/v1beta1 kind: IAMPolicyMember metadata: diff --git a/tests/e2e/golden/object/_privatecacapool.yaml b/tests/e2e/golden/object/_privatecacapool.yaml index d81c3f4af0..cacf6f6e86 100644 --- a/tests/e2e/golden/object/_privatecacapool.yaml +++ b/tests/e2e/golden/object/_privatecacapool.yaml @@ -1,17 +1,3 @@ -# 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: privateca.cnrm.cloud.google.com/v1beta1 kind: PrivateCACAPool metadata: diff --git a/tests/e2e/golden/object/_projectinfolder.yaml b/tests/e2e/golden/object/_projectinfolder.yaml index a928e1d685..4471657a93 100644 --- a/tests/e2e/golden/object/_projectinfolder.yaml +++ b/tests/e2e/golden/object/_projectinfolder.yaml @@ -1,17 +1,3 @@ -# 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: resourcemanager.cnrm.cloud.google.com/v1beta1 kind: Project metadata: @@ -39,5 +25,5 @@ status: reason: UpToDate status: "True" type: Ready - number: "2699168562" + number: "2708146942" observedGeneration: 3 diff --git a/tests/e2e/golden/object/_projectinorg.yaml b/tests/e2e/golden/object/_projectinorg.yaml index 60a34b7a30..df120269e7 100644 --- a/tests/e2e/golden/object/_projectinorg.yaml +++ b/tests/e2e/golden/object/_projectinorg.yaml @@ -1,17 +1,3 @@ -# 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: resourcemanager.cnrm.cloud.google.com/v1beta1 kind: Project metadata: @@ -39,5 +25,5 @@ status: reason: UpToDate status: "True" type: Ready - number: "2575108777" + number: "2843610072" observedGeneration: 3 diff --git a/tests/e2e/golden/object/_projectmovedfoldertofolder.yaml b/tests/e2e/golden/object/_projectmovedfoldertofolder.yaml index 306fbec105..35a6e6f0d8 100644 --- a/tests/e2e/golden/object/_projectmovedfoldertofolder.yaml +++ b/tests/e2e/golden/object/_projectmovedfoldertofolder.yaml @@ -1,17 +1,3 @@ -# 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: resourcemanager.cnrm.cloud.google.com/v1beta1 kind: Project metadata: @@ -38,5 +24,5 @@ status: reason: UpToDate status: "True" type: Ready - number: "2613119570" + number: "2606828146" observedGeneration: 3 diff --git a/tests/e2e/golden/object/_regionalcomputeaddress.yaml b/tests/e2e/golden/object/_regionalcomputeaddress.yaml index 44285b58b9..1614d63220 100644 --- a/tests/e2e/golden/object/_regionalcomputeaddress.yaml +++ b/tests/e2e/golden/object/_regionalcomputeaddress.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeAddress metadata: diff --git a/tests/e2e/golden/object/_regionalcomputedisk.yaml b/tests/e2e/golden/object/_regionalcomputedisk.yaml index b97da34fd6..b85547a06b 100644 --- a/tests/e2e/golden/object/_regionalcomputedisk.yaml +++ b/tests/e2e/golden/object/_regionalcomputedisk.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeDisk metadata: diff --git a/tests/e2e/golden/object/_secretmanagersecretversion.yaml b/tests/e2e/golden/object/_secretmanagersecretversion.yaml index 42be976044..cb56091ba9 100644 --- a/tests/e2e/golden/object/_secretmanagersecretversion.yaml +++ b/tests/e2e/golden/object/_secretmanagersecretversion.yaml @@ -1,17 +1,3 @@ -# 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: secretmanager.cnrm.cloud.google.com/v1beta1 kind: SecretManagerSecretVersion metadata: diff --git a/tests/e2e/golden/object/_service.yaml b/tests/e2e/golden/object/_service.yaml deleted file mode 100644 index e459b79626..0000000000 --- a/tests/e2e/golden/object/_service.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# 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: serviceusage.cnrm.cloud.google.com/v1beta1 -kind: Service -metadata: - annotations: - cnrm.cloud.google.com/disable-dependent-services: "false" - cnrm.cloud.google.com/management-conflict-prevention-policy: none - cnrm.cloud.google.com/state-into-spec: merge - finalizers: - - cnrm.cloud.google.com/finalizer - - cnrm.cloud.google.com/deletion-defender - generation: 2 - labels: - cnrm-test: "true" - name: runtimeconfig.googleapis.com - namespace: ${uniqueId} -spec: - projectRef: - external: ${projectId} - resourceID: runtimeconfig.googleapis.com -status: - conditions: - - lastTransitionTime: "1970-01-01T00:00:00Z" - message: The resource is up to date - reason: UpToDate - status: "True" - type: Ready - observedGeneration: 2 diff --git a/tests/e2e/golden/object/_serviceidentity.yaml b/tests/e2e/golden/object/_serviceidentity.yaml index e070190e14..a69fd0fa83 100644 --- a/tests/e2e/golden/object/_serviceidentity.yaml +++ b/tests/e2e/golden/object/_serviceidentity.yaml @@ -1,17 +1,3 @@ -# 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: serviceusage.cnrm.cloud.google.com/v1beta1 kind: ServiceIdentity metadata: diff --git a/tests/e2e/golden/object/_storagebucket#01.yaml b/tests/e2e/golden/object/_storagebucket#01.yaml index 144f8146f4..ae30ae0840 100644 --- a/tests/e2e/golden/object/_storagebucket#01.yaml +++ b/tests/e2e/golden/object/_storagebucket#01.yaml @@ -1,17 +1,3 @@ -# 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: diff --git a/tests/e2e/golden/object/_storagebucket.yaml b/tests/e2e/golden/object/_storagebucket.yaml index bb172f7bff..e337673cc7 100644 --- a/tests/e2e/golden/object/_storagebucket.yaml +++ b/tests/e2e/golden/object/_storagebucket.yaml @@ -1,17 +1,3 @@ -# 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: diff --git a/tests/e2e/golden/object/_tagkeyorgbasic.yaml b/tests/e2e/golden/object/_tagkeyorgbasic.yaml index 83aac9e4f4..86c862e583 100644 --- a/tests/e2e/golden/object/_tagkeyorgbasic.yaml +++ b/tests/e2e/golden/object/_tagkeyorgbasic.yaml @@ -1,17 +1,3 @@ -# 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: tags.cnrm.cloud.google.com/v1beta1 kind: TagsTagKey metadata: @@ -29,7 +15,7 @@ metadata: spec: description: For keyname resources. parent: organizations/123450001 - resourceID: "1711560500385836892" + resourceID: "1711574405476297067" shortName: keyname${uniqueId} status: conditions: @@ -39,7 +25,7 @@ status: status: "True" type: Ready createTime: "1970-01-01T00:00:00Z" - name: "1711560500385836892" + name: "1711574405476297067" namespacedName: 123450001/keyname${uniqueId} observedGeneration: 2 updateTime: "1970-01-01T00:00:00Z" diff --git a/tests/e2e/golden/object/_tagkeyprojectbasic.yaml b/tests/e2e/golden/object/_tagkeyprojectbasic.yaml index 08c433cfb6..2b9815eb2c 100644 --- a/tests/e2e/golden/object/_tagkeyprojectbasic.yaml +++ b/tests/e2e/golden/object/_tagkeyprojectbasic.yaml @@ -1,17 +1,3 @@ -# 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: tags.cnrm.cloud.google.com/v1beta1 kind: TagsTagKey metadata: @@ -29,7 +15,7 @@ metadata: spec: description: For keyname resources. parent: projects/${projectId} - resourceID: "1711560520243359049" + resourceID: "1711574425656635608" shortName: keyname${uniqueId} status: conditions: @@ -39,7 +25,7 @@ status: status: "True" type: Ready createTime: "1970-01-01T00:00:00Z" - name: "1711560520243359049" + name: "1711574425656635608" namespacedName: ${projectId}/keyname${uniqueId} observedGeneration: 2 updateTime: "1970-01-01T00:00:00Z" diff --git a/tests/e2e/golden/object/_userspecifiedresourceidandservergeneratedid.yaml b/tests/e2e/golden/object/_userspecifiedresourceidandservergeneratedid.yaml index 56027c72d8..b769974417 100644 --- a/tests/e2e/golden/object/_userspecifiedresourceidandservergeneratedid.yaml +++ b/tests/e2e/golden/object/_userspecifiedresourceidandservergeneratedid.yaml @@ -1,17 +1,3 @@ -# 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: resourcemanager.cnrm.cloud.google.com/v1beta1 kind: Project metadata: @@ -39,5 +25,5 @@ status: reason: UpToDate status: "True" type: Ready - number: "2664106610" + number: "2689993439" observedGeneration: 2 diff --git a/tests/e2e/golden/object/_vertexaitensorboard.yaml b/tests/e2e/golden/object/_vertexaitensorboard.yaml index 87fabef82e..04032084b3 100644 --- a/tests/e2e/golden/object/_vertexaitensorboard.yaml +++ b/tests/e2e/golden/object/_vertexaitensorboard.yaml @@ -1,17 +1,3 @@ -# 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: vertexai.cnrm.cloud.google.com/v1alpha1 kind: VertexAITensorboard metadata: @@ -32,9 +18,9 @@ spec: projectRef: external: ${projectId} region: us-central1 - resourceID: projects/${projectNumber}/locations/us-central1/tensorboards/1711560538502315374 + resourceID: projects/${projectNumber}/locations/us-central1/tensorboards/1711574445618644362 status: - blobStoragePathPrefix: cloud-ai-platform-d5dd8890-08c5-4dbd-ac97-f151ecd27419 + blobStoragePathPrefix: cloud-ai-platform-f4d61eec-b7b6-42ef-a03c-1bf0e32db716 conditions: - lastTransitionTime: "1970-01-01T00:00:00Z" message: The resource is up to date @@ -42,6 +28,6 @@ status: status: "True" type: Ready createTime: "1970-01-01T00:00:00Z" - name: projects/${projectNumber}/locations/us-central1/tensorboards/1711560538502315374 + name: projects/${projectNumber}/locations/us-central1/tensorboards/1711574445618644362 observedGeneration: 3 updateTime: "1970-01-01T00:00:00Z" diff --git a/tests/e2e/golden/object/_zonalcomputedisk.yaml b/tests/e2e/golden/object/_zonalcomputedisk.yaml index f91241f356..f2b9d75423 100644 --- a/tests/e2e/golden/object/_zonalcomputedisk.yaml +++ b/tests/e2e/golden/object/_zonalcomputedisk.yaml @@ -1,17 +1,3 @@ -# 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: compute.cnrm.cloud.google.com/v1beta1 kind: ComputeDisk metadata: diff --git a/tests/e2e/object_test.go b/tests/e2e/object_test.go deleted file mode 100644 index e3d4431da5..0000000000 --- a/tests/e2e/object_test.go +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2022 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. - -package e2e - -import ( - "context" - "fmt" - "k8s.io/apimachinery/pkg/types" - "os" - "path/filepath" - "sigs.k8s.io/yaml" - "strings" - "testing" - - "github.com/GoogleCloudPlatform/k8s-config-connector/config/tests/samples/create" - testgcp "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/gcp" - "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/resourcefixture" - testvariable "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/resourcefixture/variable" - testyaml "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/yaml" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -) - -func TestKubeObject(t *testing.T) { - if os.Getenv("RUN_E2E") == "" { - t.Skip("RUN_E2E not set; skipping") - } - - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - t.Cleanup(func() { - cancel() - }) - - t.Run("fixtures", func(t *testing.T) { - fixtures := resourcefixture.Load(t) - for _, fixture := range fixtures { - fixture := fixture - t.Run(fixture.Name, func(t *testing.T) { - uniqueID := testvariable.NewUniqueID() - loadFixture := func(project testgcp.GCPProject) (*unstructured.Unstructured, create.CreateDeleteTestOptions) { - primaryResource := bytesToUnstructured(t, fixture.Create, uniqueID, project) - - opt := create.CreateDeleteTestOptions{CleanupResources: true} - opt.Create = append(opt.Create, primaryResource) - - if fixture.Dependencies != nil { - dependencyYamls := testyaml.SplitYAML(t, fixture.Dependencies) - for _, dependBytes := range dependencyYamls { - depUnstruct := bytesToUnstructured(t, dependBytes, uniqueID, project) - opt.Create = append(opt.Create, depUnstruct) - } - } - - if fixture.Update != nil { - u := bytesToUnstructured(t, fixture.Update, uniqueID, project) - opt.Updates = append(opt.Updates, u) - } - return primaryResource, opt - } - - // Quickly load the fixture with a dummy project, just to see if we should skip it - { - _, opt := loadFixture(testgcp.GCPProject{ProjectID: "test-skip", ProjectNumber: 123456789}) - create.MaybeSkip(t, fixture.Name, opt.Create) - } - - h := create.NewHarness(ctx, t) - project := h.Project - - primaryResource, opt := loadFixture(project) - - exportResources := []*unstructured.Unstructured{primaryResource} - - create.SetupNamespacesAndApplyDefaults(h, opt.Create, project) - - opt.CleanupResources = false // We delete explicitly below - - create.RunCreateDeleteTest(h, opt) - - for _, obj := range exportResources { - u := &unstructured.Unstructured{} - u.SetGroupVersionKind(obj.GroupVersionKind()) - id := types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()} - if err := h.GetClient().Get(ctx, id, u); err != nil { - t.Errorf("failed to get kube object: %v", err) - } else { - if err := normalizeObject(u, project, uniqueID); err != nil { - t.Fatalf("error from normalizeObject: %v", err) - } - got, err := yaml.Marshal(u) - if err != nil { - t.Errorf("failed to convert kube object to yaml: %v", err) - } - dir := "golden/object/" - pieces := strings.Split(t.Name(), "/") - var testName string - if len(pieces) > 0 { - testName = pieces[len(pieces)-1] - } else { - t.Errorf("failed to get test name: %v", err) - } - // File name looks like _testname.yaml - expectedPath := filepath.Join(dir, fmt.Sprintf("_%v.yaml", testName)) - err = compareGoldenObject(expectedPath, got) - if err != nil { - t.Fatalf("unexpected diff in %s: %s", expectedPath, err) - } - } - } - create.DeleteResources(h, opt) - }) - } - }) - // Do a cleanup while we can still handle the error. - t.Logf("shutting down manager") - cancel() -} - -func compareGoldenObject(path string, got []byte) error { - writeGoldenOutput := os.Getenv("WRITE_GOLDEN_OUTPUT") != "" - want, err := os.ReadFile(path) - if err != nil { - if writeGoldenOutput && os.IsNotExist(err) { - // Expected when creating output for the first time - if err := os.WriteFile(path, got, 0644); err != nil { - return fmt.Errorf("failed to write golden output %s: %v", path, err) - } - fmt.Printf("wrote updated golden output to %s", path) - return nil - } else { - return fmt.Errorf("failed to read golden file %q: %v", path, err) - } - } - var wantMap, gotMap map[string]interface{} - yaml.Unmarshal(want, &wantMap) - yaml.Unmarshal(got, &gotMap) - if ok, err := compareNestedFields(wantMap, gotMap); !ok { - return err - } - return nil -} - -func compareNestedFields(wantMap, gotMap map[string]interface{}) (bool, error) { - for wantKey := range wantMap { - if _, exists := gotMap[wantKey]; !exists { - err := fmt.Errorf("field %s in the golden file is missing", wantKey) - return false, err - } - } - - for gotKey := range gotMap { - if _, exists := wantMap[gotKey]; !exists { - err := fmt.Errorf("field %s does not exist in golden file", gotKey) - return false, err - } - } - - // Check nested structures recursively - for wantKey, wantVal := range wantMap { - if gotVal, exists := gotMap[wantKey]; exists { - if wantNestedMap, ok1 := wantVal.(map[string]interface{}); ok1 { - if gotNestedMap, ok2 := gotVal.(map[string]interface{}); ok2 { - if ok, err := compareNestedFields(wantNestedMap, gotNestedMap); !ok { - return false, err - } - } - } - } - } - return true, nil -} diff --git a/tests/e2e/unified_test.go b/tests/e2e/unified_test.go index 9a7d91790b..2c8f77d2c6 100644 --- a/tests/e2e/unified_test.go +++ b/tests/e2e/unified_test.go @@ -25,6 +25,7 @@ import ( "net/http" "os" "path/filepath" + "sigs.k8s.io/yaml" "strings" "testing" @@ -105,6 +106,15 @@ func TestPauseInSeries(t *testing.T) { testFixturesInSeries(ctx, t, true, cancel) } +func TestKRMObject(t *testing.T) { + ctx := context.Background() + ctx, cancel := context.WithCancel(ctx) + t.Cleanup(func() { + cancel() + }) + testFixturesInSeries(ctx, t, false, cancel) +} + func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, cancel context.CancelFunc) { t.Helper() @@ -274,11 +284,40 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, can create.RunCreateDeleteTest(h, opt) for _, obj := range exportResources { + // Construct file path to save golden files + dir := "golden/" + pieces := strings.Split(t.Name(), "/") + var testName string + if len(pieces) > 0 { + testName = pieces[len(pieces)-1] + } else { + t.Errorf("failed to get test name") + } + // Golden test exported GCP object got := exportResource(h, obj) if got != "" { - expectedPath := filepath.Join(fixture.SourceDir, "export.yaml") + expectedPath := filepath.Join(dir, fmt.Sprintf("export/_%v.yaml", testName)) h.CompareGoldenFile(expectedPath, string(got), IgnoreComments, ReplaceString(project.ProjectID, "example-project-id")) } + // Golden test KRM object schema + u, err := getKRMObject(h, obj) + if u == nil { + t.Errorf("failed to get KRM object: %v", err) + } else { + if err := normalizeObject(u, project, uniqueID); err != nil { + t.Fatalf("error from normalizeObject: %v", err) + } + got, err := yaml.Marshal(u) + if err != nil { + t.Errorf("failed to convert KRM object to yaml: %v", err) + } + // File name looks like _testname.yaml + expectedPath := filepath.Join(dir, fmt.Sprintf("object/_%v.yaml", testName)) + err = test.CompareGoldenObject(expectedPath, got) + if err != nil { + t.Fatalf("unexpected diff in %s: %s", expectedPath, err) + } + } } if testPause {