forked from kubernetes-sigs/kubebuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·155 lines (126 loc) · 3.52 KB
/
test.sh
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# 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
#
# http://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.
set -o errexit
set -o nounset
set -o pipefail
source common.sh
export TRACE=1
export GO111MODULE=on
function test_init_project {
header_text "performing init project"
kubebuilder init --domain example.com <<< "n"
}
function test_make_project {
header_text "running make in project"
make
}
function test_create_api_controller {
header_text "performing creating api and controller"
kubebuilder create api --group insect --version v1beta1 --kind Bee --namespaced false <<EOF
y
y
EOF
}
function test_create_namespaced_api_controller {
header_text "performing creating namespaced api and controller"
kubebuilder create api --group insect --version v1beta1 --kind Bee --namespaced true <<EOF
y
y
EOF
}
function test_create_api_only {
header_text "performing creating api only"
kubebuilder create api --group insect --version v1beta1 --kind Bee --namespaced false <<EOF
y
n
EOF
}
function test_create_namespaced_api_only {
header_text "performing creating api only"
kubebuilder create api --group insect --version v1beta1 --kind Bee --namespaced true <<EOF
y
n
EOF
}
function test_create_skip {
header_text "performing creating but skipping everything"
kubebuilder create api --group insect --version v1beta1 --kind Bee <<EOF
n
n
EOF
}
function test_create_coretype_controller {
header_text "performing creating coretype controller"
kubebuilder create api --group apps --version v1 --kind Deployment --namespaced false <<EOF
n
y
EOF
}
function test_create_namespaced_coretype_controller {
header_text "performing creating coretype controller"
kubebuilder create api --group apps --version v1 --kind Deployment --namespaced true <<EOF
n
y
EOF
}
function test_project {
project_dir=$1
version=$2
header_text "performing tests in dir $project_dir for project version v$version"
cd testdata/$project_dir
make all test
cd -
}
prepare_staging_dir
fetch_tools
build_kb
setup_envs
prepare_testdir_under_gopath
test_init_project
cache_project
prepare_testdir_under_gopath
dump_project
test_make_project
prepare_testdir_under_gopath
dump_project
test_create_api_controller
prepare_testdir_under_gopath
dump_project
test_create_namespaced_api_controller
prepare_testdir_under_gopath
dump_project
test_create_api_only
prepare_testdir_under_gopath
dump_project
test_create_namespaced_api_only
prepare_testdir_under_gopath
dump_project
test_create_coretype_controller
prepare_testdir_under_gopath
dump_project
test_create_namespaced_coretype_controller
header_text "running kubebuilder unit tests"
cd ${go_workspace}/src/sigs.k8s.io/kubebuilder
export GO111MODULE=on
go test ./cmd/... ./pkg/...
# test project v2
GO111MODULE=on test_project project-v2 2
GO111MODULE=on test_project project-v2-multigroup 2
GO111MODULE=on test_project project-v2-addon 2
# test project v3
GO111MODULE=on test_project project-v3 3-alpha
GO111MODULE=on test_project project-v3-multigroup 3-alpha
GO111MODULE=on test_project project-v3-addon 3-alpha
exit $rc