Search in sources :

Example 1 with SuperModelProvider

use of com.yahoo.config.model.api.SuperModelProvider in project vespa by vespa-engine.

the class InstanceValidatorTest method application_has_wrong_domain.

@Test
public void application_has_wrong_domain() {
    ServiceInfo serviceInfo = new ServiceInfo("serviceName", "type", Collections.emptyList(), Collections.singletonMap(SERVICE_PROPERTIES_DOMAIN_KEY, "not-domain"), "confId", "hostName");
    SuperModelProvider superModelProvider = mockSuperModelProvider(mockApplicationInfo(applicationId, 5, Collections.singletonList(serviceInfo)));
    InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider);
    assertFalse(instanceValidator.isSameIdentityAsInServicesXml(applicationId, domain, service));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) Test(org.junit.Test)

Example 2 with SuperModelProvider

use of com.yahoo.config.model.api.SuperModelProvider in project vespa by vespa-engine.

the class InstanceValidatorTest method application_does_not_have_domain_set.

@Test
public void application_does_not_have_domain_set() {
    SuperModelProvider superModelProvider = mockSuperModelProvider(mockApplicationInfo(applicationId, 5, Collections.emptyList()));
    InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider);
    assertFalse(instanceValidator.isSameIdentityAsInServicesXml(applicationId, domain, service));
}
Also used : SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) Test(org.junit.Test)

Example 3 with SuperModelProvider

use of com.yahoo.config.model.api.SuperModelProvider in project vespa by vespa-engine.

the class InstanceValidatorTest method application_does_not_exist.

@Test
public void application_does_not_exist() {
    SuperModelProvider superModelProvider = mockSuperModelProvider();
    InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider);
    assertFalse(instanceValidator.isSameIdentityAsInServicesXml(applicationId, domain, service));
}
Also used : SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) Test(org.junit.Test)

Example 4 with SuperModelProvider

use of com.yahoo.config.model.api.SuperModelProvider in project vespa by vespa-engine.

the class SuperModelListenerImplTest method sanityCheck.

@Test
public void sanityCheck() {
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    ServiceMonitorMetrics metrics = mock(ServiceMonitorMetrics.class);
    ModelGenerator modelGenerator = mock(ModelGenerator.class);
    Zone zone = mock(Zone.class);
    List<String> configServers = new ArrayList<>();
    SuperModelListenerImpl listener = new SuperModelListenerImpl(slobrokMonitorManager, metrics, modelGenerator, zone, configServers);
    SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
    SuperModel superModel = mock(SuperModel.class);
    when(superModelProvider.snapshot(listener)).thenReturn(superModel);
    ApplicationInfo application1 = mock(ApplicationInfo.class);
    ApplicationInfo application2 = mock(ApplicationInfo.class);
    List<ApplicationInfo> applications = Stream.of(application1, application2).collect(Collectors.toList());
    when(superModel.getAllApplicationInfos()).thenReturn(applications);
    listener.start(superModelProvider);
    verify(slobrokMonitorManager).applicationActivated(superModel, application1);
    verify(slobrokMonitorManager).applicationActivated(superModel, application2);
    ServiceModel serviceModel = listener.get();
    verify(modelGenerator).toServiceModel(superModel, zone, configServers, slobrokMonitorManager);
}
Also used : Zone(com.yahoo.config.provision.Zone) SuperModel(com.yahoo.config.model.api.SuperModel) ArrayList(java.util.ArrayList) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) Test(org.junit.Test)

Example 5 with SuperModelProvider

use of com.yahoo.config.model.api.SuperModelProvider in project vespa by vespa-engine.

the class InstanceValidatorTest method application_has_same_domain_and_service.

@Test
public void application_has_same_domain_and_service() {
    Map<String, String> properties = new HashMap<>();
    properties.put(SERVICE_PROPERTIES_DOMAIN_KEY, domain);
    properties.put(SERVICE_PROPERTIES_SERVICE_KEY, service);
    ServiceInfo serviceInfo = new ServiceInfo("serviceName", "type", Collections.emptyList(), properties, "confId", "hostName");
    SuperModelProvider superModelProvider = mockSuperModelProvider(mockApplicationInfo(applicationId, 5, Collections.singletonList(serviceInfo)));
    InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider);
    assertTrue(instanceValidator.isSameIdentityAsInServicesXml(applicationId, domain, service));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HashMap(java.util.HashMap) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) Test(org.junit.Test)

Aggregations

SuperModelProvider (com.yahoo.config.model.api.SuperModelProvider)6 Test (org.junit.Test)5 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)2 SuperModel (com.yahoo.config.model.api.SuperModel)2 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1 Zone (com.yahoo.config.provision.Zone)1 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1