Skip to content

Commit 23329a2

Browse files
authored
.travis.yml: run tests on openshift cluster (#475)
* .travis.yml: run tests on openshift cluster Use `oc cluster up` for openshift cluster instead of minikube * .travis.yml,hack/ci: run minikube and openshift in parallel * test/e2e/memcached_test.go: increase up local timeout * test/e2e/memcached_test.go: run e2e tests sequentially The up local test still fails with a 100 second timeout. Instead, we run the tests sequentially to reduce load. The cluster test runs first, which also populates the GOCACHE, so the up local test shouldn't take too long to start after that.
1 parent a2f2edd commit 23329a2

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

.travis.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,21 @@ services:
88
go:
99
- 1.10.1
1010

11-
env:
12-
- CHANGE_MINIKUBE_NONE_USER=true
11+
jobs:
12+
include:
13+
- before_script: hack/ci/setup-minikube.sh
14+
env:
15+
- CLUSTER=minikube
16+
- CHANGE_MINIKUBE_NONE_USER=true
17+
- before_script: hack/ci/setup-openshift.sh
18+
env: CLUSTER=openshift
1319

14-
before_script:
20+
install:
1521
- curl -Lo dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && chmod +x dep && sudo mv dep /usr/local/bin/
1622
- dep ensure
17-
# Download kubectl, which is a requirement for using minikube.
18-
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.10.1/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
19-
# Download minikube.
20-
# We need to pin to an old version due to minikube requiring systemd starting with v0.26.0 and travis not providing it
21-
# - https://github.com/kubernetes/minikube/issues/2704
22-
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
23-
- sudo minikube start --vm-driver=none --kubernetes-version=v1.10.0
24-
# Fix the kubectl context, as it's often stale.
25-
- minikube update-context
26-
# Wait for Kubernetes to be up and ready.
27-
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
2823
# Create example operator directory
2924
- mkdir -p $GOPATH/src/github.com/example-inc
3025

31-
install:
32-
- go get -t -d ./...
33-
3426
script:
3527
- make install
3628
- go test ./pkg/...
@@ -47,10 +39,7 @@ script:
4739
- ./hack/check_error_case.sh
4840

4941
after_success:
50-
- echo 'Build succeeded, operator was generated, memcached operator is running on minikube, and unit/integration tests pass'
42+
- echo 'Build succeeded, operator was generated, memcached operator is running on $CLUSTER, and unit/integration tests pass'
5143

5244
after_failure:
53-
- echo 'Build failed, operator failed to generate, memcached operator is not running on minikube, or unit/integration tests failed'
54-
- kubectl get deployment
55-
- kubectl get pods
56-
- kubectl describe pods
45+
- echo 'Build failed, operator failed to generate, memcached operator is not running on $CLUSTER, or unit/integration tests failed'

hack/ci/setup-minikube.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Download kubectl, which is a requirement for using minikube.
2+
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.10.1/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
3+
# Download minikube.
4+
# We need to pin to an old version due to minikube requiring systemd starting with v0.26.0 and travis not providing it
5+
# - https://github.com/kubernetes/minikube/issues/2704
6+
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
7+
sudo minikube start --vm-driver=none --kubernetes-version=v1.10.0
8+
# Fix the kubectl context, as it's often stale.
9+
minikube update-context
10+
# Wait for Kubernetes to be up and ready.
11+
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done

hack/ci/setup-openshift.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Configure insecure docker registry for openshift
2+
sudo service docker stop
3+
sudo sed -i 's/DOCKER_OPTS=\"/DOCKER_OPTS=\"--insecure-registry 172.30.0.0\/16 /' /etc/default/docker
4+
sudo service docker start
5+
# Download oc to spin up openshift on local docker instance
6+
curl -Lo oc.tar.gz https://github.com/openshift/origin/releases/download/v3.10.0/openshift-origin-client-tools-v3.10.0-dd10d17-linux-64bit.tar.gz
7+
# Put oc binary in path
8+
tar xvzOf oc.tar.gz openshift-origin-client-tools-v3.10.0-dd10d17-linux-64bit/oc > oc && chmod +x oc && sudo mv oc /usr/local/bin/
9+
# Start oc cluster
10+
oc cluster up
11+
# Become cluster admin
12+
oc login -u system:admin

test/e2e/memcached_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ func memcachedScaleTest(t *testing.T, f *framework.Framework, ctx framework.Test
162162
}
163163

164164
func MemcachedLocal(t *testing.T) {
165-
t.Parallel()
166165
// get global framework variables
167166
f := framework.Global
168167
ctx := f.NewTestCtx(t)
@@ -186,7 +185,7 @@ func MemcachedLocal(t *testing.T) {
186185
ctx.AddFinalizerFn(func() error { return cmd.Process.Signal(os.Interrupt) })
187186

188187
// wait for operator to start (may take a minute to compile the command...)
189-
err = wait.Poll(time.Second*5, time.Second*80, func() (done bool, err error) {
188+
err = wait.Poll(time.Second*5, time.Second*100, func() (done bool, err error) {
190189
file, err := ioutil.ReadFile("stderr.txt")
191190
if err != nil {
192191
return false, err
@@ -197,7 +196,7 @@ func MemcachedLocal(t *testing.T) {
197196
return true, nil
198197
})
199198
if err != nil {
200-
t.Fatalf("local operator not ready after 60 seconds: %v\n", err)
199+
t.Fatalf("local operator not ready after 100 seconds: %v\n", err)
201200
}
202201

203202
if err = memcachedScaleTest(t, f, ctx); err != nil {
@@ -206,7 +205,6 @@ func MemcachedLocal(t *testing.T) {
206205
}
207206

208207
func MemcachedCluster(t *testing.T) {
209-
t.Parallel()
210208
// get global framework variables
211209
f := framework.Global
212210
ctx := f.NewTestCtx(t)

0 commit comments

Comments
 (0)