use of org.apache.heron.scheduler.TopologySubmissionException in project heron by twitter.
the class V1ControllerTest method testLoadPodFromTemplateNullConfigMap.
@Test
public void testLoadPodFromTemplateNullConfigMap() {
final List<TestTuple<Boolean, String>> testCases = new LinkedList<>();
testCases.add(new TestTuple<>("Executor not found", true, "unable to locate"));
testCases.add(new TestTuple<>("Manager not found", false, "unable to locate"));
for (TestTuple<Boolean, String> testCase : testCases) {
doReturn(null).when(v1ControllerWithPodTemplate).getConfigMap(anyString());
String message = "";
try {
v1ControllerWithPodTemplate.loadPodFromTemplate(testCase.input);
} catch (TopologySubmissionException e) {
message = e.getMessage();
}
Assert.assertTrue(testCase.description, message.contains(testCase.expected));
}
}
use of org.apache.heron.scheduler.TopologySubmissionException in project heron by twitter.
the class V1ControllerTest method testLoadPodFromTemplateBadTargetConfigMap.
@Test
public void testLoadPodFromTemplateBadTargetConfigMap() {
// ConfigMap with target ConfigMap and an invalid Pod Template.
final V1ConfigMap configMapInvalidPod = new V1ConfigMapBuilder().withNewMetadata().withName(CONFIGMAP_NAME).endMetadata().addToData(POD_TEMPLATE_NAME, "Dummy Value").build();
// ConfigMap with target ConfigMaps and an empty Pod Template.
final V1ConfigMap configMapEmptyPod = new V1ConfigMapBuilder().withNewMetadata().withName(CONFIGMAP_NAME).endMetadata().addToData(POD_TEMPLATE_NAME, "").build();
// Test case container.
// Input: ConfigMap to setup mock V1Controller, Boolean flag for executor/manager switch.
// Output: The expected error message.
final List<TestTuple<Pair<V1ConfigMap, Boolean>, String>> testCases = new LinkedList<>();
testCases.add(new TestTuple<>("Executor invalid Pod Template", new Pair<>(configMapInvalidPod, true), "Error parsing"));
testCases.add(new TestTuple<>("Manager invalid Pod Template", new Pair<>(configMapInvalidPod, false), "Error parsing"));
testCases.add(new TestTuple<>("Executor empty Pod Template", new Pair<>(configMapEmptyPod, true), "Error parsing"));
testCases.add(new TestTuple<>("Manager empty Pod Template", new Pair<>(configMapEmptyPod, false), "Error parsing"));
// Test loop.
for (TestTuple<Pair<V1ConfigMap, Boolean>, String> testCase : testCases) {
doReturn(testCase.input.first).when(v1ControllerWithPodTemplate).getConfigMap(anyString());
String message = "";
try {
v1ControllerWithPodTemplate.loadPodFromTemplate(testCase.input.second);
} catch (TopologySubmissionException e) {
message = e.getMessage();
}
Assert.assertTrue(testCase.description, message.contains(testCase.expected));
}
}
use of org.apache.heron.scheduler.TopologySubmissionException in project heron by twitter.
the class V1ControllerTest method testLoadPodFromTemplateNoConfigMap.
@Test
public void testLoadPodFromTemplateNoConfigMap() {
final List<TestTuple<Boolean, String>> testCases = new LinkedList<>();
testCases.add(new TestTuple<>("Executor no ConfigMap", true, "Failed to locate Pod Template"));
testCases.add(new TestTuple<>("Manager no ConfigMap", false, "Failed to locate Pod Template"));
for (TestTuple<Boolean, String> testCase : testCases) {
doReturn(new V1ConfigMap()).when(v1ControllerWithPodTemplate).getConfigMap(anyString());
String message = "";
try {
v1ControllerWithPodTemplate.loadPodFromTemplate(testCase.input);
} catch (TopologySubmissionException e) {
message = e.getMessage();
}
Assert.assertTrue(testCase.description, message.contains(testCase.expected));
}
}
use of org.apache.heron.scheduler.TopologySubmissionException in project heron by twitter.
the class V1ControllerTest method testDisablePodTemplates.
@Test
public void testDisablePodTemplates() {
// ConfigMap with valid Pod Template.
V1ConfigMap configMapValidPod = new V1ConfigMapBuilder().withNewMetadata().withName(CONFIGMAP_NAME).endMetadata().addToData(POD_TEMPLATE_NAME, POD_TEMPLATE_VALID).build();
final String expected = "Pod Templates are disabled";
String message = "";
doReturn(configMapValidPod).when(v1ControllerPodTemplate).getConfigMap(anyString());
try {
v1ControllerPodTemplate.loadPodFromTemplate(true);
} catch (TopologySubmissionException e) {
message = e.getMessage();
}
Assert.assertTrue(message.contains(expected));
}
Aggregations