Merge "Support a ONE_WEEK bucket size"
This commit is contained in:
committed by
Android (Google) Code Review
commit
20258d1ddb
@@ -106,6 +106,7 @@ private:
|
||||
FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgrade);
|
||||
FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgradeInNextBucket);
|
||||
FRIEND_TEST(CountMetricProducerTest, TestFirstBucket);
|
||||
FRIEND_TEST(CountMetricProducerTest, TestOneWeekTimeUnit);
|
||||
};
|
||||
|
||||
} // namespace statsd
|
||||
|
||||
@@ -445,6 +445,8 @@ int64_t TimeUnitToBucketSizeInMillis(TimeUnit unit) {
|
||||
return 12 * 60 * 60 * 1000LL;
|
||||
case ONE_DAY:
|
||||
return 24 * 60 * 60 * 1000LL;
|
||||
case ONE_WEEK:
|
||||
return 7 * 24 * 60 * 60 * 1000LL;
|
||||
case CTS:
|
||||
return 1000;
|
||||
case TIME_UNIT_UNSPECIFIED:
|
||||
|
||||
@@ -44,6 +44,7 @@ enum TimeUnit {
|
||||
SIX_HOURS = 7;
|
||||
TWELVE_HOURS = 8;
|
||||
ONE_DAY = 9;
|
||||
ONE_WEEK = 10;
|
||||
CTS = 1000;
|
||||
}
|
||||
|
||||
|
||||
@@ -396,6 +396,26 @@ TEST(CountMetricProducerTest, TestAnomalyDetectionUnSliced) {
|
||||
std::ceil(1.0 * event7.GetElapsedTimestampNs() / NS_PER_SEC + refPeriodSec));
|
||||
}
|
||||
|
||||
TEST(CountMetricProducerTest, TestOneWeekTimeUnit) {
|
||||
CountMetric metric;
|
||||
metric.set_id(1);
|
||||
metric.set_bucket(ONE_WEEK);
|
||||
|
||||
sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
|
||||
|
||||
int64_t oneDayNs = 24 * 60 * 60 * 1e9;
|
||||
int64_t fiveWeeksNs = 5 * 7 * oneDayNs;
|
||||
|
||||
CountMetricProducer countProducer(
|
||||
kConfigKey, metric, -1 /* meaning no condition */, wizard, oneDayNs, fiveWeeksNs);
|
||||
|
||||
int64_t fiveWeeksOneDayNs = fiveWeeksNs + oneDayNs;
|
||||
|
||||
EXPECT_EQ(fiveWeeksNs, countProducer.mCurrentBucketStartTimeNs);
|
||||
EXPECT_EQ(4, countProducer.mCurrentBucketNum);
|
||||
EXPECT_EQ(fiveWeeksOneDayNs, countProducer.getCurrentBucketEndTimeNs());
|
||||
}
|
||||
|
||||
} // namespace statsd
|
||||
} // namespace os
|
||||
} // namespace android
|
||||
|
||||
Reference in New Issue
Block a user