Skip to content

Commit

Permalink
test: Add autogenerated tests to prepare for a refactor PR (googleapi…
Browse files Browse the repository at this point in the history
…s#1092)

* snapshot tests for create cluster

* change request to config

* More snapshot tests

* Refactor constants out

* Add generated testcases for partial cluster update

* Add header to constants file

* Add script to regenerate snapshots

Co-authored-by: Benjamin E. Coe <[email protected]>
  • Loading branch information
danieljbruce and bcoe authored Jun 17, 2022
1 parent bdca7d1 commit 1a2e3fb
Show file tree
Hide file tree
Showing 8 changed files with 666 additions and 2 deletions.
184 changes: 184 additions & 0 deletions __snapshots__/cluster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// 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
//
// https://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.

exports[
'Bigtable/Cluster setMetadata should provide the proper request options asynchronously 1'
] = {
input: {
id: 'my-cluster',
options: {
nodes: 2,
location: 'us-central1-b',
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'partialUpdateCluster',
reqOpts: {
cluster: {
name: 'projects/grape-spaceship-123/instances/i/clusters/my-cluster',
location: 'us-central1-b',
serveNodes: 2,
},
updateMask: {
paths: ['serve_nodes', 'cluster_config.cluster_autoscaling_config'],
},
},
gaxOpts: {},
},
},
};

exports[
'Bigtable/Cluster setMetadata should provide the proper request options asynchronously 2'
] = {
input: {
id: 'my-cluster',
options: {
nodes: 2,
storage: 'ssd',
location: 'us-central1-b',
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'partialUpdateCluster',
reqOpts: {
cluster: {
name: 'projects/grape-spaceship-123/instances/i/clusters/my-cluster',
location: 'us-central1-b',
serveNodes: 2,
storage: 'ssd',
},
updateMask: {
paths: ['serve_nodes', 'cluster_config.cluster_autoscaling_config'],
},
},
gaxOpts: {},
},
},
};

exports[
'Bigtable/Cluster setMetadata should provide the proper request options asynchronously 3'
] = {
input: {
id: 'my-cluster',
options: {
nodes: 2,
key: 'kms-key-name',
location: 'us-central1-b',
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'partialUpdateCluster',
reqOpts: {
cluster: {
name: 'projects/grape-spaceship-123/instances/i/clusters/my-cluster',
location: 'us-central1-b',
serveNodes: 2,
key: 'kms-key-name',
},
updateMask: {
paths: ['serve_nodes', 'cluster_config.cluster_autoscaling_config'],
},
},
gaxOpts: {},
},
},
};

exports[
'Bigtable/Cluster setMetadata should provide the proper request options asynchronously 4'
] = {
input: {
id: 'my-cluster',
options: {
nodes: 2,
encryption: {
kmsKeyName: 'kms-key-name',
},
location: 'us-central1-b',
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'partialUpdateCluster',
reqOpts: {
cluster: {
name: 'projects/grape-spaceship-123/instances/i/clusters/my-cluster',
location: 'us-central1-b',
serveNodes: 2,
encryption: {
kmsKeyName: 'kms-key-name',
},
},
updateMask: {
paths: ['serve_nodes', 'cluster_config.cluster_autoscaling_config'],
},
},
gaxOpts: {},
},
},
};

exports[
'Bigtable/Cluster setMetadata should provide the proper request options asynchronously 5'
] = {
input: {
id: 'my-cluster',
options: {
minServeNodes: 2,
maxServeNodes: 3,
cpuUtilizationPercent: 50,
location: 'us-central1-b',
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'partialUpdateCluster',
reqOpts: {
cluster: {
name: 'projects/grape-spaceship-123/instances/i/clusters/my-cluster',
location: 'us-central1-b',
clusterConfig: {
clusterAutoscalingConfig: {
autoscalingTargets: {
cpuUtilizationPercent: 50,
},
autoscalingLimits: {
minServeNodes: 2,
maxServeNodes: 3,
},
},
},
},
updateMask: {
paths: [
'cluster_config.cluster_autoscaling_config.autoscaling_limits.min_serve_nodes',
'cluster_config.cluster_autoscaling_config.autoscaling_limits.max_serve_nodes',
'cluster_config.cluster_autoscaling_config.autoscaling_targets.cpu_utilization_percent',
],
},
},
gaxOpts: {},
},
},
};
211 changes: 211 additions & 0 deletions __snapshots__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
// 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
//
// https://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.

exports[
'Bigtable createInstance should provide the proper request options asynchronously 1'
] = {
input: {
id: 'my-instance',
options: {
clusters: {
nodes: 2,
location: 'us-central1-b',
id: 'my-cluster',
},
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'createInstance',
reqOpts: {
parent: 'projects/test-project',
instanceId: 'my-instance',
instance: {
displayName: 'my-instance',
},
clusters: {
'my-cluster': {
location: 'projects/test-project/locations/us-central1-b',
serveNodes: 2,
defaultStorageType: 0,
},
},
},
},
},
};

exports[
'Bigtable createInstance should provide the proper request options asynchronously 2'
] = {
input: {
id: 'my-instance',
options: {
clusters: {
nodes: 2,
storage: 'ssd',
location: 'us-central1-b',
id: 'my-cluster',
},
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'createInstance',
reqOpts: {
parent: 'projects/test-project',
instanceId: 'my-instance',
instance: {
displayName: 'my-instance',
},
clusters: {
'my-cluster': {
location: 'projects/test-project/locations/us-central1-b',
serveNodes: 2,
defaultStorageType: 1,
},
},
},
},
},
};

exports[
'Bigtable createInstance should provide the proper request options asynchronously 3'
] = {
input: {
id: 'my-instance',
options: {
clusters: {
nodes: 2,
key: 'kms-key-name',
location: 'us-central1-b',
id: 'my-cluster',
},
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'createInstance',
reqOpts: {
parent: 'projects/test-project',
instanceId: 'my-instance',
instance: {
displayName: 'my-instance',
},
clusters: {
'my-cluster': {
location: 'projects/test-project/locations/us-central1-b',
serveNodes: 2,
defaultStorageType: 0,
encryptionConfig: {
kmsKeyName: 'kms-key-name',
},
},
},
},
},
},
};

exports[
'Bigtable createInstance should provide the proper request options asynchronously 4'
] = {
input: {
id: 'my-instance',
options: {
clusters: {
nodes: 2,
encryption: {
kmsKeyName: 'kms-key-name',
},
location: 'us-central1-b',
id: 'my-cluster',
},
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'createInstance',
reqOpts: {
parent: 'projects/test-project',
instanceId: 'my-instance',
instance: {
displayName: 'my-instance',
},
clusters: {
'my-cluster': {
location: 'projects/test-project/locations/us-central1-b',
serveNodes: 2,
defaultStorageType: 0,
encryptionConfig: {
kmsKeyName: 'kms-key-name',
},
},
},
},
},
},
};

exports[
'Bigtable createInstance should provide the proper request options asynchronously 5'
] = {
input: {
id: 'my-instance',
options: {
clusters: {
minServeNodes: 2,
maxServeNodes: 3,
cpuUtilizationPercent: 50,
location: 'us-central1-b',
id: 'my-cluster',
},
},
},
output: {
config: {
client: 'BigtableInstanceAdminClient',
method: 'createInstance',
reqOpts: {
parent: 'projects/test-project',
instanceId: 'my-instance',
instance: {
displayName: 'my-instance',
},
clusters: {
'my-cluster': {
location: 'projects/test-project/locations/us-central1-b',
clusterConfig: {
clusterAutoscalingConfig: {
autoscalingTargets: {
cpuUtilizationPercent: 50,
},
autoscalingLimits: {
minServeNodes: 2,
maxServeNodes: 3,
},
},
},
defaultStorageType: 0,
},
},
},
},
},
};
Loading

0 comments on commit 1a2e3fb

Please sign in to comment.