Skip to content

Commit 1d0e96b

Browse files
authored
Merge pull request #690 from mengqiy/travise2e
🏃 enable e2e tests on travis
2 parents 41ed225 + 2413690 commit 1d0e96b

File tree

17 files changed

+498
-10
lines changed

17 files changed

+498
-10
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ git:
1818

1919
go_import_path: sigs.k8s.io/kubebuilder
2020

21+
services:
22+
- docker
23+
2124
before_install:
2225
- go get -u github.com/golang/dep/cmd/dep
2326
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sL https://github.com/git-lfs/git-lfs/releases/download/v2.7.2/git-lfs-darwin-amd64-v2.7.2.tar.gz | tar -xz git-lfs; fi
27+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then GO111MODULE=on scripts/install_and_setup.sh; fi
2428

2529
before_script:
26-
- git lfs install
27-
- git lfs pull
30+
- git lfs install
31+
- git lfs pull
2832

2933
# Install must be set to prevent default `go get` to run.
3034
# The dependencies have already been vendored by `dep` so
@@ -33,6 +37,7 @@ install:
3337
-
3438

3539
script:
40+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then GO111MODULE=on TRACE=1 PATH=$PATH:$(pwd) ./test_e2e.sh ; fi
3641
- GO111MODULE=on TRACE=1 ./test.sh
3742
- ./scripts/install_test.sh
3843

common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function setup_envs {
157157
export TEST_ASSET_KUBE_APISERVER=$tmp_root/kubebuilder/bin/kube-apiserver
158158
export TEST_ASSET_ETCD=$tmp_root/kubebuilder/bin/etcd
159159
export TEST_DEP=$tmp_root/kubebuilder/init_project
160+
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
160161
}
161162

162163
function restore_go_deps {

generate_vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ generate_vendor() {
5858
}
5959

6060
build_kb && \
61-
generate_vendor $1
61+
generate_vendor 1

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/spf13/afero v1.2.2
1313
github.com/spf13/cobra v0.0.3
1414
github.com/spf13/pflag v1.0.3
15-
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c // indirect
15+
golang.org/x/net v0.0.0-20190514140710-3ec191127204 // indirect
1616
golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e // indirect
1717
golang.org/x/text v0.3.2 // indirect
1818
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90Pveol
4747
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
4848
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
4949
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
50-
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw=
51-
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
50+
golang.org/x/net v0.0.0-20190514140710-3ec191127204 h1:4yG6GqBtw9C+UrLp6s2wtSniayy/Vd/3F7ffLE427XI=
51+
golang.org/x/net v0.0.0-20190514140710-3ec191127204/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5252
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5353
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
5454
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

pkg/scaffold/v1/manager/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ spec:
8989
- command:
9090
- /manager
9191
image: {{ .Image }}
92-
imagePullPolicy: Always
9392
name: manager
9493
env:
9594
- name: POD_NAMESPACE

pkg/scaffold/v2/manager/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ spec:
7272
- command:
7373
- /manager
7474
image: {{ .Image }}
75-
imagePullPolicy: Always
7675
name: manager
7776
resources:
7877
limits:

scripts/install_and_setup.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
# Copyright 2019 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
go get sigs.k8s.io/[email protected]
18+
# TODO(mengqiy): use a released version after v2.1.0 is out.
19+
go get sigs.k8s.io/kustomize@f9c631e9eec7a2d6e46eb9e1bf5122f68b97d12d
20+
21+
# You can use --image flag to specify the cluster version you want, e.g --image=kindest/node:v1.13.6, the supported version are listed at https://hub.docker.com/r/kindest/node/tags
22+
kind create cluster --config test/kind-config.yaml --image=kindest/node:v1.14.1

test/e2e/config.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
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+
package e2e
18+
19+
import (
20+
"path/filepath"
21+
)
22+
23+
// runtime config specified to run e2e tests
24+
type config struct {
25+
domain string
26+
group string
27+
version string
28+
kind string
29+
controllerImageName string
30+
workDir string
31+
}
32+
33+
// configWithSuffix init with a random suffix for test config stuff,
34+
// to avoid conflict when running tests synchronously.
35+
func configWithSuffix(testSuffix string) (*config, error) {
36+
testGroup := "bar" + testSuffix
37+
path, err := filepath.Abs("e2e-" + testSuffix)
38+
if err != nil {
39+
return nil, err
40+
}
41+
42+
return &config{
43+
domain: "example.com" + testSuffix,
44+
group: testGroup,
45+
version: "v1alpha1",
46+
kind: "Foo" + testSuffix,
47+
controllerImageName: "e2e-test/controller-manager:" + testSuffix,
48+
workDir: path,
49+
}, nil
50+
}

test/e2e/e2e_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
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+
package e2e
18+
19+
import (
20+
"fmt"
21+
"testing"
22+
23+
. "github.com/onsi/ginkgo"
24+
. "github.com/onsi/gomega"
25+
)
26+
27+
// Run e2e tests using the Ginkgo runner.
28+
func TestE2E(t *testing.T) {
29+
RegisterFailHandler(Fail)
30+
fmt.Fprintf(GinkgoWriter, "Starting kubebuilder suite\n")
31+
RunSpecs(t, "Kubebuilder e2e suite")
32+
}

0 commit comments

Comments
 (0)