From c5ec719d4803975cfdd73a787514a693828b48a6 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 2 Jul 2020 00:14:30 +0200 Subject: [PATCH 01/13] Update Envoy to 5c553261d14730af5a2c290c4b3687ae667a65db Signed-off-by: Otto van der Schaaf --- .bazelrc | 19 ++++++++++++++++++- .circleci/config.yml | 4 ++-- bazel/repositories.bzl | 4 ++-- source/client/benchmark_client_impl.cc | 4 ++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.bazelrc b/.bazelrc index c412ac097..f80346d54 100644 --- a/.bazelrc +++ b/.bazelrc @@ -166,6 +166,11 @@ build:rbe-toolchain-gcc --config=rbe-toolchain build:rbe-toolchain-gcc --crosstool_top=@rbe_ubuntu_gcc//cc:toolchain build:rbe-toolchain-gcc --extra_toolchains=@rbe_ubuntu_gcc//config:cc-toolchain +build:rbe-toolchain-msvc-cl --host_platform=@rbe_windows_msvc_cl//config:platform +build:rbe-toolchain-msvc-cl --platforms=@rbe_windows_msvc_cl//config:platform +build:rbe-toolchain-msvc-cl --crosstool_top=@rbe_windows_msvc_cl//cc:toolchain +build:rbe-toolchain-msvc-cl --extra_toolchains=@rbe_windows_msvc_cl//config:cc-toolchain + build:remote --spawn_strategy=remote,sandboxed,local build:remote --strategy=Javac=remote,sandboxed,local build:remote --strategy=Closure=remote,sandboxed,local @@ -174,6 +179,15 @@ build:remote --remote_timeout=7200 build:remote --auth_enabled=true build:remote --remote_download_toplevel +# Windows bazel does not allow sandboxed as a spawn strategy +build:remote-windows --spawn_strategy=remote,local +build:remote-windows --strategy=Javac=remote,local +build:remote-windows --strategy=Closure=remote,local +build:remote-windows --strategy=Genrule=remote,local +build:remote-windows --remote_timeout=7200 +build:remote-windows --auth_enabled=true +build:remote-windows --remote_download_toplevel + build:remote-clang --config=remote build:remote-clang --config=rbe-toolchain-clang @@ -187,9 +201,12 @@ build:remote-msan --config=remote build:remote-msan --config=rbe-toolchain-clang-libc++ build:remote-msan --config=rbe-toolchain-msan +build:remote-msvc-cl --config=remote-windows +build:remote-msvc-cl --config=rbe-toolchain-msvc-cl + # Docker sandbox # NOTE: Update this from https://github.com/envoyproxy/envoy-build-tools/blob/master/toolchains/rbe_toolchains_config.bzl#L8 -build:docker-sandbox --experimental_docker_image=envoyproxy/envoy-build-ubuntu:12b3d2c2ffa582507e5d6dd34632b2b990f1b195 +build:docker-sandbox --experimental_docker_image=envoyproxy/envoy-build-ubuntu:f21773ab398a879f976936f72c78c9dd3718ca1e build:docker-sandbox --spawn_strategy=docker build:docker-sandbox --strategy=Javac=docker build:docker-sandbox --strategy=Closure=docker diff --git a/.circleci/config.yml b/.circleci/config.yml index e26d70eb6..f24261777 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ references: - envoy-build-image: &envoy-build-image # June 19th, 2020 - envoyproxy/envoy-build-ubuntu:12b3d2c2ffa582507e5d6dd34632b2b990f1b195 + envoy-build-image: &envoy-build-image # July 1st, 2020 + envoyproxy/envoy-build-ubuntu:f21773ab398a879f976936f72c78c9dd3718ca1e version: 2 jobs: build: diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 03fcd69b5..6882d1f92 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,7 +1,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -ENVOY_COMMIT = "5c553261d14730af5a2c290c4b3687ae667a65db" # June 26th, 2020 -ENVOY_SHA = "ebfd3ead4347d27542aa7603ba2ce650d4ada7bdc21441073b85cf2e26f257d8" +ENVOY_COMMIT = "3cc670d82f44b8dda710c7e16ad23873c9d7544a" # July 1st, 2020 +ENVOY_SHA = "0aa72dcad4425d315f6e14d92c9997aa8fd74081dfd91c1db7598b7d3583111f" HDR_HISTOGRAM_C_VERSION = "0.9.13" # Feb 22nd, 2020 HDR_HISTOGRAM_C_SHA = "2bd4a4631b64f2f8cf968ef49dd03ff3c51b487c3c98a01217ae4cf4a35b8310" diff --git a/source/client/benchmark_client_impl.cc b/source/client/benchmark_client_impl.cc index 8987fdfc6..0a76c1547 100644 --- a/source/client/benchmark_client_impl.cc +++ b/source/client/benchmark_client_impl.cc @@ -38,8 +38,8 @@ Http1PoolImpl::newStream(Envoy::Http::ResponseDecoder& response_decoder, // of ready_clients_, which will pick the oldest one instead. This makes us cycle through // all the available connections. if (!ready_clients_.empty() && connection_reuse_strategy_ == ConnectionReuseStrategy::LRU) { - auto context = std::make_pair(&response_decoder, &callbacks); - attachRequestToClientImpl(*ready_clients_.back(), &context); + Envoy::Http::HttpAttachContext context({&response_decoder, &callbacks}); + attachRequestToClient(*ready_clients_.back(), context); return nullptr; } From 0c4619d2a308802de7b099949000836aed3ddaa9 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Thu, 2 Jul 2020 09:50:24 +0200 Subject: [PATCH 02/13] Update Envoy to f6b86a58b264b46a57d71a9b3b0989b2969df408 Signed-off-by: Otto van der Schaaf --- bazel/repositories.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 6882d1f92..c3dc11867 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,7 +1,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -ENVOY_COMMIT = "3cc670d82f44b8dda710c7e16ad23873c9d7544a" # July 1st, 2020 -ENVOY_SHA = "0aa72dcad4425d315f6e14d92c9997aa8fd74081dfd91c1db7598b7d3583111f" +ENVOY_COMMIT = "f6b86a58b264b46a57d71a9b3b0989b2969df408" # July 2nd, 2020 +ENVOY_SHA = "5c802266f0cdc5193b6e0247a0f5f20f39f6cc36b688b194e60a853148ba438a" HDR_HISTOGRAM_C_VERSION = "0.9.13" # Feb 22nd, 2020 HDR_HISTOGRAM_C_SHA = "2bd4a4631b64f2f8cf968ef49dd03ff3c51b487c3c98a01217ae4cf4a35b8310" From 1aeac7a0a8839111920afeeddd533119338eb705 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 3 Jul 2020 10:50:19 +0200 Subject: [PATCH 03/13] CI: Test that we can produce artifacts with gcc - First iteration on testing gcc support in CI. This restricts the task to just building Nighthawk, and not testing it yet, as that needs a change in Envoy to go in first. - Small cleanup, and a bugfix for those who use the script to run locally, which would be detected as running in CircleCI. - [ ] Prerequisite: https://github.com/envoyproxy/nighthawk/pull/394 Signed-off-by: Otto van der Schaaf --- .circleci/config.yml | 6 +++--- ci/do_ci.sh | 46 ++++++++++++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f24261777..352d6513a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,8 +23,8 @@ jobs: resource_class: xlarge steps: - checkout - - run: ci/do_ci.sh clang_tidy - test_with_valgrind: + - run: ci/do_ci.sh test_gcc + test_gcc: docker: - image: *envoy-build-image resource_class: xlarge @@ -88,8 +88,8 @@ workflows: jobs: - build - test + - test_gcc - clang_tidy - # - test_with_valgrind - coverage - asan - tsan diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 39c618052..89c939269 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -50,13 +50,22 @@ function do_coverage() { exit 0 } +function setup_gcc_toolchain() { + ENVOY_STDLIB="${ENVOY_STDLIB:-libstdc++}" + export CC=gcc + export CXX=g++ + export BAZEL_COMPILER=gcc + echo "$CC/$CXX toolchain configured" +} + function setup_clang_toolchain() { - export PATH=/opt/llvm/bin:$PATH - export CC=clang - export CXX=clang++ - export ASAN_SYMBOLIZER_PATH=/opt/llvm/bin/llvm-symbolizer - export BAZEL_COMPILER=clang - echo "$CC/$CXX toolchain configured" + ENVOY_STDLIB="${ENVOY_STDLIB:-libc++}" + if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then + export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" + else + export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}" + fi + echo "clang toolchain with ${ENVOY_STDLIB} configured" } function run_bazel() { @@ -150,7 +159,7 @@ function do_fix_format() { ./tools/format_python_tools.sh fix } -if [ -n "$CIRCLECI" ]; then +if [ -z "$CIRCLECI" ]; then if [[ -f "${HOME:-/root}/.gitconfig" ]]; then mv "${HOME:-/root}/.gitconfig" "${HOME:-/root}/.gitconfig_save" echo 1 @@ -195,24 +204,32 @@ export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYT --test_env=UBSAN_OPTIONS=print_stacktrace=1 \ --cache_test_results=no --test_output=all ${BAZEL_EXTRA_TEST_OPTIONS}" -setup_clang_toolchain export CLANG_FORMAT=clang-format case "$1" in build) + setup_clang_toolchain do_build exit 0 ;; test) + setup_clang_toolchain do_test exit 0 ;; - test_with_valgrind) - do_test_with_valgrind + test_gcc) + if [ -z "$CIRCLECI" ]; then + NUM_CPUS=7 + fi + setup_gcc_toolchain + # TODO(#362): change the line below to do_test once the upstream merges the gcc build fix + # for our tests. + do_build exit 0 ;; clang_tidy) - if [ -n "$CIRCLECI" ]; then + setup_clang_toolchain + if [ -z "$CIRCLECI" ]; then # Decrease parallelism to avoid running out of memory NUM_CPUS=7 fi @@ -220,18 +237,22 @@ case "$1" in exit 0 ;; coverage) + setup_clang_toolchain do_coverage exit 0 ;; asan) + setup_clang_toolchain do_asan exit 0 ;; tsan) + setup_clang_toolchain do_tsan exit 0 ;; docker) + setup_clang_toolchain do_docker exit 0 ;; @@ -244,11 +265,12 @@ case "$1" in exit 0 ;; benchmark_with_own_binaries) + setup_clang_toolchain do_benchmark_with_own_binaries exit 0 ;; *) - echo "must be one of [build,test,clang_tidy,test_with_valgrind,coverage,asan,tsan,benchmark_with_own_binaries,docker,check_format,fix_format]" + echo "must be one of [build,test,clang_tidy,coverage,asan,tsan,benchmark_with_own_binaries,docker,check_format,fix_format,test_gcc]" exit 1 ;; esac From bbe2b8b075373c61443a40eab8076f6d7025bee8 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 3 Jul 2020 11:17:07 +0200 Subject: [PATCH 04/13] Add setup_clang.sh, quick test Signed-off-by: Otto van der Schaaf --- .gitignore | 3 ++- bazel/setup_clang.sh | 32 ++++++++++++++++++++++++++++++++ ci/do_ci.sh | 5 +++-- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100755 bazel/setup_clang.sh diff --git a/.gitignore b/.gitignore index a099a0c5f..b6e4c0984 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ tools/pyformat test/coverage/BUILD *.bak default.profraw -tmp-* \ No newline at end of file +tmp-* +clang.bazelrc \ No newline at end of file diff --git a/bazel/setup_clang.sh b/bazel/setup_clang.sh new file mode 100755 index 000000000..0ed987b9d --- /dev/null +++ b/bazel/setup_clang.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +BAZELRC_FILE="${BAZELRC_FILE:-$(bazel info workspace)/clang.bazelrc}" + +LLVM_PREFIX=$1 + +if [[ ! -e "${LLVM_PREFIX}/bin/llvm-config" ]]; then + echo "Error: cannot find llvm-config in ${LLVM_PREFIX}." + exit 1 +fi + +export PATH="$(${LLVM_PREFIX}/bin/llvm-config --bindir):${PATH}" + +RT_LIBRARY_PATH="$(dirname $(find $(llvm-config --libdir) -name libclang_rt.ubsan_standalone_cxx-x86_64.a | head -1))" + +echo "# Generated file, do not edit. If you want to disable clang, just delete this file. +build:clang --action_env='PATH=${PATH}' +build:clang --action_env=CC=clang +build:clang --action_env=CXX=clang++ +build:clang --action_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config' +build:clang --repo_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config' +build:clang --linkopt='-L$(llvm-config --libdir)' +build:clang --linkopt='-Wl,-rpath,$(llvm-config --libdir)' + +build:clang-asan --action_env=ENVOY_UBSAN_VPTR=1 +build:clang-asan --copt=-fsanitize=vptr,function +build:clang-asan --linkopt=-fsanitize=vptr,function +build:clang-asan --linkopt='-L${RT_LIBRARY_PATH}' +build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone-x86_64.a +build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone_cxx-x86_64.a +" > ${BAZELRC_FILE} + diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 89c939269..fa73a9207 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -59,6 +59,7 @@ function setup_gcc_toolchain() { } function setup_clang_toolchain() { + bazel/setup_clang.sh /usr/lib/llvm-10 ENVOY_STDLIB="${ENVOY_STDLIB:-libc++}" if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" @@ -222,8 +223,8 @@ case "$1" in NUM_CPUS=7 fi setup_gcc_toolchain - # TODO(#362): change the line below to do_test once the upstream merges the gcc build fix - # for our tests. + # TODO(#362): change the line below to do_test once the upstream merges + # https://github.com/envoyproxy/envoy/pull/10236 do_build exit 0 ;; From f727bf3c38248c6aa9a9fb0e92e08421de61b265 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 3 Jul 2020 11:32:17 +0200 Subject: [PATCH 05/13] Fix clang setup Signed-off-by: Otto van der Schaaf --- .gitignore | 1 - bazel/setup_clang.sh | 32 -------------------------------- ci/do_ci.sh | 14 ++++++-------- 3 files changed, 6 insertions(+), 41 deletions(-) delete mode 100755 bazel/setup_clang.sh diff --git a/.gitignore b/.gitignore index b6e4c0984..2970d2e8a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ test/coverage/BUILD *.bak default.profraw tmp-* -clang.bazelrc \ No newline at end of file diff --git a/bazel/setup_clang.sh b/bazel/setup_clang.sh deleted file mode 100755 index 0ed987b9d..000000000 --- a/bazel/setup_clang.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -BAZELRC_FILE="${BAZELRC_FILE:-$(bazel info workspace)/clang.bazelrc}" - -LLVM_PREFIX=$1 - -if [[ ! -e "${LLVM_PREFIX}/bin/llvm-config" ]]; then - echo "Error: cannot find llvm-config in ${LLVM_PREFIX}." - exit 1 -fi - -export PATH="$(${LLVM_PREFIX}/bin/llvm-config --bindir):${PATH}" - -RT_LIBRARY_PATH="$(dirname $(find $(llvm-config --libdir) -name libclang_rt.ubsan_standalone_cxx-x86_64.a | head -1))" - -echo "# Generated file, do not edit. If you want to disable clang, just delete this file. -build:clang --action_env='PATH=${PATH}' -build:clang --action_env=CC=clang -build:clang --action_env=CXX=clang++ -build:clang --action_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config' -build:clang --repo_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config' -build:clang --linkopt='-L$(llvm-config --libdir)' -build:clang --linkopt='-Wl,-rpath,$(llvm-config --libdir)' - -build:clang-asan --action_env=ENVOY_UBSAN_VPTR=1 -build:clang-asan --copt=-fsanitize=vptr,function -build:clang-asan --linkopt=-fsanitize=vptr,function -build:clang-asan --linkopt='-L${RT_LIBRARY_PATH}' -build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone-x86_64.a -build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone_cxx-x86_64.a -" > ${BAZELRC_FILE} - diff --git a/ci/do_ci.sh b/ci/do_ci.sh index fa73a9207..be9886bcc 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -59,14 +59,12 @@ function setup_gcc_toolchain() { } function setup_clang_toolchain() { - bazel/setup_clang.sh /usr/lib/llvm-10 - ENVOY_STDLIB="${ENVOY_STDLIB:-libc++}" - if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then - export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" - else - export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}" - fi - echo "clang toolchain with ${ENVOY_STDLIB} configured" + export PATH=/opt/llvm/bin:$PATH + export CC=clang + export CXX=clang++ + export ASAN_SYMBOLIZER_PATH=/opt/llvm/bin/llvm-symbolizer + export BAZEL_COMPILER=clang + echo "clang toolchain configured" } function run_bazel() { From f6f5c0c7596621e14a8eb3ee8d016276a796e851 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 3 Jul 2020 13:19:29 +0200 Subject: [PATCH 06/13] Fix CIRCLECI testing Signed-off-by: Otto van der Schaaf --- ci/do_ci.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index be9886bcc..cef0f4556 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -7,7 +7,7 @@ set -u export BUILDIFIER_BIN="${BUILDIFIER_BIN:=/usr/local/bin/buildifier}" export BUILDOZER_BIN="${BUILDOZER_BIN:=/usr/local/bin/buildozer}" export NUM_CPUS=${NUM_CPUS:=$(grep -c ^processor /proc/cpuinfo)} -export CIRCLECI=${CIRCLECI:="")} +export CIRCLECI=${CIRCLECI:=""} export BAZEL_EXTRA_TEST_OPTIONS=${BAZEL_EXTRA_TEST_OPTIONS:=""} export BAZEL_OPTIONS=${BAZEL_OPTIONS:=""} export BAZEL_BUILD_EXTRA_OPTIONS=${BAZEL_BUILD_EXTRA_OPTIONS:=""} @@ -158,7 +158,7 @@ function do_fix_format() { ./tools/format_python_tools.sh fix } -if [ -z "$CIRCLECI" ]; then +if [ -n "$CIRCLECI" ]; then if [[ -f "${HOME:-/root}/.gitconfig" ]]; then mv "${HOME:-/root}/.gitconfig" "${HOME:-/root}/.gitconfig_save" echo 1 @@ -217,7 +217,7 @@ case "$1" in exit 0 ;; test_gcc) - if [ -z "$CIRCLECI" ]; then + if [ -n "$CIRCLECI" ]; then NUM_CPUS=7 fi setup_gcc_toolchain @@ -228,7 +228,7 @@ case "$1" in ;; clang_tidy) setup_clang_toolchain - if [ -z "$CIRCLECI" ]; then + if [ -n "$CIRCLECI" ]; then # Decrease parallelism to avoid running out of memory NUM_CPUS=7 fi From 2ac7b0464785242f5324cf98d1071adc0bda0d83 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 3 Jul 2020 13:23:35 +0200 Subject: [PATCH 07/13] Mimimize diff & cleanup Signed-off-by: Otto van der Schaaf --- ci/do_ci.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index cef0f4556..93b5938f0 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -51,20 +51,19 @@ function do_coverage() { } function setup_gcc_toolchain() { - ENVOY_STDLIB="${ENVOY_STDLIB:-libstdc++}" - export CC=gcc - export CXX=g++ - export BAZEL_COMPILER=gcc - echo "$CC/$CXX toolchain configured" + export CC=gcc + export CXX=g++ + export BAZEL_COMPILER=gcc + echo "$CC/$CXX toolchain configured" } function setup_clang_toolchain() { - export PATH=/opt/llvm/bin:$PATH - export CC=clang - export CXX=clang++ - export ASAN_SYMBOLIZER_PATH=/opt/llvm/bin/llvm-symbolizer - export BAZEL_COMPILER=clang - echo "clang toolchain configured" + export PATH=/opt/llvm/bin:$PATH + export CC=clang + export CXX=clang++ + export ASAN_SYMBOLIZER_PATH=/opt/llvm/bin/llvm-symbolizer + export BAZEL_COMPILER=clang + echo "$CC/$CXX toolchain configured" } function run_bazel() { From 99c7e33c741b4babe6f982f933ef043239e126fe Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 3 Jul 2020 13:30:27 +0200 Subject: [PATCH 08/13] Some tweaks, fix gcc_test Signed-off-by: Otto van der Schaaf --- .circleci/config.yml | 4 ++-- ci/do_ci.sh | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 352d6513a..2115c51b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,14 +23,14 @@ jobs: resource_class: xlarge steps: - checkout - - run: ci/do_ci.sh test_gcc + - run: ci/do_ci.sh clang_tidy test_gcc: docker: - image: *envoy-build-image resource_class: xlarge steps: - checkout - - run: ci/do_ci.sh test_with_valgrind + - run: ci/do_ci.sh test_gcc coverage: docker: - image: *envoy-build-image diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 93b5938f0..f5f356e94 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -163,7 +163,7 @@ if [ -n "$CIRCLECI" ]; then echo 1 fi # We constrain parallelism in CI to avoid running out of memory. - NUM_CPUS=8 + NUM_CPUS=6 if [[ "$1" == "asan" ]]; then NUM_CPUS=5 fi @@ -216,9 +216,6 @@ case "$1" in exit 0 ;; test_gcc) - if [ -n "$CIRCLECI" ]; then - NUM_CPUS=7 - fi setup_gcc_toolchain # TODO(#362): change the line below to do_test once the upstream merges # https://github.com/envoyproxy/envoy/pull/10236 @@ -227,10 +224,6 @@ case "$1" in ;; clang_tidy) setup_clang_toolchain - if [ -n "$CIRCLECI" ]; then - # Decrease parallelism to avoid running out of memory - NUM_CPUS=7 - fi do_clang_tidy exit 0 ;; @@ -255,10 +248,12 @@ case "$1" in exit 0 ;; check_format) + setup_clang_toolchain do_check_format exit 0 ;; fix_format) + setup_clang_toolchain do_fix_format exit 0 ;; From c438df805840e719ca92fb48b9a8999ca048df5f Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Sat, 4 Jul 2020 00:47:36 +0200 Subject: [PATCH 09/13] Lower asan parallelism in CI (3) Signed-off-by: Otto van der Schaaf --- ci/do_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index f5f356e94..9b67fe822 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -165,7 +165,7 @@ if [ -n "$CIRCLECI" ]; then # We constrain parallelism in CI to avoid running out of memory. NUM_CPUS=6 if [[ "$1" == "asan" ]]; then - NUM_CPUS=5 + NUM_CPUS=3 fi if [[ "$1" == "coverage" ]]; then NUM_CPUS=3 From 89aca7b932a730e52400de4541c09314193427b1 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Sat, 4 Jul 2020 11:09:47 +0200 Subject: [PATCH 10/13] Try experimental_local_memory_estimate feature Signed-off-by: Otto van der Schaaf --- ci/do_ci.sh | 48 +++++++++++---------------------- tools/valgrind-suppressions.txt | 12 --------- tools/valgrind-tests.sh | 4 --- tools/valgrind.sh | 1 - 4 files changed, 16 insertions(+), 49 deletions(-) delete mode 100644 tools/valgrind-suppressions.txt delete mode 100755 tools/valgrind-tests.sh delete mode 100755 tools/valgrind.sh diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 9b67fe822..105d98b73 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -14,24 +14,17 @@ export BAZEL_BUILD_EXTRA_OPTIONS=${BAZEL_BUILD_EXTRA_OPTIONS:=""} export SRCDIR=${SRCDIR:="${PWD}"} function do_build () { - bazel build $BAZEL_BUILD_OPTIONS --verbose_failures=true //:nighthawk + bazel build $BAZEL_BUILD_OPTIONS //:nighthawk tools/update_cli_readme_documentation.sh --mode check } function do_opt_build () { - bazel build $BAZEL_BUILD_OPTIONS -c opt --verbose_failures=true //:nighthawk + bazel build $BAZEL_BUILD_OPTIONS -c opt //:nighthawk } function do_test() { - bazel test $BAZEL_BUILD_OPTIONS $BAZEL_TEST_OPTIONS \ - --test_output=all \ - //test/... -} - -function do_test_with_valgrind() { - apt-get update && apt-get install valgrind && \ - bazel build $BAZEL_BUILD_OPTIONS -c dbg //test/... && \ - nighthawk/tools/valgrind-tests.sh + bazel build $BAZEL_BUILD_OPTIONS $BAZEL_TEST_OPTIONS //test/... + bazel test $BAZEL_BUILD_OPTIONS $BAZEL_TEST_OPTIONS --test_output=all //test/... } function do_clang_tidy() { @@ -41,11 +34,6 @@ function do_clang_tidy() { function do_coverage() { export TEST_TARGETS="//test/..." echo "bazel coverage build with tests ${TEST_TARGETS}" - - # Reduce the amount of memory Bazel tries to use to prevent it from launching too many subprocesses. - # This should prevent the system from running out of memory and killing tasks. See discussion on - # https://github.com/envoyproxy/envoy/pull/5611. - [ -z "$CIRCLECI" ] || export BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --local_ram_resources=12288" test/run_nighthawk_bazel_coverage.sh ${TEST_TARGETS} exit 0 } @@ -100,7 +88,7 @@ function do_tsan() { echo "bazel TSAN debug build with tests" echo "Building and testing envoy tests..." cd "${SRCDIR}" - [ -z "$CIRCLECI" ] || export BAZEL_BUILD_OPTIONS="${BAZEL_TEST_OPTIONS} --local_ram_resources=12288" + run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan -- //test/... && \ run_bazel test ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan //test/... } @@ -157,21 +145,6 @@ function do_fix_format() { ./tools/format_python_tools.sh fix } -if [ -n "$CIRCLECI" ]; then - if [[ -f "${HOME:-/root}/.gitconfig" ]]; then - mv "${HOME:-/root}/.gitconfig" "${HOME:-/root}/.gitconfig_save" - echo 1 - fi - # We constrain parallelism in CI to avoid running out of memory. - NUM_CPUS=6 - if [[ "$1" == "asan" ]]; then - NUM_CPUS=3 - fi - if [[ "$1" == "coverage" ]]; then - NUM_CPUS=3 - fi -fi - if grep 'docker\|lxc' /proc/1/cgroup; then # Create a fake home. Python site libs tries to do getpwuid(3) if we don't and the CI # Docker image gets confused as it has no passwd entry when running non-root @@ -204,6 +177,17 @@ export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYT export CLANG_FORMAT=clang-format +if [ -n "$CIRCLECI" ]; then + if [[ -f "${HOME:-/root}/.gitconfig" ]]; then + mv "${HOME:-/root}/.gitconfig" "${HOME:-/root}/.gitconfig_save" + echo 1 + fi + # Reduce the amount of memory Bazel tries to use to prevent it from launching too many subprocesses. + # This should prevent the system from running out of memory and killing tasks. See discussion on + # https://github.com/envoyproxy/envoy/pull/5611. + export BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --experimental_local_memory_estimate" +fi + case "$1" in build) setup_clang_toolchain diff --git a/tools/valgrind-suppressions.txt b/tools/valgrind-suppressions.txt deleted file mode 100644 index dce24197c..000000000 --- a/tools/valgrind-suppressions.txt +++ /dev/null @@ -1,12 +0,0 @@ -{ - - Memcheck:Leak - match-leak-kinds: definite - fun:_Znam - fun:InitModule - fun:_ZN15MallocExtension8RegisterEPS_ - fun:__cxx_global_var_init.2 - fun:_GLOBAL__sub_I_tcmalloc.cc - fun:__libc_csu_init - fun:(below main) -} \ No newline at end of file diff --git a/tools/valgrind-tests.sh b/tools/valgrind-tests.sh deleted file mode 100755 index 0b00311eb..000000000 --- a/tools/valgrind-tests.sh +++ /dev/null @@ -1,4 +0,0 @@ -export TEST_WORKSPACE=. -export TEST_SRCDIR="$(pwd)" -export ENVOY_IP_TEST_VERSIONS="v4only" -valgrind --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=nighthawk/envoy/tools/valgrind-suppressions.txt --suppressions=nighthawk/tools/valgrind-suppressions.txt bazel-bin/test/nighthawk_test diff --git a/tools/valgrind.sh b/tools/valgrind.sh deleted file mode 100755 index 049b2dacb..000000000 --- a/tools/valgrind.sh +++ /dev/null @@ -1 +0,0 @@ -valgrind --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=nighthawk/envoy/tools/valgrind-suppressions.txt --suppressions=nighthawk/tools/valgrind-suppressions.txt bazel-bin/nighthawk_client --rps 2 http://127.0.0.1:10000/ From 4414576b601ccab0d186faaf22dbb50ba59fc174 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Sat, 4 Jul 2020 11:24:47 +0200 Subject: [PATCH 11/13] Clean up Signed-off-by: Otto van der Schaaf --- ci/do_ci.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 105d98b73..b187a1952 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -12,6 +12,7 @@ export BAZEL_EXTRA_TEST_OPTIONS=${BAZEL_EXTRA_TEST_OPTIONS:=""} export BAZEL_OPTIONS=${BAZEL_OPTIONS:=""} export BAZEL_BUILD_EXTRA_OPTIONS=${BAZEL_BUILD_EXTRA_OPTIONS:=""} export SRCDIR=${SRCDIR:="${PWD}"} +export CLANG_FORMAT=clang-format function do_build () { bazel build $BAZEL_BUILD_OPTIONS //:nighthawk @@ -23,8 +24,8 @@ function do_opt_build () { } function do_test() { - bazel build $BAZEL_BUILD_OPTIONS $BAZEL_TEST_OPTIONS //test/... - bazel test $BAZEL_BUILD_OPTIONS $BAZEL_TEST_OPTIONS --test_output=all //test/... + bazel build $BAZEL_BUILD_OPTIONS //test/... + bazel test $BAZEL_TEST_OPTIONS --test_output=all //test/... } function do_clang_tidy() { @@ -88,7 +89,7 @@ function do_tsan() { echo "bazel TSAN debug build with tests" echo "Building and testing envoy tests..." cd "${SRCDIR}" - run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan -- //test/... && \ + run_bazel build ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan -- //test/... && \ run_bazel test ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan //test/... } @@ -170,24 +171,23 @@ fi export BAZEL_EXTRA_TEST_OPTIONS="--test_env=ENVOY_IP_TEST_VERSIONS=v4only ${BAZEL_EXTRA_TEST_OPTIONS}" export BAZEL_BUILD_OPTIONS=" \ --verbose_failures ${BAZEL_OPTIONS} --action_env=HOME --action_env=PYTHONUSERBASE \ ---jobs=${NUM_CPUS} --show_task_finish --experimental_generate_json_trace_profile ${BAZEL_BUILD_EXTRA_OPTIONS}" -export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \ ---test_env=UBSAN_OPTIONS=print_stacktrace=1 \ ---cache_test_results=no --test_output=all ${BAZEL_EXTRA_TEST_OPTIONS}" - -export CLANG_FORMAT=clang-format +--experimental_local_memory_estimate \ +--show_task_finish --experimental_generate_json_trace_profile ${BAZEL_BUILD_EXTRA_OPTIONS}" if [ -n "$CIRCLECI" ]; then if [[ -f "${HOME:-/root}/.gitconfig" ]]; then mv "${HOME:-/root}/.gitconfig" "${HOME:-/root}/.gitconfig_save" echo 1 fi - # Reduce the amount of memory Bazel tries to use to prevent it from launching too many subprocesses. - # This should prevent the system from running out of memory and killing tasks. See discussion on - # https://github.com/envoyproxy/envoy/pull/5611. - export BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --experimental_local_memory_estimate" + export NUM_CPUS=6 fi +BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --jobs=${NUM_CPUS}" + +export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \ +--test_env=UBSAN_OPTIONS=print_stacktrace=1 \ +--cache_test_results=no --test_output=all ${BAZEL_EXTRA_TEST_OPTIONS}" + case "$1" in build) setup_clang_toolchain From 7c365fe90e192949d147029ab47a27481e47b4f7 Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Sat, 4 Jul 2020 12:53:58 +0200 Subject: [PATCH 12/13] Never mind. Adjust asan/coverage NUM_CPU settings. Signed-off-by: Otto van der Schaaf --- ci/do_ci.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index b187a1952..f3e63addd 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -89,7 +89,10 @@ function do_tsan() { echo "bazel TSAN debug build with tests" echo "Building and testing envoy tests..." cd "${SRCDIR}" - run_bazel build ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan -- //test/... && \ + run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan -- //source/exe/... && \ + run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan -- //source/server/... && \ + run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan -- //test/mocks/... && \ + run_bazel build ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan -- //test/... && \ run_bazel test ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-tsan //test/... } @@ -179,9 +182,17 @@ if [ -n "$CIRCLECI" ]; then mv "${HOME:-/root}/.gitconfig" "${HOME:-/root}/.gitconfig_save" echo 1 fi - export NUM_CPUS=6 + + # Asan has huge memory requirements in its link steps. + # As of the new coverage methodology introduced in Envoy, that has grown memory requirements too. + # Hence we heavily reduce parallellism, to avoid being OOM killed. + if [[ "$1" == "asan" ]] || [[ "$1" == "coverage" ]]; then + NUM_CPUS=3 + else + NUM_CPUS=8 + fi fi - +echo "Running with ${NUM_CPUS} cpus" BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --jobs=${NUM_CPUS}" export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \ From cd20455b4897badb50eb8f01b2ae1c4a65a4f89c Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Sat, 4 Jul 2020 23:13:32 +0200 Subject: [PATCH 13/13] Turns out x2large is not available :(. Increase output timeout. force push to fix DCO Signed-off-by: Otto van der Schaaf --- .circleci/config.yml | 4 +++- ci/do_ci.sh | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2115c51b6..505a8ff5b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,9 @@ jobs: resource_class: xlarge steps: - checkout - - run: ci/do_ci.sh asan + - run: + command: ci/do_ci.sh asan + no_output_timeout: 30m tsan: docker: - image: *envoy-build-image diff --git a/ci/do_ci.sh b/ci/do_ci.sh index f3e63addd..ce17ca080 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -186,9 +186,11 @@ if [ -n "$CIRCLECI" ]; then # Asan has huge memory requirements in its link steps. # As of the new coverage methodology introduced in Envoy, that has grown memory requirements too. # Hence we heavily reduce parallellism, to avoid being OOM killed. - if [[ "$1" == "asan" ]] || [[ "$1" == "coverage" ]]; then + if [[ "$1" == "coverage" ]]; then + NUM_CPUS=4 + elif [[ "$1" == "asan" ]]; then NUM_CPUS=3 - else + else NUM_CPUS=8 fi fi