use of io.kubernetes.client.openapi.models.V1ConfigMapBuilder 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 io.kubernetes.client.openapi.models.V1ConfigMapBuilder 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