<commit_before>
package com.lambdaworks.redis;

import static com.google.code.tempusfugit.temporal.Duration.*;
import static com.google.code.tempusfugit.temporal.Timeout.*;
import static org.assertj.core.api.Assertions.*;

import java.util.concurrent.TimeUnit;

import org.junit.*;

import com.google.code.tempusfugit.temporal.Condition;
import com.google.code.tempusfugit.temporal.WaitFor;

public class SentinelFailoverTest extends AbstractCommandTest {

    public static final String MASTER_WITH_SLAVE_ID = "master_with_slave";

    private static RedisClient sentinelClient;
    private RedisSentinelAsyncConnection<String, String> sentinel;

    @Rule
    public SentinelRule sentinelRule = new SentinelRule(sentinelClient, 26379, 26380);

    @BeforeClass
    public static void setupClient() {
        sentinelClient = getRedisSentinelClient();
    }

    @AfterClass
    public static void shutdownClient() {
        sentinelClient.shutdown(0, 0, TimeUnit.MILLISECONDS);
    }

    @Before
    public void openConnection() throws Exception {
        sentinel = sentinelClient.connectSentinelAsync();

        int masterPort = sentinelRule.findMaster(6484, 6485);
        sentinelRule.monitor(MASTER_WITH_SLAVE_ID, "127.0.0.1", masterPort, 1);

    }

    @After
    public void closeConnection() throws Exception {
        sentinel.close();
    }

    @Test
    public void connectToRedisUsingSentinel() throws Exception {

        WaitFor.waitOrTimeout(new Condition() {
            @Override
            public boolean isSatisfied() {
                return sentinelRule.hasConnectedSlaves(MASTER_WITH_SLAVE_ID);
            }
        }, timeout(seconds(20)));

        RedisConnection<String, String> connect = sentinelClient.connect();
        connect.ping();

        RedisFuture<String> future = this.sentinel.failover(MASTER_WITH_SLAVE_ID);

        future.get();
        assertThat(future.getError()).isNull();
        assertThat(future.get()).isEqualTo("OK");
    }

    protected static RedisClient getRedisSentinelClient() {
        return new RedisClient(RedisURI.Builder.sentinel(host, 26380, MASTER_WITH_SLAVE_ID).build());
    }
}<commit_msg>Stabilizing of tests<commit_after>package com.lambdaworks.redis;

import static com.google.code.tempusfugit.temporal.Duration.*;
import static com.google.code.tempusfugit.temporal.Timeout.*;
import static org.assertj.core.api.Assertions.*;

import java.util.concurrent.TimeUnit;

import org.junit.*;

import com.google.code.tempusfugit.temporal.Condition;
import com.google.code.tempusfugit.temporal.WaitFor;

public class SentinelFailoverTest extends AbstractCommandTest {

    public static final String MASTER_WITH_SLAVE_ID = "master_with_slave";

    private static RedisClient sentinelClient;
    private RedisSentinelAsyncConnection<String, String> sentinel;

    @Rule
    public SentinelRule sentinelRule = new SentinelRule(sentinelClient, 26379, 26380);

    @BeforeClass
    public static void setupClient() {
        sentinelClient = getRedisSentinelClient();
    }

    @AfterClass
    public static void shutdownClient() {
        sentinelClient.shutdown(0, 0, TimeUnit.MILLISECONDS);
    }

    @Before
    public void openConnection() throws Exception {
        sentinel = sentinelClient.connectSentinelAsync();

        int masterPort = sentinelRule.findMaster(6484, 6485);
        sentinelRule.monitor(MASTER_WITH_SLAVE_ID, "127.0.0.1", masterPort, 1);

    }

    @After
    public void closeConnection() throws Exception {
        sentinel.close();
    }

    @Test
    public void connectToRedisUsingSentinel() throws Exception {

        WaitFor.waitOrTimeout(new Condition() {
            @Override
            public boolean isSatisfied() {
                return sentinelRule.hasConnectedSlaves(MASTER_WITH_SLAVE_ID);
            }
        }, timeout(seconds(20)));

        RedisConnection<String, String> connect = sentinelClient.connect();
        assertThat(connect.ping()).isEqualToIgnoringCase("PONG");

        connect.close();
        this.sentinel.failover(MASTER_WITH_SLAVE_ID).get();

        RedisConnection<String, String> connect2 = sentinelClient.connect();
        assertThat(connect2.ping()).isEqualToIgnoringCase("PONG");
        connect2.close();
    }

    protected static RedisClient getRedisSentinelClient() {
        return new RedisClient(RedisURI.Builder.sentinel(host, 26380, MASTER_WITH_SLAVE_ID).build());
    }
}
{'fraction_non_alphanumeric': 0.09792418772563177, 'fraction_numerical': 0.01601985559566787, 'mean_word_length': 3.5420081967213113, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5526014', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1287, 'n_words': 243}