Skip to content

Commit e541bc7

Browse files
committed
Fixed next hop tests for out of tree builds
1 parent f990f13 commit e541bc7

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

proxy/http/remap/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ test_RemapPluginInfo_SOURCES = \
125125
test_NextHopStrategyFactory_CPPFLAGS = \
126126
$(AM_CPPFLAGS) \
127127
-D_NH_UNIT_TESTS_ \
128+
-DTS_SRC_DIR=\"$(abs_top_srcdir)/proxy/http/remap/\" \
128129
-I$(abs_top_srcdir)/tests/include \
129130
$(TS_INCLUDES) \
130131
@YAMLCPP_INCLUDES@
@@ -154,6 +155,7 @@ test_NextHopStrategyFactory_SOURCES = \
154155
test_NextHopRoundRobin_CPPFLAGS = \
155156
$(AM_CPPFLAGS) \
156157
-D_NH_UNIT_TESTS_ \
158+
-DTS_SRC_DIR=\"$(abs_top_srcdir)/proxy/http/remap/\" \
157159
-I$(abs_top_srcdir)/tests/include \
158160
$(TS_INCLUDES) \
159161
@YAMLCPP_INCLUDES@
@@ -183,6 +185,7 @@ test_NextHopRoundRobin_SOURCES = \
183185
test_NextHopConsistentHash_CPPFLAGS = \
184186
$(AM_CPPFLAGS) \
185187
-D_NH_UNIT_TESTS_ \
188+
-DTS_SRC_DIR=\"$(abs_top_srcdir)/proxy/http/remap/\" \
186189
-I$(abs_top_srcdir)/tests/include \
187190
$(TS_INCLUDES) \
188191
@YAMLCPP_INCLUDES@

proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SCENARIO("Testing NextHopConsistentHash class, using policy 'consistent_hash'",
5151
{
5252
// load the configuration strtegies.
5353
std::shared_ptr<NextHopSelectionStrategy> strategy;
54-
NextHopStrategyFactory nhf("unit-tests/consistent-hash-tests.yaml");
54+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
5555
strategy = nhf.strategyInstance("consistent-hash-1");
5656

5757
WHEN("the config is loaded.")
@@ -190,7 +190,7 @@ SCENARIO("Testing NextHopConsistentHash class (all firstcalls), using policy 'co
190190
GIVEN("Loading the consistent-hash-tests.yaml config for 'consistent_hash' tests.")
191191
{
192192
std::shared_ptr<NextHopSelectionStrategy> strategy;
193-
NextHopStrategyFactory nhf("unit-tests/consistent-hash-tests.yaml");
193+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
194194
strategy = nhf.strategyInstance("consistent-hash-1");
195195

196196
WHEN("the config is loaded.")
@@ -292,7 +292,7 @@ SCENARIO("Testing NextHopConsistentHash class (alternating rings), using policy
292292
GIVEN("Loading the consistent-hash-tests.yaml config for 'consistent_hash' tests.")
293293
{
294294
std::shared_ptr<NextHopSelectionStrategy> strategy;
295-
NextHopStrategyFactory nhf("unit-tests/consistent-hash-tests.yaml");
295+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
296296
strategy = nhf.strategyInstance("consistent-hash-2");
297297

298298
WHEN("the config is loaded.")

proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'rr-strict'", "[NextHopR
4141
GIVEN("Loading the round-robin-tests.yaml config for round robin 'rr-strict' tests.")
4242
{
4343
std::shared_ptr<NextHopSelectionStrategy> strategy;
44-
NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
44+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
4545
strategy = nhf.strategyInstance("rr-strict-exhaust-ring");
4646

4747
WHEN("the config is loaded.")
@@ -146,7 +146,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'first-live'", "[NextHop
146146
GIVEN("Loading the round-robin-tests.yaml config for round robin 'first-live' tests.")
147147
{
148148
std::shared_ptr<NextHopSelectionStrategy> strategy;
149-
NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
149+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
150150
strategy = nhf.strategyInstance("first-live");
151151

152152
WHEN("the config is loaded.")
@@ -205,7 +205,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'rr-ip'", "[NextHopRound
205205
GIVEN("Loading the round-robin-tests.yaml config for round robin 'rr-ip' tests.")
206206
{
207207
std::shared_ptr<NextHopSelectionStrategy> strategy;
208-
NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
208+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
209209
strategy = nhf.strategyInstance("rr-ip");
210210
sockaddr_in sa1, sa2;
211211
sa1.sin_port = 10000;
@@ -266,7 +266,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'latched'", "[NextHopRou
266266
GIVEN("Loading the round-robin-tests.yaml config for round robin 'latched' tests.")
267267
{
268268
std::shared_ptr<NextHopSelectionStrategy> strategy;
269-
NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
269+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
270270
strategy = nhf.strategyInstance("latched");
271271

272272
WHEN("the config is loaded.")

proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ SCENARIO("factory tests loading yaml configs", "[loadConfig]")
4343
{
4444
GIVEN("Loading the strategy.yaml with included 'hosts.yaml'.")
4545
{
46-
NextHopStrategyFactory nhf("unit-tests/strategy.yaml");
46+
#ifdef TS_SRC_DIR
47+
REQUIRE(chdir(TS_SRC_DIR) == 0);
48+
#endif
49+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/strategy.yaml");
4750

4851
WHEN("the two files are loaded.")
4952
{
@@ -216,7 +219,7 @@ SCENARIO("factory tests loading yaml configs", "[loadConfig]")
216219

217220
GIVEN("loading a yaml config, simple-strategy.yaml ")
218221
{
219-
NextHopStrategyFactory nhf("unit-tests/simple-strategy.yaml");
222+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/simple-strategy.yaml");
220223

221224
WHEN("loading the single file")
222225
{
@@ -357,7 +360,7 @@ SCENARIO("factory tests loading yaml configs", "[loadConfig]")
357360

358361
GIVEN("loading a yaml config combining hosts and strategies into one file, combined.yaml")
359362
{
360-
NextHopStrategyFactory nhf("unit-tests/combined.yaml");
363+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/combined.yaml");
361364

362365
WHEN("loading the single file")
363366
{
@@ -779,7 +782,7 @@ SCENARIO("factory tests loading yaml configs from a directory", "[loadConfig]")
779782
{
780783
GIVEN("Loading the strategies using a directory of 'yaml' files")
781784
{
782-
NextHopStrategyFactory nhf("unit-tests/strategies-dir");
785+
NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/strategies-dir");
783786

784787
WHEN("the two files are loaded.")
785788
{

0 commit comments

Comments
 (0)