diff --git a/build.gradle b/build.gradle index e7bb9d6fc..0ec417f7e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,20 +1,21 @@ plugins { + id 'jacoco' + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' + id 'org.jreleaser' version '0.4.0' + id 'com.github.ben-manes.versions' version '0.39.0' id 'org.asciidoctor.jvm.convert' id 'org.ajoberstar.git-publish' version '3.0.0' - id 'com.github.ben-manes.versions' version '0.38.0' - id 'org.jreleaser' version '0.2.0' - id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' } repositories { - mavenLocal() mavenCentral() -} - -allprojects { - tasks.withType(JavaCompile) { - sourceCompatibility = "1.8" - targetCompatibility = "1.8" + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/redis-developer/registry") + credentials { + username = project.findProperty("github.username") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("github.token") ?: System.getenv("GITHUB_TOKEN") + } } } @@ -67,6 +68,7 @@ jreleaser { authors = ['Julien Ruaux'] tags = ['redis'] license = 'Apache-2.0' + copyright = '2021 Julien Ruaux' java { multiProject = true } @@ -111,4 +113,4 @@ nexusPublishing { } } -gitPublishPush.dependsOn asciidoctor \ No newline at end of file +gitPublishPush.dependsOn asciidoctor diff --git a/buildSrc/src/main/groovy/riot.connector-conventions.gradle b/buildSrc/src/main/groovy/riot.connector-conventions.gradle index 809f1a0fd..113fecf4e 100644 --- a/buildSrc/src/main/groovy/riot.connector-conventions.gradle +++ b/buildSrc/src/main/groovy/riot.connector-conventions.gradle @@ -4,8 +4,15 @@ plugins { } repositories { - mavenLocal() mavenCentral() + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/redis-developer/registry") + credentials { + username = project.findProperty("github.username") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("github.token") ?: System.getenv("GITHUB_TOKEN") + } + } } dependencies { @@ -15,4 +22,4 @@ dependencies { tasks.withType(Tar) { compression = Compression.GZIP -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/riot.java-conventions.gradle b/buildSrc/src/main/groovy/riot.java-conventions.gradle index fb58aa1e6..b7d2fd1c6 100644 --- a/buildSrc/src/main/groovy/riot.java-conventions.gradle +++ b/buildSrc/src/main/groovy/riot.java-conventions.gradle @@ -4,8 +4,19 @@ plugins { id 'io.spring.dependency-management' } +sourceCompatibility = "1.8" +targetCompatibility = "1.8" + repositories { mavenCentral() + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/redis-developer/registry") + credentials { + username = project.findProperty("github.username") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("github.token") ?: System.getenv("GITHUB_TOKEN") + } + } } bootJar { @@ -42,4 +53,8 @@ configurations.all { test { useJUnitPlatform() -} \ No newline at end of file + testLogging { + events "failed" + exceptionFormat "full" + } +} diff --git a/buildSrc/src/main/groovy/riot.publish-conventions.gradle b/buildSrc/src/main/groovy/riot.publish-conventions.gradle index 2af45a40e..4d139cc09 100644 --- a/buildSrc/src/main/groovy/riot.publish-conventions.gradle +++ b/buildSrc/src/main/groovy/riot.publish-conventions.gradle @@ -1,11 +1,26 @@ plugins { id 'maven-publish' id 'signing' + id 'jacoco' } repositories { - mavenLocal() mavenCentral() + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/redis-developer/registry") + credentials { + username = project.findProperty("github.username") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("github.token") ?: System.getenv("GITHUB_TOKEN") + } + } +} + +jacocoTestReport { + reports { + xml.enabled true + html.enabled false + } } java { @@ -53,4 +68,4 @@ publishing { signing { sign publishing.publications.mavenJava -} \ No newline at end of file +} diff --git a/docs/getting_started.adoc b/docs/getting_started.adoc index 13d7ceca7..abefd84d9 100644 --- a/docs/getting_started.adoc +++ b/docs/getting_started.adoc @@ -32,6 +32,8 @@ cd {app} == Usage +=== Help + [subs="attributes",source,bash] ---- {app} --help @@ -48,4 +50,14 @@ You can use `--help` on any subcommand: ---- ==== +=== Redis Connection + +[subs="attributes",source,bash] +---- +{app} --help +---- + +[TIP,subs="attributes"] +==== Redis connection options are the same as `redis-cli`. URI syntax is described https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details#uri-syntax[here]. +==== diff --git a/riot-core/build.gradle b/riot-core/build.gradle index e32390e0c..f9015b778 100644 --- a/riot-core/build.gradle +++ b/riot-core/build.gradle @@ -4,8 +4,15 @@ plugins { } repositories { - mavenLocal() mavenCentral() + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/redis-developer/registry") + credentials { + username = project.findProperty("github.username") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("github.token") ?: System.getenv("GITHUB_TOKEN") + } + } } dependencies { @@ -25,4 +32,4 @@ jar { manifest { attributes("Implementation-Title": "RIOT", "Implementation-Version": archiveVersion) } -} \ No newline at end of file +} diff --git a/riot-db/src/test/java/com/redislabs/riot/db/TestPostgreSQL.java b/riot-db/src/test/java/com/redislabs/riot/db/TestPostgreSQL.java index 0541a2d34..6138d672c 100644 --- a/riot-db/src/test/java/com/redislabs/riot/db/TestPostgreSQL.java +++ b/riot-db/src/test/java/com/redislabs/riot/db/TestPostgreSQL.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.redislabs.riot.DataType; import com.redislabs.testcontainers.RedisContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.api.sync.RedisHashCommands; import io.lettuce.core.api.sync.RedisKeyCommands; import io.lettuce.core.api.sync.RedisServerCommands; @@ -65,7 +66,7 @@ public void clearTables() throws SQLException { @ParameterizedTest @MethodSource("containers") - public void testExport(RedisContainer container) throws Exception { + public void testExport(RedisServer container) throws Exception { Statement statement = connection.createStatement(); statement.execute("CREATE TABLE mytable (id smallint NOT NULL, field1 bpchar, field2 bpchar)"); statement.execute("ALTER TABLE ONLY mytable ADD CONSTRAINT pk_mytable PRIMARY KEY (id)"); @@ -87,7 +88,7 @@ public void testExport(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void testImport(RedisContainer container) throws Exception { + public void testImport(RedisServer container) throws Exception { execute("import-postgresql", container, r -> configureImportCommand(r, POSTGRESQL)); Statement statement = connection.createStatement(); statement.execute("SELECT COUNT(*) AS count FROM orders"); @@ -103,7 +104,7 @@ public void testImport(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void testImportSet(RedisContainer container) throws Exception { + public void testImportSet(RedisServer container) throws Exception { execute("import-postgresql-set", container, r -> configureImportCommand(r, POSTGRESQL)); Statement statement = connection.createStatement(); statement.execute("SELECT * FROM orders"); diff --git a/riot-file/src/test/java/com/redislabs/riot/file/TestFile.java b/riot-file/src/test/java/com/redislabs/riot/file/TestFile.java index cd8a27c2e..5c912133a 100644 --- a/riot-file/src/test/java/com/redislabs/riot/file/TestFile.java +++ b/riot-file/src/test/java/com/redislabs/riot/file/TestFile.java @@ -4,9 +4,14 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.redislabs.riot.AbstractRiotIntegrationTest; import com.redislabs.riot.redis.HsetCommand; -import com.redislabs.testcontainers.RedisContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.GeoArgs; -import io.lettuce.core.api.sync.*; +import io.lettuce.core.api.sync.RedisGeoCommands; +import io.lettuce.core.api.sync.RedisHashCommands; +import io.lettuce.core.api.sync.RedisKeyCommands; +import io.lettuce.core.api.sync.RedisServerCommands; +import io.lettuce.core.api.sync.RedisSetCommands; +import io.lettuce.core.api.sync.RedisStringCommands; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; @@ -28,7 +33,11 @@ import java.nio.file.Files; import java.nio.file.Path; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.zip.GZIPInputStream; @@ -87,7 +96,7 @@ protected RiotFile app() { @ParameterizedTest @MethodSource("containers") - public void importFW(RedisContainer container) throws Exception { + public void importFW(RedisServer container) throws Exception { execute("import-fw", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("account:*"); @@ -103,7 +112,7 @@ public void importFW(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importCSV(RedisContainer container) throws Exception { + public void importCSV(RedisServer container) throws Exception { execute("import-csv", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -112,7 +121,7 @@ public void importCSV(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importPSV(RedisContainer container) throws Exception { + public void importPSV(RedisServer container) throws Exception { execute("import-psv", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("sample:*"); @@ -121,7 +130,7 @@ public void importPSV(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importTSV(RedisContainer container) throws Exception { + public void importTSV(RedisServer container) throws Exception { execute("import-tsv", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("sample:*"); @@ -130,7 +139,7 @@ public void importTSV(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importType(RedisContainer container) throws Exception { + public void importType(RedisServer container) throws Exception { execute("import-type", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("sample:*"); @@ -139,7 +148,7 @@ public void importType(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importExclude(RedisContainer container) throws Exception { + public void importExclude(RedisServer container) throws Exception { execute("import-exclude", container); RedisHashCommands sync = sync(container); Map beer1036 = sync.hgetall("beer:1036"); @@ -152,7 +161,7 @@ public void importExclude(RedisContainer container) throws Exception { // @ParameterizedTest // @MethodSource("containers") - // public void importExcludeAPI(RedisContainer container) throws Exception { + // public void importExcludeAPI(RedisServer container) throws Exception { // // riot-file import http://developer.redislabs.com/riot/beers.csv --header hset --keyspace beer --keys id --exclude row ibu // FileImportCommand.builder().file("http://developer.redislabs.com/riot/beers.csv").options(FileImportOptions.builder().header(true).build()). // sync(container); @@ -166,7 +175,7 @@ public void importExclude(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importInclude(RedisContainer container) throws Exception { + public void importInclude(RedisServer container) throws Exception { execute("import-include", container); RedisHashCommands sync = sync(container); Map beer1036 = sync.hgetall("beer:1036"); @@ -178,7 +187,7 @@ public void importInclude(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importFilter(RedisContainer container) throws Exception { + public void importFilter(RedisServer container) throws Exception { execute("import-filter", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -187,7 +196,7 @@ public void importFilter(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importRegex(RedisContainer container) throws Exception { + public void importRegex(RedisServer container) throws Exception { execute("import-regex", container); RedisHashCommands sync = sync(container); Map airport1 = sync.hgetall("airport:1"); @@ -197,7 +206,7 @@ public void importRegex(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importGlob(RedisContainer container) throws Exception { + public void importGlob(RedisServer container) throws Exception { execute("import-glob", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -206,7 +215,7 @@ public void importGlob(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importGeoadd(RedisContainer container) throws Exception { + public void importGeoadd(RedisServer container) throws Exception { execute("import-geoadd", container); RedisGeoCommands sync = sync(container); Set results = sync.georadius("airportgeo", -122.4194, 37.7749, 20, GeoArgs.Unit.mi); @@ -217,7 +226,7 @@ public void importGeoadd(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importGeoProcessor(RedisContainer container) throws Exception { + public void importGeoProcessor(RedisServer container) throws Exception { execute("import-geo-processor", container); RedisHashCommands sync = sync(container); Map airport3469 = sync.hgetall("airport:3469"); @@ -226,7 +235,7 @@ public void importGeoProcessor(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importProcess(RedisContainer container) throws Exception { + public void importProcess(RedisServer container) throws Exception { execute("import-process", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("event:*"); @@ -241,7 +250,7 @@ public void importProcess(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importProcessElvis(RedisContainer container) throws Exception { + public void importProcessElvis(RedisServer container) throws Exception { execute("import-process-elvis", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -252,7 +261,7 @@ public void importProcessElvis(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importMultiCommands(RedisContainer container) throws Exception { + public void importMultiCommands(RedisServer container) throws Exception { execute("import-multi-commands", container); RedisKeyCommands sync = sync(container); List beers = sync.keys("beer:*"); @@ -269,13 +278,13 @@ public void importMultiCommands(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importBad(RedisContainer container) throws Exception { + public void importBad(RedisServer container) throws Exception { execute("import-bad", container); } @ParameterizedTest @MethodSource("containers") - public void importGCS(RedisContainer container) throws Exception { + public void importGCS(RedisServer container) throws Exception { execute("import-gcs", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -286,7 +295,7 @@ public void importGCS(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importS3(RedisContainer container) throws Exception { + public void importS3(RedisServer container) throws Exception { execute("import-s3", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -297,7 +306,7 @@ public void importS3(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importDump(RedisContainer container) throws Exception { + public void importDump(RedisServer container) throws Exception { List records = exportToList(container); RedisServerCommands sync = sync(container); sync.flushall(); @@ -317,7 +326,7 @@ private void configureExportCommand(CommandLine.ParseResult parseResult) { @ParameterizedTest @MethodSource("containers") - public void importJsonElastic(RedisContainer container) throws Exception { + public void importJsonElastic(RedisServer container) throws Exception { execute("import-json-elastic", container); RedisKeyCommands sync = sync(container); Assertions.assertEquals(2, sync.keys("estest:*").size()); @@ -328,7 +337,7 @@ public void importJsonElastic(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importJson(RedisContainer container) throws Exception { + public void importJson(RedisServer container) throws Exception { execute("import-json", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); @@ -339,7 +348,7 @@ public void importJson(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importXml(RedisContainer container) throws Exception { + public void importXml(RedisServer container) throws Exception { execute("import-xml", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("trade:*"); @@ -351,7 +360,7 @@ public void importXml(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void exportJSON(RedisContainer container) throws Exception { + public void exportJSON(RedisServer container) throws Exception { List records = exportToList(container); RedisServerCommands sync = sync(container); Assertions.assertEquals(sync.dbsize(), records.size()); @@ -359,7 +368,7 @@ public void exportJSON(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void exportJsonGz(RedisContainer container) throws Exception { + public void exportJsonGz(RedisServer container) throws Exception { Path file = tempFile("beers.json.gz"); execute("import-json", container); execute("export-json-gz", container, this::configureExportCommand); @@ -377,7 +386,7 @@ public void exportJsonGz(RedisContainer container) throws Exception { } - private List exportToList(RedisContainer container) throws Exception { + private List exportToList(RedisServer container) throws Exception { Path file = tempFile("redis.json"); dataGenerator(container).build().call(); execute("export-json", container, this::configureExportCommand); @@ -393,7 +402,7 @@ private List exportToList(RedisContainer container) throws Except @ParameterizedTest @MethodSource("containers") - public void exportXml(RedisContainer container) throws Exception { + public void exportXml(RedisServer container) throws Exception { dataGenerator(container).build().call(); Path file = tempFile("redis.xml"); execute("export-xml", container, this::configureExportCommand); @@ -422,7 +431,7 @@ public void exportXml(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importJsonAPI(RedisContainer container) throws Exception { + public void importJsonAPI(RedisServer container) throws Exception { // riot-file import hset --keyspace beer --keys id FileImportCommand command = new FileImportCommand(); command.setFiles(Arrays.asList("http://developer.redislabs.com/riot/beers.json")); @@ -443,7 +452,7 @@ public void importJsonAPI(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void importJSONGzip(RedisContainer container) throws Exception { + public void importJSONGzip(RedisServer container) throws Exception { execute("import-json-gz", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("beer:*"); diff --git a/riot-gen/src/test/java/com/redislabs/riot/gen/TestGen.java b/riot-gen/src/test/java/com/redislabs/riot/gen/TestGen.java index 902345232..87a149064 100644 --- a/riot-gen/src/test/java/com/redislabs/riot/gen/TestGen.java +++ b/riot-gen/src/test/java/com/redislabs/riot/gen/TestGen.java @@ -2,14 +2,21 @@ import com.redislabs.mesclun.RedisModulesClient; import com.redislabs.mesclun.StatefulRedisModulesConnection; -import com.redislabs.mesclun.search.*; -import com.redislabs.riot.RedisOptions; +import com.redislabs.mesclun.search.CreateOptions; +import com.redislabs.mesclun.search.Document; +import com.redislabs.mesclun.search.Field; +import com.redislabs.mesclun.search.SearchResults; import com.redislabs.riot.AbstractRiotIntegrationTest; -import com.redislabs.testcontainers.RedisContainer; +import com.redislabs.riot.RedisOptions; import com.redislabs.testcontainers.RedisModulesContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.Range; import io.lettuce.core.StreamMessage; -import io.lettuce.core.api.sync.*; +import io.lettuce.core.api.sync.RedisHashCommands; +import io.lettuce.core.api.sync.RedisKeyCommands; +import io.lettuce.core.api.sync.RedisSetCommands; +import io.lettuce.core.api.sync.RedisSortedSetCommands; +import io.lettuce.core.api.sync.RedisStreamCommands; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -33,7 +40,7 @@ protected RiotGen app() { @ParameterizedTest @MethodSource("containers") - public void genFakerHash(RedisContainer container) throws Exception { + public void genFakerHash(RedisServer container) throws Exception { execute("import-hset", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("person:*"); @@ -46,7 +53,7 @@ public void genFakerHash(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void genFakerSet(RedisContainer container) throws Exception { + public void genFakerSet(RedisServer container) throws Exception { execute("import-sadd", container); RedisSetCommands sync = sync(container); Set names = sync.smembers("got:characters"); @@ -58,7 +65,7 @@ public void genFakerSet(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void genFakerZset(RedisContainer container) throws Exception { + public void genFakerZset(RedisServer container) throws Exception { execute("import-zadd", container); RedisKeyCommands sync = sync(container); List keys = sync.keys("leases:*"); @@ -69,7 +76,7 @@ public void genFakerZset(RedisContainer container) throws Exception { @ParameterizedTest @MethodSource("containers") - public void genFakerStream(RedisContainer container) throws Exception { + public void genFakerStream(RedisServer container) throws Exception { execute("import-xadd", container); RedisStreamCommands sync = sync(container); List> messages = sync.xrange("teststream:1", Range.unbounded()); diff --git a/riot-redis/src/test/java/com/redis/riot/redis/TestReplicate.java b/riot-redis/src/test/java/com/redis/riot/redis/TestReplicate.java index 6a0ca35e7..c6b593840 100644 --- a/riot-redis/src/test/java/com/redis/riot/redis/TestReplicate.java +++ b/riot-redis/src/test/java/com/redis/riot/redis/TestReplicate.java @@ -7,7 +7,7 @@ import com.redislabs.riot.redis.ReplicationMode; import com.redislabs.riot.redis.RiotRedis; import com.redislabs.testcontainers.RedisContainer; -import com.redislabs.testcontainers.RedisStandaloneContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.RedisClient; import io.lettuce.core.RedisURI; import io.lettuce.core.api.StatefulRedisConnection; @@ -32,7 +32,7 @@ public class TestReplicate extends AbstractRiotIntegrationTest { @Container - private static final RedisStandaloneContainer TARGET = new RedisStandaloneContainer(); + private static final RedisContainer TARGET = new RedisContainer(); private RedisClient targetClient; private StatefulRedisConnection targetConnection; @@ -70,7 +70,7 @@ private void configureReplicateCommand(CommandLine.ParseResult parseResult, bool @ParameterizedTest @MethodSource("containers") - void replicate(RedisContainer container) throws Throwable { + void replicate(RedisServer container) throws Throwable { dataGenerator(container).build().call(); RedisServerCommands sync = sync(container); Long sourceSize = sync.dbsize(); @@ -81,17 +81,17 @@ void replicate(RedisContainer container) throws Throwable { @ParameterizedTest @MethodSource("containers") - public void replicateLive(RedisContainer container) throws Exception { + public void replicateLive(RedisServer container) throws Exception { testLiveReplication(container, "replicate-live"); } @ParameterizedTest @MethodSource("containers") - public void replicateLiveValue(RedisContainer container) throws Exception { + public void replicateLiveValue(RedisServer container) throws Exception { testLiveReplication(container, "replicate-live-value"); } - private void testLiveReplication(RedisContainer container, String filename) throws Exception { + private void testLiveReplication(RedisServer container, String filename) throws Exception { dataGenerator(container).build().call(); execute(filename, container, r -> configureReplicateCommand(r,true)); while (targetSync.dbsize() < 100) { diff --git a/riot-stream/src/test/java/com/redislabs/riot/stream/TestKafka.java b/riot-stream/src/test/java/com/redislabs/riot/stream/TestKafka.java index a6040b1db..f6f33cb0b 100644 --- a/riot-stream/src/test/java/com/redislabs/riot/stream/TestKafka.java +++ b/riot-stream/src/test/java/com/redislabs/riot/stream/TestKafka.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableMap; import com.redislabs.riot.AbstractRiotIntegrationTest; -import com.redislabs.testcontainers.RedisContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.LettuceFutures; import io.lettuce.core.Range; import io.lettuce.core.RedisFuture; @@ -32,7 +32,12 @@ import picocli.CommandLine; import java.time.Duration; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.Future; @SuppressWarnings("unchecked") @@ -49,7 +54,7 @@ protected RiotStream app() { @ParameterizedTest @MethodSource("containers") - public void testImport(RedisContainer container) throws Exception { + public void testImport(RedisServer container) throws Exception { KafkaProducer> producer = new KafkaProducer<>(ImmutableMap.of(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, KAFKA.getBootstrapServers(), ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString()), new StringSerializer(), new JsonSerializer<>()); int count = 100; for (int index = 0; index < count; index++) { @@ -89,7 +94,7 @@ private Map map() { @ParameterizedTest @MethodSource("containers") - public void testExport(RedisContainer container) throws Exception { + public void testExport(RedisServer container) throws Exception { String stream = "stream1"; int producedCount = 100; log.debug("Producing {} stream messages", producedCount); diff --git a/test/build.gradle b/test/build.gradle index 7f55b9a5f..e9f155e7b 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -3,18 +3,26 @@ plugins { } repositories { - mavenLocal() mavenCentral() + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/redis-developer/registry") + credentials { + username = project.findProperty("github.username") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("github.token") ?: System.getenv("GITHUB_TOKEN") + } + } } dependencies { implementation project(':riot-core') implementation 'org.codehaus.plexus:plexus-utils:3.3.0' - implementation 'org.junit.jupiter:junit-jupiter-api' - implementation 'org.junit.jupiter:junit-jupiter-params' - implementation 'org.junit.jupiter:junit-jupiter-engine' + api 'org.junit.jupiter:junit-jupiter-api' + api 'org.junit.jupiter:junit-jupiter-params' + api 'org.junit.jupiter:junit-jupiter-engine' implementation group: 'info.picocli', name: 'picocli', version: picocliVersion annotationProcessor group: 'info.picocli', name: 'picocli-codegen', version: picocliVersion - api 'com.redislabs:testcontainers-redis:1.1.3' + api 'com.redislabs:testcontainers-redis:1.1.6' + api 'org.testcontainers:junit-jupiter:1.15.3' implementation 'commons-io:commons-io:2.8.0' -} \ No newline at end of file +} diff --git a/test/src/main/java/com/redislabs/riot/AbstractRiotIntegrationTest.java b/test/src/main/java/com/redislabs/riot/AbstractRiotIntegrationTest.java index 216c566ca..bf42f6f78 100644 --- a/test/src/main/java/com/redislabs/riot/AbstractRiotIntegrationTest.java +++ b/test/src/main/java/com/redislabs/riot/AbstractRiotIntegrationTest.java @@ -2,7 +2,7 @@ import com.redislabs.testcontainers.RedisClusterContainer; import com.redislabs.testcontainers.RedisContainer; -import com.redislabs.testcontainers.RedisStandaloneContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.AbstractRedisClient; import io.lettuce.core.RedisClient; import io.lettuce.core.api.StatefulConnection; @@ -31,16 +31,16 @@ public abstract class AbstractRiotIntegrationTest extends AbstractRiotTest { @Container - private static final RedisStandaloneContainer REDIS = new RedisStandaloneContainer().withKeyspaceNotifications(); + private static final RedisContainer REDIS = new RedisContainer().withKeyspaceNotifications(); @Container private static final RedisClusterContainer REDIS_CLUSTER = new RedisClusterContainer().withKeyspaceNotifications(); - protected static final Map CLIENTS = new HashMap<>(); - protected static final Map>> POOLS = new HashMap<>(); - protected static final Map> CONNECTIONS = new HashMap<>(); - protected static final Map> PUBSUB_CONNECTIONS = new HashMap<>(); - protected static final Map> ASYNCS = new HashMap<>(); - protected static final Map> SYNCS = new HashMap<>(); + protected static final Map CLIENTS = new HashMap<>(); + protected static final Map>> POOLS = new HashMap<>(); + protected static final Map> CONNECTIONS = new HashMap<>(); + protected static final Map> PUBSUB_CONNECTIONS = new HashMap<>(); + protected static final Map> ASYNCS = new HashMap<>(); + protected static final Map> SYNCS = new HashMap<>(); @BeforeAll public static void setup() { @@ -48,7 +48,7 @@ public static void setup() { add(REDIS_CLUSTER); } - private static void add(RedisContainer container) { + private static void add(RedisServer container) { if (container instanceof RedisClusterContainer) { RedisClusterClient client = RedisClusterClient.create(container.getRedisURI()); CLIENTS.put(container, client); @@ -91,7 +91,7 @@ public static void teardown() { CLIENTS.clear(); } - static Stream containers() { + static Stream containers() { return Stream.of(REDIS, REDIS_CLUSTER); } @@ -99,23 +99,23 @@ static Stream standaloneContainer() { return Stream.of(REDIS); } - protected static T sync(RedisContainer container) { + protected static T sync(RedisServer container) { return (T) SYNCS.get(container); } - protected static T async(RedisContainer container) { + protected static T async(RedisServer container) { return (T) ASYNCS.get(container); } - protected static > C connection(RedisContainer container) { + protected static > C connection(RedisServer container) { return (C) CONNECTIONS.get(container); } - protected static > GenericObjectPool pool(RedisContainer container) { + protected static > GenericObjectPool pool(RedisServer container) { return (GenericObjectPool) POOLS.get(container); } - protected DataGenerator.DataGeneratorBuilder dataGenerator(RedisContainer container) { + protected DataGenerator.DataGeneratorBuilder dataGenerator(RedisServer container) { return DataGenerator.builder(connection(container)); } diff --git a/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java b/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java index 493fb409a..04d3979d0 100644 --- a/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java +++ b/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java @@ -2,6 +2,7 @@ import com.redislabs.testcontainers.RedisClusterContainer; import com.redislabs.testcontainers.RedisContainer; +import com.redislabs.testcontainers.RedisServer; import io.lettuce.core.RedisURI; import org.apache.commons.io.IOUtils; import org.codehaus.plexus.util.cli.CommandLineUtils; @@ -27,7 +28,7 @@ protected String[] args(String filename) throws Exception { } } - protected int execute(String filename, RedisContainer container, Consumer... configurators) throws Exception { + protected int execute(String filename, RedisServer container, Consumer... configurators) throws Exception { RiotApp app = app(); RiotCommandLine commandLine = app.commandLine(); CommandLine.ParseResult parseResult = commandLine.parseArgs(args(filename)); @@ -38,7 +39,7 @@ protected int execute(String filename, RedisContainer container, Consumer