Skip to content

Commit

Permalink
* Fix #93
Browse files Browse the repository at this point in the history
Added tests for cluster auto scaling
  • Loading branch information
kopachevsky committed Nov 18, 2019
1 parent 5f9184d commit 45e0063
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ suites:
systems:
- name: simple_regional
backend: local
- name: "simple_regional_beta"
driver:
root_module_directory: test/fixtures/simple_regional_beta
verifier:
systems:
- name: simple_regional_beta
backend: local
- name: "simple_regional_with_networking"
driver:
root_module_directory: test/fixtures/simple_regional_with_networking
Expand Down
20 changes: 20 additions & 0 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ steps:
- verify simple-regional-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-local']
- id: create simple-regional-beta-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-regional-beta-local']
- id: converge simple-regional-beta-local
waitFor:
- create simple-regional-beta-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-beta-local']
- id: verify simple-regional-beta-local
waitFor:
- converge simple-regional-beta-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-beta-local']
- id: destroy simple-regional-beta-local
waitFor:
- verify simple-regional-beta-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-beta-local']
- id: create simple-regional-private-local
waitFor:
- prepare
Expand Down
57 changes: 57 additions & 0 deletions test/integration/simple_regional_beta/controls/gcloud.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2019 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.

project_id = attribute('project_id')
location = attribute('location')
cluster_name = attribute('cluster_name')

control "gcloud" do
title "Google Compute Engine GKE cluster autoscaling configuration"
describe command("gcloud --project=#{project_id} container clusters --zone=#{location} describe #{cluster_name} --format=json") do
its(:exit_status) { should eq 0 }
its(:stderr) { should eq '' }

let!(:data) do
if subject.exit_status == 0
JSON.parse(subject.stdout)
else
{}
end
end

describe "cluster-autoscaling" do
it "has the expected cluster autoscaling settings" do
expect(data['autoscaling']).to eq({
"autoprovisioningNodePoolDefaults" => {
"oauthScopes" => %w(https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring),
"serviceAccount" => "default"
},
"enableNodeAutoprovisioning" => true,
"resourceLimits" => [
{
"maximum" => "20",
"minimum" => "5",
"resourceType" => "cpu"
},
{
"maximum" => "30",
"minimum" => "10",
"resourceType" => "memory"
}
]
})
end
end
end
end
17 changes: 17 additions & 0 deletions test/integration/simple_regional_beta/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: simple_regional_beta
attributes:
- name: project_id
required: true
type: string
- name: location
required: true
type: string
- name: cluster_name
required: true
type: string
- name: kubernetes_endpoint
required: true
type: string
- name: client_token
required: true
type: string

0 comments on commit 45e0063

Please sign in to comment.