summaryrefslogtreecommitdiffstats
path: root/node-repository/src/test/java/com
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2021-08-12 11:36:46 +0200
committerGitHub <noreply@github.com>2021-08-12 11:36:46 +0200
commit9d85c855752b355a577134d56b87fdf33fee55a7 (patch)
treec891bc44626d8d98dd1a57e5ffc9008f76296aea /node-repository/src/test/java/com
parent2e543d310304136c2785d49d42d82e396f6f10ac (diff)
parent12244346f22fd6ca36f811c3913609c6e7ee4e5a (diff)
Merge pull request #18486 from vespa-engine/bratseth/gc-in-sql-reapply
Use SQL to gc
Diffstat (limited to 'node-repository/src/test/java/com')
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDbTest.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDbTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDbTest.java
index 34243f4548f..1c458750569 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDbTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDbTest.java
@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* Tests the Quest metrics db.
@@ -163,21 +164,25 @@ public class QuestMetricsDbTest {
String dataDir = "data/QuestMetricsDbGc";
IOUtils.recursiveDeleteDir(new File(dataDir));
IOUtils.createDirectory(dataDir + "/metrics");
- ManualClock clock = new ManualClock("2020-10-01T00:00:00");
- QuestMetricsDb db = new QuestMetricsDb(dataDir, clock);
+ ManualClock clock = new ManualClock();
+ int days = 10; // The first metrics are this many days in the past
+ clock.retreat(Duration.ofDays(10));
Instant startTime = clock.instant();
- int dayOffset = 3;
- clock.advance(Duration.ofHours(dayOffset));
- db.addNodeMetrics(nodeTimeseries(24 * 10, Duration.ofHours(1), clock, "host1", "host2", "host3"));
- assertEquals(24 * 10, db.getNodeTimeseries(Duration.between(startTime, clock.instant()),
- Set.of("host1")).get(0).size());
- db.gc();
- assertEquals(75, db.getNodeTimeseries(Duration.between(startTime, clock.instant()),
+ QuestMetricsDb db = new QuestMetricsDb(dataDir, clock);
+
+ db.addNodeMetrics(nodeTimeseries(24 * days, Duration.ofHours(1), clock, "host1", "host2", "host3"));
+
+ var application1 = ApplicationId.from("t1", "a1", "i1");
+ var cluster1 = new ClusterSpec.Id("cluster1");
+ db.addClusterMetrics(application1, Map.of(cluster1, new ClusterMetricSnapshot(clock.instant(), 30.0, 15.0)));
+
+ assertEquals(24 * days, db.getNodeTimeseries(Duration.between(startTime, clock.instant()),
Set.of("host1")).get(0).size());
+ db.gc();
+ assertTrue(db.getNodeTimeseries(Duration.between(startTime, clock.instant()), Set.of("host1")).get(0).size() < 24 * 4);
db.gc(); // no-op
- assertEquals(75, db.getNodeTimeseries(Duration.between(startTime, clock.instant()),
- Set.of("host1")).get(0).size());
+ assertTrue(db.getNodeTimeseries(Duration.between(startTime, clock.instant()), Set.of("host1")).get(0).size() < 24 * 4);
}
/** To manually test that we can read existing data */