Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,24 @@ build:coverage --strategy=CoverageReport=sandboxed,local
build:coverage --experimental_use_llvm_covmap
build:coverage --collect_code_coverage
build:coverage --test_tag_filters=-nocoverage
build:coverage --instrumentation_filter="//source(?!/common/chromium_url|/extensions/quic_listeners/quiche/platform)[/:],//include[/:]"
coverage:test-coverage --test_arg="--log-path /dev/null"
build:coverage --instrumentation_filter="//source(?!/extensions/quic_listeners/quiche/platform)[/:],//include[/:]"
coverage:test-coverage --test_arg="-l trace"
coverage:fuzz-coverage --config=asan-fuzzer
coverage:fuzz-coverage --config=plain-fuzzer
coverage:fuzz-coverage --run_under=@envoy//bazel/coverage:fuzz_coverage_wrapper.sh

# Remote execution: https://docs.bazel.build/versions/master/remote-execution.html
build:rbe-toolchain --host_platform=@envoy_build_tools//toolchains:rbe_ubuntu_clang_platform
build:rbe-toolchain --platforms=@envoy_build_tools//toolchains:rbe_ubuntu_clang_platform
build:rbe-toolchain --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

build:rbe-toolchain-clang --config=rbe-toolchain
build:rbe-toolchain-clang --platforms=@rbe_ubuntu_clang//config:platform
build:rbe-toolchain-clang --host_platform=@rbe_ubuntu_clang//config:platform
build:rbe-toolchain-clang --crosstool_top=@rbe_ubuntu_clang//cc:toolchain
build:rbe-toolchain-clang --extra_toolchains=@rbe_ubuntu_clang//config:cc-toolchain
build:rbe-toolchain-clang --action_env=CC=clang --action_env=CXX=clang++ --action_env=PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/llvm/bin

build:rbe-toolchain-clang-libc++ --config=rbe-toolchain
build:rbe-toolchain-clang-libc++ --platforms=@rbe_ubuntu_clang_libcxx//config:platform
build:rbe-toolchain-clang-libc++ --host_platform=@rbe_ubuntu_clang_libcxx//config:platform
build:rbe-toolchain-clang-libc++ --crosstool_top=@rbe_ubuntu_clang_libcxx//cc:toolchain
build:rbe-toolchain-clang-libc++ --extra_toolchains=@rbe_ubuntu_clang_libcxx//config:cc-toolchain
build:rbe-toolchain-clang-libc++ --action_env=CC=clang --action_env=CXX=clang++ --action_env=PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/llvm/bin
Expand All @@ -163,6 +164,8 @@ build:rbe-toolchain-msan --linkopt=-Wl,-rpath,/opt/libcxx_msan/lib
build:rbe-toolchain-msan --config=clang-msan

build:rbe-toolchain-gcc --config=rbe-toolchain
build:rbe-toolchain-gcc --platforms=@rbe_ubuntu_gcc//config:platform
build:rbe-toolchain-gcc --host_platform=@rbe_ubuntu_gcc//config:platform
build:rbe-toolchain-gcc --crosstool_top=@rbe_ubuntu_gcc//cc:toolchain
build:rbe-toolchain-gcc --extra_toolchains=@rbe_ubuntu_gcc//config:cc-toolchain

Expand Down
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
steps:
- checkout
- run: ci/do_ci.sh clang_tidy
test_with_valgrind:
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
Expand All @@ -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
Expand Down Expand Up @@ -88,8 +90,8 @@ workflows:
jobs:
- build
- test
- test_gcc
- clang_tidy
# - test_with_valgrind
- coverage
- asan
- tsan
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ tools/pyformat
test/coverage/BUILD
*.bak
default.profraw
tmp-*
tmp-*
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ envoy_cc_binary(
name = "nighthawk_test_server",
repository = "@envoy",
deps = [
"//source/server:http_dynamic_delay_filter_config",
"//source/server:http_test_server_filter_config",
"@envoy//source/exe:envoy_main_entry_lib",
],
Expand Down
20 changes: 19 additions & 1 deletion api/server/response_options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ package nighthawk.server;
import "google/protobuf/wrappers.proto";
import "validate/validate.proto";
import "envoy/api/v2/core/base.proto";
import "google/protobuf/duration.proto";

// Options that control the test server response.
message ConcurrencyBasedLinearDelay {
// Minimal delay to add to replies.
google.protobuf.Duration minimal_delay = 1 [(validate.rules).duration.gte.nanos = 0];
// Factor to use when adding latency as concurrency increases.
google.protobuf.Duration concurrency_delay_factor = 2 [(validate.rules).duration.gte.nanos = 0];
}

// Options that control the test server response. Can be provided via request
// headers as well as via static file-based configuration. In case both are
// provided, a merge will happen, in which case the header-provided
// configuration will override.
message ResponseOptions {
// List of additional response headers.
repeated envoy.api.v2.core.HeaderValueOption response_headers = 1;
// Number of 'a' characters in the the response body.
uint32 response_body_size = 2 [(validate.rules).uint32 = {lte: 4194304}];
// If true, then echo request headers in the response body.
bool echo_request_headers = 3;

oneof oneof_delay_options {
// Static delay duration.
google.protobuf.Duration static_delay = 4 [(validate.rules).duration.gte.nanos = 0];
// Concurrency based linear delay configuration.
ConcurrencyBasedLinearDelay concurrency_based_linear_delay = 5;
}
}
8 changes: 4 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

ENVOY_COMMIT = "f6b86a58b264b46a57d71a9b3b0989b2969df408" # July 2nd, 2020
ENVOY_SHA = "5c802266f0cdc5193b6e0247a0f5f20f39f6cc36b688b194e60a853148ba438a"
ENVOY_COMMIT = "7abb0e0bbed4f6b6304403b93762614ad385f80d" # July 14th, 2020
ENVOY_SHA = "13fd08f9478e3dee5289581eb8f5f85dfc53fa5ac21555e0e86af536e5a200d8"

HDR_HISTOGRAM_C_VERSION = "0.9.13" # Feb 22nd, 2020
HDR_HISTOGRAM_C_SHA = "2bd4a4631b64f2f8cf968ef49dd03ff3c51b487c3c98a01217ae4cf4a35b8310"
HDR_HISTOGRAM_C_VERSION = "0.11.0" # July 14th, 2020
HDR_HISTOGRAM_C_SHA = "c00696b3d81776675aa2bc62d3642e31bd8a48cc9619c9bd7d4a78762896e353"

def nighthawk_dependencies():
http_archive(
Expand Down
98 changes: 54 additions & 44 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,25 @@ 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:=""}
export SRCDIR=${SRCDIR:="${PWD}"}
export CLANG_FORMAT=clang-format

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 //test/...
bazel test $BAZEL_TEST_OPTIONS --test_output=all //test/...
}

