Skip to content

Commit 0a02611

Browse files
committed
ci: add Go e2e test for new project layouts
1 parent 5b992a6 commit 0a02611

File tree

4 files changed

+54
-29
lines changed

4 files changed

+54
-29
lines changed

.travis.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ jobs:
132132
name: Subcommands on Kubernetes
133133
script: make test-subcommand
134134

135-
# Build and test go
135+
# Build and test go for legacy project layouts
136136
- <<: *test
137-
name: Go on Kubernetes
137+
name: Go for legacy project layouts on Kubernetes
138138
before_script:
139139
- (cd / && go get github.com/mattn/goveralls)
140140
script:
@@ -143,6 +143,23 @@ jobs:
143143
- make test-e2e-go
144144
- make test-integration
145145

146+
# Build and test go for new project layouts
147+
- name: Go e2e tests for new project layouts
148+
before_install:
149+
# hack/ci/check-doc-only-update.sh needs to be sourced so
150+
# that it can properly exit the test early with success
151+
- source hack/ci/check-doc-only-update.sh
152+
script:
153+
- make test-e2e-go-new
154+
after_success:
155+
- echo "E2E tests passed"
156+
after_failure:
157+
- echo "E2E tests failed"
158+
- kubectl get all --all-namespaces
159+
- kubectl get events --all-namespaces --field-selector=type=Warning
160+
services:
161+
- docker
162+
146163
# Build and test helm
147164
- <<: *test
148165
name: Helm on Kubernetes

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,17 @@ test-subcommand-scorecard:
254254
test-subcommand-olm-install:
255255
./hack/tests/subcommand-olm-install.sh
256256

257-
# E2E and integration tests.
258-
.PHONY: test-e2e test-e2e-go test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm test-integration
257+
# E2E tests.
258+
.PHONY: test-e2e test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm
259259

260-
test-e2e: test-e2e-go test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm ## Run the e2e tests
260+
test-e2e: test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm ## Run the e2e tests
261261

262262
test-e2e-go:
263263
./hack/tests/e2e-go.sh $(ARGS)
264264

265+
test-e2e-go-new:
266+
K8S_VERSION=$(K8S_VERSION) ./hack/tests/e2e-go-new.sh
267+
265268
test-e2e-ansible: image-build-ansible
266269
./hack/tests/e2e-ansible.sh
267270

@@ -271,5 +274,8 @@ test-e2e-ansible-molecule: image-build-ansible
271274
test-e2e-helm: image-build-helm
272275
./hack/tests/e2e-helm.sh
273276

274-
test-integration:
277+
# Integration tests.
278+
.PHONY: test-integration
279+
280+
test-integration: ## Run integration tests
275281
./hack/tests/integration.sh

hack/lib/common.sh

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#!/usr/bin/env bash
22

3-
tmp_root=/tmp
4-
tmp_sdk_root=$tmp_root/operator-sdk
5-
6-
function log() { printf '%s\n' "$*"; }
7-
function error() { error_text "ERROR:" $* >&2; }
8-
function fatal() { error "$@"; exit 1; }
9-
3+
# Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
4+
# in your environment to any value:
5+
#
6+
# $ SKIP_FETCH_TOOLS=1 ./test.sh
7+
#
8+
# If you skip fetching tools, this script will use the tools already on your
9+
# machine, but rebuild the operator-sdk binary.
10+
SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
11+
# Current version of the 'kind' binary. Update this when a new breaking release
12+
# is made for a docker.io/kindest/node:${K8S_VERSION} image.
13+
KIND_VERSION="v0.8.1"
14+
# ENVTEST_TOOLS_VERSION is the version of k8s server tarballs used for envtest.
15+
# TODO: use K8S_VERSION once we start building our own server binary tarballs.
16+
ENVTEST_TOOLS_VERSION="1.16.4"
1017
# Turn colors in this script off by setting the NO_COLOR variable in your
1118
# environment to any value:
1219
NO_COLOR=${NO_COLOR:-""}
@@ -20,6 +27,14 @@ else
2027
reset_color=''
2128
fi
2229

30+
# Roots used by tests.
31+
tmp_root=/tmp
32+
tmp_sdk_root=$tmp_root/operator-sdk
33+
34+
function log() { printf '%s\n' "$*"; }
35+
function error() { error_text "ERROR:" $* >&2; }
36+
function fatal() { error "$@"; exit 1; }
37+
2338
function header_text {
2439
echo "$header_color$*$reset_color"
2540
}
@@ -41,15 +56,6 @@ function install_service_monitor_crd {
4156
kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.35/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
4257
}
4358

44-
# Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
45-
# in your environment to any value:
46-
#
47-
# $ SKIP_FETCH_TOOLS=1 ./test.sh
48-
#
49-
# If you skip fetching tools, this script will use the tools already on your
50-
# machine, but rebuild the operator-sdk binary.
51-
SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
52-
5359
# prepare the e2e test staging dir, containing test tools (SKIP_FETCH_TOOLS aware).
5460
function prepare_staging_dir {
5561

@@ -83,7 +89,7 @@ function fetch_envtest_tools {
8389
# curl -fL --retry 3 --keepalive-time 2 "${url}" -o "${tmp_sdk_root}/${server_tar}"
8490
# tar -zxvf "${tmp_sdk_root}/${server_tar}"
8591

86-
local tools_archive_name="kubebuilder-tools-1.16.4-$(go env GOOS)-$(go env GOARCH).tar.gz"
92+
local tools_archive_name="kubebuilder-tools-${ENVTEST_TOOLS_VERSION}-$(go env GOOS)-$(go env GOARCH).tar.gz"
8793
local tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$tools_archive_name"
8894

8995
local tools_archive_path="$1/$tools_archive_name"
@@ -114,10 +120,6 @@ function build_sdk {
114120
mv ./build/operator-sdk "$1"/bin/operator-sdk
115121
}
116122

117-
# Current version of the 'kind' binary. Update this when a new breaking release
118-
# is made for a docker.io/kindest/node:${K8S_VERSION} image.
119-
KIND_VERSION="v0.8.1"
120-
121123
# Install the 'kind' binary at version $KIND_VERSION.
122124
function install_kind {
123125

hack/tests/e2e-go-new.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ set -o pipefail
1212
source ./hack/lib/common.sh
1313
source ./hack/lib/test_lib.sh
1414

15-
tmp_root=/tmp
16-
tmp_sdk_root=$tmp_root/operator-sdk
1715
test_dir=./test
1816
tests=$test_dir/e2e-new
1917

@@ -24,6 +22,8 @@ export GO111MODULE=on
2422

2523
prepare_staging_dir $tmp_sdk_root
2624
fetch_tools $tmp_sdk_root
25+
# These envtest environment variables are required for the default unit tests
26+
# scaffolded in the test operator project. No e2e tests currently use envtest.
2727
setup_envs $tmp_sdk_root
2828
build_sdk $tmp_sdk_root
2929

0 commit comments

Comments
 (0)