-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemtests now run completely in containers #46
Conversation
As mentioned on Slack, CI will not pass until the firewall issue is resolved and the unit tests are also containerized (in progress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions. Mostly looks good.
docker run --rm \ | ||
-p 10000:10000 \ | ||
-v $(pwd)/local_certs:/certs:ro \ | ||
ccn_proxy:devbuild \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is devbuild version hardcoded here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script can actually be deleted I guess. This was a convenience script for quickly testing the proxy during the early stages of development. There's now too many external components (datastore, netmaster, AD, etc.) to realistically have a universal "quick run" target.
-p 10000:10000 \ | ||
-v $(pwd)/local_certs:/local_certs:ro \ | ||
--network $NETWORK_NAME \ | ||
ccn_proxy:devbuild \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, why hardcode of version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default name when no BUILD_VERSION is given to the make build
target.
Hmm... I was thinking about this in the context of a CI run (which invokes the make ci
target which runs make build
before tests run). I guess we can't make that assumption and need to always build the main proxy container before tests run (either systemtests or unit tests)
-p 10001:10001 \ | ||
-v $(pwd)/local_certs:/local_certs:ro \ | ||
--network $NETWORK_NAME \ | ||
ccn_proxy:devbuild \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should really be made into a variable. I missed it because originally there was only one proxy being spawned and I just copy-pasted and tweaked the --data-store-address and port
func Test(t *testing.T) { | ||
if len(os.Getenv("DEBUG")) > 0 { | ||
log.SetLevel(log.DebugLevel) | ||
} | ||
|
||
datastore := test.GetDatastore() | ||
proxyHost = os.Getenv("PROXY_ADDRESS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that systemtests assume that proxy is setup and running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this will always be set before this container is invoked. Can you think of a use case for running systemtests in any other way than the make systemtests
target?
I'll add a comment here that this is being set by systemtests_in_container.sh
when the test suite is spun up
|
||
|
||
echo "Stopping etcd proxy container..." | ||
docker stop $ETCD_PROXY_CONTAINER_ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker rm -f -v to do both in one shot? Same for all below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll test this tomorrow and make sure it does The Right Thing™ when the container doesn't shut down in a timely manner. docker stop
lets you specify a timeout (which I use when shutting down the systemtests container)
Removed Also, cleaned up the systemtests.sh script a bit by moving some redundant IP stuff into a function and adding more comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Nice hack with the systemtest container start!
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will having this local save us some CI headaches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you thinking that we put it into the repo itself? This will permanently increase the size of the repo by ~70mb for each version we upgrade to, and Github will start yelling at us and telling us to use their Large File Storage service 🙃
Also because we COPY
the whole repo into our build container, it'll slow down almost every Docker-related operation we do here... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points :) Ignore the suggestion. I wish we could build and push this to docker hub once and reuse it, though docker pull has its reliability issues too.
echo 1>&2 "${out}" | ||
exit 1 | ||
# only build the base if necessary (saves a lot of time) | ||
if [[ "$(docker images -q ccn_proxy_build_base 2>/dev/null)" == "" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when go version changes? Why is the image not being cached and how much additional time do you see this step taking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm going to remove the caching on this stuff and just change us to a more lightweight base image instead of using ubuntu:16.04
set -e | ||
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ] | ||
then | ||
echo 1>&2 "gocycle errors in:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gocycle -> gocyclo. Wouldn't it be simpler to move 10-60 to a function and call all the commands using it - something like run_check("gofmt", gofmt -s -l ${files}) ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is originally from volplugin (https://github.com/contiv/volplugin/blob/0453e29b4d9916ae35ae492b9f3f302ff72bcc58/build/scripts/checks.sh) and we were using it verbatim. In this PR, I just removed the "fetch if not installed" lines because we're baking them in in the Dockerfile.checks
I'll fix this typo though :)
# 12. stops etcd container | ||
# 13. stops consul container | ||
# 14. destroys the docker network | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you use the mock server vs a real netmaster for the system tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a peek at any of the systemtests/*_test.go
files and look for the runTest()
function. Each systemtest has the MockServer injected into it and it can be programmed in a test-specific way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I misread the actual question being asked here. As mentioned on Slack, we don't support running the systemtests against a real netmaster for various logistical reasons. We use the mockserver to emulate the responses a real netmaster would send (@yuva29 did the heavy lifting on that) and validate that we process them properly.
docker exec $SYSTEMTESTS_CONTAINER_ID bash ./scripts/systemtests_in_container.sh $ETCD_PROXY_ADDRESS $CONSUL_PROXY_ADDRESS || true | ||
|
||
# ---- CLEANUP ------------------------------------------------------------------ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the logs stored somewhere, in case things fail and we want to debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the test logs are written to stdout, and there's additional output if the DEBUG
envvar is set. I actually need to pass -e DEBUG="$DEBUG"
to the systemtests container docker run
command...
I think having the tests clean up after themselves by default is a good idea, but I'm open to ideas around allowing state to hang around afterwards. Maybe a KEEP_CONTAINERS
envvar you can set will result in the containers not being deleted? The downside there is that you would need to manually delete all the containers and then delete the Docker network before you could run the systemtests again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the CI gets them through stdout it is sufficient. For the rare cases where we need the containers themselves running (which is a pure proxy case should be very rare), we can change it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run DEBUG=1 make systemtests
, you'll now get log.Debug*()
output on stdout/stderr as well 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Signed-off-by: Bill Robinson <[email protected]>
Signed-off-by: Bill Robinson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Copied from the top of systemtests.sh:
Fixes https://github.com/contiv/ccn/issues/84