Search in sources :

Example 76 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project redisson by redisson.

the class RedissonBatchRxTest method testBatchList.

@ParameterizedTest
@MethodSource("data")
public void testBatchList(BatchOptions batchOptions) {
    RBatchRx b = redisson.createBatch(batchOptions);
    RListRx<Integer> listAsync = b.getList("list");
    for (int i = 1; i < 540; i++) {
        listAsync.add(i);
    }
    BatchResult<?> res = sync(b.execute());
    Assertions.assertEquals(539, res.getResponses().size());
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 77 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project redisson by redisson.

the class RedissonBatchRxTest method testSyncSlaves.

@ParameterizedTest
@MethodSource("data")
public void testSyncSlaves(BatchOptions batchOptions) throws FailedToStartRedisException, IOException, InterruptedException {
    RedisRunner master1 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner master2 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner master3 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner slave1 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner slave2 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner slave3 = new RedisRunner().randomPort().randomDir().nosave();
    ClusterRunner clusterRunner = new ClusterRunner().addNode(master1, slave1).addNode(master2, slave2).addNode(master3, slave3);
    ClusterProcesses process = clusterRunner.run();
    Config config = new Config();
    config.useClusterServers().setTimeout(1000000).setRetryInterval(1000000).addNodeAddress(process.getNodes().stream().findAny().get().getRedisServerAddressAndPort());
    RedissonRxClient redisson = Redisson.create(config).rxJava();
    batchOptions.syncSlaves(1, 1, TimeUnit.SECONDS);
    RBatchRx batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 100; i++) {
        RMapRx<String, String> map = batch.getMap("test");
        map.put("" + i, "" + i);
    }
    BatchResult<?> result = sync(batch.execute());
    assertThat(result.getResponses()).hasSize(100);
    assertThat(result.getSyncedSlaves()).isEqualTo(1);
    process.shutdown();
    redisson.shutdown();
}
Also used : ClusterProcesses(org.redisson.ClusterRunner.ClusterProcesses) Config(org.redisson.config.Config) RedisRunner(org.redisson.RedisRunner) ClusterRunner(org.redisson.ClusterRunner) RBatchRx(org.redisson.api.RBatchRx) RedissonRxClient(org.redisson.api.RedissonRxClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 78 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project redisson by redisson.

the class RedissonBatchRxTest method testConvertor.

@ParameterizedTest
@MethodSource("data")
public void testConvertor(BatchOptions batchOptions) {
    RBatchRx batch = redisson.createBatch(batchOptions);
    Single<Double> f1 = batch.getScoredSortedSet("myZKey").addScore("abc", 1d);
    Completable f2 = batch.getBucket("test").set("1");
    sync(batch.execute());
    assertThat(sync(f1)).isEqualTo(1d);
    sync(f2);
    RScoredSortedSetRx<String> set = redisson.getScoredSortedSet("myZKey");
    assertThat(sync(set.getScore("abc"))).isEqualTo(1d);
    RBucketRx<String> bucket = redisson.getBucket("test");
    assertThat(sync(bucket.get())).isEqualTo("1");
    RBatchRx batch2 = redisson.createBatch(batchOptions);
    Single<Double> b2f1 = batch2.getScoredSortedSet("myZKey2").addScore("abc", 1d);
    Single<Double> b2f2 = batch2.getScoredSortedSet("myZKey2").addScore("abc", 1d);
    sync(batch2.execute());
    assertThat(sync(b2f1)).isEqualTo(1d);
    assertThat(sync(b2f2)).isEqualTo(2d);
}
Also used : Completable(io.reactivex.rxjava3.core.Completable) RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 79 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project redisson by redisson.

the class RedissonBatchRxTest method test.

@ParameterizedTest
@MethodSource("data")
public void test(BatchOptions batchOptions) {
    RBatchRx batch = redisson.createBatch(batchOptions);
    batch.getMap("test").fastPut("1", "2");
    batch.getMap("test").fastPut("2", "3");
    batch.getMap("test").put("2", "5");
    batch.getAtomicLong("counter").incrementAndGet();
    batch.getAtomicLong("counter").incrementAndGet();
    List<?> res = sync(batch.execute()).getResponses();
    Assertions.assertEquals(5, res.size());
    Assertions.assertTrue((Boolean) res.get(0));
    Assertions.assertTrue((Boolean) res.get(1));
    Assertions.assertEquals("3", res.get(2));
    Assertions.assertEquals(1L, res.get(3));
    Assertions.assertEquals(2L, res.get(4));
    Map<String, String> map = new HashMap<String, String>();
    map.put("1", "2");
    map.put("2", "5");
    assertThat(sync(redisson.getAtomicLong("counter").get())).isEqualTo(2);
    Assertions.assertTrue(sync(redisson.getMap("test").remove("2", "5")));
    Assertions.assertTrue(sync(redisson.getMap("test").remove("1", "2")));
}
Also used : HashMap(java.util.HashMap) RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 80 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project redisson by redisson.

the class RedissonBatchRxTest method testAtomicSyncSlaves.

@ParameterizedTest
@MethodSource("data")
public void testAtomicSyncSlaves(BatchOptions batchOptions) throws FailedToStartRedisException, IOException, InterruptedException {
    RedisRunner master1 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner master2 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner master3 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner slave1 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner slave2 = new RedisRunner().randomPort().randomDir().nosave();
    RedisRunner slave3 = new RedisRunner().randomPort().randomDir().nosave();
    ClusterRunner clusterRunner = new ClusterRunner().addNode(master1, slave1).addNode(master2, slave2).addNode(master3, slave3);
    ClusterProcesses process = clusterRunner.run();
    Config config = new Config();
    config.useClusterServers().setTimeout(123000).addNodeAddress(process.getNodes().stream().findAny().get().getRedisServerAddressAndPort());
    RedissonRxClient redisson = Redisson.create(config).rxJava();
    batchOptions.executionMode(ExecutionMode.IN_MEMORY_ATOMIC).syncSlaves(1, 1, TimeUnit.SECONDS);
    RBatchRx batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 10; i++) {
        batch.getAtomicLong("{test}" + i).addAndGet(i);
    }
    BatchResult<?> result = sync(batch.execute());
    assertThat(result.getSyncedSlaves()).isEqualTo(1);
    int i = 0;
    for (Object res : result.getResponses()) {
        assertThat((Long) res).isEqualTo(i++);
    }
    process.shutdown();
    redisson.shutdown();
}
Also used : ClusterProcesses(org.redisson.ClusterRunner.ClusterProcesses) Config(org.redisson.config.Config) AtomicLong(java.util.concurrent.atomic.AtomicLong) RedisRunner(org.redisson.RedisRunner) ClusterRunner(org.redisson.ClusterRunner) RBatchRx(org.redisson.api.RBatchRx) RedissonRxClient(org.redisson.api.RedissonRxClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2045 MethodSource (org.junit.jupiter.params.provider.MethodSource)1116 EnumSource (org.junit.jupiter.params.provider.EnumSource)325 ValueSource (org.junit.jupiter.params.provider.ValueSource)302 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)181 Transaction (org.neo4j.graphdb.Transaction)117 CsvSource (org.junit.jupiter.params.provider.CsvSource)113 ArrayList (java.util.ArrayList)112 ByteBuffer (java.nio.ByteBuffer)81 List (java.util.List)81 Path (java.nio.file.Path)75 Test (org.junit.jupiter.api.Test)74 InterruptAfter (io.aeron.test.InterruptAfter)72 IOException (java.io.IOException)72 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)67 TimeUnit (java.util.concurrent.TimeUnit)65 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)62 CountDownLatch (java.util.concurrent.CountDownLatch)61 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)60 Stream (java.util.stream.Stream)59