Skip to content

Commit

Permalink
test(go) go Kong unit tests (#205)
Browse files Browse the repository at this point in the history
* test(go) ability to test GO

* chore(ci) test against next as the default in CI

* chore(ci) add a retry

* chore(ci) only retry the Ubuntu stage
  • Loading branch information
hutchic authored Jan 14, 2020
1 parent 503f103 commit d51a46a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
38 changes: 38 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,44 @@ RUN apt-get update && apt-get install -y \
iputils-ping \
net-tools

ENV GOLANG_VERSION 1.13.5

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture || echo amd64)"; \
case "${dpkgArch##*-}" in \
amd64) goRelArch='linux-amd64'; goRelSha256='512103d7ad296467814a6e3f635631bd35574cab3369a97a323c9a585ccaa569' ;; \
armhf) goRelArch='linux-armv6l'; goRelSha256='26259f61d52ee2297b1e8feef3a0fc82144b666a2b95512402c31cc49713c133' ;; \
arm64) goRelArch='linux-arm64'; goRelSha256='227b718923e20c846460bbecddde9cb86bad73acc5fb6f8e1a96b81b5c84668b' ;; \
*) goRelArch='src'; goRelSha256='27d356e2a0b30d9983b60a788cf225da5f914066b37a6b4f69d457ba55a626ff'; \
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
esac; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
curl -fsSLo go.tgz "$url"; \
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
if [ "$goRelArch" = 'src' ]; then \
echo >&2; \
echo >&2 'error: UNIMPLEMENTED'; \
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
echo >&2; \
exit 1; \
fi; \
\
export PATH="/usr/local/go/bin:$PATH"; \
go version

ENV KONG_GO_PLUGINSERVER_VERSION=master
ENV GOPATH=/tmp/go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

RUN mkdir -p /tmp/go/src/github.com/kong/ \
&& git clone --branch ${KONG_GO_PLUGINSERVER_VERSION} https://github.com/Kong/go-pluginserver.git /tmp/go/src/github.com/kong/go-pluginserver \
&& cd /tmp/go/src/github.com/kong/go-pluginserver \
&& go get ./...


COPY kong /kong
RUN mkdir -p /kong/servroot/logs
Expand Down
20 changes: 12 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
pipeline {
agent none
environment {
KONG_SOURCE = "next"
KONG_SOURCE_LOCATION = "/tmp/kong"
}
stages {
stage('Test Builds') {
parallel {
Expand All @@ -10,8 +14,6 @@ pipeline {
}
}
environment {
KONG_SOURCE = "master"
KONG_SOURCE_LOCATION = "/tmp/kong"
PACKAGE_TYPE = "rpm"
RESTY_IMAGE_BASE = "rhel"
DOCKERHUB = credentials('dockerhub')
Expand All @@ -34,8 +36,6 @@ pipeline {
}
}
environment {
KONG_SOURCE = "master"
KONG_SOURCE_LOCATION = "/tmp/kong"
PACKAGE_TYPE = "rpm"
RESTY_IMAGE_BASE = "centos"
DOCKERHUB = credentials('dockerhub')
Expand All @@ -59,8 +59,6 @@ pipeline {
}
}
environment {
KONG_SOURCE = "master"
KONG_SOURCE_LOCATION = "/tmp/kong"
PACKAGE_TYPE = "deb"
RESTY_IMAGE_BASE = "debian"
DOCKERHUB = credentials('dockerhub')
Expand All @@ -84,9 +82,10 @@ pipeline {
label 'docker-compose'
}
}
options {
retry(2)
}
environment {
KONG_SOURCE = "master"
KONG_SOURCE_LOCATION = "/tmp/kong"
PACKAGE_TYPE = "deb"
RESTY_IMAGE_BASE = "ubuntu"
DOCKERHUB = credentials('dockerhub')
Expand All @@ -104,6 +103,11 @@ pipeline {
sh 'export BUILDX=false RESTY_IMAGE_TAG=bionic && make package-kong && make test'
sh 'export CACHE=false UPDATE_CACHE=true RESTY_IMAGE_TAG=xenial DOCKER_MACHINE_ARM64_NAME="jenkins-kong-"`cat /proc/sys/kernel/random/uuid` && make setup-build && make package-kong && make test'
}
post {
always {
sh 'make cleanup-build'
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ kong-test-container:
ifneq ($(RESTY_IMAGE_BASE),src)
$(CACHE_COMMAND) kong/kong-build-tools:test-$(DOCKER_TEST_SUFFIX) || \
( $(MAKE) build-kong && $(DOCKER_COMMAND) -f Dockerfile.test \
--build-arg KONG_GO_PLUGINSERVER_VERSION=$(KONG_GO_PLUGINSERVER_VERSION) \
--build-arg DOCKER_KONG_SUFFIX=$(DOCKER_KONG_SUFFIX) \
--build-arg DOCKER_BASE_SUFFIX=$(DOCKER_BASE_SUFFIX) \
--build-arg KONG_SHA=${KONG_SHA} \
Expand Down

0 comments on commit d51a46a

Please sign in to comment.