Skip to content

Commit

Permalink
added redis connection option to all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jruaux committed Apr 8, 2020
1 parent 2de37e4 commit d7ab9d7
Show file tree
Hide file tree
Showing 29 changed files with 33 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ bin/
/.gradle/
*.log
/.externalToolBuilders/
.idea
2 changes: 1 addition & 1 deletion src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,6 @@ image::images/rs-strings.png[]
==== Streams
[source,shell]
----
$ riot -s redis-12001.internal.jrx.demo.redislabs.com:12001 --max-total 96 gen --batch 5000 --threads 96 --max 100000000 --command xadd --keyspace stream --keys partition
$ riot -s redis-12001.internal.jrx.demo.redislabs.com:12001 --pool-max-total 96 gen --batch 5000 --threads 96 --max 100000000 --command xadd --keyspace stream --keys partition
----
image::images/rs-streams.png[]
9 changes: 2 additions & 7 deletions src/test/java/com/redislabs/riot/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class BaseTest {

private final static String COMMAND_PREAMBLE = "$ riot ";

private final static int REDIS_PORT = 16379;
private final static int REDIS_PORT = 6379;
private final static String REDIS_HOST = "localhost";

private static RedisServer server;
Expand Down Expand Up @@ -71,15 +71,10 @@ public static void teardown() {

protected int runFile(String filename, Object... args) throws Exception {
try (InputStream inputStream = BaseTest.class.getResourceAsStream("/commands/" + filename + ".txt")) {
return runCommandWithServer(IOUtils.toString(inputStream, Charset.defaultCharset()), args);
return runCommand(removePreamble(IOUtils.toString(inputStream, Charset.defaultCharset())), args);
}
}

protected int runCommandWithServer(String command, Object... args) throws Exception {
String server = REDIS_HOST + ":" + REDIS_PORT;
return runCommand("-s" + " " + server + " " + removePreamble(command), args);
}

protected int runCommand(String command, Object... args) throws Exception {
return new Riot().execute(CommandLineUtils.translateCommandline(String.format(command, args)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/redislabs/riot/TestFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testExportCsv() throws UnexpectedInputException, ParseException, Exc
runFile("import-json-hash");
runFile("export-csv");
String[] header = Files.readAllLines(file.toPath()).get(0).split("\\|");
FlatFileItemReaderBuilder<Map<String, Object>> builder = new FlatFileItemReaderBuilder<Map<String, Object>>();
FlatFileItemReaderBuilder<Map<String, Object>> builder = new FlatFileItemReaderBuilder<>();
builder.name("flat-file-reader");
builder.resource(new FileSystemResource(file));
builder.strict(true);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/redislabs/riot/TestReplicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
public class TestReplicate extends BaseTest {

private final static String TARGET_HOST = "localhost";
private final static int TARGET_PORT = 16380;
private final static int TARGET_PORT = 6380;

@Test
public void testReplicate() throws Exception {
RedisServer target = serverBuilder(TARGET_PORT).build();
try {
target.start();
runCommandWithServer("gen -d field1=100 field2=1000 --max 1000 --keyspace test --keys index");
runCommand(" -s localhost:6379 gen -d field1=100 field2=1000 --max 1000 --keyspace test --keys index");
Long sourceSize = commands().dbsize();
Assertions.assertTrue(sourceSize > 0);
runFile("replicate");
Expand All @@ -39,7 +39,7 @@ public void testReplicateLive() throws Exception {
RedisServer target = serverBuilder(TARGET_PORT).build();
try {
target.start();
runCommandWithServer("gen -d field1=100 field2=1000 --max 1000 --keyspace test --keys index");
runCommand(" -s localhost:6379 gen -d field1=100 field2=1000 --max 1000 --keyspace test --keys index");
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
final AtomicInteger index = new AtomicInteger();
scheduler.scheduleWithFixedDelay(() -> {
Expand All @@ -60,7 +60,7 @@ public void testReplicateLive() throws Exception {
System.out.println("Made " + index.get() + " updates");
replicateThread.interrupt();
Thread.sleep(3000);
RedisClient targetClient = RedisClient.create(RedisURI.create("localhost", 16380));
RedisClient targetClient = RedisClient.create(RedisURI.create(TARGET_HOST, TARGET_PORT));
Long sourceSize = commands().dbsize();
Assertions.assertTrue(sourceSize > 0);
Long targetSize = targetClient.connect().sync().dbsize();
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/commands/export-csv.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot export --file /tmp/beers.csv --match beer:* --key-regex "beer:(?<id>.*)" --fields id name brewery_id abv --header --delimiter '|'
$ riot -s localhost:6379 export --file /tmp/beers.csv --match beer:* --key-regex "beer:(?<id>.*)" --fields id name brewery_id abv --header --delimiter '|'
2 changes: 1 addition & 1 deletion src/test/resources/commands/export-db.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot export --match "beer:*" --key-regex "beer:(?<id>.*)" --db-url jdbc:hsqldb:mem:mymemdb --sql "INSERT INTO beers (id, name) VALUES (:id, :name)"
$ riot -s localhost:6379 export --match "beer:*" --key-regex "beer:(?<id>.*)" --db-url jdbc:hsqldb:mem:mymemdb --sql "INSERT INTO beers (id, name) VALUES (:id, :name)"
2 changes: 1 addition & 1 deletion src/test/resources/commands/export-json.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot export --file /tmp/beers.json --match beer:* --key-regex "beer:(?<id>.*)" --fields id name brewery_id abv
$ riot -s localhost:6379 export --file /tmp/beers.json --match beer:* --key-regex "beer:(?<id>.*)" --fields id name brewery_id abv
2 changes: 1 addition & 1 deletion src/test/resources/commands/export-json_gz.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot export --file /tmp/beers.json.gz --match beer:* --fields id name brewery_id abv
$ riot -s localhost:6379 export --file /tmp/beers.json.gz --match beer:* --fields id name brewery_id abv
2 changes: 1 addition & 1 deletion src/test/resources/commands/gen-faker-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --faker id=index firstName=name.firstName lastName=name.lastName address=address.fullAddress --max 100 --keyspace person --keys id
$ riot -s localhost:6379 gen --faker id=index firstName=name.firstName lastName=name.lastName address=address.fullAddress --max 100 --keyspace person --keys id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --faker-index beerIntrospection --max 100 --command ftadd --index beerIntrospection --keys id
$ riot -s localhost:6379 gen --faker-index beerIntrospection --max 100 --command ftadd --index beerIntrospection --keys id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --faker id=index firstName=name.firstName lastName=name.lastName address=address.fullAddress --script "function process(item) { item.address = item.address.toUpperCase(); return item; } process(item);" --max 100 --keyspace person --keys id
$ riot -s localhost:6379 gen --faker id=index firstName=name.firstName lastName=name.lastName address=address.fullAddress --script "function process(item) { item.address = item.address.toUpperCase(); return item; } process(item);" --max 100 --keyspace person --keys id
2 changes: 1 addition & 1 deletion src/test/resources/commands/gen-faker-set.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --faker name=gameOfThrones.character --max 10000 --command sadd --members name --keyspace got:characters
$ riot -s localhost:6379 gen --faker name=gameOfThrones.character --max 10000 --command sadd --members name --keyspace got:characters
2 changes: 1 addition & 1 deletion src/test/resources/commands/gen-faker-stream.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --faker id=index category=number.randomDigit --batch 50 --max 1000 --command xadd --keyspace teststream --keys category
$ riot -s localhost:6379 gen --faker id=index category=number.randomDigit --batch 50 --max 1000 --command xadd --keyspace teststream --keys category
2 changes: 1 addition & 1 deletion src/test/resources/commands/gen-faker-zset.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --faker ip=number.digits(4) lease=number.digits(2) time=number.digits(5) --batch 50 --max 10000 --command zadd --keyspace leases --keys ip --members lease --score=time
$ riot -s localhost:6379 gen --faker ip=number.digits(4) lease=number.digits(2) time=number.digits(5) --batch 50 --max 10000 --command zadd --keyspace leases --keys ip --members lease --score=time
2 changes: 1 addition & 1 deletion src/test/resources/commands/gen-simple-reactive.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot --api reactive gen -d field1=100 field2=1000 --batch 100 --threads 3 --max 10000 --keyspace test --keys index
$ riot -s localhost:6379 --api reactive gen -d field1=100 field2=1000 --batch 100 --threads 3 --max 10000 --keyspace test --keys index
2 changes: 1 addition & 1 deletion src/test/resources/commands/gen-simple.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot gen --metadata -d field1=100 field2=1000 --batch 100 --threads 3 --max 10000 --keyspace test --keys index
$ riot -s localhost:6379 gen --metadata -d field1=100 field2=1000 --batch 100 --threads 3 --max 10000 --keyspace test --keys index
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-csv-geo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --fields AirportID Name City Country IATA ICAO Latitude Longitude Altitude Timezone DST Tz Type Source --command geoadd --keyspace airportgeo --members AirportID --lon Longitude --lat Latitude
$ riot -s localhost:6379 import --url https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --fields AirportID Name City Country IATA ICAO Latitude Longitude Altitude Timezone DST Tz Type Source --command geoadd --keyspace airportgeo --members AirportID --lon Longitude --lat Latitude
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-csv-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url https://git.io/fjxPs --header --keyspace beer --keys id
$ riot -s localhost:6379 import --url https://git.io/fjxPs --header --keyspace beer --keys id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url "https://data.lacity.org/api/views/rx9t-fp7k/rows.csv?accessType=DOWNLOAD" --header --date-format "MM/dd/yyyy HH:mm:ss a" --spel "EventStartDate=remove('Event Start Date')" "EpochStart=#date.parse(EventStartDate).getTime()" "index=#context.index()" --keyspace event --keys Id
$ riot -s localhost:6379 import --url "https://data.lacity.org/api/views/rx9t-fp7k/rows.csv?accessType=DOWNLOAD" --header --date-format "MM/dd/yyyy HH:mm:ss a" --spel "EventStartDate=remove('Event Start Date')" "EpochStart=#date.parse(EventStartDate).getTime()" "index=#context.index()" --keyspace event --keys Id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --fields AirportID Name City Country IATA ICAO Latitude Longitude Altitude Timezone DST Tz Type Source --spel "Location=#geo(Longitude,Latitude)" --command ftadd --index airports -k AirportID
$ riot -s localhost:6379 import --url https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --fields AirportID Name City Country IATA ICAO Latitude Longitude Altitude Timezone DST Tz Type Source --spel "Location=#geo(Longitude,Latitude)" --command ftadd --index airports -k AirportID
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url "https://data.lacity.org/api/views/rx9t-fp7k/rows.csv?accessType=DOWNLOAD" --header --regex 'Event Location'="\((?<lat>.+),\s+(?<lon>.+)\)" --spel location=#geo(lon,lat) --command ftadd --index laevents --keys Id
$ riot -s localhost:6379 import --url "https://data.lacity.org/api/views/rx9t-fp7k/rows.csv?accessType=DOWNLOAD" --header --regex 'Event Location'="\((?<lat>.+),\s+(?<lon>.+)\)" --spel location=#geo(lon,lat) --command ftadd --index laevents --keys Id
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-csv-search.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url https://git.io/fjxPs --header --command ftadd --index beers --keys id
$ riot -s localhost:6379 import --url https://git.io/fjxPs --header --command ftadd --index beers --keys id
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-db.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --db-url jdbc:hsqldb:mem:mymemdb --sql "SELECT * FROM beers" --keyspace dbbeer --keys id
$ riot -s localhost:6379 import --db-url jdbc:hsqldb:mem:mymemdb --sql "SELECT * FROM beers" --keyspace dbbeer --keys id
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-elastic-json.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --file %s --keyspace estest --keys _id
$ riot -s localhost:6379 import --file %s --keyspace estest --keys _id
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-json-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url https://git.io/fjxPZ --filetype json --keyspace beer --keys id
$ riot -s localhost:6379 import --url https://git.io/fjxPZ --filetype json --keyspace beer --keys id
2 changes: 1 addition & 1 deletion src/test/resources/commands/import-xml-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot import --url https://raw.githubusercontent.com/Redislabs-Solution-Architects/riot/master/src/test/resources/releases.xml --keyspace release --keys id
$ riot -s localhost:6379 import --url https://raw.githubusercontent.com/Redislabs-Solution-Architects/riot/master/src/test/resources/releases.xml --keyspace release --keys id
2 changes: 1 addition & 1 deletion src/test/resources/commands/replicate-live.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot -s localhost:16379 replicate -s localhost:16380 --listen
$ riot -s localhost:6379 replicate -s localhost:6380 --listen
2 changes: 1 addition & 1 deletion src/test/resources/commands/replicate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$ riot -s localhost:16379 replicate -s localhost:16380 --batch 1
$ riot -s localhost:6379 replicate -s localhost:6380 --batch 1

0 comments on commit d7ab9d7

Please sign in to comment.