From 66e12ca65291cbf8d0a0b5deb00ed56301ad99d6 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Thu, 1 Feb 2018 15:20:53 -0800 Subject: [PATCH] migrate to prow, which uses node-e2e to run tests --- Makefile | 3 ++ build/integration.sh | 19 ++++---- build/jenkins_e2e.sh | 67 ---------------------------- build/prow_e2e.sh | 42 +++++++++++++++++ integration/tests/api/docker_test.go | 6 +-- 5 files changed, 55 insertions(+), 82 deletions(-) delete mode 100755 build/jenkins_e2e.sh create mode 100755 build/prow_e2e.sh diff --git a/Makefile b/Makefile index 5c127f63..34fe625c 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,9 @@ test: @$(GO) test -short -race $(pkgs) test-integration: + GO_FLAGS="-race" ./build/build.sh + go test -c github.com/google/cadvisor/integration/tests/api + go test -c github.com/google/cadvisor/integration/tests/healthz @./build/integration.sh test-runner: diff --git a/build/integration.sh b/build/integration.sh index fc2cfaef..5cd5dc32 100755 --- a/build/integration.sh +++ b/build/integration.sh @@ -14,21 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -if [[ -n "${JENKINS_HOME}" ]]; then - exec ./build/jenkins_e2e.sh -fi - set -e -# Build the test binary. -GO_FLAGS="-race" ./build/build.sh +log_file="cadvisor.log" +if [ "$#" -gt 0 ]; then + log_file="$1" +fi TEST_PID=$$ -sudo printf "" # Refresh sudo credentials if necessary. +printf "" # Refresh sudo credentials if necessary. function start { set +e # We want to handle errors if cAdvisor crashes. echo ">> starting cAdvisor locally" - GORACE="halt_on_error=1" sudo -E ./cadvisor --docker_env_metadata_whitelist=TEST_VAR + GORACE="halt_on_error=1" ./cadvisor --docker_env_metadata_whitelist=TEST_VAR --v=4 --logtostderr &> "$log_file" if [ $? != 0 ]; then echo "!! cAdvisor exited unexpectedly with Exit $?" kill $TEST_PID # cAdvisor crashed: abort testing. @@ -40,7 +38,7 @@ RUNNER_PID=$! function cleanup { if pgrep cadvisor > /dev/null; then echo ">> stopping cAdvisor" - sudo pkill -SIGINT cadvisor + pkill -SIGINT cadvisor wait $RUNNER_PID fi } @@ -58,4 +56,5 @@ while [ "$(curl -Gs http://localhost:8080/healthz)" != "ok" ]; do done echo ">> running integration tests against local cAdvisor" -go test github.com/google/cadvisor/integration/tests/... --vmodule=*=2 +./api.test --vmodule=*=2 +./healthz.test --vmodule=*=2 diff --git a/build/jenkins_e2e.sh b/build/jenkins_e2e.sh deleted file mode 100755 index 36e4a49b..00000000 --- a/build/jenkins_e2e.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2016 Google Inc. All rights reserved. -# -# 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 -e -set -x - -BUILDER=${BUILDER:-false} # Whether this is running a PR builder job. - -export GO_FLAGS="-race" -export GORACE="halt_on_error=1" - -# Check whether assets need to be rebuilt. -FORCE=true build/assets.sh -if [[ ! -z "$(git diff --name-only pages)" ]]; then - echo "Found changes to UI assets:" - git diff --name-only pages - echo "Run: `make assets FORCE=true`" - exit 1 -fi - -# Build & test with go 1.8 -docker run --rm \ - -w "/go/src/github.com/google/cadvisor" \ - -v "${GOPATH}/src/github.com/google/cadvisor:/go/src/github.com/google/cadvisor" \ - golang:1.8 make all test-runner - -# Nodes that are currently stable. When tests fail on a specific node, and the failure is not remedied within a week, that node will be removed from this list. -golden_nodes=( - e2e-cadvisor-ubuntu-trusty - e2e-cadvisor-container-vm-v20151215 - e2e-cadvisor-container-vm-v20160127 - e2e-cadvisor-rhel-7 -) - -# TODO: Add test on GCI - -# TODO: Add test for kubernetes default image -# e2e-cadvisor-container-vm-v20160321 - -# TODO: Temporarily disabled for #1344 -# e2e-cadvisor-coreos-beta - -# TODO: enable when docker 1.10 is working -# e2e-cadvisor-ubuntu-trusty-docker110 - -# TODO: Always fails with "Network tx and rx bytes should not be equal" -# e2e-cadvisor-centos-v7 - -max_retries=8 - -./runner --logtostderr --test-retry-count=$max_retries \ - --test-retry-whitelist=integration/runner/retrywhitelist.txt \ - --ssh-options "-i /var/lib/jenkins/gce_keys/google_compute_engine -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no -o StrictHostKeyChecking=no" \ - ${golden_nodes[*]} diff --git a/build/prow_e2e.sh b/build/prow_e2e.sh new file mode 100755 index 00000000..22e84b65 --- /dev/null +++ b/build/prow_e2e.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Copyright 2018 Google Inc. All rights reserved. +# +# 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 -e +set -x + +BUILDER=${BUILDER:-false} # Whether this is running a PR builder job. + +export GO_FLAGS="-race" +export GORACE="halt_on_error=1" + +# cd to cadvisor directory +parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +cd "$parent_path/.." + +# Check whether assets need to be rebuilt. +FORCE=true build/assets.sh +if [[ ! -z "$(git diff --name-only pages)" ]]; then + echo "Found changes to UI assets:" + git diff --name-only pages + echo "Run: `make assets FORCE=true`" + exit 1 +fi + +make all + +# compile integration tests so they can be run without go installed +go test -c github.com/google/cadvisor/integration/tests/api +go test -c github.com/google/cadvisor/integration/tests/healthz diff --git a/integration/tests/api/docker_test.go b/integration/tests/api/docker_test.go index dea2f236..bb88127f 100644 --- a/integration/tests/api/docker_test.go +++ b/integration/tests/api/docker_test.go @@ -193,15 +193,11 @@ func TestDockerContainerSpec(t *testing.T) { labels = map[string]string{"bar": "baz"} ) - cpusetArg := "--cpuset" - if getDockerMinorVersion(fm) >= 10 { - cpusetArg = "--cpuset-cpus" - } containerId := fm.Docker().Run(framework.DockerRunArgs{ Image: image, Args: []string{ "--cpu-shares", strconv.FormatUint(cpuShares, 10), - cpusetArg, cpuMask, + "--cpuset-cpus", cpuMask, "--memory", strconv.FormatUint(memoryLimit, 10), "--env", "TEST_VAR=FOO", "--label", "bar=baz",