@Test public void testIsContainerRecycled () throws ApiException { String uid = randomUUID().toString(); String containerName = randomUUID().toString(); KubernetesPodContainer kubernetesPodContainer = spy(KubernetesPodContainer.builder() .withUUID(uid) .withSubcontainers(List.of( containerName)) .build()); V1ObjectMeta podMetadata = new V1ObjectMeta().uid(uid); V1ContainerState state = new V1ContainerState().running(new V1ContainerStateRunning().startedAt(DateTime.now() .minusMinutes( 1))); V1PodStatus podStatus = new V1PodStatus().containerStatuses(List.of(new V1ContainerStatus().name(containerName) .state(state))); V1Pod pod = new V1Pod().metadata(podMetadata).status(podStatus); doReturn(new V1PodList().items(List.of(pod))).when(coreV1Api) .listNamespacedPod(NAMESPACE_NAME, "true", false, "", "", "", 0, "", 0, false); doReturn(pod).when(coreV1Api).readNamespacedPodStatus(any(), any(), any()); doReturn(Instant.now().minusSeconds(100)).when(kubernetesPodContainer).getExperimentStartTime(); assertTrue(platform.isContainerRecycled(kubernetesPodContainer)); }
@Override public boolean isContainerRecycled (Container container) { KubernetesPodContainer kubernetesPodContainer = (KubernetesPodContainer) container; if (podExists(kubernetesPodContainer).orElse(false)) return isContainerRestarted(kubernetesPodContainer, ((KubernetesPodContainer) container).getTargetedSubcontainer()); return isDesiredReplicas(kubernetesPodContainer); }
KubernetesPlatform extends Platform implements ShellBasedExperiment<KubernetesPodContainer> { @Override public boolean isContainerRecycled (Container container) { KubernetesPodContainer kubernetesPodContainer = (KubernetesPodContainer) container; if (podExists(kubernetesPodContainer).orElse(false)) return isContainerRestarted(kubernetesPodContainer, ((KubernetesPodContainer) container).getTargetedSubcontainer()); return isDesiredReplicas(kubernetesPodContainer); } }
KubernetesPlatform extends Platform implements ShellBasedExperiment<KubernetesPodContainer> { @Override public boolean isContainerRecycled (Container container) { KubernetesPodContainer kubernetesPodContainer = (KubernetesPodContainer) container; if (podExists(kubernetesPodContainer).orElse(false)) return isContainerRestarted(kubernetesPodContainer, ((KubernetesPodContainer) container).getTargetedSubcontainer()); return isDesiredReplicas(kubernetesPodContainer); } @Autowired  KubernetesPlatform(ApiClient apiClient); }
KubernetesPlatform extends Platform implements ShellBasedExperiment<KubernetesPodContainer> { @Override public boolean isContainerRecycled (Container container) { KubernetesPodContainer kubernetesPodContainer = (KubernetesPodContainer) container; if (podExists(kubernetesPodContainer).orElse(false)) return isContainerRestarted(kubernetesPodContainer, ((KubernetesPodContainer) container).getTargetedSubcontainer()); return isDesiredReplicas(kubernetesPodContainer); } @Autowired  KubernetesPlatform(ApiClient apiClient); String getNamespace(); void setNamespace(String namespace); ContainerHealth checkHealth(KubernetesPodContainer kubernetesPodContainer); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override boolean isContainerRecycled(Container container); ContainerHealth replicaSetRecovered(KubernetesPodContainer kubernetesPodContainer); boolean isDesiredReplicas(KubernetesPodContainer instance); @Override void recycleContainer(KubernetesPodContainer container); boolean deletePod(KubernetesPodContainer instance); @Override ShellClient getConnectedShellClient(KubernetesPodContainer container); }
KubernetesPlatform extends Platform implements ShellBasedExperiment<KubernetesPodContainer> { @Override public boolean isContainerRecycled (Container container) { KubernetesPodContainer kubernetesPodContainer = (KubernetesPodContainer) container; if (podExists(kubernetesPodContainer).orElse(false)) return isContainerRestarted(kubernetesPodContainer, ((KubernetesPodContainer) container).getTargetedSubcontainer()); return isDesiredReplicas(kubernetesPodContainer); } @Autowired  KubernetesPlatform(ApiClient apiClient); String getNamespace(); void setNamespace(String namespace); ContainerHealth checkHealth(KubernetesPodContainer kubernetesPodContainer); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override boolean isContainerRecycled(Container container); ContainerHealth replicaSetRecovered(KubernetesPodContainer kubernetesPodContainer); boolean isDesiredReplicas(KubernetesPodContainer instance); @Override void recycleContainer(KubernetesPodContainer container); boolean deletePod(KubernetesPodContainer instance); @Override ShellClient getConnectedShellClient(KubernetesPodContainer container);  }