Skip to content

Commit

Permalink
deps: Upgraded spring-batch-redis
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Ruaux committed Jul 31, 2022
1 parent 6143c68 commit 7d6c538
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void clearTables() throws SQLException {

@ParameterizedTest
@RedisTestContextsSource
void testExport(RedisTestContext redis) throws Exception {
void export(RedisTestContext redis) throws Exception {
try (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)");
Expand All @@ -96,18 +96,18 @@ void testExport(RedisTestContext redis) throws Exception {

@ParameterizedTest
@RedisTestContextsSource
void testExportNullValues(RedisTestContext redis) throws Exception {
void nullValueExport(RedisTestContext redis) throws Exception {
try (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)");
RedisModulesCommands<String, String> sync = redis.sync();
Map<String, String> hash1 = new HashMap<>();
hash1.put("field1", "value1");
hash1.put("field2", "value2");
sync.hmset("gen:hash:1", hash1);
sync.hmset("gen:1", hash1);
Map<String, String> hash2 = new HashMap<>();
hash2.put("field2", "value2");
sync.hmset("gen:hash:2", hash2);
sync.hmset("gen:2", hash2);
execute("export-postgresql", redis, r -> configureExportCommand(r, POSTGRESQL));
statement.execute("SELECT COUNT(*) AS count FROM mytable");
ResultSet countResultSet = statement.getResultSet();
Expand All @@ -126,7 +126,7 @@ void testExportNullValues(RedisTestContext redis) throws Exception {

@ParameterizedTest
@RedisTestContextsSource
void testImport(RedisTestContext redis) throws Exception {
void hashImport(RedisTestContext redis) throws Exception {
execute("import-postgresql", redis, r -> configureImportCommand(r, POSTGRESQL));
try (Statement statement = connection.createStatement()) {
statement.execute("SELECT COUNT(*) AS count FROM orders");
Expand All @@ -143,14 +143,14 @@ void testImport(RedisTestContext redis) throws Exception {

@ParameterizedTest
@RedisTestContextsSource
void testImportNoop(RedisTestContext redis) throws Exception {
void noopImport(RedisTestContext redis) throws Exception {
execute("import-postgresql-noop", redis, r -> configureImportCommand(r, POSTGRESQL));
Assertions.assertEquals(0, redis.sync().dbsize());
}

@ParameterizedTest
@RedisTestContextsSource
void testMultiThreadedImport(RedisTestContext redis) throws Exception {
void multiThreadedImport(RedisTestContext redis) throws Exception {
execute("import-postgresql-multithreaded", redis, r -> configureImportCommand(r, POSTGRESQL));
try (Statement statement = connection.createStatement()) {
statement.execute("SELECT COUNT(*) AS count FROM orders");
Expand All @@ -167,7 +167,7 @@ void testMultiThreadedImport(RedisTestContext redis) throws Exception {

@ParameterizedTest
@RedisTestContextsSource
void testImportSet(RedisTestContext redis) throws Exception {
void setImport(RedisTestContext redis) throws Exception {
execute("import-postgresql-set", redis, r -> configureImportCommand(r, POSTGRESQL));
try (Statement statement = connection.createStatement()) {
statement.execute("SELECT * FROM orders");
Expand Down
2 changes: 1 addition & 1 deletion connectors/riot-db/src/test/resources/export-postgresql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
riot-db export "INSERT INTO mytable (id, field1, field2) VALUES (CAST(:id AS SMALLINT), :field1, :field2)" --url "jdbc:postgresql://host:port/database" --username appuser --password passwd --scan-match "gen:hash:*" --key-regex "gen:hash:(?<id>.*)"
riot-db export "INSERT INTO mytable (id, field1, field2) VALUES (CAST(:id AS SMALLINT), :field1, :field2)" --url "jdbc:postgresql://host:port/database" --username appuser --password passwd --scan-match "gen:*" --key-regex "gen:(?<id>.*)"
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ protected Job job(JobBuilder jobBuilder) throws Exception {

private ItemReader<DataStructure<String>> reader() {
DataStructureGeneratorItemReader.Builder reader = DataStructureGeneratorItemReader.builder()
.start(options.getStart()).count(options.getCount()).streamSize(options.getStreamSize())
.streamFieldCount(options.getStreamFieldCount()).streamFieldSize(options.getStreamFieldSize())
.listSize(options.getListSize()).setSize(options.getSetSize()).zsetSize(options.getZsetSize())
.currentItemCount(options.getStart() - 1).maxItemCount(options.getCount())
.streamSize(options.getStreamSize()).streamFieldCount(options.getStreamFieldCount())
.streamFieldSize(options.getStreamFieldSize()).listSize(options.getListSize())
.setSize(options.getSetSize()).zsetSize(options.getZsetSize())
.timeseriesSize(options.getTimeseriesSize()).keyspace(options.getKeyspace())
.stringSize(options.getStringSize()).types(options.getTypes().toArray(Type[]::new))
.zsetScore(options.getZsetScore()).hashSize(options.getHashSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void replicateHyperLogLog(RedisTestContext redis) throws Throwable {
@ParameterizedTest
@RedisTestContextsSource
void replicateKeyProcessor(RedisTestContext redis) throws Throwable {
generate(DataStructureGeneratorItemReader.builder().count(200).build(), redis);
generate(DataStructureGeneratorItemReader.builder().maxItemCount(200).build(), redis);
Long sourceSize = redis.sync().dbsize();
Assertions.assertTrue(sourceSize > 0);
execute("replicate-key-processor", redis, this::configureReplicateCommand);
Expand Down Expand Up @@ -116,11 +116,13 @@ void replicateDSLive(RedisTestContext container) throws Exception {

private void runLiveReplication(String filename, RedisTestContext source) throws Exception {
source.sync().configSet("notify-keyspace-events", "AK");
generate(DataStructureGeneratorItemReader.builder().count(3000).build(), source);
generate(DataStructureGeneratorItemReader.builder().maxItemCount(3000).build(), source);
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
executor.schedule(() -> {
try {
generate(1, DataStructureGeneratorItemReader.builder().start(3000).count(2000).build(), source);
generate(1,
DataStructureGeneratorItemReader.builder().currentItemCount(3000).maxItemCount(2000).build(),
source);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ kordampBuildVersion=2.6.0
avroVersion=1.11.0
awaitilityVersion=4.2.0
awsVersion=2.2.6.RELEASE
batchRedisVersion=2.32.1
batchRedisVersion=2.32.2
commonsIoVersion=2.11.0
db2Version=11.5.7.0
fakerVersion=1.0.2
Expand Down

0 comments on commit 7d6c538

Please sign in to comment.