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
39 changes: 21 additions & 18 deletions test/integration/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,26 @@ void IntegrationTestServerImpl::createAndRunEnvoyServer(
Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks,
Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory,
Runtime::RandomGeneratorPtr&& random_generator) {
Stats::FakeSymbolTableImpl symbol_table;
Server::HotRestartNopImpl restarter;
ThreadLocal::InstanceImpl tls;
Stats::HeapStatDataAllocator stats_allocator(symbol_table);
Stats::ThreadLocalStoreImpl stat_store(stats_allocator);

Server::InstanceImpl server(options, time_system, local_address, hooks, restarter, stat_store,
access_log_lock, component_factory, std::move(random_generator), tls,
Thread::threadFactoryForTest(), Filesystem::fileSystemForTest(),
nullptr);
// This is technically thread unsafe (assigning to a shared_ptr accessed
// across threads), but because we synchronize below through serverReady(), the only
// consumer on the main test thread in ~IntegrationTestServerImpl will not race.
admin_address_ = server.admin().socket().localAddress();
server_ = &server;
stat_store_ = &stat_store;
serverReady();
server.run();
{
Stats::FakeSymbolTableImpl symbol_table;
Server::HotRestartNopImpl restarter;
ThreadLocal::InstanceImpl tls;
Stats::HeapStatDataAllocator stats_allocator(symbol_table);
Stats::ThreadLocalStoreImpl stat_store(stats_allocator);
Server::InstanceImpl server(options, time_system, local_address, hooks, restarter, stat_store,
access_log_lock, component_factory, std::move(random_generator),
tls, Thread::threadFactoryForTest(),
Filesystem::fileSystemForTest(), nullptr);
// This is technically thread unsafe (assigning to a shared_ptr accessed
// across threads), but because we synchronize below through serverReady(), the only
// consumer on the main test thread in ~IntegrationTestServerImpl will not race.
admin_address_ = server.admin().socket().localAddress();
server_ = &server;
stat_store_ = &stat_store;
serverReady();
server.run();
}
server_gone_.Notify();
}

IntegrationTestServerImpl::~IntegrationTestServerImpl() {
Expand All @@ -202,6 +204,7 @@ IntegrationTestServerImpl::~IntegrationTestServerImpl() {
admin_address, "POST", "/quitquitquit", "", Http::CodecClient::Type::HTTP1);
EXPECT_TRUE(response->complete());
EXPECT_EQ("200", response->headers().Status()->value().getStringView());
server_gone_.WaitForNotification();
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/integration/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "test/test_common/test_time_system.h"
#include "test/test_common/utility.h"

#include "absl/synchronization/notification.h"

namespace Envoy {
namespace Server {

Expand Down Expand Up @@ -380,6 +382,7 @@ class IntegrationTestServerImpl : public IntegrationTestServer {
Server::Instance* server_{};
Stats::Store* stat_store_{};
Network::Address::InstanceConstSharedPtr admin_address_;
absl::Notification server_gone_;
};

} // namespace Envoy