Search in sources :

Example 11 with ConfigKey

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

the class TenantRequestHandlerTest method testListConfigs.

@Test
public void testListConfigs() throws IOException, SAXException {
    assertdefaultAppNotFound();
    /*assertTrue(server.allConfigIds(ApplicationId.defaultId()).isEmpty());
        assertTrue(server.allConfigsProduced(ApplicationId.defaultId()).isEmpty());
        assertTrue(server.listConfigs(ApplicationId.defaultId(), false).isEmpty());
        assertTrue(server.listConfigs(ApplicationId.defaultId(), true).isEmpty());*/
    VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(new File("src/test/apps/app")));
    server.reloadConfig(ApplicationSet.fromSingle(new Application(model, new ServerCache(), 1, vespaVersion, MetricUpdater.createTestUpdater(), ApplicationId.defaultId())));
    Set<ConfigKey<?>> configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), false);
    assertTrue(configNames.contains(new ConfigKey<>("sentinel", "hosts", "cloud.config")));
    // for (ConfigKey<?> ck : configNames) {
    // assertTrue(!"".equals(ck.getConfigId()));
    // }
    configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), true);
    System.out.println(configNames);
    assertTrue(configNames.contains(new ConfigKey<>("feeder", "jdisc", "vespaclient.config")));
    assertTrue(configNames.contains(new ConfigKey<>("documentmanager", "jdisc", "document.config")));
    assertTrue(configNames.contains(new ConfigKey<>("documentmanager", "", "document.config")));
    assertTrue(configNames.contains(new ConfigKey<>("documenttypes", "", "document")));
    assertTrue(configNames.contains(new ConfigKey<>("documentmanager", "jdisc", "document.config")));
    assertTrue(configNames.contains(new ConfigKey<>("health-monitor", "jdisc", "container.jdisc.config")));
    assertTrue(configNames.contains(new ConfigKey<>("specific", "jdisc", "project")));
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) ConfigKey(com.yahoo.vespa.config.ConfigKey) VespaModel(com.yahoo.vespa.model.VespaModel) File(java.io.File) Application(com.yahoo.vespa.config.server.application.Application) Test(org.junit.Test)

Example 12 with ConfigKey

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

the class ConfiguredApplication method watchPortChange.

private void watchPortChange() {
    Subscriber subscriber = subscriberFactory.getSubscriber(Collections.singleton(new ConfigKey<>(QrConfig.class, configId)));
    try {
        while (true) {
            subscriber.waitNextGeneration();
            QrConfig newConfig = QrConfig.class.cast(first(subscriber.config().values()));
            if (qrConfig.rpc().port() != newConfig.rpc().port()) {
                com.yahoo.protect.Process.logAndDie("Rpc port config has changed from " + qrConfig.rpc().port() + " to " + newConfig.rpc().port() + ". This we can not handle without a restart so we will just bail out.");
            }
            log.fine("Received new QrConfig :" + newConfig);
        }
    } finally {
        subscriber.close();
    }
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) Subscriber(com.yahoo.container.di.config.Subscriber) QrConfig(com.yahoo.container.QrConfig)

Example 13 with ConfigKey

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

the class FileConfigSubscriptionTest method require_that_dir_config_id_reference_is_not_changed.

@Test
public void require_that_dir_config_id_reference_is_not_changed() {
    final String cfgDir = "src/test/resources/configs/foo";
    final String cfgId = "dir:" + cfgDir;
    final ConfigKey<TestReferenceConfig> key = new ConfigKey<>(TestReferenceConfig.class, cfgId);
    ConfigSubscriber subscriber = new ConfigSubscriber();
    ConfigSubscription<TestReferenceConfig> sub = ConfigSubscription.get(key, subscriber, new DirSource(new File(cfgDir)), new TimingValues());
    assertTrue(sub.nextConfig(1000));
    assertThat(sub.getConfigState().getConfig().configId(), is(cfgId));
}
Also used : TestReferenceConfig(com.yahoo.foo.TestReferenceConfig) ConfigKey(com.yahoo.vespa.config.ConfigKey) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) DirSource(com.yahoo.config.subscription.DirSource) File(java.io.File) Test(org.junit.Test)

Example 14 with ConfigKey

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

the class ComponentClassTestCase method testCreateComponent.

@SuppressWarnings("unchecked")
@Test
public void testCreateComponent() throws NoSuchMethodException {
    Map<ConfigKey, ConfigInstance> availableConfigs = new HashMap<>();
    String configId = "testConfigId";
    availableConfigs.put(new ConfigKey(StringConfig.class, configId), new StringConfig(new StringConfig.Builder()));
    availableConfigs.put(new ConfigKey(IntConfig.class, configId), new IntConfig(new IntConfig.Builder()));
    ComponentClass<TestComponent> testClass = new ComponentClass<>(TestComponent.class);
    TestComponent component = testClass.createComponent(new ComponentId("test", new Version(1)), availableConfigs, configId);
    assertEquals("test", component.getId().getName());
    assertEquals(1, component.getId().getVersion().getMajor());
    assertEquals(1, component.intVal);
    assertEquals("_default_", component.stringVal);
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) HashMap(java.util.HashMap) IntConfig(com.yahoo.config.core.IntConfig) StringConfig(com.yahoo.config.core.StringConfig) Version(com.yahoo.component.Version) ComponentId(com.yahoo.component.ComponentId) ComponentClass(com.yahoo.component.provider.ComponentClass) ConfigInstance(com.yahoo.config.ConfigInstance) Test(org.junit.Test)

Example 15 with ConfigKey

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

the class ComponentClassTestCase method testNullIdComponent.

/**
 * Verifies that ComponentClass sets the ComponentId when a component that takes a ComponentId as
 * constructor argument fails to call super(id).
 */
@Test
public void testNullIdComponent() throws NoSuchMethodException {
    ComponentClass<NullIdComponent> testClass = new ComponentClass<>(NullIdComponent.class);
    NullIdComponent component = testClass.createComponent(new ComponentId("null-test", new Version(1)), new HashMap<ConfigKey, ConfigInstance>(), null);
    assertEquals("null-test", component.getId().getName());
    assertEquals(1, component.getId().getVersion().getMajor());
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) Version(com.yahoo.component.Version) ComponentId(com.yahoo.component.ComponentId) ComponentClass(com.yahoo.component.provider.ComponentClass) ConfigInstance(com.yahoo.config.ConfigInstance) Test(org.junit.Test)

Aggregations

ConfigKey (com.yahoo.vespa.config.ConfigKey)23 Test (org.junit.Test)9 ApplicationId (com.yahoo.config.provision.ApplicationId)4 MockRequestHandler (com.yahoo.vespa.config.server.rpc.MockRequestHandler)4 Before (org.junit.Before)4 ConfigInstance (com.yahoo.config.ConfigInstance)3 ComponentId (com.yahoo.component.ComponentId)2 Version (com.yahoo.component.Version)2 ComponentClass (com.yahoo.component.provider.ComponentClass)2 TenantName (com.yahoo.config.provision.TenantName)2 HttpResponse (com.yahoo.container.jdisc.HttpResponse)2 RequestHandler (com.yahoo.vespa.config.server.RequestHandler)2 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2 Tenants (com.yahoo.vespa.config.server.tenant.Tenants)2 File (java.io.File)2 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)1 RoutingConfig (com.yahoo.cloud.config.RoutingConfig)1 ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)1 IntConfig (com.yahoo.config.core.IntConfig)1