Skip to content

Commit

Permalink
Upgrade project dependencies and remove IntelliJ warnings (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
asafm authored Sep 18, 2022
1 parent 262f6c0 commit fbeaba8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
<version>31.1-jre</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -115,13 +115,13 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.1</version>
<version>2.13.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
<version>2.13.4</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -132,43 +132,43 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.42.Final</version>
<version>4.1.81.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.16.2</version>
<version>1.17.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.1</version>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.14.0</version>
<version>3.23.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.2</version>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
Expand Down
76 changes: 38 additions & 38 deletions src/test/java/io/logz/jmx2graphite/GraphiteITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ public class GraphiteITest {
private static Stopwatch beforeClassStopwatch;
public static final String TEST_SERVICE_HOST = "testhost";
public static final String TEST_SERVICE_NAME = "testservice";
private static File tempDir;

@SuppressWarnings({"resource", "unchecked"})
@BeforeClass
public static void beforeClass() throws IOException {
beforeClassStopwatch = Stopwatch.createStarted();
tempDir = createTempDir();
File tempDir = createTempDir();

graphiteContainer = new GenericContainer("sitespeedio/graphite:0.9.14").withExposedPorts(2003, 80)
graphiteContainer = new GenericContainer<>("sitespeedio/graphite:1.0.2-2").withExposedPorts(2003, 80)
.withFileSystemBind(tempDir.getAbsolutePath(), "/var/log/carbon", BindMode.READ_WRITE)
.withClasspathResourceMapping("carbon.conf", "/opt/graphite/conf/carbon.conf", BindMode.READ_ONLY)
.withClasspathResourceMapping("blacklist.conf", "/opt/graphite/conf/blacklist.conf", BindMode.READ_ONLY)
.withClasspathResourceMapping("storage-schemas.conf", "/opt/graphite/conf/storage-schemas.conf",
BindMode.READ_ONLY)
.waitingFor(new HostPortWaitStrategy().withStartupTimeout(Duration.ofSeconds(10)))
.waitingFor(new HostPortWaitStrategy().withStartupTimeout(Duration.ofSeconds(30)))
.withLogConsumer(new Slf4jLogConsumer(logger).withPrefix("graphite"));

graphiteContainer.setPortBindings(Lists.newArrayList("2003:2003", "1180:80"));
Expand All @@ -69,46 +69,46 @@ public static void afterClass() {
}

@Test
public void testResilienceToGraphiteRestart() {
GraphiteClient graphite = createGraphiteClient();
public void testResilienceToGraphiteRestart() throws IOException {
try (GraphiteClient graphite = createGraphiteClient()) {
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")).truncatedTo(MINUTES);
String metricName = "numOfLogz";
float value = 100.0f;
graphite.sendMetrics(metricsListOf(metricName, value, now.toEpochSecond()));
assertThat(graphite.getFailedAtLastWrite()).isEqualTo(0);

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String fullMetricPath = String.format("%s.%s.%s", TEST_SERVICE_NAME, TEST_SERVICE_HOST, metricName);

await().atMost(10, TimeUnit.SECONDS).until(() -> {
String result = queryGraphiteAsCsv(fullMetricPath);
assertThat(result).contains(fullMetricPath + "," + dateTimeFormatter.format(now) + "," + value);
});

ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")).truncatedTo(MINUTES);
String metricName = "numOfLogz";
float value = 100.0f;
graphite.sendMetrics(metricsListOf(metricName, value, now.toEpochSecond()));
assertThat(graphite.getFailedAtLastWrite()).isEqualTo(0);

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String fullMetricPath = String.format("%s.%s.%s", TEST_SERVICE_NAME, TEST_SERVICE_HOST, metricName);

await().atMost(10, TimeUnit.SECONDS).until(() -> {
String result = queryGraphiteAsCsv(fullMetricPath);
assertThat(result).contains(fullMetricPath + "," + dateTimeFormatter.format(now) + "," + value);
});

graphiteContainer.stop();
graphiteContainer.stop();

await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS)
.until(() -> assertThatThrownBy(
() -> graphite.sendMetrics(metricsListOf(metricName, value, now.toEpochSecond())))
.isInstanceOf(GraphiteClient.GraphiteWriteFailed.class)
.hasMessageContaining("Connection refused"));
await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS)
.until(() -> assertThatThrownBy(
() -> graphite.sendMetrics(metricsListOf(metricName, value, now.toEpochSecond())))
.isInstanceOf(GraphiteClient.GraphiteWriteFailed.class)
.hasMessageContaining("Connection refused"));

graphiteContainer.start();
graphiteContainer.start();

await().atMost(10, TimeUnit.SECONDS).ignoreExceptionsInstanceOf(ConnectException.class)
.until(() -> queryGraphiteAsCsv(fullMetricPath) != null);
await().atMost(10, TimeUnit.SECONDS).ignoreExceptionsInstanceOf(ConnectException.class)
.until(() -> queryGraphiteAsCsv(fullMetricPath) != null);

String metricName2 = "numOfLogz2";
String metricName2 = "numOfLogz2";

graphite.sendMetrics(metricsListOf(metricName2, value, now.toEpochSecond()));
assertThat(graphite.getFailedAtLastWrite()).isEqualTo(0);
graphite.sendMetrics(metricsListOf(metricName2, value, now.toEpochSecond()));
assertThat(graphite.getFailedAtLastWrite()).isEqualTo(0);

String fullMetricPath2 = String.format("%s.%s.%s", TEST_SERVICE_NAME, TEST_SERVICE_HOST, metricName2);
await().atMost(10, TimeUnit.SECONDS).until(() -> {
String result2 = queryGraphiteAsCsv(fullMetricPath2);
assertThat(result2).contains(fullMetricPath2 + "," + dateTimeFormatter.format(now) + "," + value);
});
String fullMetricPath2 = String.format("%s.%s.%s", TEST_SERVICE_NAME, TEST_SERVICE_HOST, metricName2);
await().atMost(10, TimeUnit.SECONDS).until(() -> {
String result2 = queryGraphiteAsCsv(fullMetricPath2);
assertThat(result2).contains(fullMetricPath2 + "," + dateTimeFormatter.format(now) + "," + value);
});
}
}

private String queryGraphiteAsCsv(String fullMetricPath) {
Expand All @@ -132,7 +132,7 @@ private static List<MetricValue> metricsListOf(String metricName, Number value,
}

private static File createTempDir() throws IOException {
final File tempFile = Files.createTempDirectory("mytest").toFile();;
final File tempFile = Files.createTempDirectory("mytest").toFile();
logger.info("Logging to {}", tempFile.getAbsolutePath());
return tempFile;
}
Expand Down

0 comments on commit fbeaba8

Please sign in to comment.