@Test public void testDynamicCounterIncrement() { DynamicCounter.increment(CONFIG); assertEquals(1, registry.counter(ID).count()); }
@Test public void testUnregisteredBasicCounterIncrement() { BasicCounter c = new BasicCounter(CONFIG); c.increment(); assertEquals(1, registry.counters().count()); assertEquals(1, registry.counter("test").count()); }
@Test public void testStepCounterIncrementAmount() { StepCounter c = new StepCounter(CONFIG); register(c); c.increment(42); assertEquals(42, registry.counter(ID).count()); }
@Test public void testStepCounterIncrement() { StepCounter c = new StepCounter(CONFIG); register(c); c.increment(); assertEquals(1, registry.counter(ID).count()); }
@Test public void testBasicCounterIncrementAmount() { BasicCounter c = new BasicCounter(CONFIG); register(c); c.increment(42); assertEquals(42, registry.counter(ID).count()); }
@Test public void testBasicCounterIncrement() { BasicCounter c = new BasicCounter(CONFIG); register(c); c.increment(); assertEquals(1, registry.counter(ID).count()); }
@Test public void testAsyncDownloadFailure() throws Exception { Future<Path> future = failureFileSystem.asyncDownloadFile(Paths.get(""), null, 2); try { future.get(); } catch (Exception e) { // Verify the failure metric for upload is incremented. Assert.assertEquals(1, (int) backupMetrics.getInvalidDownloads().count()); } }
@Test public void testCustomCompositeMemberCounter() { CustomCompositeExample c = new CustomCompositeExample("foo"); c.update("2"); Id id = registry.createId("test").withTag("c", "2"); assertEquals(1, registry.counter(id).count()); }
@Test public void testCustomCounter() { CustomCounter c = new CustomCounter(); register(c); c.increment(); PolledMeter.update(registry); assertEquals(1, registry.counter(ID).count()); }
@Test public void testBasicDistributionSummaryRecord() { BasicDistributionSummary d = new BasicDistributionSummary(CONFIG); register(d); d.record(42); assertEquals(1, registry.counter(ID.withTag(Statistic.count)).count()); assertEquals(42, registry.counter(ID.withTag(Statistic.totalAmount)).count()); assertEquals(42.0, registry.maxGauge(ID.withTag(Statistic.max)).value(), 1e-12); }
@Test public void testContextualCounter() { TagList context = BasicTagList.of("a", "1"); ContextualCounter c = new ContextualCounter(CONFIG, () -> context, BasicCounter::new); c.increment(); Id id = ID.withTag("a", "1"); assertEquals(1, registry.counter(id).count()); }
@Test public void testFailedRetriesDownload() { try { failureFileSystem.downloadFile(Paths.get(""), null, 2); } catch (BackupRestoreException e) { // Verify the failure metric for download is incremented. Assert.assertEquals(1, (int) backupMetrics.getInvalidDownloads().count()); } }
@Test public void testFailedRetriesUpload() throws Exception { try { Collection<File> files = generateFiles(1, 1, 1); for (File file : files) { failureFileSystem.uploadFile( file.toPath(), file.toPath(), getDummyPath(file.toPath()), 2, true); } } catch (BackupRestoreException e) { // Verify the failure metric for upload is incremented. Assert.assertEquals(1, (int) backupMetrics.getInvalidUploads().count()); } }
@Test public void testMemberCounter() { AnnotateExample ex = new AnnotateExample("foo"); ex.update(); Id id = registry.createId("test") .withTag("class", "AnnotateExample") .withTag("id", "foo"); assertEquals(1, registry.counter(id).count()); }
@Test public void testContextualMemberCounter() { ContextualExample c = new ContextualExample("foo"); c.update(); Id id = registry.createId("counter") .withTag("a", "2") .withTag("id", "foo") .withTag("class", "ContextualExample"); assertEquals(1, registry.counter(id).count()); }
@Test public void testAnnotatedCounter() { AnnotateExample ex = new AnnotateExample("foo"); PolledMeter.update(registry); Id id = registry.createId("counter") .withTag("class", "AnnotateExample") .withTag("level", "INFO") .withTag("id", "foo"); assertEquals(1, registry.counter(id).count()); }
@Test public void testDynamicTimerRecordSeconds() { DynamicTimer.record(CONFIG, 42); Id id = ID.withTag("unit", "MILLISECONDS"); assertEquals(1, registry.counter(id.withTag(Statistic.count)).count()); assertEquals(42, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12); assertEquals(42 * 42, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12); assertEquals(42, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12); }
@Test public void testBasicTimerRecordMillis() { BasicTimer d = new BasicTimer(CONFIG); register(d); d.record(42, TimeUnit.NANOSECONDS); Id id = ID.withTag("unit", "MILLISECONDS"); assertEquals(1, registry.counter(id.withTag(Statistic.count)).count()); assertEquals(42e-6, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12); assertEquals(42e-6 * 42e-6, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12); assertEquals(42e-6, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12); }
@Test public void testBasicTimerRecordSeconds() { BasicTimer d = new BasicTimer(CONFIG, TimeUnit.SECONDS); register(d); d.record(42, TimeUnit.NANOSECONDS); Id id = ID.withTag("unit", "SECONDS"); assertEquals(1, registry.counter(id.withTag(Statistic.count)).count()); assertEquals(42e-9, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12); assertEquals(42e-9 * 42e-9, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12); assertEquals(42e-9, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12); }
@Test public void testContextualTimerRecordMillis() { TagList context = BasicTagList.of("a", "1"); ContextualTimer d = new ContextualTimer(CONFIG, () -> context, BasicTimer::new); d.record(42, TimeUnit.NANOSECONDS); Id id = ID.withTag("unit", "MILLISECONDS").withTag("a", "1"); assertEquals(1, registry.counter(id.withTag(Statistic.count)).count()); assertEquals(42e-6, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12); assertEquals(42e-6 * 42e-6, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12); assertEquals(42e-6, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12); }