Skip to content

Commit f52e95c

Browse files
committed
finalize test integration for gateway api
1 parent ec1b045 commit f52e95c

File tree

3 files changed

+231
-1
lines changed

3 files changed

+231
-1
lines changed

.kitchen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ suites:
8282
backend: local
8383
- name: "simple_regional_with_gateway_api"
8484
driver:
85-
root_module_directory: test/fixtures/simple_regional_with_gateway_api
85+
root_module_directory: test/fixtures/simple_regional_with_gateway_api
8686
verifier:
8787
systems:
8888
- name: simple_regional_with_gateway_api
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
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 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']['enablePrivateEndpoint']).to eq nil
44+
expect(data['privateClusterConfig']['enablePrivateNodes']).to eq nil
45+
end
46+
47+
it "has the expected addon settings" do
48+
expect(data['addonsConfig']).to include(
49+
"horizontalPodAutoscaling" => {},
50+
"httpLoadBalancing" => {},
51+
"kubernetesDashboard" => {
52+
"disabled" => true,
53+
},
54+
"networkPolicyConfig" => {
55+
"disabled" => true,
56+
},
57+
)
58+
end
59+
60+
it "has gateway api enabled" do
61+
expect(data['networkConfig']).to include(
62+
"gatewayApiConfig" => {
63+
"channel" => "CHANNEL_STANDARD",
64+
},
65+
)
66+
end
67+
68+
it "has the expected databaseEncryption config" do
69+
expect(data['databaseEncryption']).to eq({
70+
"state" => 'DECRYPTED',
71+
})
72+
end
73+
74+
it "has the expected shieldedNodes config" do
75+
expect(data['shieldedNodes']).to eq({
76+
"enabled" => true,
77+
})
78+
end
79+
80+
it "has the expected binaryAuthorization config" do
81+
expect(data['binaryAuthorization']).to eq({
82+
"evaluationMode" => "PROJECT_SINGLETON_POLICY_ENFORCE",
83+
})
84+
end
85+
end
86+
87+
describe "default node pool" do
88+
let(:default_node_pool) { data['nodePools'].select { |p| p['name'] == "default-pool" }.first }
89+
90+
it "exists" do
91+
expect(data['nodePools']).to include(
92+
including(
93+
"name" => "default-pool",
94+
)
95+
)
96+
end
97+
end
98+
99+
describe "node pool" do
100+
let(:node_pools) { data['nodePools'].reject { |p| p['name'] == "default-pool" } }
101+
102+
it "has autoscaling enabled" do
103+
expect(node_pools).to include(
104+
including(
105+
"autoscaling" => including(
106+
"enabled" => true,
107+
),
108+
)
109+
)
110+
end
111+
112+
it "has the expected minimum node count" do
113+
expect(node_pools).to include(
114+
including(
115+
"autoscaling" => including(
116+
"minNodeCount" => 1,
117+
),
118+
)
119+
)
120+
end
121+
122+
it "has the expected maximum node count" do
123+
expect(node_pools).to include(
124+
including(
125+
"autoscaling" => including(
126+
"maxNodeCount" => 100,
127+
),
128+
)
129+
)
130+
end
131+
132+
it "is the expected machine type" do
133+
expect(node_pools).to include(
134+
including(
135+
"config" => including(
136+
"machineType" => "e2-medium",
137+
),
138+
)
139+
)
140+
end
141+
142+
it "has the expected disk size" do
143+
expect(node_pools).to include(
144+
including(
145+
"config" => including(
146+
"diskSizeGb" => 100,
147+
),
148+
)
149+
)
150+
end
151+
152+
it "has the expected labels" do
153+
expect(node_pools).to include(
154+
including(
155+
"config" => including(
156+
"labels" => including(
157+
"cluster_name" => cluster_name,
158+
"node_pool" => "default-node-pool",
159+
),
160+
),
161+
)
162+
)
163+
end
164+
165+
it "has the expected network tags" do
166+
expect(node_pools).to include(
167+
including(
168+
"config" => including(
169+
"tags" => match_array([
170+
"gke-#{cluster_name}",
171+
"gke-#{cluster_name}-default-node-pool",
172+
]),
173+
),
174+
)
175+
)
176+
end
177+
178+
it "has autorepair enabled" do
179+
expect(node_pools).to include(
180+
including(
181+
"management" => including(
182+
"autoRepair" => true,
183+
),
184+
)
185+
)
186+
end
187+
188+
it "has autoupgrade enabled" do
189+
expect(node_pools).to include(
190+
including(
191+
"management" => including(
192+
"autoUpgrade" => true,
193+
),
194+
)
195+
)
196+
end
197+
end
198+
end
199+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 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+
name: simple_regional_with_gateway_api
16+
attributes:
17+
- name: project_id
18+
required: true
19+
type: string
20+
- name: location
21+
required: true
22+
type: string
23+
- name: cluster_name
24+
required: true
25+
type: string
26+
- name: kubernetes_endpoint
27+
required: true
28+
type: string
29+
- name: client_token
30+
required: true
31+
type: string

0 commit comments

Comments
 (0)