You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2011/01/01 18:09:22 UTC

svn commit: r1054259 - in /trafficserver/traffic/trunk/proxy: InkAPI.cc InkAPITest.cc api/ts/ts.h.in http2/HttpTransact.h

Author: zwoop
Date: Sat Jan  1 17:09:21 2011
New Revision: 1054259

URL: http://svn.apache.org/viewvc?rev=1054259&view=rev
Log:
TS-599 Added regression tests

Modified:
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/InkAPITest.cc
    trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
    trafficserver/traffic/trunk/proxy/http2/HttpTransact.h

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1054259&r1=1054258&r2=1054259&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Sat Jan  1 17:09:21 2011
@@ -7433,10 +7433,10 @@ _conf_to_memberp(TSOverridableConfigKey 
     return &sm->t_state.txn_conf.append_xforwards_header;
     break;
   case TS_CONFIG_HTTP_RESPONSE_SERVER_ENABLED:
-    return &sm->t_state.txn_conf.append_xforwards_header;
+    return &sm->t_state.txn_conf.proxy_response_server_enabled;
     break;
   case TS_CONFIG_HTTP_INSERT_SQUID_X_FORWARDED_FOR:
-    return &sm->t_state.txn_conf.append_xforwards_header;
+    return &sm->t_state.txn_conf.insert_squid_x_forwarded_for;
     break;
   case TS_CONFIG_HTTP_SEND_HTTP11_REQUESTS:
     return &sm->t_state.txn_conf.send_http11_requests;
@@ -7542,7 +7542,7 @@ TSHttpTxnConfigIntGet(TSHttpTxn txnp, TS
 // TODO: When there are more string / float configurations that are overridable,
 // we should do something similar to the Int versions (using _conf_to_memberp).
 TSReturnCode
-TSHttpTxnConfigFLoatSet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtFloat value)
+TSHttpTxnConfigFloatSet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtFloat value)
 {
   if (sdk_sanity_check_txn(txnp) != TS_SUCCESS)
     return TS_ERROR;
@@ -7584,7 +7584,7 @@ TSHttpTxnConfigFloatGet(TSHttpTxn txnp, 
 }
 
 TSReturnCode
-TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, char* value, int length)
+TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char* value, int length)
 {
   if ((sdk_sanity_check_txn(txnp) != TS_SUCCESS) ||
       (sdk_sanity_check_null_ptr((void*)value) != TS_SUCCESS))
@@ -7597,7 +7597,7 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp,
 
   switch (conf) {
   case TS_CONFIG_HTTP_RESPONSE_SERVER_STR:
-    sm->t_state.txn_conf.proxy_response_server_string = value;
+    sm->t_state.txn_conf.proxy_response_server_string = const_cast<char*>(value); // The "core" likes non-const char*
     sm->t_state.txn_conf.proxy_response_server_string_len = length;
     break;
   default:
@@ -7610,7 +7610,7 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp,
 
 
 TSReturnCode
-TSHttpTxnConfigStringGet(TSHttpTxn txnp, TSOverridableConfigKey conf, char **value, int *length)
+TSHttpTxnConfigStringGet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char **value, int *length)
 {
   if ((sdk_sanity_check_txn(txnp) != TS_SUCCESS) ||
       (sdk_sanity_check_null_ptr((void**)value) != TS_SUCCESS) ||
@@ -7622,7 +7622,8 @@ TSHttpTxnConfigStringGet(TSHttpTxn txnp,
   switch (conf) {
   case TS_CONFIG_HTTP_RESPONSE_SERVER_STR:
     *value = sm->t_state.txn_conf.proxy_response_server_string;
-    *length = sm->t_state.txn_conf.proxy_response_server_string_len;
+    if (length)
+      *length = sm->t_state.txn_conf.proxy_response_server_string_len;
     break;
   default:
     return TS_ERROR;

Modified: trafficserver/traffic/trunk/proxy/InkAPITest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITest.cc?rev=1054259&r1=1054258&r2=1054259&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITest.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITest.cc Sat Jan  1 17:09:21 2011
@@ -8236,3 +8236,141 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_TSHttp
 
   return;
 }
+
+
+////////////////////////////////////////////////
+// SDK_API_OVERRIDABLE_CONFIGS
+//
+// Unit Test for API: TSHttpTxnConfigFind
+//                    TSHttpTxnConfigIntSet
+//                    TSHttpTxnConfigIntGet
+//                    TSHttpTxnConfigFloatSet
+//                    TSHttpTxnConfigFloatGet
+//                    TSHttpTxnConfigStringSet
+//                    TSHttpTxnConfigStringGet
+////////////////////////////////////////////////
+
+// The order of these should be the same as TSOverridableConfigKey
+const char *SDK_Overridable_Configs[] = {
+  "proxy.config.url_remap.pristine_host_hdr",
+  "proxy.config.http.chunking_enabled",
+  "proxy.config.http.negative_caching_enabled",
+  "proxy.config.http.negative_caching_lifetime",
+  "proxy.config.http.cache.when_to_revalidate",
+  "proxy.config.http.keep_alive_enabled",
+  "proxy.config.http.keep_alive_post_out",
+  "proxy.config.net.sock_recv_buffer_size_out",
+  "proxy.config.net.sock_send_buffer_size_out",
+  "proxy.config.net.sock_option_flag_out",
+  "proxy.config.http.anonymize_remove_from",
+  "proxy.config.http.anonymize_remove_referer",
+  "proxy.config.http.anonymize_remove_user_agent",
+  "proxy.config.http.anonymize_remove_cookie",
+  "proxy.config.http.anonymize_remove_client_ip",
+  "proxy.config.http.anonymize_insert_client_ip",
+  "proxy.config.http.append_xforwards_header",
+  "proxy.config.http.response_server_enabled",
+  "proxy.config.http.insert_squid_x_forwarded_for",
+  "proxy.config.http.send_http11_requests",
+  "proxy.config.http.cache.http",
+  "proxy.config.http.cache.ignore_client_no_cache",
+  "proxy.config.http.cache.ignore_client_cc_max_age",
+  "proxy.config.http.cache.ims_on_client_no_cache",
+  "proxy.config.http.cache.ignore_server_no_cache",
+  "proxy.config.http.cache.cache_responses_to_cookies",
+  "proxy.config.http.cache.ignore_authentication",
+  "proxy.config.http.cache.cache_urls_that_look_dynamic",
+  "proxy.config.http.insert_request_via_str",
+  "proxy.config.http.insert_response_via_str",
+  "proxy.config.http.cache.heuristic_min_lifetime",
+  "proxy.config.http.cache.heuristic_max_lifetime",
+  "proxy.config.http.cache.guaranteed_min_lifetime",
+  "proxy.config.http.cache.guaranteed_max_lifetime",
+  "proxy.config.http.keep_alive_no_activity_timeout_in",
+  "proxy.config.http.origin_max_connections",
+  // These are "special", since they are not MgmtInt's
+  "proxy.config.http.response_server_str",
+  "proxy.config.http.cache.heuristic_lm_factor",
+  NULL
+};
+
+REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int atype, int *pstatus)
+{
+  NOWARN_UNUSED(atype);
+  const char* conf;
+  TSOverridableConfigKey key;
+  TSRecordDataType type;
+  HttpSM* s = HttpSM::allocate();
+  bool success = true;
+  TSHttpTxn txnp = static_cast<TSHttpTxn>(s); // Convenience ...
+  TSMgmtInt ival;
+  TSMgmtFloat fval;
+  const char* sval;
+  const char* test_string = "The Apache Traffic Server";
+
+  s->init();
+
+  *pstatus = REGRESSION_TEST_INPROGRESS;
+  for (int i=TS_CONFIG_NULL + 1; i < TS_CONFIG_LAST_ENTRY; ++i) {
+    conf = SDK_Overridable_Configs[i];
+    if (TS_SUCCESS == TSHttpTxnConfigFind(conf, -1, &key, &type)) {
+      if (key != i) {
+        SDK_RPRINT(test, "TSHttpTxnConfigFind", "TestCase1", TC_FAIL, "Failed on %s, expected %d, got %d", conf, i, key);
+        success = false;
+        continue;
+      }
+    } else {
+      SDK_RPRINT(test, "TSHttpTxnConfigFind", "TestCase1", TC_FAIL, "Called returned unexpected TS_ERROR");
+      success = false;
+      continue;
+    }
+    // Now check the getters / setters
+    switch (type) {
+    case TS_RECORDDATATYPE_INT:
+      TSHttpTxnConfigIntSet(txnp, key, 17);
+      TSHttpTxnConfigIntGet(txnp, key, &ival);
+      if (17 != ival) {
+        SDK_RPRINT(test, "TSHttpTxnConfigIntSet", "TestCase1", TC_FAIL, "Failed on %s, expected 17, got %d", conf, ival);
+        success = false;
+        continue;
+      }
+      break;
+
+    case TS_RECORDDATATYPE_FLOAT:
+      TSHttpTxnConfigFloatSet(txnp, key, 17.17);
+      TSHttpTxnConfigFloatGet(txnp, key, &fval);
+      if (17.17 != fval) {
+        SDK_RPRINT(test, "TSHttpTxnConfigFloatSet", "TestCase1", TC_FAIL, "Failed on %s, expected 17, got %d", conf, ival);
+        success = false;
+        continue;
+      }
+      break;
+
+    case TS_RECORDDATATYPE_STRING:
+      TSHttpTxnConfigStringSet(txnp, key, test_string, -1);
+      TSHttpTxnConfigStringGet(txnp, key, &sval, NULL);
+      if (test_string != sval) {
+        SDK_RPRINT(test, "TSHttpTxnConfigStringSet", "TestCase1", TC_FAIL, "Failed on %s, expected 17, got %s", conf, sval);
+        success = false;
+        continue;
+      }
+      break;
+
+    default:
+      break;
+    }
+  }
+
+  s->destroy();
+  if (success) {
+    *pstatus = REGRESSION_TEST_PASSED;
+    SDK_RPRINT(test, "TSHttpTxnConfigFind", "TestCase1", TC_PASS, "ok");
+    SDK_RPRINT(test, "TSHttpTxnConfigIntSet", "TestCase1", TC_PASS, "ok");
+    SDK_RPRINT(test, "TSHttpTxnConfigFloatSet", "TestCase1", TC_PASS, "ok");
+    SDK_RPRINT(test, "TSHttpTxnConfigStringSet", "TestCase1", TC_PASS, "ok");
+  } else {
+    *pstatus = REGRESSION_TEST_FAILED;
+  }
+
+  return;
+}

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h.in?rev=1054259&r1=1054258&r2=1054259&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h.in (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h.in Sat Jan  1 17:09:21 2011
@@ -2860,8 +2860,8 @@ extern "C"
   tsapi TSReturnCode TSHttpTxnConfigIntGet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtInt* value);
   tsapi TSReturnCode TSHttpTxnConfigFloatSet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtFloat value);
   tsapi TSReturnCode TSHttpTxnConfigFloatGet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtFloat* value);
-  tsapi TSReturnCode TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, char* value, int length);
-  tsapi TSReturnCode TSHttpTxnConfigStringGet(TSHttpTxn txnp, TSOverridableConfigKey conf, char** value, int* length);
+  tsapi TSReturnCode TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char* value, int length);
+  tsapi TSReturnCode TSHttpTxnConfigStringGet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char** value, int* length);
 
   tsapi TSReturnCode TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey* conf, TSRecordDataType* type);
 

Modified: trafficserver/traffic/trunk/proxy/http2/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/HttpTransact.h?rev=1054259&r1=1054258&r2=1054259&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/HttpTransact.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/HttpTransact.h Sat Jan  1 17:09:21 2011
@@ -1180,8 +1180,8 @@ public:
         // Loop over our transaction stat blocks and record the stats
         //  in the global arrays
         STAT_LOCK_ACQUIRE(&(global_http_trans_stat_lock));
-        StatBlock *
-          b = &first_stats;
+        StatBlock *b = &first_stats;
+
         while (b != NULL) {
           for (int i = 0; i < b->next_insert && i < StatBlockEntries; i++) {
             RecIncrRawStat(http_rsb, this_ethread(), b->stats[i].index, b->stats[i].increment);