summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tej Singh <singhtejinder@google.com> 2019-09-24 19:12:41 -0700
committer Tej Singh <singhtejinder@google.com> 2019-09-24 19:19:55 -0700
commit3ce441f63c1bb90f356c801f11dc08e341294ae9 (patch)
tree398792887a53295dccd01124528854b2e0a6b5c4
parent4e13461ef96281c2fabfbc29a8a8c609d629c039 (diff)
Statsd unit tests: clear data on disk after tests
A couple of tests had data stored to disk, but were not reading the data. This meant that the data would persist across tests (and between tests runs and forever). This causes issues when conbined with the fact that in tests, we use ConfigKey without initializing it. This means that the uid/id of the config key will just be set to some random stack space. In Christine's case, adding State to the StatsdConfig.proto caused the "random" stack space to be the same as the one in ConfigTttl_e2e_test, which also wrote data to disk. Then, when the duration metric test called onDumpReport, it would grab the data on disk (from ConfigTtl, which used a count metric), in addition to the actual data we cared about, Adding the logic to convert the output to base64 string likely changed which stack space was allocated, meaning the config ttl data would not be pulled, thereby destroying our debugging efforts. Test: unit tests pass, nothing is written to /data/misc/stats-data after running unit tests. Test: unit tests pass with Christine's proto change to add State to StatsdConfig Change-Id: Ica987b7a1c089dae6c45d0500bf6557fa7402191
-rw-r--r--cmds/statsd/tests/StatsLogProcessor_test.cpp5
-rw-r--r--cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/cmds/statsd/tests/StatsLogProcessor_test.cpp b/cmds/statsd/tests/StatsLogProcessor_test.cpp
index fe25a257aa67..76ee9a6e5996 100644
--- a/cmds/statsd/tests/StatsLogProcessor_test.cpp
+++ b/cmds/statsd/tests/StatsLogProcessor_test.cpp
@@ -1713,6 +1713,11 @@ TEST(StatsLogProcessorTest, TestActivationsPersistAcrossSystemServerRestart) {
EXPECT_EQ(kActive, activation1004->state);
EXPECT_EQ(ACTIVATE_IMMEDIATELY, activation1004->activationType);
// }}}------------------------------------------------------------------------------
+
+ // Clear the data stored on disk as a result of the system server death.
+ vector<uint8_t> buffer;
+ processor->onDumpReport(cfgKey1, configAddedTimeNs + NS_PER_SEC, false, true,
+ ADB_DUMP, FAST, &buffer);
}
#else
diff --git a/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp b/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp
index b98dc60086ac..325e869e5a9b 100644
--- a/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp
@@ -96,6 +96,11 @@ TEST(ConfigTtlE2eTest, TestCountMetric) {
EXPECT_EQ((int64_t)(bucketStartTimeNs + 25 * bucketSizeNs + 2 + 2 * 3600 * NS_PER_SEC),
processor->mMetricsManagers.begin()->second->getTtlEndNs());
+
+ // Clear the data stored on disk as a result of the ttl.
+ vector<uint8_t> buffer;
+ processor->onDumpReport(cfgKey, bucketStartTimeNs + 25 * bucketSizeNs + 3, false, true,
+ ADB_DUMP, FAST, &buffer);
}