package com.hazelcast.ringbuffer.impl;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
import com.hazelcast.test.TestHazelcastInstanceFactory;
import com.hazelcast.test.annotation.ParallelTest;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;

@RunWith(HazelcastParallelClassRunner.class)
@Category({QuickTest.class, ParallelTest.class})
public class RingbufferMigrationTest extends HazelcastTestSupport {

    public static final int CAPACITY = 100;
    private TestHazelcastInstanceFactory instanceFactory;

    @Before
    public void setup() {
        instanceFactory = createHazelcastInstanceFactory(3);
    }

    @Test
    public void test() throws Exception {
        HazelcastInstance hz1 = instanceFactory.newHazelcastInstance();

        for (int k = 0; k < 10 * CAPACITY; k++) {
            hz1.getRingbuffer("ringbuffer").add(k);
        }

        long oldTailSeq = hz1.getRingbuffer("ringbuffer").tailSequence();
        long oldHeadSeq = hz1.getRingbuffer("ringbuffer").headSequence();

        HazelcastInstance hz2 = instanceFactory.newHazelcastInstance();
        HazelcastInstance hz3 = instanceFactory.newHazelcastInstance();
        hz1.shutdown();

        sleepSeconds(5);

        assertEquals(oldTailSeq, hz2.getRingbuffer("ringbuffer").tailSequence());
        assertEquals(oldHeadSeq, hz2.getRingbuffer("ringbuffer").headSequence());
    }
}

@@ -33,16 +33,98 @@
 .impl;%0A%0A
+import com.hazelcast.config.Config;%0Aimport com.hazelcast.config.RingbufferConfig;%0A
 import c
@@ -1022,16 +1022,211 @@
 ption %7B%0A
+        final String ringbufferName = %22ringbuffer%22;%0A        final Config config = new Config()%0A                .addRingBufferConfig(new RingbufferConfig(ringbufferName).setTimeToLiveSeconds(0));%0A
         
@@ -1282,24 +1282,30 @@
 astInstance(
+config
 );%0A%0A        
@@ -1368,33 +1368,32 @@
 1.getRingbuffer(
-%22
 ringbuffer%22).add
@@ -1386,17 +1386,20 @@
 ngbuffer
-%22
+Name
 ).add(k)
@@ -1447,33 +1447,32 @@
 1.getRingbuffer(
-%22
 ringbuffer%22).tai
@@ -1457,33 +1457,36 @@
 uffer(ringbuffer
-%22
+Name
 ).tailSequence()
@@ -1523,33 +1523,32 @@
 1.getRingbuffer(
-%22
 ringbuffer%22).hea
@@ -1533,33 +1533,36 @@
 uffer(ringbuffer
-%22
+Name
 ).headSequence()
@@ -1625,32 +1625,38 @@
 zelcastInstance(
+config
 );%0A        Hazel
@@ -1707,24 +1707,76 @@
 astInstance(
+config);%0A%0A        assertClusterSizeEventually(3, hz2
 );%0A        h
@@ -1790,25 +1790,24 @@
 down();%0A
-%0A
         
 sleepSec
@@ -1802,22 +1802,42 @@
     
-sleepSeconds(5
+assertClusterSizeEventually(2, hz2
 );%0A%0A
@@ -1879,33 +1879,32 @@
 2.getRingbuffer(
-%22
 ringbuffer%22).tai
@@ -1897,17 +1897,20 @@
 ngbuffer
-%22
+Name
 ).tailSe
@@ -1971,17 +1971,16 @@
 gbuffer(
-%22
 ringbuff
@@ -1981,17 +1981,20 @@
 ngbuffer
-%22
+Name
 ).headSe

Disable TTL on ringbuffer migration test