Skip to content

Commit

Permalink
Modify jenkins unit/integration scripts to work on branches
Browse files Browse the repository at this point in the history
Also add a makefile. This will need a cherrypick onto 1.0,1.1
with edits to hack/jenkins/test-dockerized.sh to run branch-specific
test scripts.

Also had to modify hack/verify-api-reference.sh to handle volume mount
path peculiarity when doing `docker run -v` inside a container started
with `docker run -v`. See associated comment in
hack/jenkins/test-dockerized.sh
  • Loading branch information
j3ffml committed Oct 29, 2015
1 parent 1524d74 commit 04e891c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
22 changes: 17 additions & 5 deletions hack/jenkins/gotest-pr.sh → hack/jenkins/gotest-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,23 @@ export REPO_DIR=${REPO_DIR:-$(pwd)}
# Produce a JUnit-style XML test report for Jenkins.
export KUBE_JUNIT_REPORT_DIR=${WORKSPACE}/_artifacts

# Run the kubekins container, mapping in docker (so we can launch containers)
# and the repo directory
docker run -v /var/run/docker.sock:/var/run/docker.sock \
# Run the kubekins container, mapping in docker (so we can launch containers),
# the repo directory, and the artifacts output directory.
#
# Note: We pass in the absolute path to the repo on the host as an env var incase
# any tests that get run need to launch containers that also map volumes.
# This is required because if you do
#
# $ docker run -v $PATH:/container/path ...
#
# From _inside_ a container that has the host's docker mapped in, the $PATH
# provided must be resolvable on the *HOST*, not the container.

docker run --rm=true \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(which docker)":/bin/docker \
-v "${REPO_DIR}":/go/src/k8s.io/kubernetes \
-v "${KUBE_JUNIT_REPORT_DIR}":/workspace/artifacts \
-it kubekins-test \
bash -c "cd kubernetes && /workspace/run.sh"
--env REPO_DIR="${REPO_DIR}" \
-it gcr.io/google_containers/kubekins-test:0.1 \
bash -c "cd kubernetes && ./hack/jenkins/test-dockerized.sh"
26 changes: 10 additions & 16 deletions hack/jenkins/test-image/run.sh → hack/jenkins/test-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ set -o nounset
set -o pipefail
set -o xtrace

# Runs the unit and integration tests, producing JUnit-style XML test
# reports in ${WORKSPACE}/artifacts. This script is intended to be run from
# kubekins-test container with a kubernetes repo mapped in. See
# hack/jenkins/gotest-dockerized.sh

export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH}

./hack/install-etcd.sh
go get -u github.com/jstemmer/go-junit-report
go get golang.org/x/tools/cmd/cover
go get github.com/mattn/goveralls
go get github.com/tools/godep
go get github.com/jstemmer/go-junit-report

Expand All @@ -36,22 +37,15 @@ export KUBE_COVER="n"
export KUBE_JUNIT_REPORT_DIR=${WORKSPACE}/artifacts
# Save the verbose stdout as well.
export KUBE_KEEP_VERBOSE_TEST_OUTPUT=y
export KUBE_GOVERALLS_BIN="${GOPATH}/bin/goveralls"
export KUBE_TIMEOUT='-timeout 300s'
export KUBE_COVERPROCS=8
export KUBE_INTEGRATION_TEST_MAX_CONCURRENCY=4
export LOG_LEVEL=4

./hack/verify-gofmt.sh
./hack/verify-boilerplate.sh
./hack/verify-description.sh
./hack/verify-flags-underscore.py
./hack/verify-generated-conversions.sh
./hack/verify-generated-deep-copies.sh
./hack/verify-generated-docs.sh
./hack/verify-generated-swagger-docs.sh
./hack/verify-swagger-spec.sh
./hack/verify-linkcheck.sh
./hack/build-go.sh
godep go install ./...
./hack/install-etcd.sh

./hack/verify-all.sh

./hack/test-go.sh -- -p=2
./hack/test-cmd.sh
Expand Down
5 changes: 3 additions & 2 deletions hack/jenkins/test-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
# unit and integration tests

FROM golang:1.4
MAINTAINER jeff lowdermilk <jeffml@google.com>
MAINTAINER Jeff Lowdermilk <jeffml@google.com>

ENV KUBE_TEST_API_VERSIONS v1,extensions/v1beta1
ENV KUBE_TEST_ETCD_PREFIXES registry
ENV WORKSPACE /workspace
ENV TERM xterm

WORKDIR /workspace
ADD run.sh ./

RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y rsync
RUN apt-get install -y file
RUN mkdir -p /go/src/k8s.io/kubernetes
RUN ln -s /go/src/k8s.io/kubernetes /workspace/kubernetes

Expand Down
13 changes: 13 additions & 0 deletions hack/jenkins/test-image/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
all: push

TAG = 0.1

container:
docker build -t gcr.io/google_containers/kubekins-test .
docker tag gcr.io/google_containers/kubekins-test gcr.io/google_containers/kubekins-test:$(TAG)

push: container
gcloud docker push gcr.io/google_containers/kubekins-test # Push image tagged as latest to repository
gcloud docker push gcr.io/google_containers/kubekins-test:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)

clean:
5 changes: 3 additions & 2 deletions hack/update-api-reference-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ set -o nounset
set -o pipefail

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
DEFAULT_OUTPUT_PATH="$PWD/${KUBE_ROOT}/docs/api-reference"
REPO_DIR=${REPO_DIR:-"${PWD}/${KUBE_ROOT}"}
DEFAULT_OUTPUT_PATH="${REPO_DIR}/docs/api-reference"
OUTPUT=${1:-${DEFAULT_OUTPUT_PATH}}

echo "Generating api reference docs at ${OUTPUT}"

V1_PATH="${OUTPUT}/v1/"
V1BETA1_PATH="${OUTPUT}/extensions/v1beta1"
SWAGGER_PATH="$PWD/${KUBE_ROOT}/api/swagger-spec/"
SWAGGER_PATH="${REPO_DIR}/api/swagger-spec/"

echo "Reading swagger spec from: ${SWAGGER_PATH}"

Expand Down
10 changes: 9 additions & 1 deletion hack/verify-api-reference-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env

API_REFERENCE_DOCS_ROOT="${KUBE_ROOT}/docs/api-reference"
# Use REPO_DIR if provided so we can set it to the host-resolvable path
# to the repo root if we are running this script from a container with
# docker mounted in as a volume.
# We pass the host output dir to update-api-reference-docs.sh, but use
# the regular one to compute diff (they will be the same if running this
# test on the host, potentially different if running in a container).
REPO_DIR=${REPO_DIR:-"${KUBE_ROOT}"}
HOST_OUTPUT_DIR="${REPO_DIR}/_tmp/api-reference"
TMP_OUTPUT_DIR="${KUBE_ROOT}/_tmp/api-reference"
TMP_ROOT="${KUBE_ROOT}/_tmp"

# Generate API reference docs in tmp.
"./hack/update-api-reference-docs.sh" "${TMP_OUTPUT_DIR}"
"./hack/update-api-reference-docs.sh" "${HOST_OUTPUT_DIR}"

echo "diffing ${API_REFERENCE_DOCS_ROOT} against freshly generated docs"
ret=0
Expand Down

1 comment on commit 04e891c

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 2871 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 193 Build time: 00:10:30

Please sign in to comment.