You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2016/09/27 17:30:30 UTC
[trafficserver] 04/06: TS-4877: Fix incorrect TSStat SDK assertions.
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch 7.0.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
commit 6ccbc0fda1881b2fd4cc038f56065bdfa895ab83
Author: James Peach <jp...@apache.org>
AuthorDate: Fri Sep 16 13:53:30 2016 -0700
TS-4877: Fix incorrect TSStat SDK assertions.
(cherry picked from commit 1541ebab0b6e827c7e77e3d2447c2081aed2f4bd)
---
proxy/InkAPI.cc | 6 +++---
proxy/InkAPITest.cc | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 0abcce7..b1c9ba0 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -6932,7 +6932,7 @@ TSStatCreate(const char *the_name, TSRecordDataType the_type, TSStatPersistence
void
TSStatIntIncrement(int id, TSMgmtInt amount)
{
- sdk_assert(sdk_sanity_check_stat_id(id));
+ sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS);
RecIncrRawStat(api_rsb, NULL, id, amount);
}
@@ -6947,7 +6947,7 @@ TSStatIntGet(int id)
{
TSMgmtInt value;
- sdk_assert(sdk_sanity_check_stat_id(id));
+ sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS);
RecGetGlobalRawStatSum(api_rsb, id, &value);
return value;
}
@@ -6955,7 +6955,7 @@ TSStatIntGet(int id)
void
TSStatIntSet(int id, TSMgmtInt value)
{
- sdk_assert(sdk_sanity_check_stat_id(id));
+ sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS);
RecSetGlobalRawStatSum(api_rsb, id, value);
}
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 672d682..fe91445 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -48,6 +48,7 @@
#include "InkAPITestTool.cc"
#include "http/HttpSM.h"
+#include "ts/TestBox.h"
#define TC_PASS 1
#define TC_FAIL 0
@@ -8062,3 +8063,29 @@ REGRESSION_TEST(SDK_API_TSSslServerContextCreate)(RegressionTest *test, int leve
*pstatus = ctx ? REGRESSION_TEST_PASSED : REGRESSION_TEST_FAILED;
TSSslContextDestroy(ctx);
}
+
+REGRESSION_TEST(SDK_API_TSStatCreate)(RegressionTest *test, int level, int *pstatus)
+{
+ const char name[] = "regression.test.metric";
+ int id;
+
+ TestBox box(test, pstatus);
+
+ box = REGRESSION_TEST_PASSED;
+
+ if (TSStatFindName(name, &id) == TS_SUCCESS) {
+ box.check(id >= 0, "TSStatFind(%s) failed with bogus ID %d", name, id);
+ } else {
+ id = TSStatCreate("generator.response_bytes", TS_RECORDDATATYPE_COUNTER, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+ box.check(id != TS_ERROR, "TSStatCreate(%s) failed with %d", name, id);
+ }
+
+ TSStatIntSet(id, getpid());
+ TSStatIntIncrement(id, 1);
+ TSStatIntIncrement(id, 1);
+
+ TSMgmtInt value = TSStatIntGet(id);
+ TSMgmtInt expected = getpid() + 2;
+
+ box.check(expected >= value, "TSStatIntGet(%s) gave %" PRId64 ", expected at least %" PRId64, name, value, expected);
+}
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.