use of io.fabric8.kubernetes.client.dsl.Deletable in project che-server by eclipse-che.
the class AsyncStoragePodInterceptorTest method shouldDoDeletePodIfWorkspaceWithEmptyAttributes.
@Test
public void shouldDoDeletePodIfWorkspaceWithEmptyAttributes() throws InfrastructureException {
when(identity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
when(identity.getInfrastructureNamespace()).thenReturn(NAMESPACE);
when(clientFactory.create(WORKSPACE_ID)).thenReturn(kubernetesClient);
when(kubernetesEnvironment.getAttributes()).thenReturn(emptyMap());
when(kubernetesClient.pods()).thenReturn(mixedOperationPod);
when(mixedOperationPod.inNamespace(NAMESPACE)).thenReturn(namespacePodOperation);
when(namespacePodOperation.withName(ASYNC_STORAGE)).thenReturn(podResource);
when(podResource.get()).thenReturn(null);
when(kubernetesClient.apps()).thenReturn(apps);
when(apps.deployments()).thenReturn(mixedOperation);
when(mixedOperation.inNamespace(NAMESPACE)).thenReturn(namespaceOperation);
when(namespaceOperation.withName(ASYNC_STORAGE)).thenReturn(deploymentResource);
ObjectMeta meta = new ObjectMeta();
meta.setName(ASYNC_STORAGE);
Deployment deployment = new Deployment();
deployment.setMetadata(meta);
when(deploymentResource.get()).thenReturn(deployment);
when(deploymentResource.withPropagationPolicy(BACKGROUND)).thenReturn(deletable);
Watch watch = mock(Watch.class);
when(deploymentResource.watch(any())).thenReturn(watch);
asyncStoragePodInterceptor.intercept(kubernetesEnvironment, identity);
verify(deletable).delete();
verify(watch).close();
}
use of io.fabric8.kubernetes.client.dsl.Deletable in project che-server by eclipse-che.
the class AsyncStoragePodInterceptorTest method shouldDoDeletePodIfWorkspaceConfigureToPersistentStorage.
@Test
public void shouldDoDeletePodIfWorkspaceConfigureToPersistentStorage() throws InfrastructureException {
when(identity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
when(identity.getInfrastructureNamespace()).thenReturn(NAMESPACE);
when(clientFactory.create(WORKSPACE_ID)).thenReturn(kubernetesClient);
when(kubernetesEnvironment.getAttributes()).thenReturn(ImmutableMap.of(PERSIST_VOLUMES_ATTRIBUTE, "true"));
when(kubernetesClient.pods()).thenReturn(mixedOperationPod);
when(mixedOperationPod.inNamespace(NAMESPACE)).thenReturn(namespacePodOperation);
when(namespacePodOperation.withName(ASYNC_STORAGE)).thenReturn(podResource);
when(podResource.get()).thenReturn(null);
when(kubernetesClient.apps()).thenReturn(apps);
when(apps.deployments()).thenReturn(mixedOperation);
when(mixedOperation.inNamespace(NAMESPACE)).thenReturn(namespaceOperation);
when(namespaceOperation.withName(ASYNC_STORAGE)).thenReturn(deploymentResource);
ObjectMeta meta = new ObjectMeta();
meta.setName(ASYNC_STORAGE);
Deployment deployment = new Deployment();
deployment.setMetadata(meta);
when(deploymentResource.get()).thenReturn(deployment);
when(deploymentResource.withPropagationPolicy(BACKGROUND)).thenReturn(deletable);
Watch watch = mock(Watch.class);
when(deploymentResource.watch(any())).thenReturn(watch);
asyncStoragePodInterceptor.intercept(kubernetesEnvironment, identity);
verify(deletable).delete();
verify(watch).close();
}
use of io.fabric8.kubernetes.client.dsl.Deletable in project devspaces-images by redhat-developer.
the class AsyncStoragePodInterceptorTest method shouldDoDeletePodIfWorkspaceWithEmptyAttributes.
@Test
public void shouldDoDeletePodIfWorkspaceWithEmptyAttributes() throws InfrastructureException {
when(identity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
when(identity.getInfrastructureNamespace()).thenReturn(NAMESPACE);
when(clientFactory.create(WORKSPACE_ID)).thenReturn(kubernetesClient);
when(kubernetesEnvironment.getAttributes()).thenReturn(emptyMap());
when(kubernetesClient.pods()).thenReturn(mixedOperationPod);
when(mixedOperationPod.inNamespace(NAMESPACE)).thenReturn(namespacePodOperation);
when(namespacePodOperation.withName(ASYNC_STORAGE)).thenReturn(podResource);
when(podResource.get()).thenReturn(null);
when(kubernetesClient.apps()).thenReturn(apps);
when(apps.deployments()).thenReturn(mixedOperation);
when(mixedOperation.inNamespace(NAMESPACE)).thenReturn(namespaceOperation);
when(namespaceOperation.withName(ASYNC_STORAGE)).thenReturn(deploymentResource);
ObjectMeta meta = new ObjectMeta();
meta.setName(ASYNC_STORAGE);
Deployment deployment = new Deployment();
deployment.setMetadata(meta);
when(deploymentResource.get()).thenReturn(deployment);
when(deploymentResource.withPropagationPolicy(BACKGROUND)).thenReturn(deletable);
Watch watch = mock(Watch.class);
when(deploymentResource.watch(any())).thenReturn(watch);
asyncStoragePodInterceptor.intercept(kubernetesEnvironment, identity);
verify(deletable).delete();
verify(watch).close();
}
Aggregations