Skip to content

Commit

Permalink
Merge pull request #46 from dseevr/make_testing_great_again
Browse files Browse the repository at this point in the history
systemtests now run completely in containers
  • Loading branch information
dseevr authored Jan 6, 2017
2 parents 93df860 + b71dbac commit 55648a8
Show file tree
Hide file tree
Showing 18 changed files with 374 additions and 218 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ build: checks
checks:
@bash ./scripts/checks.sh

# ci does everything necessary for a Github PR-triggered CI run
ci: checks test
# ci does everything necessary for a Github PR-triggered CI run.
# currently, this means building a container image and running
# all of the available tests. (systemtests require a container)
ci: build test

# generate-certificate generates a local key and cert for running the proxy.
# if an existing certificate and key exist, it will do nothing.
Expand All @@ -35,8 +37,7 @@ run: build generate-certificate

# systemtests runs the system tests suite.
systemtests:
go get gopkg.in/check.v1
go test -v -timeout 5m ./systemtests -check.v
@bash ./scripts/systemtests.sh

# unittests runs all the unit tests
unit-tests:
Expand Down
18 changes: 18 additions & 0 deletions build/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:16.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y upgrade && \
apt-get -y install curl build-essential docker.io

RUN curl -O https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.7.4.linux-amd64.tar.gz && rm go1.7.4.linux-amd64.tar.gz

ENV PATH="/usr/local/go/bin:$PATH"
ENV GOPATH="/go"

RUN mkdir -p /go/src/github.com/contiv/ccn_proxy

WORKDIR /go/src/github.com/contiv/ccn_proxy

ENTRYPOINT ["/bin/bash"]
15 changes: 1 addition & 14 deletions build/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
FROM ubuntu:16.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y upgrade && \
apt-get -y install curl build-essential docker.io

RUN curl -O https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.7.4.linux-amd64.tar.gz && rm go1.7.4.linux-amd64.tar.gz

ENV PATH="/usr/local/go/bin:$PATH"
ENV GOPATH="/go"
FROM ccn_proxy_build_base

COPY ./ /go/src/github.com/contiv/ccn_proxy

WORKDIR /go/src/github.com/contiv/ccn_proxy

RUN scripts/build-in-container.sh

ENTRYPOINT ["docker", "build"]
9 changes: 9 additions & 0 deletions build/Dockerfile.checks
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ccn_proxy_build_base

RUN go get github.com/gordonklaus/ineffassign
RUN go get github.com/golang/lint/golint
RUN go get github.com/fzipp/gocyclo
RUN go get github.com/client9/misspell/...
RUN go get github.com/remyoudompheng/go-misc/deadcode/...

ENTRYPOINT ["/bin/bash", "./scripts/checks_in_container.sh"]
9 changes: 9 additions & 0 deletions build/Dockerfile.systemtests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ccn_proxy_build_base

# go-check must be installed to run systemtests
RUN go get gopkg.in/check.v1

COPY ./ /go/src/github.com/contiv/ccn_proxy

ENTRYPOINT ["/bin/bash"]
#, "./scripts/systemtests_in_container.sh"]
3 changes: 3 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ fi

cd $START_DIR

# ensure base has been built
docker build -t "ccn_proxy_build_base" -f ./build/Dockerfile.base .

# create a local build image
docker build -t $BUILD_IMAGE_NAME -f ./build/Dockerfile.build .

Expand Down
91 changes: 10 additions & 81 deletions scripts/checks.sh
Original file line number Diff line number Diff line change
@@ -1,85 +1,14 @@
#!/bin/sh
#!/bin/bash

set -e
set -euo pipefail

dirs=$(go list ./... | sed -e 's!github.com/contiv/ccn_proxy!.!g' | grep -v ./vendor)
files=$(find . -type f -name '*.go' | grep -v ./vendor)
CHECKS_CONTAINER_NAME="ccn_proxy_checks"

echo "Running gofmt..."
set +e
out=$(gofmt -s -l ${files})
set -e
# gofmt can include empty lines in its output
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gofmt errors in:"
echo 1>&2 "${out}"
exit 1
fi
docker build -t "ccn_proxy_build_base" -f ./build/Dockerfile.base .
docker build -t $CHECKS_CONTAINER_NAME -f ./build/Dockerfile.checks .

echo "Running ineffassign..."
[ -n "`which ineffassign`" ] || go get github.com/gordonklaus/ineffassign
for i in ${dirs}
do
ineffassign $i
done

echo "Running golint..."
[ -n "`which golint`" ] || go get github.com/golang/lint/golint
set +e
out=$(golint ./... | grep -vE '^vendor')
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "golint errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running govet..."
set +e
out=$(go tool vet -composites=false ${dirs} 2>&1 | grep -v vendor)
set -e

if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "go vet errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running gocyclo..."
[ -n "`which gocyclo`" ] || go get github.com/fzipp/gocyclo
set +e
out=$(gocyclo -over 15 . | grep -v vendor)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gocycle errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running misspell..."
[ -n "`which misspell`" ] || go get github.com/client9/misspell/...
set +e
out=$(misspell -locale US -error -i exportfs ${files})
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "misspell errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running deadcode..."
[ -n "`which deadcode`" ] || go get github.com/remyoudompheng/go-misc/deadcode/...
set +e
out=$(deadcode ${dirs} 2>&1)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "deadcode errors in:"
echo 1>&2 "${out}"
exit 1
fi
# the ccn_proxy directory exists in the base image, but it's empty so we'll
# bindmount the current directory into it.
docker run --rm \
-v $(pwd):/go/src/github.com/contiv/ccn_proxy:ro \
$CHECKS_CONTAINER_NAME
82 changes: 82 additions & 0 deletions scripts/checks_in_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

set -e

export PATH="/go/bin:$PATH"

dirs=$(go list ./... | sed -e 's!github.com/contiv/ccn_proxy!.!g' | grep -v ./vendor)
files=$(find . -type f -name '*.go' | grep -v ./vendor)

echo "Running gofmt..."
set +e
out=$(gofmt -s -l ${files})
set -e
# gofmt can include empty lines in its output
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gofmt errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running ineffassign..."
for i in ${dirs}
do
ineffassign $i
done

echo "Running golint..."
set +e
out=$(golint ./... | grep -vE '^vendor')
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "golint errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running govet..."
set +e
out=$(go tool vet -composites=false ${dirs} 2>&1 | grep -v vendor)
set -e

if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "go vet errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running gocyclo..."
set +e
out=$(gocyclo -over 15 . | grep -v vendor)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gocyclo errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running misspell..."
set +e
out=$(misspell -locale US -error -i exportfs ${files})
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "misspell errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running deadcode..."
set +e
out=$(deadcode ${dirs} 2>&1)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "deadcode errors in:"
echo 1>&2 "${out}"
exit 1
fi
Empty file modified scripts/generate-certificate.sh
100644 → 100755
Empty file.
30 changes: 0 additions & 30 deletions scripts/run.sh

This file was deleted.

Loading

0 comments on commit 55648a8

Please sign in to comment.