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
7 changes: 4 additions & 3 deletions test/common/grpc/grpc_client_integration_test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ class GrpcClientIntegrationTest : public GrpcClientIntegrationParamTest {

virtual void initialize() {
if (fake_upstream_ == nullptr) {
fake_upstream_ =
std::make_unique<FakeUpstream>(0, FakeHttpConnection::Type::HTTP2, ipVersion());
fake_upstream_ = std::make_unique<FakeUpstream>(0, FakeHttpConnection::Type::HTTP2,
ipVersion(), test_time_.timeSystem());
}
switch (clientType()) {
case ClientType::EnvoyGrpc:
Expand Down Expand Up @@ -473,7 +473,8 @@ class GrpcSslClientIntegrationTest : public GrpcClientIntegrationTest {
async_client_transport_socket_ =
mock_cluster_info_->transport_socket_factory_->createTransportSocket();
fake_upstream_ = std::make_unique<FakeUpstream>(createUpstreamSslContext(), 0,
FakeHttpConnection::Type::HTTP2, ipVersion());
FakeHttpConnection::Type::HTTP2, ipVersion(),
test_time_.timeSystem());

GrpcClientIntegrationTest::initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ namespace {
class AccessLogIntegrationTest : public HttpIntegrationTest,
public Grpc::GrpcClientIntegrationParamTest {
public:
AccessLogIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, ipVersion()) {}
AccessLogIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, ipVersion(), realTime()) {}

void createUpstreams() override {
HttpIntegrationTest::createUpstreams();
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
}

void initialize() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Envoy {
class CorsFilterIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
public:
CorsFilterIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {}
CorsFilterIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), realTime()) {}

void initialize() override {
config_helper_.addFilter("name: envoy.cors");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GrpcJsonTranscoderIntegrationTest
public testing::TestWithParam<Network::Address::IpVersion> {
public:
GrpcJsonTranscoderIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {}
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), realTime()) {}
/**
* Global initializer for all integration tests.
*/
Expand Down
1 change: 1 addition & 0 deletions test/extensions/filters/http/gzip/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ envoy_cc_test(
"//source/common/decompressor:decompressor_lib",
"//source/extensions/filters/http/gzip:config",
"//test/integration:http_integration_lib",
"//test/test_common:simulated_time_system_lib",
"//test/test_common:utility_lib",
],
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "envoy/event/timer.h"

#include "common/decompressor/zlib_decompressor_impl.h"

#include "test/integration/http_integration.h"
#include "test/test_common/simulated_time_system.h"
#include "test/test_common/utility.h"

#include "gtest/gtest.h"
Expand All @@ -10,7 +13,8 @@ namespace Envoy {
class GzipIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
public:
GzipIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {}
GzipIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), simTime()) {}

void SetUp() override { decompressor_.init(window_bits); }
void TearDown() override { cleanupUpstreamAndDownstream(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class RemoteJwksIntegrationTest : public HttpProtocolIntegrationTest {
void createUpstreams() override {
HttpProtocolIntegrationTest::createUpstreams();
// for Jwks upstream.
fake_upstreams_.emplace_back(new FakeUpstream(0, GetParam().upstream_protocol, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, GetParam().upstream_protocol, version_, timeSystem()));
}

void initializeFilter() {
Expand Down
9 changes: 6 additions & 3 deletions test/extensions/filters/http/lua/lua_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ namespace {
class LuaIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
public:
LuaIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {}
LuaIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), realTime()) {}

void createUpstreams() override {
HttpIntegrationTest::createUpstreams();
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_));
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_, timeSystem()));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_, timeSystem()));
}

void initializeFilter(const std::string& filter_config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace Envoy {
class SquashFilterIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
public:
SquashFilterIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {}
SquashFilterIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), realTime()) {}

