use of io.fabric8.kubernetes.api.model.PodList in project zeppelin by apache.
the class PodPhaseWatcherTest method testPhaseWithError.
@Test
@Ignore("Reamer - ZEPPELIN-5403")
public void testPhaseWithError() throws InterruptedException {
KubernetesClient client = server.getClient();
// CREATE
client.pods().inNamespace("ns1").create(new PodBuilder().withNewMetadata().withName("pod1").endMetadata().build());
// READ
PodList podList = client.pods().inNamespace("ns1").list();
assertNotNull(podList);
assertEquals(1, podList.getItems().size());
// WATCH
PodPhaseWatcher podWatcher = new PodPhaseWatcher(phase -> StringUtils.equalsAnyIgnoreCase(phase, "Succeeded", "Failed", "Running"));
Watch watch = client.pods().inNamespace("ns1").withName("pod1").watch(podWatcher);
// In the case of close, we do not block thread execution
watch.close();
assertTrue(podWatcher.getCountDownLatch().await(1, TimeUnit.SECONDS));
}
use of io.fabric8.kubernetes.api.model.PodList in project fabric8 by fabric8io.
the class PodSelectionAssert method getPods.
/**
* Loads the current pods for this selection
*
* @return the current pods
*/
public List<Pod> getPods() {
PodList list = getClient().pods().withLabels(getMatchLabels()).list();
assertThat(list).describedAs(getDescription() + " pods").isNotNull();
return list.getItems();
}
use of io.fabric8.kubernetes.api.model.PodList in project fabric8 by fabric8io.
the class KubernetesHelperTest method testRemoveEmptyPods.
@Test
public void testRemoveEmptyPods() throws Exception {
Pod pod1 = new Pod();
pod1.setMetadata(new ObjectMeta());
pod1.getMetadata().setName("test1");
Pod pod2 = new Pod();
pod2.setMetadata(new ObjectMeta());
PodList podSchema = new PodList();
podSchema.getItems().add(pod1);
podSchema.getItems().add(pod2);
KubernetesHelper.removeEmptyPods(podSchema);
assertNotNull(podSchema);
assertEquals(1, podSchema.getItems().size());
}
use of io.fabric8.kubernetes.api.model.PodList in project fabric8 by fabric8io.
the class KubernetesAssert method getPods.
protected List<Pod> getPods(String namespace) {
PodList podList = client.pods().inNamespace(namespace).list();
assertThat(podList).isNotNull();
List<Pod> pods = podList.getItems();
podList(pods).isNotNull();
return pods;
}
use of io.fabric8.kubernetes.api.model.PodList in project fabric8 by jboss-fuse.
the class Util method cleanupAllResources.
public static void cleanupAllResources(KubernetesClient client, Session session, List<Throwable> errors) throws MultiException {
String sessionNamespace = session.getNamespace();
session.getLogger().info("Removing all resources in namespace " + sessionNamespace);
/**
* Lets use a loop to ensure we really do delete all the matching resources
*/
for (int i = 0; i < 10; i++) {
OpenShiftClient openShiftClient = new Controller(client).getOpenShiftClientOrNull();
if (openShiftClient != null) {
try {
openShiftClient.deploymentConfigs().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
openShiftClient.routes().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
}
try {
client.extensions().deployments().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
client.extensions().replicaSets().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
client.replicationControllers().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
client.pods().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
client.extensions().ingresses().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
client.services().inNamespace(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
try {
client.securityContextConstraints().withName(sessionNamespace).delete();
} catch (KubernetesClientException e) {
errors.add(e);
}
// lets see if there are any matching podList left
List<Pod> filteredPods = notNullList(client.pods().inNamespace(sessionNamespace).list().getItems());
if (filteredPods.isEmpty()) {
return;
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
Aggregations