Skip to content

Commit

Permalink
travis: add a new test case to create a test api server from scratch
Browse files Browse the repository at this point in the history
This test does these action:
* build an apserver-boot tarball
* genereate a test api server with namespaces and non-namespaced
  resources.
* run tests for this api server

Signed-off-by: Andrei Vagin <[email protected]>
  • Loading branch information
avagin committed Jul 28, 2017
1 parent 59120d0 commit 0615395
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
language: go

go:
- 1.8.1
- 1.8.3

go_import_path: github.com/kubernetes-incubator/apiserver-builder

cache:
directories:
- $HOME/.glide

git:
depth: 3

env:
- TEST=example
- TEST=test

install:
- scripts/install_etcd.sh
- scripts/install_etcd.sh

script:
- cd example
- PATH=$PATH:/tmp/test-etcd make test
./test/travis.sh
49 changes: 49 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2017 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.

.PHONY: all test build generate docs cmds clean cleangenerated cleandocs skeleton

all: test

test: build
go test ./pkg/...
bash -c "find pkg/apis/ -name apiserver.local.config | xargs rm -rf"

skeleton: cmds
apiserver-boot init repo --domain sample.kubernetes.io
apiserver-boot create group version resource --group storage --version v1 --kind VolumeClaim
apiserver-boot create group version resource --group storage --version v1 --kind SnapshotClaim
apiserver-boot create group version resource --group storage --version v1 --kind Volume --non-namespaced
apiserver-boot create group version resource --group storage --version v1 --kind Snapshot --non-namespaced

build: cmds skeleton
apiserver-boot build executables

# Build docs
docs: cleandocs build
apiserver-boot build docs --server bin/apiserver

# Build the tools
# Note: These are available in the apiserver-builder release tar.gz
cmds:
./build-tools.sh

# Clean up functions
clean: cleangenerated cleandocs

cleangenerated: cmds
apiserver-boot build generated clean

cleandocs: cmds
apiserver-boot build docs clean
16 changes: 16 additions & 0 deletions test/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Copyright YEAR 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.
*/

26 changes: 26 additions & 0 deletions test/build-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -x -e

# NOTE: Do not copy this file unless you need to use apiserver-builder at HEAD.
# Otherwise, download the pre-built apiserver-builder tar release from
# https://github.com/kubernetes-incubator/apiserver-builder/releases instead.

(
cd /home/travis/gopath/src/github.com/
mkdir Masterminds
cd Masterminds
git clone https://github.com/Masterminds/glide.git
cd glide
make build
)

export PATH=/home/travis/gopath/src/github.com/Masterminds/glide:$PATH

# Install generators from this repo
cd ..
go build -o bin/apiserver-builder-release cmd/apiserver-builder-release/main.go
./bin/apiserver-builder-release vendor --version 1.0
./bin/apiserver-builder-release build --version 1.0 --targets linux:amd64

tar -xzf apiserver-builder-1.0-linux-amd64.tar.gz -C test
11 changes: 11 additions & 0 deletions test/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -x -e

if [ "$TEST" == "example" ]; then
cd example
PATH=$PATH:/tmp/test-etcd make test
elif [ "$TEST" == "test" ]; then
cd test
PATH=$PATH:/tmp/test-etcd:`pwd`/bin/ make test
fi

0 comments on commit 0615395

Please sign in to comment.