You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2016/05/31 15:54:50 UTC

[trafficserver] 05/09: TS-4473: Fix ParentProxy API test race condition.

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

sorber pushed a commit to branch 6.2.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit ccd8e78ed1d2ab64d847a1964ea9671164827aa7
Author: James Peach <jp...@apache.org>
AuthorDate: Mon May 23 16:12:54 2016 -0700

    TS-4473: Fix ParentProxy API test race condition.
    
    The actual configuration change is made an undefined time after
    applying the configuration change, so when we write tests that
    depend on changing the configuration, we need to wait until it is
    applied.
    
    (cherry picked from commit 08b2ed4aa22e67ee77ee8a128154c7e9d4012b6f)
---
 proxy/InkAPITest.cc | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 8f87248..51f670e 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -5269,7 +5269,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
 
 REGRESSION_TEST(SDK_API_TSMgmtGet)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus)
 {
-  const char *CONFIG_PARAM_COUNTER_NAME = "proxy.process.http.total_parent_proxy_connections";
+  const char *CONFIG_PARAM_COUNTER_NAME = "proxy.process.ssl.total_tickets_renewed";
   int CONFIG_PARAM_COUNTER_VALUE = 0;
 
   const char *CONFIG_PARAM_FLOAT_NAME = "proxy.config.http.background_fill_completed_threshold";
@@ -5900,6 +5900,8 @@ struct ParentTest {
     this->regtest = test;
     this->pstatus = pstatus;
     this->magic = MAGIC_ALIVE;
+    this->deferred.event = TS_EVENT_NONE;
+    this->deferred.edata = NULL;
 
     /* If parent proxy routing is not enabled, enable it for the life of the test. */
     RecGetRecordBool("proxy.config.http.parent_proxy_routing_enable", &this->parent_proxy_routing_enable);
@@ -5920,9 +5922,24 @@ struct ParentTest {
     this->magic = MAGIC_DEAD;
   }
 
+  bool parent_routing_enabled() const {
+    RecBool enabled = false;
+
+    ParentConfigParams *params = ParentConfig::acquire();
+    enabled = params->policy.ParentEnable;
+    ParentConfig::release(params);
+
+    return enabled;
+  }
+
   RegressionTest *regtest;
   int *pstatus;
 
+  struct {
+    TSEvent event;
+    void *  edata;
+  } deferred;
+
   const char *testcase;
   SocketServer *os;
   ClientTxn *browser;
@@ -6006,8 +6023,26 @@ parent_proxy_handler(TSCont contp, TSEvent event, void *edata)
   CHECK_SPURIOUS_EVENT(contp, event, edata);
   ptest = (ParentTest *)TSContDataGet(contp);
 
+  if (ptest && ptest->deferred.event != TS_EVENT_NONE) {
+    event = ptest->deferred.event;
+    edata = ptest->deferred.edata;
+    ptest->deferred.event = TS_EVENT_NONE;
+    ptest->deferred.edata = NULL;
+  }
+
   switch (event) {
   case TS_EVENT_HTTP_READ_REQUEST_HDR:
+    // Keep deferring the test start until the parent configuration
+    // has taken effect.
+    if (!ptest->parent_routing_enabled()) {
+      rprintf(ptest->regtest, "waiting for parent proxy configuration\n");
+
+      ptest->deferred.event = event;
+      ptest->deferred.edata = edata;
+      TSContSchedule(contp, 100, TS_THREAD_POOL_NET);
+      break;
+    }
+
     rprintf(ptest->regtest, "setting synserver parent proxy to %s:%d\n", "127.0.0.1", SYNSERVER_LISTEN_PORT);
 
     // Since we chose a request format with a hostname of trafficserver.apache.org, it won't get

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.