Search in sources :

Example 6 with RawConfig

use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.

the class ClientUpdaterTest method basic.

@Test
public void basic() {
    assertThat(rpcServer.responses, is(0L));
    final RawConfig fooConfig = ProxyServerTest.fooConfig;
    clientUpdater.updateSubscribers(fooConfig);
    // No delayed response, so not returned
    assertEquals(0, rpcServer.responses);
    delayedResponses.add(new DelayedResponse(JRTServerConfigRequestV3.createFromRequest(JRTConfigRequestFactory.createFromRaw(fooConfig, -10L).getRequest())));
    clientUpdater.updateSubscribers(fooConfig);
    assertEquals(1, rpcServer.responses);
    // Will not find bar config in delayed responses
    RawConfig barConfig = new RawConfig(new ConfigKey<>("bar", "id", "namespace"), fooConfig.getDefMd5());
    clientUpdater.updateSubscribers(barConfig);
    assertEquals(1, rpcServer.responses);
}
Also used : RawConfig(com.yahoo.vespa.config.RawConfig) Test(org.junit.Test)

Example 7 with RawConfig

use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.

the class JRTConfigRequestFactoryTest method testCreateFromRaw.

@Test
public void testCreateFromRaw() {
    Class<FunctionTestConfig> clazz = FunctionTestConfig.class;
    final String configId = "foo";
    RawConfig config = new RawConfig(new ConfigKey<>(clazz, configId), "595f44fec1e92a71d3e9e77456ba80d1");
    // Default vespa version
    JRTClientConfigRequest request = JRTConfigRequestFactory.createFromRaw(config, 1000);
    assertThat(request.getProtocolVersion(), is(3L));
    assertThat(request.getVespaVersion().get(), is(defaultVespaVersion));
    // Create with vespa version set
    String version = "5.37.38";
    System.setProperty(JRTConfigRequestFactory.VESPA_VERSION, version);
    request = JRTConfigRequestFactory.createFromRaw(config, 1000);
    assertThat(request.getProtocolVersion(), is(3L));
    assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
    System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
Also used : FunctionTestConfig(com.yahoo.foo.FunctionTestConfig) RawConfig(com.yahoo.vespa.config.RawConfig) Test(org.junit.Test)

Example 8 with RawConfig

use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.

the class ConfigProxyRpcServerTest method testRpcMethodListCachedConfig.

/**
 * Tests listCachedConfig RPC command
 */
@Test
public void testRpcMethodListCachedConfig() {
    Request req = new Request("listCachedConfig");
    rpcServer.listCachedConfig(req);
    assertFalse(req.errorMessage(), req.isError());
    String[] ret = req.returnValues().get(0).asStringArray();
    assertThat(req.returnValues().size(), is(1));
    assertThat(ret.length, is(0));
    final RawConfig config = ProxyServerTest.fooConfig;
    proxyServer.getMemoryCache().put(config);
    req = new Request("listCachedConfig");
    rpcServer.listCachedConfig(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(1));
    assertThat(ret[0], is(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," + config.getGeneration() + "," + config.getConfigMd5()));
}
Also used : Request(com.yahoo.jrt.Request) RawConfig(com.yahoo.vespa.config.RawConfig) Test(org.junit.Test)

Example 9 with RawConfig

use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.

the class ConfigProxyRpcServerTest method testRpcMethodListCachedConfigFull.

/**
 * Tests listCachedConfig RPC command
 */
@Test
public void testRpcMethodListCachedConfigFull() {
    Request req = new Request("listCachedConfigFull");
    rpcServer.listCachedConfigFull(req);
    assertFalse(req.errorMessage(), req.isError());
    assertThat(req.returnValues().size(), is(1));
    String[] ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(0));
    final RawConfig config = ProxyServerTest.fooConfig;
    proxyServer.getMemoryCache().put(config);
    req = new Request("listCachedConfigFull");
    rpcServer.listCachedConfigFull(req);
    assertFalse(req.errorMessage(), req.isError());
    ret = req.returnValues().get(0).asStringArray();
    assertThat(ret.length, is(1));
    assertThat(ret[0], is(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," + config.getGeneration() + "," + config.getConfigMd5() + "," + config.getPayload().getData()));
}
Also used : Request(com.yahoo.jrt.Request) RawConfig(com.yahoo.vespa.config.RawConfig) Test(org.junit.Test)

Example 10 with RawConfig

use of com.yahoo.vespa.config.RawConfig in project vespa by vespa-engine.

the class MemoryCache method dumpCacheToDisk.

String dumpCacheToDisk(String path, MemoryCache cache) {
    if (path == null || path.isEmpty()) {
        path = DEFAULT_DUMP_DIR;
        log.log(LogLevel.DEBUG, "dumpCache. No path or empty path. Using dir '" + path + "'");
    }
    if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
    }
    log.log(LogLevel.DEBUG, "Dumping cache to path '" + path + "'");
    IOUtils.createDirectory(path);
    File dir = new File(path);
    if (!dir.isDirectory() || !dir.canWrite()) {
        return "Not a dir or not able to write to '" + dir + "'";
    }
    for (RawConfig config : cache.values()) {
        writeConfigToFile(config, path);
    }
    return "success";
}
Also used : File(java.io.File) RawConfig(com.yahoo.vespa.config.RawConfig)

Aggregations

RawConfig (com.yahoo.vespa.config.RawConfig)13 Test (org.junit.Test)7 Request (com.yahoo.jrt.Request)2 ConfigCacheKey (com.yahoo.vespa.config.ConfigCacheKey)2 FunctionTestConfig (com.yahoo.foo.FunctionTestConfig)1 Slime (com.yahoo.slime.Slime)1 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)1 JRTServerConfigRequest (com.yahoo.vespa.config.protocol.JRTServerConfigRequest)1 File (java.io.File)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Before (org.junit.Before)1