Skip to content

Commit 45e0063

Browse files
committed
* Fix #93
Added tests for cluster auto scaling
1 parent 5f9184d commit 45e0063

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

.kitchen.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ suites:
5252
systems:
5353
- name: simple_regional
5454
backend: local
55+
- name: "simple_regional_beta"
56+
driver:
57+
root_module_directory: test/fixtures/simple_regional_beta
58+
verifier:
59+
systems:
60+
- name: simple_regional_beta
61+
backend: local
5562
- name: "simple_regional_with_networking"
5663
driver:
5764
root_module_directory: test/fixtures/simple_regional_with_networking

build/int.cloudbuild.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ steps:
8181
- verify simple-regional-local
8282
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
8383
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-local']
84+
- id: create simple-regional-beta-local
85+
waitFor:
86+
- prepare
87+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
88+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-regional-beta-local']
89+
- id: converge simple-regional-beta-local
90+
waitFor:
91+
- create simple-regional-beta-local
92+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
93+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-beta-local']
94+
- id: verify simple-regional-beta-local
95+
waitFor:
96+
- converge simple-regional-beta-local
97+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
98+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-beta-local']
99+
- id: destroy simple-regional-beta-local
100+
waitFor:
101+
- verify simple-regional-beta-local
102+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
103+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-beta-local']
84104
- id: create simple-regional-private-local
85105
waitFor:
86106
- prepare
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
project_id = attribute('project_id')
16+
location = attribute('location')
17+
cluster_name = attribute('cluster_name')
18+
19+
control "gcloud" do
20+
title "Google Compute Engine GKE cluster autoscaling configuration"
21+
describe command("gcloud --project=#{project_id} container clusters --zone=#{location} describe #{cluster_name} --format=json") do
22+
its(:exit_status) { should eq 0 }
23+
its(:stderr) { should eq '' }
24+
25+
let!(:data) do
26+
if subject.exit_status == 0
27+
JSON.parse(subject.stdout)
28+
else
29+
{}
30+
end
31+
end
32+
33+
describe "cluster-autoscaling" do
34+
it "has the expected cluster autoscaling settings" do
35+
expect(data['autoscaling']).to eq({
36+
"autoprovisioningNodePoolDefaults" => {
37+
"oauthScopes" => %w(https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring),
38+
"serviceAccount" => "default"
39+
},
40+
"enableNodeAutoprovisioning" => true,
41+
"resourceLimits" => [
42+
{
43+
"maximum" => "20",
44+
"minimum" => "5",
45+
"resourceType" => "cpu"
46+
},
47+
{
48+
"maximum" => "30",
49+
"minimum" => "10",
50+
"resourceType" => "memory"
51+
}
52+
]
53+
})
54+
end
55+
end
56+
end
57+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: simple_regional_beta
2+
attributes:
3+
- name: project_id
4+
required: true
5+
type: string
6+
- name: location
7+
required: true
8+
type: string
9+
- name: cluster_name
10+
required: true
11+
type: string
12+
- name: kubernetes_endpoint
13+
required: true
14+
type: string
15+
- name: client_token
16+
required: true
17+
type: string

0 commit comments

Comments
 (0)