Search in sources :

Example 6 with InMemoryDiscoveryClient

use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.

the class TestCachingServiceSelector method testBasics.

@Test
public void testBasics() {
    CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor);
    assertEquals(serviceSelector.getType(), "type");
    assertEquals(serviceSelector.getPool(), "pool");
}
Also used : InMemoryDiscoveryClient(io.airlift.discovery.client.testing.InMemoryDiscoveryClient) Test(org.testng.annotations.Test)

Example 7 with InMemoryDiscoveryClient

use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.

the class TestAnnouncer method setUp.

@BeforeMethod
protected void setUp() throws Exception {
    nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setPool("pool"));
    discoveryClient = new InMemoryDiscoveryClient(nodeInfo, MAX_AGE);
    serviceAnnouncement = ServiceAnnouncement.serviceAnnouncement(serviceType.value()).addProperty("a", "apple").build();
    announcer = new Announcer(discoveryClient, ImmutableSet.of(serviceAnnouncement));
}
Also used : NodeInfo(io.airlift.node.NodeInfo) InMemoryDiscoveryClient(io.airlift.discovery.client.testing.InMemoryDiscoveryClient) NodeConfig(io.airlift.node.NodeConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with InMemoryDiscoveryClient

use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.

the class TestCachingServiceSelector method testStartedEmpty.

@Test
public void testStartedEmpty() throws Exception {
    CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor);
    serviceSelector.start();
    assertEquals(serviceSelector.selectAllServices(), ImmutableList.of());
}
Also used : InMemoryDiscoveryClient(io.airlift.discovery.client.testing.InMemoryDiscoveryClient) Test(org.testng.annotations.Test)

Example 9 with InMemoryDiscoveryClient

use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.

the class TestCachingServiceSelector method testNotStartedWithServices.

@Test
public void testNotStartedWithServices() {
    InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo);
    discoveryClient.addDiscoveredService(APPLE_1_SERVICE);
    discoveryClient.addDiscoveredService(APPLE_2_SERVICE);
    discoveryClient.addDiscoveredService(DIFFERENT_TYPE);
    discoveryClient.addDiscoveredService(DIFFERENT_POOL);
    CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor);
    assertEquals(serviceSelector.selectAllServices(), ImmutableList.of());
}
Also used : InMemoryDiscoveryClient(io.airlift.discovery.client.testing.InMemoryDiscoveryClient) Test(org.testng.annotations.Test)

Example 10 with InMemoryDiscoveryClient

use of io.airlift.discovery.client.testing.InMemoryDiscoveryClient in project airlift by airlift.

the class TestCachingServiceSelector method testStartedWithServices.

@Test
public void testStartedWithServices() throws Exception {
    InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo);
    discoveryClient.addDiscoveredService(APPLE_1_SERVICE);
    discoveryClient.addDiscoveredService(APPLE_2_SERVICE);
    discoveryClient.addDiscoveredService(DIFFERENT_TYPE);
    discoveryClient.addDiscoveredService(DIFFERENT_POOL);
    CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor);
    serviceSelector.start();
    Thread.sleep(100);
    assertEqualsIgnoreOrder(serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE));
}
Also used : InMemoryDiscoveryClient(io.airlift.discovery.client.testing.InMemoryDiscoveryClient) Test(org.testng.annotations.Test)

Aggregations

InMemoryDiscoveryClient (io.airlift.discovery.client.testing.InMemoryDiscoveryClient)12 Test (org.testng.annotations.Test)11 Injector (com.google.inject.Injector)6 ConfigurationFactory (io.airlift.configuration.ConfigurationFactory)6 ConfigurationModule (io.airlift.configuration.ConfigurationModule)6 TestingDiscoveryModule (io.airlift.discovery.client.testing.TestingDiscoveryModule)6 TestingNodeModule (io.airlift.node.testing.TestingNodeModule)6 NodeConfig (io.airlift.node.NodeConfig)1 NodeInfo (io.airlift.node.NodeInfo)1 BeforeMethod (org.testng.annotations.BeforeMethod)1