Fixed next hop tests for out of tree builds
diff --git a/proxy/http/remap/Makefile.am b/proxy/http/remap/Makefile.am
index 89be4da..c569801 100644
--- a/proxy/http/remap/Makefile.am
+++ b/proxy/http/remap/Makefile.am
@@ -125,6 +125,7 @@
test_NextHopStrategyFactory_CPPFLAGS = \
$(AM_CPPFLAGS) \
-D_NH_UNIT_TESTS_ \
+ -DTS_SRC_DIR=\"$(abs_top_srcdir)/proxy/http/remap/\" \
-I$(abs_top_srcdir)/tests/include \
$(TS_INCLUDES) \
@YAMLCPP_INCLUDES@
@@ -154,6 +155,7 @@
test_NextHopRoundRobin_CPPFLAGS = \
$(AM_CPPFLAGS) \
-D_NH_UNIT_TESTS_ \
+ -DTS_SRC_DIR=\"$(abs_top_srcdir)/proxy/http/remap/\" \
-I$(abs_top_srcdir)/tests/include \
$(TS_INCLUDES) \
@YAMLCPP_INCLUDES@
@@ -183,6 +185,7 @@
test_NextHopConsistentHash_CPPFLAGS = \
$(AM_CPPFLAGS) \
-D_NH_UNIT_TESTS_ \
+ -DTS_SRC_DIR=\"$(abs_top_srcdir)/proxy/http/remap/\" \
-I$(abs_top_srcdir)/tests/include \
$(TS_INCLUDES) \
@YAMLCPP_INCLUDES@
diff --git a/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc b/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc
index 912a5da..cbd29bd 100644
--- a/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc
+++ b/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc
@@ -51,7 +51,7 @@
{
// load the configuration strtegies.
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/consistent-hash-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
strategy = nhf.strategyInstance("consistent-hash-1");
WHEN("the config is loaded.")
@@ -190,7 +190,7 @@
GIVEN("Loading the consistent-hash-tests.yaml config for 'consistent_hash' tests.")
{
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/consistent-hash-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
strategy = nhf.strategyInstance("consistent-hash-1");
WHEN("the config is loaded.")
@@ -292,7 +292,7 @@
GIVEN("Loading the consistent-hash-tests.yaml config for 'consistent_hash' tests.")
{
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/consistent-hash-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
strategy = nhf.strategyInstance("consistent-hash-2");
WHEN("the config is loaded.")
diff --git a/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc b/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
index 7df2fd3..df47f3c 100644
--- a/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
+++ b/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
@@ -41,7 +41,7 @@
GIVEN("Loading the round-robin-tests.yaml config for round robin 'rr-strict' tests.")
{
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
strategy = nhf.strategyInstance("rr-strict-exhaust-ring");
WHEN("the config is loaded.")
@@ -146,7 +146,7 @@
GIVEN("Loading the round-robin-tests.yaml config for round robin 'first-live' tests.")
{
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
strategy = nhf.strategyInstance("first-live");
WHEN("the config is loaded.")
@@ -205,7 +205,7 @@
GIVEN("Loading the round-robin-tests.yaml config for round robin 'rr-ip' tests.")
{
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
strategy = nhf.strategyInstance("rr-ip");
sockaddr_in sa1, sa2;
sa1.sin_port = 10000;
@@ -266,7 +266,7 @@
GIVEN("Loading the round-robin-tests.yaml config for round robin 'latched' tests.")
{
std::shared_ptr<NextHopSelectionStrategy> strategy;
- NextHopStrategyFactory nhf("unit-tests/round-robin-tests.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
strategy = nhf.strategyInstance("latched");
WHEN("the config is loaded.")
diff --git a/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc b/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc
index 2bfc260..de9a71f 100644
--- a/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc
+++ b/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc
@@ -43,7 +43,10 @@
{
GIVEN("Loading the strategy.yaml with included 'hosts.yaml'.")
{
- NextHopStrategyFactory nhf("unit-tests/strategy.yaml");
+#ifdef TS_SRC_DIR
+ REQUIRE(chdir(TS_SRC_DIR) == 0);
+#endif
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/strategy.yaml");
WHEN("the two files are loaded.")
{
@@ -216,7 +219,7 @@
GIVEN("loading a yaml config, simple-strategy.yaml ")
{
- NextHopStrategyFactory nhf("unit-tests/simple-strategy.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/simple-strategy.yaml");
WHEN("loading the single file")
{
@@ -357,7 +360,7 @@
GIVEN("loading a yaml config combining hosts and strategies into one file, combined.yaml")
{
- NextHopStrategyFactory nhf("unit-tests/combined.yaml");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/combined.yaml");
WHEN("loading the single file")
{
@@ -779,7 +782,7 @@
{
GIVEN("Loading the strategies using a directory of 'yaml' files")
{
- NextHopStrategyFactory nhf("unit-tests/strategies-dir");
+ NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/strategies-dir");
WHEN("the two files are loaded.")
{