Search in sources :

Example 1 with MockTenantProvider

use of com.yahoo.vespa.config.server.tenant.MockTenantProvider in project vespa by vespa-engine.

the class GetConfigProcessorTest method testSentinelConfig.

@Test
public void testSentinelConfig() {
    MockRpc rpc = new MockRpc(13337, false);
    // should be a sentinel config, but it does not matter for this test
    rpc.response = new MockConfigResponse("foo");
    // one tenant, which has host1 assigned
    boolean pretentToHaveLoadedApplications = true;
    TenantName testTenant = TenantName.from("test");
    rpc.onTenantCreate(testTenant, new MockTenantProvider(pretentToHaveLoadedApplications));
    rpc.hostsUpdated(testTenant, Collections.singleton("host1"));
    {
        // a config is returned normally
        JRTServerConfigRequest req = createV3SentinelRequest("host1");
        GetConfigProcessor proc = new GetConfigProcessor(rpc, req, false);
        proc.run();
        assertTrue(rpc.tryResolveConfig);
        assertTrue(rpc.tryRespond);
        assertThat(rpc.errorCode, is(0));
    }
    rpc.resetChecks();
    // host1 is replaced by host2 for this tenant
    rpc.hostsUpdated(testTenant, Collections.singleton("host2"));
    {
        // this causes us to get an empty config instead of normal config resolution
        JRTServerConfigRequest req = createV3SentinelRequest("host1");
        GetConfigProcessor proc = new GetConfigProcessor(rpc, req, false);
        proc.run();
        // <-- no normal config resolution happening
        assertFalse(rpc.tryResolveConfig);
        assertTrue(rpc.tryRespond);
        assertThat(rpc.errorCode, is(0));
    }
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) GetConfigProcessor(com.yahoo.vespa.config.server.rpc.GetConfigProcessor) MockRpc(com.yahoo.vespa.config.server.rpc.MockRpc) TenantName(com.yahoo.config.provision.TenantName) MockTenantProvider(com.yahoo.vespa.config.server.tenant.MockTenantProvider) Test(org.junit.Test)

Example 2 with MockTenantProvider

use of com.yahoo.vespa.config.server.tenant.MockTenantProvider in project vespa by vespa-engine.

the class TestWithRpc method setupRpc.

@Before
public void setupRpc() throws InterruptedException {
    allocatedPorts = new ArrayList<>();
    port = allocatePort();
    spec = createSpec(port);
    tenantProvider = new MockTenantProvider();
    generationCounter = new MemoryGenerationCounter();
    createAndStartRpcServer(false);
    assertFalse(hostLivenessTracker.lastRequestFrom(myHostname).isPresent());
}
Also used : MockTenantProvider(com.yahoo.vespa.config.server.tenant.MockTenantProvider) Before(org.junit.Before)

Aggregations

MockTenantProvider (com.yahoo.vespa.config.server.tenant.MockTenantProvider)2 TenantName (com.yahoo.config.provision.TenantName)1 JRTServerConfigRequest (com.yahoo.vespa.config.protocol.JRTServerConfigRequest)1 GetConfigProcessor (com.yahoo.vespa.config.server.rpc.GetConfigProcessor)1 MockRpc (com.yahoo.vespa.config.server.rpc.MockRpc)1 Before (org.junit.Before)1 Test (org.junit.Test)1