Skip to content

Commit

Permalink
Merge pull request #1696 from anhdle-sso/fix_cluster_typo
Browse files Browse the repository at this point in the history
Fix mock test for AlloyDB Cluster
  • Loading branch information
google-oss-prow[bot] committed May 8, 2024
2 parents a18413c + f0247a4 commit 0b8cc19
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 332 deletions.
2 changes: 1 addition & 1 deletion config/tests/samples/create/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func MaybeSkip(t *testing.T, name string, resources []*unstructured.Unstructured
}

switch gvk.GroupKind() {
case schema.GroupKind{Group: "alloydb.googleapis.com", Kind: "AlloyDBCluster"}:
case schema.GroupKind{Group: "alloydb.cnrm.cloud.google.com", Kind: "AlloyDBCluster"}:

case schema.GroupKind{Group: "apikeys.cnrm.cloud.google.com", Kind: "APIKeysKey"}:

Expand Down
2 changes: 1 addition & 1 deletion mockgcp/mockalloydb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *AlloyDBAdminV1) GetCluster(ctx context.Context, req *pb.GetClusterReque
}

func (s *AlloyDBAdminV1) CreateCluster(ctx context.Context, req *pb.CreateClusterRequest) (*longrunning.Operation, error) {
reqName := req.Parent + "/cluster/" + req.ClusterId
reqName := req.Parent + "/clusters/" + req.ClusterId
name, err := s.parseClusterName(reqName)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion mockgcp/mockalloydb/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type clusterName struct {
}

func (n *clusterName) String() string {
return "projects/" + n.Project.ID + "/locations/" + n.Location + "/repositories/" + n.ClusterName
return "projects/" + n.Project.ID + "/locations/" + n.Location + "/clusters/" + n.ClusterName
}

// parseClusterName parses a string into an alloyDBClusterName.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# 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: alloydb.cnrm.cloud.google.com/v1beta1
kind: AlloyDBCluster
metadata:
annotations:
cnrm.cloud.google.com/management-conflict-prevention-policy: none
cnrm.cloud.google.com/mutable-but-unreadable-fields: '{"spec":{"deletionPolicy":"DEFAULT","displayName":"test
alloydb cluster 2","initialUser":{"password":{"value":"postgres"},"user":"postgres"}}}'
cnrm.cloud.google.com/observed-secret-versions: (removed)
cnrm.cloud.google.com/state-into-spec: merge
finalizers:
- cnrm.cloud.google.com/finalizer
- cnrm.cloud.google.com/deletion-defender
generation: 3
labels:
cnrm-test: "true"
name: alloydbcluster-${uniqueId}
namespace: ${uniqueId}
spec:
automatedBackupPolicy:
backupWindow: 3600s
labels:
source: kcc-test
location: us-central1
timeBasedRetention:
retentionPeriod: 1209600s
weeklySchedule:
daysOfWeek:
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
- SUNDAY
startTimes:
- hours: 23
clusterType: PRIMARY
continuousBackupConfig:
enabled: true
recoveryWindowDays: 14
deletionPolicy: DEFAULT
displayName: test alloydb cluster 2
initialUser:
password:
value: postgres
user: postgres
location: us-central1
networkConfig:
networkRef:
name: default
networkRef:
external: projects/${projectNumber}/global/networks/default
projectRef:
external: ${projectId}
resourceID: alloydbcluster${uniqueId}
status:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: The resource is up to date
reason: UpToDate
status: "True"
type: Ready
continuousBackupInfo:
- enabledTime: "1970-01-01T00:00:00Z"
encryptionInfo:
- encryptionType: GOOGLE_DEFAULT_ENCRYPTION
schedule:
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
- SUNDAY
databaseVersion: POSTGRES_15
encryptionInfo:
- encryptionType: GOOGLE_DEFAULT_ENCRYPTION
name: projects/${projectId}/locations/us-central1/clusters/alloydbcluster${uniqueId}
observedGeneration: 3
uid: "12345678"
Loading

0 comments on commit 0b8cc19

Please sign in to comment.