Search in sources :

Example 1 with RedisServer

use of ai.grakn.redismock.RedisServer in project grakn by graknlabs.

the class RedisWrapperTest method whenBuildingNoSentinelWellFormed_Succeeds.

@Test
public void whenBuildingNoSentinelWellFormed_Succeeds() {
    RedisServer server = inMemoryRedisContext.server();
    RedisWrapper redisWrapper = RedisWrapper.builder().setUseSentinel(false).addURI(new SimpleURI(server.getHost(), server.getBindPort()).toString()).build();
    assertNotNull(redisWrapper.getJedisPool());
}
Also used : SimpleURI(ai.grakn.util.SimpleURI) RedisServer(ai.grakn.redismock.RedisServer) Test(org.junit.Test)

Example 2 with RedisServer

use of ai.grakn.redismock.RedisServer in project grakn by graknlabs.

the class GraknEngineServerTest method whenEngineServerIsStarted_SystemKeyspaceIsLoaded.

@Test
public void whenEngineServerIsStarted_SystemKeyspaceIsLoaded() throws IOException {
    SimpleURI uri = new SimpleURI(Iterables.getOnlyElement(config.getProperty(GraknConfigKey.REDIS_HOST)));
    RedisServer redisServer = RedisServer.newRedisServer(uri.getPort());
    redisServer.start();
    try {
        try (GraknEngineServer server = createGraknEngineServer(mockRedisWrapper)) {
            server.start();
            assertNotNull(graknKeyspaceStore);
            // init a random keyspace
            String keyspaceName = "thisisarandomwhalekeyspace";
            graknKeyspaceStore.addKeyspace(Keyspace.of(keyspaceName));
            assertTrue(graknKeyspaceStore.containsKeyspace(Keyspace.of(keyspaceName)));
        }
    } finally {
        redisServer.stop();
    }
}
Also used : SimpleURI(ai.grakn.util.SimpleURI) RedisServer(ai.grakn.redismock.RedisServer) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with RedisServer

use of ai.grakn.redismock.RedisServer in project grakn by graknlabs.

the class RedisWrapperTest method whenBuildingSentinelNoMaster_Fails.

@Test(expected = IllegalStateException.class)
public void whenBuildingSentinelNoMaster_Fails() {
    RedisServer server = inMemoryRedisContext.server();
    RedisWrapper.builder().setUseSentinel(true).addURI(new SimpleURI(server.getHost(), server.getBindPort()).toString()).build();
}
Also used : SimpleURI(ai.grakn.util.SimpleURI) RedisServer(ai.grakn.redismock.RedisServer) Test(org.junit.Test)

Example 4 with RedisServer

use of ai.grakn.redismock.RedisServer in project grakn by graknlabs.

the class RedisWrapperTest method whenBuildingSentinelWellFormed_JedisCantConnect.

@Test(expected = JedisConnectionException.class)
public void whenBuildingSentinelWellFormed_JedisCantConnect() {
    RedisServer server = inMemoryRedisContext.server();
    RedisWrapper.builder().setUseSentinel(true).addURI(new SimpleURI(server.getHost(), server.getBindPort()).toString()).setMasterName("masterName").build();
}
Also used : SimpleURI(ai.grakn.util.SimpleURI) RedisServer(ai.grakn.redismock.RedisServer) Test(org.junit.Test)

Aggregations

RedisServer (ai.grakn.redismock.RedisServer)4 SimpleURI (ai.grakn.util.SimpleURI)4 Test (org.junit.Test)4 Matchers.containsString (org.hamcrest.Matchers.containsString)1