Skip to content

Commit

Permalink
Merge branch 'envoyproxy:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dubious90 authored Apr 12, 2022
2 parents e574320 + 5f72e3d commit d6d72ad
Show file tree
Hide file tree
Showing 25 changed files with 437 additions and 37 deletions.
25 changes: 25 additions & 0 deletions .azure-pipelines/bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
parameters:
- name: ciTarget
displayName: "CI target"
type: string
default: build

steps:
- bash: |
echo "disk space at beginning of build:"
df -h
displayName: "Check disk space at beginning"

- script: ci/run_envoy_docker.sh 'ci/do_ci.sh ${{ parameters.ciTarget }}'
workingDirectory: $(Build.SourcesDirectory)
displayName: "Run the CI script"
env:
BAZEL_REMOTE_CACHE: $(LocalBuildCache)

- bash: |
echo "disk space at end of build:"
df -h
# Cleanup offending files with unicode names
rm -rf $(Build.StagingDirectory)/tmp/*/*/external/go_sdk/test/fixedbugs
displayName: "Check disk space at end"
condition: always()
25 changes: 25 additions & 0 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
trigger:
branches:
include:
- "main"

stages:
- stage: check
dependsOn: []
jobs:
- job: bazel
displayName: "do_ci.sh"
dependsOn: []
strategy:
maxParallel: 1
matrix:
build:
CI_TARGET: "build"
test:
CI_TARGET: "test"
timeoutInMinutes: 120
pool: "x64-large"
steps:
- template: bazel.yml
parameters:
ciTarget: $(CI_TARGET)
5 changes: 4 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ build --action_env=CXX
build --action_env=LLVM_CONFIG
build --action_env=PATH

# Disable ICU linking for googleurl.
build --@com_googlesource_googleurl//build_config:system_icu=0

# Common flags for sanitizers
build:sanitizer --define tcmalloc=disabled
build:sanitizer --linkopt -ldl
Expand Down Expand Up @@ -288,7 +291,7 @@ build:remote-clang-cl --config=rbe-toolchain-clang-cl

