Merge pull request #1090 from cvgw/u/cgwippern/1089-split-integration-tests

Split travis integration tests
This commit is contained in:
Tejal Desai 2020-03-04 14:09:31 -08:00 committed by GitHub
commit d00c84a304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 8 deletions

View File

@ -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

View File

@ -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 .

35
misc-integration-test.sh Executable file
View File

@ -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

26
travis-setup.sh Executable file
View File

@ -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