function do_clang_tidy() {
Expand All @@ -41,15 +35,17 @@ 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
}

function setup_gcc_toolchain() {
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
Expand Down Expand Up @@ -93,7 +89,10 @@ 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 -- //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/...
}

Expand Down Expand Up @@ -150,21 +149,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=8
if [[ "$1" == "asan" ]]; then
NUM_CPUS=5
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
Expand All @@ -190,65 +174,91 @@ 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}"
--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

# 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" == "coverage" ]]; then
NUM_CPUS=4
elif [[ "$1" == "asan" ]]; 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 \
--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)
setup_gcc_toolchain
do_test
exit 0
;;
clang_tidy)
if [ -n "$CIRCLECI" ]; then
# Decrease parallelism to avoid running out of memory
NUM_CPUS=7
fi
setup_clang_toolchain
do_clang_tidy
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
;;
check_format)
setup_clang_toolchain
do_check_format
exit 0
;;
fix_format)
setup_clang_toolchain
do_fix_format
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
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ pytest
pytest-dependency
pytest-xdist
pyyaml
zipp
importlib_metadata
1 change: 1 addition & 0 deletions source/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ envoy_cc_library(
"//include/nighthawk/common:base_includes",
"//source/common:request_source_impl_lib",
"//source/common:nighthawk_common_lib",
"@envoy//source/common/common:random_generator_lib_with_external_headers",
"@envoy//source/common/access_log:access_log_manager_lib_with_external_headers",
"@envoy//source/common/api:api_lib_with_external_headers",
"@envoy//source/common/common:cleanup_lib_with_external_headers",
Expand Down
3 changes: 2 additions & 1 deletion source/client/benchmark_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "nighthawk/common/statistic.h"

#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/common/random_generator.h"
#include "external/envoy/source/common/http/http1/conn_pool.h"
#include "external/envoy/source/common/http/http2/conn_pool.h"
#include "external/envoy/source/common/runtime/runtime_impl.h"
Expand Down Expand Up @@ -129,7 +130,7 @@ class BenchmarkClientHttpImpl : public BenchmarkClient,
uint32_t max_active_requests_{UINT32_MAX};
uint32_t max_requests_per_connection_{UINT32_MAX};
Envoy::Event::TimerPtr timer_;
Envoy::Runtime::RandomGeneratorImpl generator_;
Envoy::Random::RandomGeneratorImpl generator_;
uint64_t requests_completed_{};
uint64_t requests_initiated_{};
bool measure_latencies_{};
Expand Down
3 changes: 2 additions & 1 deletion source/client/process_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "external/envoy/source/common/access_log/access_log_manager_impl.h"
#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/common/random_generator.h"
#include "external/envoy/source/common/event/real_time_system.h"
#include "external/envoy/source/common/grpc/context_impl.h"
#include "external/envoy/source/common/http/context_impl.h"
Expand Down Expand Up @@ -133,7 +134,7 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger

Envoy::Init::ManagerImpl init_manager_;
Envoy::LocalInfo::LocalInfoPtr local_info_;
Envoy::Runtime::RandomGeneratorImpl generator_;
Envoy::Random::RandomGeneratorImpl generator_;
Envoy::Server::ConfigTrackerImpl config_tracker_;
Envoy::Secret::SecretManagerImpl secret_manager_;
Envoy::Http::ContextImpl http_context_;
Expand Down
Loading