forked from envoyproxy/envoy-filter-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecho2_integration_test.cc
48 lines (41 loc) · 1.47 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
45
46
47
48
#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"));
}
public:
Echo2IntegrationTest() : BaseIntegrationTest(GetParam(), echoConfig()) {}
/**
* Initializer for an individual integration test.
*/
void SetUp() override {
named_ports_ = {{"echo"}};
BaseIntegrationTest::initialize();
}
/**
* Destructor for an individual integration test.
*/
void TearDown() override {
test_server_.reset();
fake_upstreams_.clear();
}
};
INSTANTIATE_TEST_CASE_P(IpVersions, Echo2IntegrationTest,
testing::ValuesIn(TestEnvironment::getIpVersionsForTest()));
TEST_P(Echo2IntegrationTest, Echo) {
Buffer::OwnedImpl buffer("hello");
std::string response;
RawConnectionDriver connection(lookupPort("echo"), buffer,
[&](Network::ClientConnection&, const Buffer::Instance& data)
-> void {
response.append(TestUtility::bufferToString(data));
connection.close();
}, GetParam());
connection.run();
EXPECT_EQ("hello", response);
}
} // Envoy