This repository has been archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
http_protocol_integration.h
60 lines (51 loc) · 2.17 KB
/
http_protocol_integration.h
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
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "test/integration/http_integration.h"
#include "gtest/gtest.h"
namespace Envoy {
struct HttpProtocolTestParams {
Network::Address::IpVersion version;
Http::CodecClient::Type downstream_protocol;
FakeHttpConnection::Type upstream_protocol;
};
// Allows easy testing of Envoy code for HTTP/HTTP2 upstream/downstream.
//
// Usage:
//
// using MyTest = HttpProtocolIntegrationTest;
//
// INSTANTIATE_TEST_SUITE_P(Protocols, MyTest,
// testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
// HttpProtocolIntegrationTest::protocolTestParamsToString);
//
//
// TEST_P(MyTest, TestInstance) {
// ....
// }
class HttpProtocolIntegrationTest : public testing::TestWithParam<HttpProtocolTestParams>,
public HttpIntegrationTest {
public:
// By default returns 8 combinations of
// [HTTP upstream / HTTP downstream] x [Ipv4, IPv6]
// [HTTP upstream / HTTP2 downstream] x [Ipv4, IPv6]
// [HTTP2 upstream / HTTP2 downstream] x [IPv4, Ipv6]
// [HTTP upstream / HTTP2 downstream] x [IPv4, Ipv6]
//
// Upstream and downstream protocols may be changed via the input vectors.
// Address combinations are propagated from TestEnvironment::getIpVersionsForTest()
static std::vector<HttpProtocolTestParams>
getProtocolTestParams(const std::vector<Http::CodecClient::Type>& downstream_protocols =
{Http::CodecClient::Type::HTTP1, Http::CodecClient::Type::HTTP2},
const std::vector<FakeHttpConnection::Type>& upstream_protocols = {
FakeHttpConnection::Type::HTTP1, FakeHttpConnection::Type::HTTP2});
// Allows pretty printed test names of the form
// FooTestCase.BarInstance/IPv4_Http2Downstream_HttpUpstream
static std::string
protocolTestParamsToString(const ::testing::TestParamInfo<HttpProtocolTestParams>& p);
HttpProtocolIntegrationTest()
: HttpIntegrationTest(GetParam().downstream_protocol, GetParam().version) {}
void SetUp() override {
setDownstreamProtocol(GetParam().downstream_protocol);
setUpstreamProtocol(GetParam().upstream_protocol);
}
};
} // namespace Envoy