Skip to content

Commit

Permalink
Use gradle-oci for container images in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Aug 5, 2024
1 parent c763b3c commit 79d6549
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 43 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ jobs:
java-version: 11
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Check
run: ./gradlew check
env:
ORG_GRADLE_PROJECT_dockerHubUsername: ${{ secrets.DOCKER_USERNAME }}
ORG_GRADLE_PROJECT_dockerHubPassword: ${{ secrets.DOCKER_TOKEN }}
15 changes: 14 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.hivemq.extension)
alias(libs.plugins.defaults)
alias(libs.plugins.oci)
alias(libs.plugins.license)
}

Expand All @@ -21,11 +22,18 @@ hivemqExtension {

dependencies {
compileOnly(libs.jetbrains.annotations)

implementation(libs.metrics.influxdb)
implementation(libs.commonsLang)
}

oci {
registries {
dockerHub {
optionalCredentials()
}
}
}

@Suppress("UnstableApiUsage")
testing {
suites {
Expand All @@ -49,10 +57,15 @@ testing {
implementation(libs.testcontainers.junitJupiter)
implementation(libs.testcontainers.hivemq)
implementation(libs.testcontainers.influxdb)
implementation(libs.gradleOci.junitJupiter)
implementation(libs.influxdb)
implementation(libs.okhttp)
runtimeOnly(libs.logback.classic)
}
ociImageDependencies {
runtime("hivemq:hivemq-ce:latest") { isChanging = true }
runtime("library:influxdb:1.4.3").name("influxdb").tag("latest")
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
assertj = "3.25.3"
awaitility = "4.2.1"
commonsLang = "3.14.0"
gradleOci-junitJupiter = "0.6.0"
hivemq-extensionSdk = "4.1.0"
hivemq-mqttClient = "1.3.3"
influxdb = "2.24"
Expand All @@ -18,6 +19,7 @@ wiremock = "3.5.4"
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
awaitility = { module = "org.awaitility:awaitility", version.ref = "awaitility" }
commonsLang = { module = "org.apache.commons:commons-lang3", version.ref = "commonsLang" }
gradleOci-junitJupiter = { module = "io.github.sgtsilvio:gradle-oci-junit-jupiter", version.ref = "gradleOci-junitJupiter" }
hivemq-mqttClient = { module = "com.hivemq:hivemq-mqtt-client", version.ref = "hivemq-mqttClient" }
influxdb = { module = "org.influxdb:influxdb-java", version.ref = "influxdb" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" }
Expand All @@ -33,4 +35,5 @@ wiremock = { module = "org.wiremock:wiremock", version.ref = "wiremock" }
[plugins]
hivemq-extension = { id = "com.hivemq.extension", version = "3.1.0" }
defaults = { id = "io.github.sgtsilvio.gradle.defaults", version = "0.2.0" }
oci = { id = "io.github.sgtsilvio.gradle.oci", version = "0.15.1" }
license = { id = "com.github.hierynomus.license", version = "0.16.1" }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.hivemq.client.mqtt.mqtt5.Mqtt5BlockingClient;
import com.hivemq.client.mqtt.mqtt5.Mqtt5Client;
import io.github.sgtsilvio.gradle.oci.junit.jupiter.OciImages;
import org.influxdb.InfluxDB;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
Expand All @@ -33,8 +34,6 @@

import java.util.List;

import static com.hivemq.extensions.influxdb.DockerImageNames.HIVEMQ_IMAGE;
import static com.hivemq.extensions.influxdb.DockerImageNames.INFLUXDB_IMAGE;
import static org.awaitility.Awaitility.await;
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;

Expand All @@ -49,7 +48,7 @@ public class InfluxDbExtensionIT {
private final @NotNull Network network = Network.newNetwork();

@Container
private final @NotNull HiveMQContainer hivemq = new HiveMQContainer(HIVEMQ_IMAGE) //
private final @NotNull HiveMQContainer hivemq = new HiveMQContainer(OciImages.getImageName("hivemq/hivemq-ce")) //
.withExtension(MountableFile.forClasspathResource("hivemq-influxdb-extension"))
.waitForExtension("InfluxDB Monitoring Extension")
.withNetwork(network)
Expand All @@ -59,7 +58,7 @@ public class InfluxDbExtensionIT {
.withLogConsumer(outputFrame -> System.out.print("HIVEMQ: " + outputFrame.getUtf8String()));

@Container
private final @NotNull InfluxDBContainer<?> influxDB = new InfluxDBContainer<>(INFLUXDB_IMAGE) //
private final @NotNull InfluxDBContainer<?> influxDB = new InfluxDBContainer<>(OciImages.getImageName("influxdb")) //
.withAuthEnabled(false).withNetwork(network).withNetworkAliases("influxdb");

@Test
Expand Down

0 comments on commit 79d6549

Please sign in to comment.