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
2 changes: 1 addition & 1 deletion test/integration/ads_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ TEST_P(AdsIntegrationTest, XdsBatching) {
static_resources->add_listeners()->MergeFrom(buildListener("rds_listener2", "route_config2"));
});

pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createXdsConnection();
ASSERT_TRUE(xds_connection_->waitForNewStream(*dispatcher_, xds_stream_));
xds_stream_->startGrpcStream();
Expand Down
2 changes: 1 addition & 1 deletion test/integration/header_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class HeaderIntegrationTest

void initialize() override {
if (use_eds_) {
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
AssertionResult result =
fake_upstreams_[1]->waitForHttpConnection(*dispatcher_, eds_connection_);
RELEASE_ASSERT(result, result.message());
Expand Down
10 changes: 5 additions & 5 deletions test/integration/integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ void BaseIntegrationTest::registerTestServerPorts(const std::vector<std::string>

void BaseIntegrationTest::createGeneratedApiTestServer(const std::string& bootstrap_path,
const std::vector<std::string>& port_names) {
test_server_ = IntegrationTestServer::create(bootstrap_path, version_,
pre_worker_start_test_steps_, deterministic_,
timeSystem(), *api_, defer_listener_finalization_);
test_server_ = IntegrationTestServer::create(bootstrap_path, version_, on_server_init_function_,
deterministic_, timeSystem(), *api_,
defer_listener_finalization_);
if (config_helper_.bootstrap().static_resources().listeners_size() > 0 &&
!defer_listener_finalization_) {
// Wait for listeners to be created before invoking registerTestServerPorts() below, as that
Expand Down Expand Up @@ -424,9 +424,9 @@ void BaseIntegrationTest::sendRawHttpAndWaitForResponse(int port, const char* ra

IntegrationTestServerPtr
BaseIntegrationTest::createIntegrationTestServer(const std::string& bootstrap_path,
std::function<void()> pre_worker_start_test_steps,
std::function<void()> on_server_init_function,
Event::TestTimeSystem& time_system) {
return IntegrationTestServer::create(bootstrap_path, version_, pre_worker_start_test_steps,
return IntegrationTestServer::create(bootstrap_path, version_, on_server_init_function,
deterministic_, time_system, *api_,
defer_listener_finalization_);
}
Expand Down
8 changes: 5 additions & 3 deletions test/integration/integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class BaseIntegrationTest : Logger::Loggable<Logger::Id::testing> {
// Will not return until that server is listening.
virtual IntegrationTestServerPtr
createIntegrationTestServer(const std::string& bootstrap_path,
std::function<void()> pre_worker_start_steps,
std::function<void()> on_server_init_function,
Event::TestTimeSystem& time_system);

bool initialized() const { return initialized_; }
Expand All @@ -238,8 +238,10 @@ class BaseIntegrationTest : Logger::Loggable<Logger::Id::testing> {
Network::Address::IpVersion version_;
// The config for envoy start-up.
ConfigHelper config_helper_;
// Steps that should be done prior to the workers starting. E.g., xDS pre-init.
std::function<void()> pre_worker_start_test_steps_;

// Steps that should be done in parallel with the envoy server starting. E.g., xDS
// pre-init, control plane synchronization needed for server start.
std::function<void()> on_server_init_function_;

std::vector<std::unique_ptr<FakeUpstream>> fake_upstreams_;
// Target number of upstreams.
Expand Down
12 changes: 6 additions & 6 deletions test/integration/sds_dynamic_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, SdsDynamicDownstreamIntegrationTe
// A test that SDS server send a good server secret for a static listener.
// The first ssl request should be OK.
TEST_P(SdsDynamicDownstreamIntegrationTest, BasicSuccess) {
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createSdsStream(*(fake_upstreams_[1]));
sendSdsResponse(getServerSecret());
};
Expand All @@ -215,7 +215,7 @@ TEST_P(SdsDynamicDownstreamIntegrationTest, BasicSuccess) {
// The first ssl request should fail at connecting.
// then SDS send a good server secret, the second request should be OK.
TEST_P(SdsDynamicDownstreamIntegrationTest, WrongSecretFirst) {
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createSdsStream(*(fake_upstreams_[1]));
sendSdsResponse(getWrongSecret(server_cert_));
};
Expand Down Expand Up @@ -296,7 +296,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, SdsDynamicDownstreamCertValidatio
// A test that SDS server send a good certificate validation context for a static listener.
// The first ssl request should be OK.
TEST_P(SdsDynamicDownstreamCertValidationContextTest, BasicSuccess) {
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createSdsStream(*(fake_upstreams_[1]));
sendSdsResponse(getCvcSecret());
};
Expand All @@ -313,7 +313,7 @@ TEST_P(SdsDynamicDownstreamCertValidationContextTest, BasicSuccess) {
// The first ssl request should be OK.
TEST_P(SdsDynamicDownstreamCertValidationContextTest, CombinedCertValidationContextSuccess) {
enableCombinedValidationContext(true);
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createSdsStream(*(fake_upstreams_[1]));
sendSdsResponse(getCvcSecretWithOnlyTrustedCa());
};
Expand Down Expand Up @@ -375,7 +375,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, SdsDynamicUpstreamIntegrationTest,
// To test a static cluster with sds. SDS send a good client secret first.
// The first request should work.
TEST_P(SdsDynamicUpstreamIntegrationTest, BasicSuccess) {
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createSdsStream(*(fake_upstreams_[1]));
sendSdsResponse(getClientSecret());
};
Expand All @@ -400,7 +400,7 @@ TEST_P(SdsDynamicUpstreamIntegrationTest, BasicSuccess) {
// The first request should fail with 503, then SDS sends a good client secret,
// the second request should work.
TEST_P(SdsDynamicUpstreamIntegrationTest, WrongSecretFirst) {
pre_worker_start_test_steps_ = [this]() {
on_server_init_function_ = [this]() {
createSdsStream(*(fake_upstreams_[1]));
sendSdsResponse(getWrongSecret(client_cert_));
};
Expand Down
16 changes: 10 additions & 6 deletions test/integration/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ OptionsImpl createTestOptionsImpl(const std::string& config_path, const std::str

IntegrationTestServerPtr IntegrationTestServer::create(
const std::string& config_path, const Network::Address::IpVersion version,
std::function<void()> pre_worker_start_test_steps, bool deterministic,
std::function<void()> on_server_init_function, bool deterministic,
Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization) {
IntegrationTestServerPtr server{
std::make_unique<IntegrationTestServerImpl>(time_system, api, config_path)};
server->start(version, pre_worker_start_test_steps, deterministic, defer_listener_finalization);
server->start(version, on_server_init_function, deterministic, defer_listener_finalization);
return server;
}

Expand All @@ -64,16 +64,20 @@ void IntegrationTestServer::waitUntilListenersReady() {
}

void IntegrationTestServer::start(const Network::Address::IpVersion version,
std::function<void()> pre_worker_start_test_steps,
bool deterministic, bool defer_listener_finalization) {
std::function<void()> on_server_init_function, bool deterministic,
bool defer_listener_finalization) {
ENVOY_LOG(info, "starting integration test server");
ASSERT(!thread_);
thread_ = api_.threadFactory().createThread(
[version, deterministic, this]() -> void { threadRoutine(version, deterministic); });

// If any steps need to be done prior to workers starting, do them now. E.g., xDS pre-init.
if (pre_worker_start_test_steps != nullptr) {
pre_worker_start_test_steps();
// Note that there is no synchronization guaranteeing this happens either
// before workers starting or after server start. Any needed synchronization must occur in the
// routines. These steps are executed at this point in the code to allow server initialization to
// be dependent on them (e.g. control plane peers).
if (on_server_init_function != nullptr) {
on_server_init_function();
}

// Wait for the server to be created and the number of initial listeners to wait for to be set.
Expand Down
4 changes: 2 additions & 2 deletions test/integration/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class IntegrationTestServer : public Logger::Loggable<Logger::Id::testing>,
public:
static IntegrationTestServerPtr create(const std::string& config_path,
const Network::Address::IpVersion version,
std::function<void()> pre_worker_start_test_steps,
std::function<void()> on_server_init_function,
bool deterministic, Event::TestTimeSystem& time_system,
Api::Api& api, bool defer_listener_finalization = false);
// Note that the derived class is responsible for tearing down the server in its
Expand All @@ -191,7 +191,7 @@ class IntegrationTestServer : public Logger::Loggable<Logger::Id::testing>,
on_worker_listener_removed_cb_ = on_worker_listener_removed;
}
void start(const Network::Address::IpVersion version,
std::function<void()> pre_worker_start_test_steps, bool deterministic,
std::function<void()> on_server_init_function, bool deterministic,
bool defer_listener_finalization);

void waitForCounterGe(const std::string& name, uint64_t value) override {
Expand Down