use of org.apache.samza.monitor.mock.InstantSchedulingProvider in project samza by apache.
the class TestMonitorService method testMonitorExceptionIsolation.
@Test
public void testMonitorExceptionIsolation() {
// Test that an exception from a monitor doesn't bubble up out of the scheduler.
Map<String, String> configMap = ImmutableMap.of(String.format("monitor.name.%s", CONFIG_MONITOR_FACTORY_CLASS), ExceptionThrowingMonitorFactory.class.getCanonicalName());
SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
SamzaMonitorService monitorService = new SamzaMonitorService(config, METRICS_REGISTRY, new InstantSchedulingProvider());
// This will throw if the exception isn't caught within the provider.
monitorService.start();
monitorService.stop();
}
use of org.apache.samza.monitor.mock.InstantSchedulingProvider in project samza by apache.
the class TestMonitorService method testShouldFailWhenTheMonitorFactoryClassIsInvalid.
@Test(expected = SamzaException.class)
public void testShouldFailWhenTheMonitorFactoryClassIsInvalid() {
// Test that when MonitorFactoryClass is defined in the config and is invalid,
// monitor service should fail. Should throw back SamzaException.
Map<String, String> configMap = ImmutableMap.of(String.format("monitor.name.%s", CONFIG_MONITOR_FACTORY_CLASS), "RandomClassName");
SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
SamzaMonitorService monitorService = new SamzaMonitorService(config, METRICS_REGISTRY, new InstantSchedulingProvider());
monitorService.start();
}
use of org.apache.samza.monitor.mock.InstantSchedulingProvider in project samza by apache.
the class TestMonitorService method testShouldNotFailWhenTheMonitorFactoryClassIsNotDefined.
@Test
public void testShouldNotFailWhenTheMonitorFactoryClassIsNotDefined() throws Exception {
// Test that when MonitorFactoryClass is not defined in the config, monitor service
// should not fail.
Map<String, String> configMap = ImmutableMap.of("monitor.monitor1.config.key1", "configValue1", "monitor.monitor1.config.key2", "configValue2", String.format("monitor.MOCK_MONITOR.%s", CONFIG_MONITOR_FACTORY_CLASS), MockMonitorFactory.class.getCanonicalName());
SamzaRestConfig config = new SamzaRestConfig(new MapConfig(configMap));
SamzaMonitorService monitorService = new SamzaMonitorService(config, METRICS_REGISTRY, new InstantSchedulingProvider());
try {
monitorService.start();
} catch (Exception e) {
fail();
}
Mockito.verify(MockMonitorFactory.MOCK_MONITOR, Mockito.times(1)).monitor();
}
Aggregations