forked from govuk-paas/paas-docker-cloudfoundry-tools
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathk8s-tools_spec.rb
More file actions
134 lines (112 loc) · 3.8 KB
/
k8s-tools_spec.rb
File metadata and controls
134 lines (112 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
require 'spec_helper'
require 'docker'
require 'serverspec'
BOSH_CLI_VERSION="7.7.1" # renovate: datasource=github-releases depName=cloudfoundry/bosh-cli
YTT_VERSION="0.51.0" # renovate: datasource=github-releases depName=k14s/ytt
CREDHUB_CLI_VERSION='2.9.39' # renovate: datasource=github-releases depName=cloudfoundry/credhub-cli
KUSTOMIZE_VERSION="5.0.3" # renovate: datasource=github-releases depName=kubernetes-sigs/kustomize
KAPP_VERSION="0.63.3" # renovate: datasource=github-releases depName=k14s/kapp
KUBECTL_VERSION="1.29.12" # renovate: datasource=github-tags depName=kubernetes/kubectl
HELM_VERSION="3.14.4" # renovate: datasource=github-releases depName=helm/helm
KUTTL_VERSION="0.19.0" # renovate: datasource=github-releases depName=kudobuilder/kuttl
RUBY_VERSION = "3.1"
DEPS = "unzip curl openssl ca-certificates git libc6 bash jq gettext"
describe "k8s image" do
before(:all) {
set :docker_image, find_image_id('k8s-tools:latest')
}
it "installs required packages" do
DEPS.split(' ').each do |package|
expect(package(package)).to be_installed
end
end
it "has the expected version of Kubectl (#{KUBECTL_VERSION}) with embedded Kustomize" do
EMBEDDED_KUSTOMIZE_VERSION="5.0.4-0.20230601165947-6ce0bf390ce3"
expect(
command("kubectl version --client=true").stdout.strip
# ).to eq("Client Version: v#{KUBECTL_VERSION}\nKustomize Version: v#{KUSTOMIZE_VERSION}")
).to eq("Client Version: v#{KUBECTL_VERSION}\nKustomize Version: v#{EMBEDDED_KUSTOMIZE_VERSION}")
end
it "has the expected version of YTT (#{YTT_VERSION})" do
expect(
command("ytt --version").stdout.strip
).to eq("ytt version #{YTT_VERSION}")
end
it "has the expected version of credhub (#{CREDHUB_CLI_VERSION})" do
expect(
command("credhub --version").stdout.strip
).to match("#{CREDHUB_CLI_VERSION}\n")
end
it "has the expected version of stand-alone Kustomize (#{KUSTOMIZE_VERSION})" do
expect(
command("kustomize version").stdout
).to match("v#{KUSTOMIZE_VERSION}\n")
end
it "has the expected version of Kapp (#{KAPP_VERSION})" do
expect(
command("kapp --version").stdout
).to match(/#{KAPP_VERSION}/)
end
it "has the expected version of helm (#{HELM_VERSION})" do
expect(
command("helm version --short").stdout
).to match(/#{HELM_VERSION}/)
end
it "has the expected version of kuttle (#{KUTTL_VERSION})" do
expect(
command("kuttl version").stdout
).to match(/#{KUTTL_VERSION}/)
end
it "has curl available" do
expect(
command("curl --version").exit_status
).to eq(0)
end
it "has unzip available" do
expect(
command("unzip -v").exit_status
).to eq(0)
end
it "has git available" do
expect(
command("git --version").exit_status
).to eq(0)
end
it "has jq available" do
cmd = command("jq --version")
expect(cmd.exit_status).to eq(0)
end
it "has ruby #{RUBY_VERSION} available" do
cmd = command("ruby -v")
expect(cmd.exit_status).to eq(0)
expect(cmd.stdout).to match(/^ruby #{RUBY_VERSION}/)
end
it "has ruby json gem available" do
cmd = command("ruby -e 'require \"json\"'")
expect(cmd.exit_status).to eq(0)
end
it "has ruby yaml gem available" do
cmd = command("ruby -e 'require \"yaml\"'")
expect(cmd.exit_status).to eq(0)
end
it "has `bash` available" do
expect(
command("bash --version").exit_status
).to eq(0)
end
it "has `envsubst` available" do
expect(
command("envsubst --help").exit_status
).to eq(0)
end
it "has `yq` available" do
expect(
command("yq --version").exit_status
).to eq(0)
end
it "has the expected version of the Bosh CLI" do
expect(
command("bosh -v").stdout.strip
).to match("version #{BOSH_CLI_VERSION}$")
end
end