diff options
| author | Junyu Lai <junyulai@google.com> | 2022-01-29 04:12:58 +0000 |
|---|---|---|
| committer | Cherrypicker Worker <android-build-cherrypicker-worker@google.com> | 2022-05-16 05:53:02 +0000 |
| commit | 108d20f84a55e7808d322edec6c4828a55cc4312 (patch) | |
| tree | fb11756891fda274bdaa13aec87434993aee19de /tests/unit/java/android/net/NetworkStatsHistoryTest.java | |
| parent | d1ba6a4f53ece5afcbd5f56f6e780cf70e98fdfd (diff) | |
[MS81] Support remove history before cutoff timestamp
This is needed to ensure corrupted data can be clean up if
the data migration process dones't go well.
Test: NetworkStatsCollectionTest
Bug: 197717846
Change-Id: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
(cherry picked from commit 306a00316cac03a0c61f995316c9c5682bec2a19)
Merged-In: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
Diffstat (limited to 'tests/unit/java/android/net/NetworkStatsHistoryTest.java')
| -rw-r--r-- | tests/unit/java/android/net/NetworkStatsHistoryTest.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/unit/java/android/net/NetworkStatsHistoryTest.java b/tests/unit/java/android/net/NetworkStatsHistoryTest.java index c5f8c00459..26079a21b6 100644 --- a/tests/unit/java/android/net/NetworkStatsHistoryTest.java +++ b/tests/unit/java/android/net/NetworkStatsHistoryTest.java @@ -270,7 +270,7 @@ public class NetworkStatsHistoryTest { } @Test - public void testRemove() throws Exception { + public void testRemoveStartingBefore() throws Exception { stats = new NetworkStatsHistory(HOUR_IN_MILLIS); // record some data across 24 buckets @@ -278,28 +278,28 @@ public class NetworkStatsHistoryTest { assertEquals(24, stats.size()); // try removing invalid data; should be no change - stats.removeBucketsBefore(0 - DAY_IN_MILLIS); + stats.removeBucketsStartingBefore(0 - DAY_IN_MILLIS); assertEquals(24, stats.size()); // try removing far before buckets; should be no change - stats.removeBucketsBefore(TEST_START - YEAR_IN_MILLIS); + stats.removeBucketsStartingBefore(TEST_START - YEAR_IN_MILLIS); assertEquals(24, stats.size()); // try removing just moments into first bucket; should be no change - // since that bucket contains data beyond the cutoff - stats.removeBucketsBefore(TEST_START + SECOND_IN_MILLIS); + // since that bucket doesn't contain data starts before the cutoff + stats.removeBucketsStartingBefore(TEST_START); assertEquals(24, stats.size()); // try removing single bucket - stats.removeBucketsBefore(TEST_START + HOUR_IN_MILLIS); + stats.removeBucketsStartingBefore(TEST_START + HOUR_IN_MILLIS); assertEquals(23, stats.size()); // try removing multiple buckets - stats.removeBucketsBefore(TEST_START + (4 * HOUR_IN_MILLIS)); + stats.removeBucketsStartingBefore(TEST_START + (4 * HOUR_IN_MILLIS)); assertEquals(20, stats.size()); // try removing all buckets - stats.removeBucketsBefore(TEST_START + YEAR_IN_MILLIS); + stats.removeBucketsStartingBefore(TEST_START + YEAR_IN_MILLIS); assertEquals(0, stats.size()); } @@ -349,7 +349,7 @@ public class NetworkStatsHistoryTest { stats.recordData(start, end, entry); } else { // trim something - stats.removeBucketsBefore(r.nextLong()); + stats.removeBucketsStartingBefore(r.nextLong()); } } assertConsistent(stats); |
