forked from envoyproxy/envoy-filter-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo2_integration_test.cc
44 lines (37 loc) · 1.31 KB
/
echo2_integration_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "test/integration/integration.h"
#include "test/integration/utility.h"
namespace Envoy {
class Echo2IntegrationTest : public BaseIntegrationTest,
public testing::TestWithParam<Network::Address::IpVersion> {
std::string echoConfig() {
return TestEnvironment::readFileToStringForTest(
TestEnvironment::runfilesPath("echo2_server.yaml", "envoy_filter_example"));
}
public:
Echo2IntegrationTest() : BaseIntegrationTest(GetParam(), echoConfig()) {}
/**
* Initializer for an individual integration test.
*/
void SetUp() override { BaseIntegrationTest::initialize(); }
/**
* Destructor for an individual integration test.
*/
void TearDown() override {
test_server_.reset();
fake_upstreams_.clear();
}
};
INSTANTIATE_TEST_SUITE_P(IpVersions, Echo2IntegrationTest,
testing::ValuesIn(TestEnvironment::getIpVersionsForTest()));
TEST_P(Echo2IntegrationTest, Echo) {
std::string response;
auto connection = createConnectionDriver(
lookupPort("listener_0"), "hello",
[&](Network::ClientConnection& conn, const Buffer::Instance& data) -> void {
response.append(data.toString());
conn.close(Network::ConnectionCloseType::FlushWrite);
});
connection->run();
EXPECT_EQ("hello", response);
}
} // namespace Envoy