Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excavator: Upgrades Baseline to the latest version #443

Merged
merged 1 commit into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:gradle-info-plugin:5.1.0'
classpath 'com.netflix.nebula:nebula-publishing-plugin:13.6.1'
classpath 'com.palantir.baseline:gradle-baseline-java:2.12.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.13.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:1.12.4'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void evictionCount() {

@Test
void hitCount() {
assertThat(stats.hitCount().getValue()).isEqualTo(1);
assertThat(stats.hitCount().getValue()).isOne();
verifyNoMoreInteractions(cache, policy, eviction);
}

Expand Down
24 changes: 10 additions & 14 deletions tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ public void after() {

@Test
public void testInstrument() {
assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();
assertThat(metricRegistry.getTimers().get(Runnable.class.getName())).isNull();

instrumentedService.test();
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();

SortedMap<String, Timer> timers = metricRegistry.getTimers();
assertThat(timers.keySet()).hasSize(1);
assertThat(timers.keySet()).isEqualTo(ImmutableSet.of(EXPECTED_METRIC_NAME));
assertThat(timers.get(EXPECTED_METRIC_NAME)).isNotNull();
assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isEqualTo(1);
assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isOne();

instrumentedService.test();

Expand All @@ -112,21 +112,21 @@ public void testInstrument() {

@Test
public void testInstrumentWithTags() {
assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();
assertThat(taggedMetricRegistry.getMetrics())
// The global failures metric is created eagerly
.containsOnlyKeys(MetricName.builder().safeName("failures").build());

taggedInstrumentedService.test();
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();

Map<MetricName, Metric> metrics = taggedMetricRegistry.getMetrics();
assertThat(metrics.keySet())
.containsExactly(EXPECTED_TAGGED_METRIC_NAME, MetricName.builder().safeName("failures").build());
Metric actual = metrics.get(EXPECTED_TAGGED_METRIC_NAME);
assertThat(actual).isInstanceOf(Timer.class);
Timer timer = (Timer) actual;
assertThat(timer.getCount()).isEqualTo(1);
assertThat(timer.getCount()).isOne();

taggedInstrumentedService.test();

Expand All @@ -147,25 +147,21 @@ public void rethrowOutOfMemoryErrorMetrics() {
String methodMetricName = MetricRegistry.name(TestInterface.class, "throwsOutOfMemoryError");
assertThat(metricRegistry.meter(
MetricRegistry.name(methodMetricName, "failures"))
.getCount())
.isEqualTo(0);
.getCount()).isZero();
assertThat(metricRegistry.meter(
MetricRegistry.name(methodMetricName, "failures", "java.lang.OutOfMemoryError"))
.getCount())
.isEqualTo(0);
.getCount()).isZero();

assertThatThrownBy(instrumentedService::throwsOutOfMemoryError)
.isInstanceOf(OutOfMemoryError.class)
.hasMessage("Testing OOM");

assertThat(metricRegistry.meter(
MetricRegistry.name(methodMetricName, "failures"))
.getCount())
.isEqualTo(1);
.getCount()).isOne();
assertThat(metricRegistry.meter(
MetricRegistry.name(methodMetricName, "failures", "java.lang.OutOfMemoryError"))
.getCount())
.isEqualTo(1);
.getCount()).isOne();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public void testNoLogging() {
Runnable instrumentedService = Instrumentation.builder(Runnable.class, delegate)
.withLogging(logger, LoggingLevel.TRACE, LoggingInvocationEventHandler.LOG_ALL_DURATIONS)
.build();
assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();
instrumentedService.run();
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();
}

@Test
Expand All @@ -86,11 +86,11 @@ public String test() {
TestInterface instrumentedService = Instrumentation.builder(TestInterface.class, delegate)
.withLogging(logger, LoggingLevel.ERROR, LoggingInvocationEventHandler.NEVER_LOG)
.build();
assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();
assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(instrumentedService::test)
.withMessage("expected");
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();
}


Expand All @@ -112,7 +112,7 @@ private static void testLoggingAtLevel(LoggingLevel level) {

assertThat(LoggingInvocationEventHandler.isEnabled(logger, level)).isTrue();

assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();

instrumented.multiArgumentMethod("test", 1, Collections.singletonList("hello"));

Expand All @@ -133,7 +133,7 @@ private static void testLoggingAtLevel(LoggingLevel level) {
assertThat(logger.isTraceEnabled()).isTrue();
break;
}
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ void testBuilder() {
.withPerformanceTraceLogging()
.build();

assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();
assertThat(metricRegistry.getTimers().get(Runnable.class.getName())).isNull();

instrumentedService.test();
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();

SortedMap<String, Timer> timers = metricRegistry.getTimers();
assertThat(timers.keySet()).hasSize(1);
assertThat(timers.keySet()).isEqualTo(ImmutableSet.of(EXPECTED_METRIC_NAME));
assertThat(timers.get(EXPECTED_METRIC_NAME)).isNotNull();
assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isEqualTo(1);
assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isOne();

executeManyTimes(instrumentedService, INVOCATION_ITERATIONS);
Slf4jReporter.forRegistry(metricRegistry).withLoggingLevel(LoggingLevel.INFO).build().report();
Expand Down Expand Up @@ -185,9 +185,9 @@ void testMetricGroupBuilder() {

assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".ONE").getCount()).isEqualTo(2L);
assertThat(metricRegistry.timer(globalPrefix + ".ONE").getCount()).isEqualTo(2L);
assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".DEFAULT").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".method").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".DEFAULT").getCount()).isOne();
assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isOne();
assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".method").getCount()).isOne();
}

