Skip to content

Commit 3ca42a5

Browse files
author
chrislovecnm
committed
Adding new integration test
This commit adds a new integration test, which tests the beta public module.
1 parent 87bdc01 commit 3ca42a5

File tree

9 files changed

+298
-0
lines changed

9 files changed

+298
-0
lines changed

.kitchen.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,16 @@ suites:
104104
systems:
105105
- name: stub_domains_private
106106
backend: local
107+
- name: "beta_public_cluster"
108+
driver:
109+
root_module_directory: test/fixtures/beta_public_cluster
110+
verifier:
111+
systems:
112+
- name: gcloud
113+
backend: local
114+
controls:
115+
- gcloud
116+
- name: gcp
117+
backend: gcp
118+
controls:
119+
- gcp

test/ci/beta-public-cluster.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
platform: linux
4+
5+
inputs:
6+
- name: pull-request
7+
path: terraform-google-kubernetes-engine
8+
9+
run:
10+
path: make
11+
args: ['test_integration']
12+
dir: terraform-google-kubernetes-engine
13+
14+
params:
15+
SUITE: "beta-public-cluster"
16+
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
17+
REGION: "us-east4"
18+
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module "example" {
18+
source = "../../../examples/beta-public-cluster"
19+
20+
project_id = "${var.project_id}"
21+
cluster_name_suffix = "-${random_string.suffix.result}"
22+
region = "${var.region}"
23+
network = "${google_compute_network.main.name}"
24+
subnetwork = "${google_compute_subnetwork.main.name}"
25+
ip_range_pods = "${google_compute_subnetwork.main.secondary_ip_range.0.range_name}"
26+
ip_range_services = "${google_compute_subnetwork.main.secondary_ip_range.1.range_name}"
27+
compute_engine_service_account = "${var.compute_engine_service_account}"
28+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
resource "random_string" "suffix" {
18+
length = 4
19+
special = false
20+
upper = false
21+
}
22+
23+
provider "google" {
24+
project = "${var.project_id}"
25+
}
26+
27+
resource "google_compute_network" "main" {
28+
name = "cft-gke-test-${random_string.suffix.result}"
29+
auto_create_subnetworks = "false"
30+
}
31+
32+
resource "google_compute_subnetwork" "main" {
33+
name = "cft-gke-test-${random_string.suffix.result}"
34+
ip_cidr_range = "10.0.0.0/17"
35+
region = "${var.region}"
36+
network = "${google_compute_network.main.self_link}"
37+
38+
secondary_ip_range {
39+
range_name = "cft-gke-test-pods-${random_string.suffix.result}"
40+
ip_cidr_range = "192.168.0.0/18"
41+
}
42+
43+
secondary_ip_range {
44+
range_name = "cft-gke-test-services-${random_string.suffix.result}"
45+
ip_cidr_range = "192.168.64.0/18"
46+
}
47+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../shared/outputs.tf
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../shared/terraform.tfvars
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../shared/variables.tf
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Copyright 2018 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+
# http://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 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" do
34+
it "is running" do
35+
expect(data['status']).to eq 'RUNNING'
36+
end
37+
38+
it "is regional" do
39+
expect(data['location']).to match(/^.*[1-9]$/)
40+
end
41+
42+
it "uses public nodes and master endpoint" do
43+
expect(data['privateClusterConfig']).to eq nil
44+
end
45+
46+
it "has the expected addon settings" do
47+
expect(data['addonsConfig']).to eq({
48+
"horizontalPodAutoscaling" => {},
49+
"httpLoadBalancing" => {},
50+
"kubernetesDashboard" => {
51+
"disabled" => true,
52+
},
53+
"networkPolicyConfig" => {
54+
"disabled" => true,
55+
},
56+
})
57+
end
58+
end
59+
60+
describe "default node pool" do
61+
let(:default_node_pool) { data['nodePools'].select { |p| p['name'] == "default-pool" }.first }
62+
63+
it "exists" do
64+
expect(data['nodePools']).to include(
65+
including(
66+
"name" => "default-pool",
67+
)
68+
)
69+
end
70+
end
71+
72+
describe "node pool" do
73+
let(:node_pools) { data['nodePools'].reject { |p| p['name'] == "default-pool" } }
74+
75+
it "has autoscaling enabled" do
76+
expect(node_pools).to include(
77+
including(
78+
"autoscaling" => including(
79+
"enabled" => true,
80+
),
81+
)
82+
)
83+
end
84+
85+
it "has the expected minimum node count" do
86+
expect(node_pools).to include(
87+
including(
88+
"autoscaling" => including(
89+
"minNodeCount" => 1,
90+
),
91+
)
92+
)
93+
end
94+
95+
it "has the expected maximum node count" do
96+
expect(node_pools).to include(
97+
including(
98+
"autoscaling" => including(
99+
"maxNodeCount" => 100,
100+
),
101+
)
102+
)
103+
end
104+
105+
it "is the expected machine type" do
106+
expect(node_pools).to include(
107+
including(
108+
"config" => including(
109+
"machineType" => "n1-standard-2",
110+
),
111+
)
112+
)
113+
end
114+
115+
it "has the expected disk size" do
116+
expect(node_pools).to include(
117+
including(
118+
"config" => including(
119+
"diskSizeGb" => 100,
120+
),
121+
)
122+
)
123+
end
124+
125+
it "has the expected labels" do
126+
expect(node_pools).to include(
127+
including(
128+
"config" => including(
129+
"labels" => including(
130+
"cluster_name" => cluster_name,
131+
"node_pool" => "default-node-pool",
132+
),
133+
),
134+
)
135+
)
136+
end
137+
138+
it "has the expected network tags" do
139+
expect(node_pools).to include(
140+
including(
141+
"config" => including(
142+
"tags" => match_array([
143+
"gke-#{cluster_name}",
144+
"gke-#{cluster_name}-default-node-pool",
145+
]),
146+
),
147+
)
148+
)
149+
end
150+
151+
it "has autorepair enabled" do
152+
expect(node_pools).to include(
153+
including(
154+
"management" => including(
155+
"autoRepair" => true,
156+
),
157+
)
158+
)
159+
end
160+
161+
it "has autoupgrade enabled" do
162+
expect(node_pools).to include(
163+
including(
164+
"management" => including(
165+
"autoUpgrade" => true,
166+
),
167+
)
168+
)
169+
end
170+
end
171+
end
172+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: beta_public_cluster
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)