~SquashFilterIntegrationTest() {
if (fake_squash_connection_) {
Expand Down Expand Up @@ -70,7 +71,8 @@ class SquashFilterIntegrationTest : public HttpIntegrationTest,

void createUpstreams() override {
HttpIntegrationTest::createUpstreams();
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
fake_upstreams_.back()->set_allow_unexpected_disconnects(true);
}

Expand Down
2 changes: 1 addition & 1 deletion test/extensions/filters/network/rbac/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RoleBasedAccessControlNetworkFilterIntegrationTest
public testing::TestWithParam<Network::Address::IpVersion> {
public:
RoleBasedAccessControlNetworkFilterIntegrationTest()
: BaseIntegrationTest(GetParam(), rbac_config) {}
: BaseIntegrationTest(GetParam(), realTime(), rbac_config) {}

static void SetUpTestCase() {
rbac_config = ConfigHelper::BASE_CONFIG + R"EOF(
Expand Down
2 changes: 1 addition & 1 deletion test/extensions/filters/network/thrift_proxy/integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct PayloadOptions {
class BaseThriftIntegrationTest : public BaseIntegrationTest {
public:
BaseThriftIntegrationTest()
: BaseIntegrationTest(Network::Address::IpVersion::v4, thrift_config_) {}
: BaseIntegrationTest(Network::Address::IpVersion::v4, realTime(), thrift_config_) {}

/**
* Given PayloadOptions, generate a client request and server response and store the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ class MetricsServiceIntegrationTest : public HttpIntegrationTest,
public Grpc::GrpcClientIntegrationParamTest {
public:
MetricsServiceIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, ipVersion()) {}
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, ipVersion(), realTime()) {}

void createUpstreams() override {
HttpIntegrationTest::createUpstreams();
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
fake_upstreams_.back()->set_allow_unexpected_disconnects(true);
}

Expand Down
3 changes: 3 additions & 0 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ envoy_cc_test_library(
":add_trailers_filter_config_lib",
":integration_lib",
":test_host_predicate_lib",
"//include/envoy/event:timer_interface",
"//source/extensions/filters/http/router:config",
"//source/extensions/filters/network/http_connection_manager:config",
"//test/common/upstream:utility_lib",
Expand Down Expand Up @@ -314,7 +315,9 @@ envoy_cc_test_library(
"//test/test_common:environment_lib",
"//test/test_common:network_utility_lib",
"//test/test_common:printers_lib",
"//test/test_common:simulated_time_system_lib",
"//test/test_common:test_time_lib",
"//test/test_common:test_time_system_interface",
"//test/test_common:utility_lib",
],
)
Expand Down
12 changes: 7 additions & 5 deletions test/integration/ads_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AdsIntegrationBaseTest : public HttpIntegrationTest {
AdsIntegrationBaseTest(Http::CodecClient::Type downstream_protocol,
Network::Address::IpVersion version,
const std::string& config = ConfigHelper::HTTP_PROXY_CONFIG)
: HttpIntegrationTest(downstream_protocol, version, config) {}
: HttpIntegrationTest(downstream_protocol, version, realTime(), config) {}

void createAdsConnection(FakeUpstream& upstream) {
ads_upstream_ = &upstream;
Expand Down Expand Up @@ -104,8 +104,8 @@ class AdsIntegrationTest : public AdsIntegrationBaseTest,

void createUpstreams() override {
AdsIntegrationBaseTest::createUpstreams();
fake_upstreams_.emplace_back(
new FakeUpstream(createUpstreamSslContext(), 0, FakeHttpConnection::Type::HTTP2, version_));
fake_upstreams_.emplace_back(new FakeUpstream(
createUpstreamSslContext(), 0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
}

Network::TransportSocketFactoryPtr createUpstreamSslContext() {
Expand Down Expand Up @@ -651,7 +651,8 @@ class AdsFailIntegrationTest : public AdsIntegrationBaseTest,

void createUpstreams() override {
AdsIntegrationBaseTest::createUpstreams();
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
}

void initialize() override {
Expand Down Expand Up @@ -696,7 +697,8 @@ class AdsConfigIntegrationTest : public AdsIntegrationBaseTest,

void createUpstreams() override {
AdsIntegrationBaseTest::createUpstreams();
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_));
fake_upstreams_.emplace_back(
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
}

void initialize() override {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/autonomous_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ typedef std::unique_ptr<AutonomousHttpConnection> AutonomousHttpConnectionPtr;
class AutonomousUpstream : public FakeUpstream {
public:
AutonomousUpstream(uint32_t port, FakeHttpConnection::Type type,
Network::Address::IpVersion version)
: FakeUpstream(port, type, version) {}
Network::Address::IpVersion version, Event::TestTimeSystem& time_system)
: FakeUpstream(port, type, version, time_system) {}
~AutonomousUpstream();
bool
createNetworkFilterChain(Network::Connection& connection,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/echo_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ std::string echo_config;
class EchoIntegrationTest : public BaseIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
public:
EchoIntegrationTest() : BaseIntegrationTest(GetParam(), echo_config) {}
EchoIntegrationTest() : BaseIntegrationTest(GetParam(), realTime(), echo_config) {}

// Called once by the gtest framework before any EchoIntegrationTests are run.
static void SetUpTestCase() {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/eds_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace {
class EdsIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
public:
EdsIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {}
EdsIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), realTime()) {}

// We need to supply the endpoints via EDS to provide health status. Use a
// filesystem delivery to simplify test mechanics.
Expand Down
27 changes: 15 additions & 12 deletions test/integration/fake_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using testing::AssertionSuccess;

namespace Envoy {
FakeStream::FakeStream(FakeHttpConnection& parent, Http::StreamEncoder& encoder,
Event::TimeSystem& time_system)
Event::TestTimeSystem& time_system)
: parent_(parent), encoder_(encoder), time_system_(time_system) {
encoder.getStream().addCallbacks(*this);
}
Expand Down Expand Up @@ -202,7 +202,7 @@ void FakeStream::finishGrpcStream(Grpc::Status::GrpcStatus status) {

FakeHttpConnection::FakeHttpConnection(SharedConnectionWrapper& shared_connection,
Stats::Store& store, Type type,
Event::TimeSystem& time_system)
Event::TestTimeSystem& time_system)
: FakeConnectionBase(shared_connection, time_system) {
if (type == Type::HTTP1) {
codec_.reset(new Http::Http1::ServerConnectionImpl(shared_connection_.connection(), *this,
Expand Down Expand Up @@ -327,11 +327,12 @@ AssertionResult FakeHttpConnection::waitForNewStream(Event::Dispatcher& client_d
return AssertionSuccess();
}

FakeUpstream::FakeUpstream(const std::string& uds_path, FakeHttpConnection::Type type)
FakeUpstream::FakeUpstream(const std::string& uds_path, FakeHttpConnection::Type type,
Event::TestTimeSystem& time_system)
: FakeUpstream(Network::Test::createRawBufferSocketFactory(),
Network::SocketPtr{new Network::UdsListenSocket(
std::make_shared<Network::Address::PipeInstance>(uds_path))},
type, false) {
type, time_system, false) {
ENVOY_LOG(info, "starting fake server on unix domain socket {}", uds_path);
}

Expand All @@ -343,27 +344,28 @@ static Network::SocketPtr makeTcpListenSocket(uint32_t port, Network::Address::I
}

FakeUpstream::FakeUpstream(uint32_t port, FakeHttpConnection::Type type,
Network::Address::IpVersion version, bool enable_half_close)
Network::Address::IpVersion version, Event::TestTimeSystem& time_system,
bool enable_half_close)
: FakeUpstream(Network::Test::createRawBufferSocketFactory(),
makeTcpListenSocket(port, version), type, enable_half_close) {
makeTcpListenSocket(port, version), type, time_system, enable_half_close) {
ENVOY_LOG(info, "starting fake server on port {}. Address version is {}",
this->localAddress()->ip()->port(), Network::Test::addressVersionAsString(version));
}

FakeUpstream::FakeUpstream(Network::TransportSocketFactoryPtr&& transport_socket_factory,
uint32_t port, FakeHttpConnection::Type type,
Network::Address::IpVersion version)
Network::Address::IpVersion version, Event::TestTimeSystem& time_system)
: FakeUpstream(std::move(transport_socket_factory), makeTcpListenSocket(port, version), type,
false) {
time_system, false) {
ENVOY_LOG(info, "starting fake SSL server on port {}. Address version is {}",
this->localAddress()->ip()->port(), Network::Test::addressVersionAsString(version));
}

FakeUpstream::FakeUpstream(Network::TransportSocketFactoryPtr&& transport_socket_factory,
Network::SocketPtr&& listen_socket, FakeHttpConnection::Type type,
bool enable_half_close)
Event::TestTimeSystem& time_system, bool enable_half_close)
: http_type_(type), socket_(std::move(listen_socket)), api_(new Api::Impl(milliseconds(10000))),
dispatcher_(api_->allocateDispatcher(test_time_.timeSystem())),
time_system_(time_system), dispatcher_(api_->allocateDispatcher(time_system_)),
handler_(new Server::ConnectionHandlerImpl(ENVOY_LOGGER(), *dispatcher_)),
allow_unexpected_disconnects_(false), enable_half_close_(enable_half_close), listener_(*this),
filter_chain_(Network::Test::createEmptyFilterChain(std::move(transport_socket_factory))) {
Expand Down Expand Up @@ -410,7 +412,7 @@ void FakeUpstream::threadRoutine() {
AssertionResult FakeUpstream::waitForHttpConnection(Event::Dispatcher& client_dispatcher,
FakeHttpConnectionPtr& connection,
milliseconds timeout) {
Event::TimeSystem& time_system = timeSystem();
Event::TestTimeSystem& time_system = timeSystem();
auto end_time = time_system.monotonicTime() + timeout;
{
Thread::LockGuard lock(lock_);
Expand Down Expand Up @@ -455,7 +457,8 @@ FakeUpstream::waitForHttpConnection(Event::Dispatcher& client_dispatcher,
client_dispatcher.run(Event::Dispatcher::RunType::NonBlock);
} else {
connection = std::make_unique<FakeHttpConnection>(
upstream.consumeConnection(), upstream.stats_store_, upstream.http_type_, time_system);
upstream.consumeConnection(), upstream.stats_store_, upstream.http_type_,
upstream.timeSystem());
lock.release();
VERIFY_ASSERTION(connection->initialize());
VERIFY_ASSERTION(connection->readDisable(false));
Expand Down
Loading