Skip to content

Commit

Permalink
Upgrade ffwd http reporter, github actions for java8+
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuhlha committed Jan 15, 2021
1 parent f14c6cd commit e6f2de8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 40 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-latest

strategy:
matrix:
java-version: [ 8, 10, 11]

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDKs
uses: actions/setup-java@v1
with:
java-version: 11
java-version: ${{ matrix.java-version }}
- name: Build with Maven
run: mvn -B -D environment=test verify
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package com.spotify.metrics.core;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.codahale.metrics.Clock;
import com.codahale.metrics.Meter;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;

import java.util.concurrent.TimeUnit;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class DelegatingDerivingMeterTest {
DelegatingDerivingMeter meter;
private DelegatingDerivingMeter meter;

Meter delegate;
private Meter delegate;

@Before
public void setUp() throws Exception {
Expand All @@ -32,7 +27,7 @@ public void setUp() throws Exception {
public void shouldNotCountSingleValue() throws Exception {
meter.mark(10);

assertThat(meter.getCount(), equalTo(0L));
assertEquals(meter.getCount(), 0L);
}

@Test
Expand All @@ -41,7 +36,7 @@ public void shouldCountDeltasNotAbsolutes() throws Exception {
meter.mark(20);
meter.mark(30);

assertThat(meter.getCount(), equalTo(20L));
assertEquals(meter.getCount(), 20L);
}

@Test
Expand All @@ -50,35 +45,35 @@ public void shouldDiscardWraparounds() throws Exception {
meter.mark(20);
meter.mark(30);

assertThat(meter.getCount(), equalTo(10L));
assertEquals(meter.getCount(), 10L);
}

@Test
public void shouldReturnValueFromDelegateForMeanRate() throws Exception {
setupRateTest();

assertThat(meter.getMeanRate(), is(greaterThan(300.0)));
assertTrue(meter.getMeanRate()> 300.0);
}

@Test
public void shouldReturnValueFromDelegateForOneMinuteRate() throws Exception {
setupRateTest();

assertThat(meter.getOneMinuteRate(), is(greaterThan(300.0)));
assertTrue(meter.getOneMinuteRate() > 300.0);
}

@Test
public void shouldReturnValueFromDelegateForFiveMinuteRate() throws Exception {
setupRateTest();

assertThat(meter.getFiveMinuteRate(), is(greaterThan(300.0)));
assertTrue(meter.getFiveMinuteRate() > 300.0);
}

@Test
public void shouldReturnValueFromDelegateForFifteenMinuteRate() throws Exception {
setupRateTest();

assertThat(meter.getFifteenMinuteRate(), is(greaterThan(300.0)));
assertTrue(meter.getFifteenMinuteRate() > 300.0);
}

private void setupRateTest() throws InterruptedException {
Expand All @@ -92,18 +87,4 @@ private void setupRateTest() throws InterruptedException {
// need to 'wait' more than 5 seconds for the Codahale metrics meter to 'tick'.
when(clock.getTick()).thenReturn(TimeUnit.NANOSECONDS.convert(6, TimeUnit.SECONDS));
}

private Matcher<Double> greaterThan(final double expected) {
return new TypeSafeMatcher<Double>() {
@Override
protected boolean matchesSafely(Double item) {
return item > expected;
}

@Override
public void describeTo(Description description) {
description.appendText("double greater than " + expected);
}
};
}
}
}
21 changes: 20 additions & 1 deletion ffwd-http-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<dependency>
<groupId>com.spotify.ffwd</groupId>
<artifactId>ffwd-http-client</artifactId>
<version>0.4.4</version>
<version>0.4.6</version>
</dependency>

<dependency>
Expand All @@ -37,6 +37,25 @@
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>1.3.3</version>
</dependency>

<dependency>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-loadbalancer</artifactId>
<version>2.2.2</version>
<exclusions>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>


<!-- testing -->
<dependency>
<groupId>junit</groupId>
Expand Down
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<metrics.version>4.0.2</metrics.version>
<tdunning.tdigest.version>3.2</tdunning.tdigest.version>
<com.google.protobuf.version>3.11.1</com.google.protobuf.version>
<maven.compiler.release>8</maven.compiler.release>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
Expand Down

0 comments on commit e6f2de8

Please sign in to comment.