# Docker sandbox
# NOTE: Update this from https://github.com/envoyproxy/envoy-build-tools/blob/main/toolchains/rbe_toolchains_config.bzl#L8
build:docker-sandbox --experimental_docker_image=envoyproxy/envoy-build-ubuntu:514e2f7bc36c1f0495a523b16aab9168a4aa13b6
build:docker-sandbox --experimental_docker_image=envoyproxy/envoy-build-ubuntu:142e6d5662b98277a84c327da26ed266ab0e3191
build:docker-sandbox --spawn_strategy=docker
build:docker-sandbox --strategy=Javac=docker
build:docker-sandbox --strategy=Closure=docker
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
references:
envoy-build-image: &envoy-build-image
envoyproxy/envoy-build-ubuntu:514e2f7bc36c1f0495a523b16aab9168a4aa13b6
envoyproxy/envoy-build-ubuntu:142e6d5662b98277a84c327da26ed266ab0e3191
version: 2
jobs:
build:
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bazel build -c opt //:nighthawk
USAGE:
bazel-bin/nighthawk_client [--latency-response-header-name <string>]
[--stats-flush-interval-duration <duration>]
[--stats-flush-interval <uint32_t>]
[--stats-sinks <string>] ... [--no-duration]
[--simple-warmup]
Expand Down Expand Up @@ -99,9 +100,14 @@ tandem with the test server's response option
"emit_previous_request_delta_in_response_header" to record elapsed
time between request arrivals. Default: ""
--stats-flush-interval-duration <duration>
Time interval (in Duration) between flushes to configured stats sinks.
For example '1s' or '1.000000001s'. Mutually exclusive with
--stats-flush-interval.
--stats-flush-interval <uint32_t>
Time interval (in seconds) between flushes to configured stats sinks.
Default: 5.
Mutually exclusive with --stats-flush-interval-duration. Default: 5.
--stats-sinks <string> (accepted multiple times)
Stats sinks (in json) where Nighthawk metrics will be flushed. This
Expand Down Expand Up @@ -251,8 +257,8 @@ Use proactive connection prefetching (HTTP/1 only).
--output-format <json|human|yaml|dotted|fortio
|experimental_fortio_pedantic>
Output format. Possible values: {"json", "human", "yaml", "dotted",
"fortio", "experimental_fortio_pedantic"}. The default output format
Output format. Possible values: ["json", "human", "yaml", "dotted",
"fortio", "experimental_fortio_pedantic"]. The default output format
is 'human'.
-v <trace|debug|info|warn|error|critical>, --verbosity <trace|debug
Expand Down Expand Up @@ -384,8 +390,8 @@ Where:
--output-format <json|human|yaml|dotted|fortio
|experimental_fortio_pedantic>
(required) Output format. Possible values: {"json", "human", "yaml",
"dotted", "fortio", "experimental_fortio_pedantic"}.
(required) Output format. Possible values: ["json", "human", "yaml",
"dotted", "fortio", "experimental_fortio_pedantic"].
--, --ignore_rest
Ignores the rest of the labeled arguments following this flag.
Expand Down
20 changes: 15 additions & 5 deletions api/client/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ message Protocol {

// TODO(oschaaf): Ultimately this will be a load test specification. The fact that it
// can arrive via CLI is just a concrete detail. Change this to reflect that.
// Highest unused number is 110.
// Highest unused number is 111.
message CommandLineOptions {
// The target requests-per-second rate. Default: 5.
google.protobuf.UInt32Value requests_per_second = 1
Expand Down Expand Up @@ -264,10 +264,20 @@ message CommandLineOptions {
google.protobuf.BoolValue simple_warmup = 32;
// Optional set of stat sinks where Nighthawk metrics will be flushed to.
repeated envoy.config.metrics.v3.StatsSink stats_sinks = 34;
// Time interval (number of seconds) between periodical flushes to configured stats sinks. If not
// specified the default is 5 seconds. Time interval must be at least 1s and at most 300s.
google.protobuf.UInt32Value stats_flush_interval = 35
[(validate.rules).uint32 = {gte: 1, lte: 300}];

oneof oneof_stats_flush_interval {
// Time interval (number of seconds) between periodical flushes to
// configured stats sinks. If not specified the default is 5 seconds.
// stats_flush_interval must be at least 1s and at most 300s.
google.protobuf.UInt32Value stats_flush_interval = 35
[(validate.rules).uint32 = {gte: 1, lte: 300}];

// Time interval in Duration between periodical flushes to configured stats
// sinks.
google.protobuf.Duration stats_flush_interval_duration = 110
[(validate.rules).duration = {gte {seconds: 0 nanos: 0}}];
}

// Set an optional header name that will be returned in responses, whose values will be tracked in
// a latency histogram if set. Can be used in tandem with the test server's response option
// "emit_previous_request_delta_in_response_header" to record elapsed time between request
Expand Down
4 changes: 2 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

ENVOY_COMMIT = "4ce48c4a89c3aad09949287679ba06a92ca1c540" # Feb 28, 2022
ENVOY_SHA = "bcfa1c291749de3d30771a713df73d908ec3bf850fdae31eb1c77ddd36a2dc5c"
ENVOY_COMMIT = "8cf3a2b9f619f5ca5650a40fb325d6d552ceb8ec" # Apr 4, 2022
ENVOY_SHA = "0423ea507c6bc65d266657c96a97a4c8950f3136130332717e4c600379fd5234"

HDR_HISTOGRAM_C_VERSION = "0.11.2" # October 12th, 2020
HDR_HISTOGRAM_C_SHA = "637f28b5f64de2e268131e4e34e6eef0b91cf5ff99167db447d9b2825eae6bad"
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if __name__ == '__main__':
path = os.path.dirname(os.path.realpath(__file__))
r = pytest.main([
"--rootdir=" + path, "-x", path, "-p", "no:cacheprovider", "--log-level", "INFO",
"--log-cli-level", "INFO", *sys.argv
"--assert=plain", "--rootdir=" + path, "-x", path, "-p", "no:cacheprovider", "--log-level",
"INFO", "--log-cli-level", "INFO", *sys.argv
])
exit(r)
7 changes: 6 additions & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export BAZEL_BUILD_EXTRA_OPTIONS=${BAZEL_BUILD_EXTRA_OPTIONS:=""}
export SRCDIR=${SRCDIR:="${PWD}"}
export CLANG_FORMAT=clang-format
export NIGHTHAWK_BUILD_ARCH=$(uname -m)
export BAZEL_REMOTE_CACHE=${BAZEL_REMOTE_CACHE:=""}

# We build in steps to avoid running out of memory in CI.
# This list doesn't have to be complete, execution of bazel test will build any
Expand Down Expand Up @@ -219,6 +220,10 @@ if grep 'docker\|lxc' /proc/1/cgroup; then
export BAZEL="bazel"
fi

if [ -n "${BAZEL_REMOTE_CACHE}" ]; then
export BAZEL_BUILD_EXTRA_OPTIONS="${BAZEL_BUILD_EXTRA_OPTIONS} --remote_cache=${BAZEL_REMOTE_CACHE}"
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 \
Expand All @@ -236,9 +241,9 @@ if [ -n "$CIRCLECI" ]; then
BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} \
--discard_analysis_cache --notrack_incremental_state --nokeep_state_after_build"
fi
echo "Running with ${NUM_CPUS} cpus and BAZEL_BUILD_OPTIONS: ${BAZEL_BUILD_OPTIONS}"
BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --jobs=${NUM_CPUS}"
fi
echo "Running with ${NUM_CPUS} cpus and BAZEL_BUILD_OPTIONS: ${BAZEL_BUILD_OPTIONS}"

export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \
--test_env=UBSAN_OPTIONS=print_stacktrace=1 \
Expand Down
1 change: 1 addition & 0 deletions include/nighthawk/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ envoy_basic_cc_library(
"@envoy//envoy/common:time_interface",
"@envoy//envoy/http:protocol_interface_with_external_headers",
"@envoy//source/common/common:minimal_logger_lib_with_external_headers",
"@envoy//source/common/protobuf:utility_lib_with_external_headers",
"@envoy_api//envoy/config/cluster/v3:pkg_cc_proto",
"@envoy_api//envoy/config/metrics/v3:pkg_cc_proto",
],
Expand Down
3 changes: 3 additions & 0 deletions include/nighthawk/client/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "nighthawk/common/termination_predicate.h"

#include "external/envoy/source/common/protobuf/protobuf.h"

#include "api/client/options.pb.h"

#include "absl/types/optional.h"
Expand Down Expand Up @@ -86,6 +88,7 @@ class Options {
virtual bool noDuration() const PURE;
virtual std::vector<envoy::config::metrics::v3::StatsSink> statsSinks() const PURE;
virtual uint32_t statsFlushInterval() const PURE;
virtual Envoy::ProtobufWkt::Duration statsFlushIntervalDuration() const PURE;
virtual std::string responseHeaderWithLatencyInput() const PURE;

virtual absl::optional<Envoy::SystemTime> scheduled_start() const PURE;
Expand Down
1 change: 1 addition & 0 deletions source/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ envoy_cc_library(
"@envoy//source/server/config_validation:admin_lib_with_external_headers",
"@envoy//envoy/http:protocol_interface_with_external_headers",
"@envoy//envoy/network:address_interface",
"@envoy//envoy/server:instance_interface",
"@envoy//source/common/common:statusor_lib_with_external_headers",
"@envoy//source/common/router:context_lib_with_external_headers",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
Expand Down
48 changes: 41 additions & 7 deletions source/client/options_impl.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "source/client/options_impl.h"

#include "external/envoy/source/common/protobuf/message_validator_impl.h"
#include "external/envoy/source/common/protobuf/protobuf.h"
#include "external/envoy/source/common/protobuf/utility.h"

#include "api/client/options.pb.validate.h"
Expand Down Expand Up @@ -331,10 +332,16 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv) {

TCLAP::ValueArg<uint32_t> stats_flush_interval(
"", "stats-flush-interval",
fmt::format("Time interval (in seconds) between flushes to configured "
"stats sinks. Default: {}.",
stats_flush_interval_),
fmt::format(
"Time interval (in seconds) between flushes to configured "
"stats sinks. Mutually exclusive with --stats-flush-interval-duration. Default: {}.",
stats_flush_interval_),
false, 5, "uint32_t", cmd);
TCLAP::ValueArg<std::string> stats_flush_interval_duration(
"", "stats-flush-interval-duration",
"Time interval (in Duration) between flushes to configured stats sinks. For example '1s' or "
"'1.000000001s'. Mutually exclusive with --stats-flush-interval.",
false, "", "duration", cmd);

TCLAP::ValueArg<std::string> latency_response_header_name(
"", "latency-response-header-name",
Expand Down Expand Up @@ -362,10 +369,19 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv) {
throw MalformedArgvException("--duration and --no-duration are mutually exclusive");
}

// Verify that if --stats-flush-interval is set, then --stats-sinks must also be set.
if (stats_flush_interval.isSet() && !stats_sinks.isSet()) {
// --stats-flush-interval and --stats-flush-interval-duration are mutually exclusive.
if (stats_flush_interval.isSet() && stats_flush_interval_duration.isSet()) {
throw MalformedArgvException("--stats-flush-interval and --stats-flush-interval-duration are "
"mutually exclusive");
}

// Verify that if --stats-flush-interval or --stats-flush-interval-duration is
// set, then --stats-sinks must also be set.
if ((stats_flush_interval.isSet() || stats_flush_interval_duration.isSet()) &&
!stats_sinks.isSet()) {
throw MalformedArgvException(
"if --stats-flush-interval is set, then --stats-sinks must also be set");
"if --stats-flush-interval or --stats-flush-interval-duration is set, "
"then --stats-sinks must also be set");
}

TCLAP_SET_IF_SPECIFIED(requests_per_second, requests_per_second_);
Expand Down Expand Up @@ -496,6 +512,17 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv) {
}
}
TCLAP_SET_IF_SPECIFIED(stats_flush_interval, stats_flush_interval_);
if (stats_flush_interval_duration.isSet()) {
if (Envoy::Protobuf::util::TimeUtil::FromString(stats_flush_interval_duration.getValue(),
&stats_flush_interval_duration_)) {
if (stats_flush_interval_duration_.nanos() < 0 ||
stats_flush_interval_duration_.seconds() < 0) {
throw MalformedArgvException("--stats-flush-interval-duration is out of range");
}
} else {
throw MalformedArgvException("Invalid value for --stats-flush-interval-duration");
}
}
TCLAP_SET_IF_SPECIFIED(latency_response_header_name, latency_response_header_name_);

// CLI-specific tests.
Expand Down Expand Up @@ -725,6 +752,9 @@ OptionsImpl::OptionsImpl(const nighthawk::client::CommandLineOptions& options) {
}
stats_flush_interval_ =
PROTOBUF_GET_WRAPPED_OR_DEFAULT(options, stats_flush_interval, stats_flush_interval_);
if (options.has_stats_flush_interval_duration()) {
stats_flush_interval_duration_ = options.stats_flush_interval_duration();
}
nighthawk_service_ =
PROTOBUF_GET_WRAPPED_OR_DEFAULT(options, nighthawk_service, nighthawk_service_);
h2_use_multiple_connections_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT(
Expand Down Expand Up @@ -933,7 +963,11 @@ CommandLineOptionsPtr OptionsImpl::toCommandLineOptionsInternal() const {
for (const envoy::config::metrics::v3::StatsSink& stats_sink : stats_sinks_) {
*command_line_options->add_stats_sinks() = stats_sink;
}
command_line_options->mutable_stats_flush_interval()->set_value(stats_flush_interval_);
if (stats_flush_interval_duration_.seconds() > 0 || stats_flush_interval_duration_.nanos() > 0) {
*command_line_options->mutable_stats_flush_interval_duration() = stats_flush_interval_duration_;
} else {
command_line_options->mutable_stats_flush_interval()->set_value(stats_flush_interval_);
}
command_line_options->mutable_latency_response_header_name()->set_value(
latency_response_header_name_);
if (scheduled_start_.has_value()) {
Expand Down
5 changes: 5 additions & 0 deletions source/client/options_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "nighthawk/common/exception.h"

#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/protobuf/protobuf.h"

#include "absl/types/optional.h"
#include "tclap/CmdLine.h"
Expand Down Expand Up @@ -98,6 +99,9 @@ class OptionsImpl : public Options, public Envoy::Logger::Loggable<Envoy::Logger
return stats_sinks_;
}
uint32_t statsFlushInterval() const override { return stats_flush_interval_; }
Envoy::ProtobufWkt::Duration statsFlushIntervalDuration() const override {
return stats_flush_interval_duration_;
}
std::string responseHeaderWithLatencyInput() const override {
return latency_response_header_name_;
};
Expand Down Expand Up @@ -161,6 +165,7 @@ class OptionsImpl : public Options, public Envoy::Logger::Loggable<Envoy::Logger
bool no_duration_{false};
std::vector<envoy::config::metrics::v3::StatsSink> stats_sinks_;
uint32_t stats_flush_interval_{5};
Envoy::ProtobufWkt::Duration stats_flush_interval_duration_;
std::string latency_response_header_name_;
absl::optional<Envoy::SystemTime> scheduled_start_;
absl::optional<std::string> execution_id_;
Expand Down
8 changes: 7 additions & 1 deletion source/client/process_bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ absl::StatusOr<Bootstrap> createBootstrapConfiguration(
for (const StatsSink& stats_sink : options.statsSinks()) {
*bootstrap.add_stats_sinks() = stats_sink;
}
bootstrap.mutable_stats_flush_interval()->set_seconds(options.statsFlushInterval());

if (options.statsFlushIntervalDuration().seconds() > 0 ||
options.statsFlushIntervalDuration().nanos() > 0) {
*bootstrap.mutable_stats_flush_interval() = options.statsFlushIntervalDuration();
} else {
bootstrap.mutable_stats_flush_interval()->set_seconds(options.statsFlushInterval());
}

if (options.upstreamBindConfig().has_value()) {
*bootstrap.mutable_cluster_manager()->mutable_upstream_bind_config() =
Expand Down
Loading

0 comments on commit d6d72ad

Please sign in to comment.