diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 7cfd177fd..f3367efd9 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -255,6 +255,14 @@ function do_check_format() { ./tools/format_python_tools.sh check } +function do_build_nighthawk_image() { + echo "Building docker images" + do_opt_build + + echo "do_docker: Running ci/docker/docker_build.sh." + ./ci/docker/docker_build.sh +} + function do_docker() { echo "docker..." cd "${SRCDIR}" @@ -368,6 +376,11 @@ case "$1" in do_opt_build exit 0 ;; + build_nighthawk_image) + setup_clang_toolchain + do_build_nighthawk_image + exit 0 + ;; *) echo "must be one of [opt_build,build,test,clang_tidy,coverage,coverage_integration,asan,tsan,benchmark_with_own_binaries,docker,check_format,fix_format,test_gcc]" exit 1 diff --git a/ci/docker/Dockerfile-nighthawk b/ci/docker/Dockerfile-nighthawk index 46813bca3..10e148e0a 100644 --- a/ci/docker/Dockerfile-nighthawk +++ b/ci/docker/Dockerfile-nighthawk @@ -1,18 +1,19 @@ FROM ubuntu:24.04@sha256:1e622c5f073b4f6bfad6632f2616c7f59ef256e96fe78bf6a595d1dc4376ac02 -RUN apt-get update && apt-get install libatomic1 +RUN apt -y update && apt -y install libatomic1 curl ADD nighthawk_client /usr/local/bin/nighthawk_client ADD nighthawk_test_server /usr/local/bin/nighthawk_test_server ADD nighthawk_output_transform /usr/local/bin/nighthawk_output_transform ADD nighthawk_service /usr/local/bin/nighthawk_service ADD nighthawk_adaptive_load_client /usr/local/bin/nighthawk_adaptive_load_client -ADD default-config.yaml /etc/envoy/envoy.yaml + +ADD default-config.yaml /etc/nighthawk/nighthawk.yaml # Ports for nighthawk_test_server, see default-config.yaml -EXPOSE 10001 -EXPOSE 10080 +EXPOSE 10001 10080 # The default port for nighthawk_service EXPOSE 8443 -CMD ["-c", "/etc/envoy/envoy.yaml"] +ENTRYPOINT ["/usr/local/bin/nighthawk_test_server"] +CMD ["-c", "/etc/nighthawk/nighthawk.yaml"] diff --git a/ci/docker/default-config.yaml b/ci/docker/default-config.yaml index 741c9800c..a0575b5c6 100644 --- a/ci/docker/default-config.yaml +++ b/ci/docker/default-config.yaml @@ -5,31 +5,40 @@ admin: socket_address: { address: 0.0.0.0, port_value: 10001 } static_resources: listeners: - - address: - socket_address: - address: 0.0.0.0 - port_value: 10080 - filter_chains: - - filters: - - name: envoy.http_connection_manager - config: - generate_request_id: false - codec_type: auto - stat_prefix: ingress_http - route_config: - name: local_route - virtual_hosts: - - name: service - domains: - - "*" - http_filters: - - name: time-tracking - - name: dynamic-delay - - name: test-server - config: - response_body_size: 10 - v3_response_headers: - - { header: { key: "x-nh", value: "1"}} - - name: envoy.router - config: - dynamic_stats: false + - address: + socket_address: + address: 0.0.0.0 + port_value: 10080 + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + generate_request_id: false + codec_type: AUTO + stat_prefix: ingress_http + route_config: + name: local_route + virtual_hosts: + - name: service + domains: + - "*" + http_filters: + - name: time-tracking + typed_config: + "@type": type.googleapis.com/nighthawk.server.TimeTrackingConfiguration + emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta + - name: dynamic-delay + typed_config: + "@type": type.googleapis.com/nighthawk.server.DynamicDelayConfiguration + static_delay: 0s + - name: test-server # before envoy.router because order matters! + typed_config: + "@type": type.googleapis.com/nighthawk.server.ResponseOptions + response_body_size: 10 + v3_response_headers: + - { header: { key: "x-nh", value: "1" } } + - name: envoy.filters.http.router + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router + dynamic_stats: false diff --git a/ci/docker/docker_build.sh b/ci/docker/docker_build.sh index 54361e49f..fd32e01ec 100755 --- a/ci/docker/docker_build.sh +++ b/ci/docker/docker_build.sh @@ -10,8 +10,8 @@ set -e # publishing sensitive information into public CI logs if someone makes a change in a # consuming script that is off guard. -DOCKER_NAME="nighthawk" -DOCKER_IMAGE_PREFIX="envoyproxy/${DOCKER_NAME}" +DOCKER_IMAGE_PREFIX="${DOCKER_IMAGE_PREFIX:-envoyproxy/nighthawk}" + BINARIES=(nighthawk_test_server nighthawk_client nighthawk_service nighthawk_output_transform nighthawk_adaptive_load_client) BAZEL_BIN="$(bazel info -c opt bazel-bin)" WORKSPACE="$(bazel info workspace)" @@ -33,6 +33,6 @@ done cd "${TMP_DIR}" echo "running docker build ... " -docker build -f "${TMP_DIR}/Dockerfile-${DOCKER_NAME}" -t "${DOCKER_IMAGE_PREFIX}-dev:latest" . +docker build -f "${TMP_DIR}/Dockerfile-nighthawk" -t "${DOCKER_IMAGE_PREFIX}-dev:latest" . rm -rf "${TMP_DIR}" echo "docker build finished" diff --git a/source/client/benchmark_client_impl.cc b/source/client/benchmark_client_impl.cc index d166e46ac..08b565334 100644 --- a/source/client/benchmark_client_impl.cc +++ b/source/client/benchmark_client_impl.cc @@ -127,7 +127,7 @@ void BenchmarkClientHttpImpl::terminate() { ENVOY_LOG(info, "Wait for the connection pool drain timed out, proceeding to hard shutdown."); dispatcher_.exit(); }); - drain_timer_->enableTimer(30s); + drain_timer_->enableTimer(timeout_); dispatcher_.run(Envoy::Event::Dispatcher::RunType::RunUntilExit); } } diff --git a/source/client/benchmark_client_impl.h b/source/client/benchmark_client_impl.h index 81ee2d9c6..2501c16f8 100644 --- a/source/client/benchmark_client_impl.h +++ b/source/client/benchmark_client_impl.h @@ -123,6 +123,7 @@ class BenchmarkClientHttpImpl : public BenchmarkClient, void setMaxRequestsPerConnection(uint32_t max_requests_per_connection) { max_requests_per_connection_ = max_requests_per_connection; } + void setTimeout(std::chrono::seconds timeout) { timeout_ = timeout; } // BenchmarkClient void terminate() override; @@ -161,7 +162,7 @@ class BenchmarkClientHttpImpl : public BenchmarkClient, Envoy::Stats::ScopeSharedPtr scope_; BenchmarkClientStatistic statistic_; const Envoy::Http::Protocol protocol_; - std::chrono::seconds timeout_{5s}; + std::chrono::seconds timeout_{30s}; uint32_t connection_limit_{1}; uint32_t max_pending_requests_{1}; uint32_t max_active_requests_{UINT32_MAX}; diff --git a/source/client/factories_impl.cc b/source/client/factories_impl.cc index 99ab69a4a..569caf254 100644 --- a/source/client/factories_impl.cc +++ b/source/client/factories_impl.cc @@ -60,6 +60,8 @@ BenchmarkClientPtr BenchmarkClientFactoryImpl::create( benchmark_client->setMaxPendingRequests(options_.maxPendingRequests()); benchmark_client->setMaxActiveRequests(options_.maxActiveRequests()); benchmark_client->setMaxRequestsPerConnection(options_.maxRequestsPerConnection()); + benchmark_client->setTimeout(options_.timeout()); + return benchmark_client; } diff --git a/test/factories_test.cc b/test/factories_test.cc index da88a61df..5e58299f5 100644 --- a/test/factories_test.cc +++ b/test/factories_test.cc @@ -43,6 +43,7 @@ TEST_F(FactoriesTest, CreateBenchmarkClient) { EXPECT_CALL(options_, maxRequestsPerConnection()); EXPECT_CALL(options_, openLoop()); EXPECT_CALL(options_, responseHeaderWithLatencyInput()); + EXPECT_CALL(options_, timeout()); auto cmd = std::make_unique(); EXPECT_CALL(options_, toCommandLineOptions()).WillOnce(Return(ByMove(std::move(cmd)))); StaticRequestSourceImpl request_generator(