From 101ba2245a96134964c92c1fd8de54751e482b5f Mon Sep 17 00:00:00 2001 From: cvgw Date: Sat, 29 Feb 2020 15:34:38 -0800 Subject: [PATCH] Split travis integration tests Split integration tests into three travis jobs and move image building to it's own stage. TestRun and TestLayers each have their own job while the rest of the integration tests run in a single job --- .travis.yml | 23 +++++++++++++++-------- Makefile | 17 +++++++++++++++++ misc-integration-test.sh | 35 +++++++++++++++++++++++++++++++++++ travis-setup.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 8 deletions(-) create mode 100755 misc-integration-test.sh create mode 100755 travis-setup.sh diff --git a/.travis.yml b/.travis.yml index 9c29dcebd..df05f880a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,14 +11,21 @@ jobs: - name: unit-test script: - make test - - name: integration-test + - name: integration-test-run before_install: - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - - sudo apt-get update - - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - - curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && chmod +x container-diff-linux-amd64 && sudo mv container-diff-linux-amd64 /usr/local/bin/container-diff - - docker run -d -p 5000:5000 --restart always --name registry registry:2 + - make travis-setup + script: + - make integration-test-run + - name: integration-test-layers + before_install: + - make travis-setup + script: + - make integration-test-layers + - name: integration-test-misc + before_install: + - make travis-setup + script: + - make integration-test-misc + - stage: build-images script: - - make integration-test - make images diff --git a/Makefile b/Makefile index 3f67aa797..07d5804e2 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,10 @@ out/executor: $(GO_FILES) out/warmer: $(GO_FILES) GOARCH=$(GOARCH) GOOS=linux CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -o $@ $(WARMER_PACKAGE) +.PHONY: travis-setup +travis-setup: + @ ./travis-setup.sh + .PHONY: test test: out/executor @ ./test.sh @@ -61,6 +65,19 @@ test: out/executor integration-test: @ ./integration-test.sh +.PHONY: integration-test-run +integration-test-run: + @ ./integration-test.sh -run "TestRun" + +.PHONY: integration-test-layers +integration-test-layers: + @ ./integration-test.sh -run "TestLayers" + +.PHONY: integration-test-misc +integration-test-misc: + $(eval RUN_ARG=$(shell ./misc-integration-test.sh)) + @ ./integration-test.sh -run "$(RUN_ARG)" + .PHONY: images images: docker build ${BUILD_ARG} --build-arg=GOARCH=$(GOARCH) -t $(REGISTRY)/executor:latest -f deploy/Dockerfile . diff --git a/misc-integration-test.sh b/misc-integration-test.sh new file mode 100755 index 000000000..c227fcb14 --- /dev/null +++ b/misc-integration-test.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Copyright 2020 Google LLC +# +# 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. + +# This script runs all integration tests except for +# TestRun and TestLayers +set -e + +TESTS=$(./integration-test.sh -list=Test -mod=vendor) + +TESTS=$(echo $TESTS | tr ' ' '\n' | grep 'Test'| grep -v 'TestRun' | grep -v 'TestLayers') + +RUN_ARG='' +count=0 +for i in $TESTS; do + if [ "$count" -gt "0" ]; then + RUN_ARG="$RUN_ARG|$i" + else + RUN_ARG="$RUN_ARG$i" + fi + count=$((count+1)) +done + +echo $RUN_ARG diff --git a/travis-setup.sh b/travis-setup.sh new file mode 100755 index 000000000..c8e957843 --- /dev/null +++ b/travis-setup.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright 2020 Google LLC +# +# 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. + +set -ex + +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +sudo apt-get update +sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce +curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && chmod +x container-diff-linux-amd64 && sudo mv container-diff-linux-amd64 /usr/local/bin/container-diff +docker run -d -p 5000:5000 --restart always --name registry registry:2 + +mkdir -p $HOME/.docker/ +echo '{}' > $HOME/.docker/config.json