private void executeManyTimes(TestInterface instrumentedService, int invocations) {
Expand Down Expand Up @@ -360,9 +360,9 @@ void testTaggedMetrics() {
.withTaggedMetrics(taggedMetricRegistry, "testPrefix")
.withMetrics(metrics)
.build();
assertThat(delegate.invocationCount()).isEqualTo(0);
assertThat(delegate.invocationCount()).isZero();
runnable.test();
assertThat(delegate.invocationCount()).isEqualTo(1);
assertThat(delegate.invocationCount()).isOne();
Map<MetricName, Metric> taggedMetrics = taggedMetricRegistry.getMetrics();
assertThat(taggedMetrics.keySet()).containsExactly(
MetricName.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void testFailure() throws Exception {
handler.onFailure(context, new RuntimeException("unexpected"));

assertThat(metricRegistry.getMeters().get("failures")).isNotNull();
assertThat(metricRegistry.getMeters().get("failures").getCount()).isEqualTo(1L);
assertThat(metricRegistry.getMeters().get("failures").getCount()).isOne();
}

@Test
Expand All @@ -85,7 +85,7 @@ void testOnFailureNullContext() {
handler.onFailure(null, new RuntimeException("expected"));

assertThat(metricRegistry.getMeters().get("failures")).isNotNull();
assertThat(metricRegistry.getMeters().get("failures").getCount()).isEqualTo(1L);
assertThat(metricRegistry.getMeters().get("failures").getCount()).isOne();
}

@Test
Expand Down Expand Up @@ -117,13 +117,13 @@ void testMetricGroupAnnotations() throws Exception {
callVoidMethod(handler, obj, "methodA", /* success= */false);

assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE").getCount()).isEqualTo(2L);
assertThat(metricRegistry.timer(obj.getClass().getName() + ".TWO").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(obj.getClass().getName() + ".DEFAULT").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE.failures").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(obj.getClass().getName() + ".TWO").getCount()).isOne();
assertThat(metricRegistry.timer(obj.getClass().getName() + ".DEFAULT").getCount()).isOne();
assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE.failures").getCount()).isOne();

//AnnotatedOtherInterface
callVoidMethod(otherHandler, other, "methodE", /* success= */true);
assertThat(metricRegistry.timer(other.getClass().getName() + ".DEFAULT").getCount()).isEqualTo(1L);
assertThat(metricRegistry.timer(other.getClass().getName() + ".DEFAULT").getCount()).isOne();

//GlobalPrefix Tests
assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isEqualTo(2L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void testClientInstrumentationHttpsUrlConnection() throws Exception {
.putSafeTags("protocol", ENABLED_PROTOCOL)
.build();
assertThat(metrics.getMetrics()).containsOnlyKeys(name);
assertThat(metrics.meter(name).getCount()).isEqualTo(1);
assertThat(metrics.meter(name).getCount()).isOne();
}

@Test
Expand All @@ -101,7 +101,7 @@ void testClientInstrumentationOkHttp() throws Exception {
.putSafeTags("protocol", ENABLED_PROTOCOL)
.build();
assertThat(metrics.getMetrics()).containsOnlyKeys(name);
assertThat(metrics.meter(name).getCount()).isEqualTo(1);
assertThat(metrics.meter(name).getCount()).isOne();
}

@Test
Expand Down Expand Up @@ -129,7 +129,7 @@ void testClientInstrumentationOkHttpHttp2() throws Exception {
.putSafeTags("protocol", ENABLED_PROTOCOL)
.build();
assertThat(metrics.getMetrics()).containsOnlyKeys(name);
assertThat(metrics.meter(name).getCount()).isEqualTo(1);
assertThat(metrics.meter(name).getCount()).isOne();
}

@Test
Expand All @@ -155,7 +155,7 @@ void testServerInstrumentationHttp2() throws Exception {
.putSafeTags("protocol", ENABLED_PROTOCOL)
.build();
assertThat(metrics.getMetrics()).containsOnlyKeys(name);
assertThat(metrics.meter(name).getCount()).isEqualTo(1);
assertThat(metrics.meter(name).getCount()).isOne();
}

@Test
Expand All @@ -174,7 +174,7 @@ void testServerInstrumentation() throws Exception {
.putSafeTags("protocol", ENABLED_PROTOCOL)
.build();
assertThat(metrics.getMetrics()).containsOnlyKeys(name);
assertThat(metrics.meter(name).getCount()).isEqualTo(1);
assertThat(metrics.meter(name).getCount()).isOne();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ void testHdrHistogram() {

Histogram histogram = metrics.histogram("histogram");
histogram.update(42L);
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
Snapshot histogramSnapshot = histogram.getSnapshot();
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogramSnapshot.size()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
assertThat(histogramSnapshot.size()).isOne();
assertThat(histogramSnapshot.getMax()).isEqualTo(42);

metrics.timer("timer").update(123, TimeUnit.MILLISECONDS);
assertThat(metrics.timer("timer").getCount()).isEqualTo(1);
assertThat(metrics.timer("timer").getCount()).isOne();
}

@Test
Expand All @@ -117,14 +117,14 @@ void testSlidingTimeWindowHistogram() {

Histogram histogram = metrics.histogram("histogram");
histogram.update(42L);
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
Snapshot histogramSnapshot = histogram.getSnapshot();
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogramSnapshot.size()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
assertThat(histogramSnapshot.size()).isOne();
assertThat(histogramSnapshot.getMax()).isEqualTo(42);

metrics.timer("timer").update(123, TimeUnit.MILLISECONDS);
assertThat(metrics.timer("timer").getCount()).isEqualTo(1);
assertThat(metrics.timer("timer").getCount()).isOne();
}

@Test
Expand All @@ -139,10 +139,10 @@ void testSlidingTimeWindowHistogramExpiery() {

Histogram histogram = metrics.histogram("histogram");
histogram.update(42L);
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
Snapshot histogramSnapshot = histogram.getSnapshot();
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogramSnapshot.size()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
assertThat(histogramSnapshot.size()).isOne();
assertThat(histogramSnapshot.getMax()).isEqualTo(42);

clock.advance(window / 2, windowUnit);
Expand All @@ -157,17 +157,17 @@ void testSlidingTimeWindowHistogramExpiery() {

histogramSnapshot = histogram.getSnapshot();
assertThat(histogram.getCount()).isEqualTo(2);
assertThat(histogramSnapshot.size()).isEqualTo(1);
assertThat(histogramSnapshot.size()).isOne();
assertThat(histogramSnapshot.getMax()).isEqualTo(1337);

clock.advance(window, windowUnit);

histogramSnapshot = histogram.getSnapshot();
assertThat(histogram.getCount()).isEqualTo(2);
assertThat(histogramSnapshot.size()).isEqualTo(0);
assertThat(histogramSnapshot.size()).isZero();

metrics.timer("timer").update(123, TimeUnit.MILLISECONDS);
assertThat(metrics.timer("timer").getCount()).isEqualTo(1);
assertThat(metrics.timer("timer").getCount()).isOne();
}

@Test
Expand All @@ -177,14 +177,14 @@ void testDecayingHistogramReservoirs() {

Histogram histogram = metrics.histogram("histogram");
histogram.update(42L);
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
Snapshot histogramSnapshot = histogram.getSnapshot();
assertThat(histogram.getCount()).isEqualTo(1);
assertThat(histogramSnapshot.size()).isEqualTo(1);
assertThat(histogram.getCount()).isOne();
assertThat(histogramSnapshot.size()).isOne();
assertThat(histogramSnapshot.getMax()).isEqualTo(42);

metrics.timer("timer").update(123, TimeUnit.MILLISECONDS);
assertThat(metrics.timer("timer").getCount()).isEqualTo(1);
assertThat(metrics.timer("timer").getCount()).isOne();
}

@Test
Expand Down
Loading