You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jr...@apache.org on 2019/05/24 19:58:20 UTC

[trafficserver] branch master updated: Fix ParentSelection regression/unit tests.

This is an automated email from the ASF dual-hosted git repository.

jrushford pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new cee077b  Fix ParentSelection regression/unit tests.
cee077b is described below

commit cee077bf4ecd454dc9d00d214f6b552115da83c9
Author: John Rushford <jr...@apache.org>
AuthorDate: Fri May 24 16:08:08 2019 +0000

    Fix ParentSelection regression/unit tests.
    
    Commit c1f8435ef12623a9a9f5b57432a518867a39a7ff added a feature to
    load persisted host status.  After the introduction of this feature
    it was found that ParentSelection regression/unit tests were failing
    due to an assertion failure.  This is because, the unit tests test
    the HostStatus setHostStatus() functionality and as part of this
    testing, the test host staus gets persisted and reloaded each time
    tests are run.  Since the test hosts were never marked back up,
    they are unavailble when new tests are run leading to test failures.
    
    This PR fixes the unit tests by marking up all test hosts prior to
    Test 1 putting us in a know state for testing.
---
 proxy/ParentSelection.cc | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 63b43b7..a529797 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -1055,6 +1055,17 @@ EXCLUSIVE_REGRESSION_TEST(PARENTSELECTION)(RegressionTest * /* t ATS_UNUSED */,
     params->findParent(request, result, fail_threshold, retry_time); \
   } while (0)
 
+  // start tests by marking up all tests hosts that will be marked down
+  // as part of testing.  This will insure that test hosts are not loaded
+  // from records.snap as DOWN due to previous testing.
+  //
+  HostStatus &_st = HostStatus::instance();
+  _st.setHostStatus("furry", HOST_STATUS_UP, 0, Reason::MANUAL);
+  _st.setHostStatus("fluffy", HOST_STATUS_UP, 0, Reason::MANUAL);
+  _st.setHostStatus("frisky", HOST_STATUS_UP, 0, Reason::MANUAL);
+  _st.setHostStatus("fuzzy", HOST_STATUS_UP, 0, Reason::MANUAL);
+  _st.setHostStatus("curly", HOST_STATUS_UP, 0, Reason::MANUAL);
+
   // Test 1
   tbl[0] = '\0';
   ST(1);
@@ -1439,7 +1450,6 @@ EXCLUSIVE_REGRESSION_TEST(PARENTSELECTION)(RegressionTest * /* t ATS_UNUSED */,
 
   // Test 184
   // mark fuzzy down with HostStatus API.
-  HostStatus &_st = HostStatus::instance();
   _st.setHostStatus("fuzzy", HOST_STATUS_DOWN, 0, Reason::MANUAL);
 
   ST(184);
@@ -1771,12 +1781,6 @@ EXCLUSIVE_REGRESSION_TEST(PARENTSELECTION)(RegressionTest * /* t ATS_UNUSED */,
   FP;
   RE(verify(result, PARENT_SPECIFIED, "carol", 80), 211);
 
-  // cleanup, allow changes to be persisted to records.snap
-  // so that subsequent test runs do not fail unexpectedly.
-  _st.setHostStatus("curly", HOST_STATUS_UP, 0, Reason::MANUAL);
-  _st.setHostStatus("fuzzy", HOST_STATUS_UP, 0, Reason::MANUAL);
-  sleep(2);
-
   delete request;
   delete result;
   delete params;