KubernetesInternalRuntime extends InternalRuntime<KubernetesRuntimeContext<E>> { public void scheduleServersCheckers() throws InfrastructureException { WorkspaceStatus status = getStatus(); if (status != WorkspaceStatus.RUNNING && status != WorkspaceStatus.STARTING) { return; } ServerLivenessHandler consumer = new ServerLivenessHandler(); WorkspaceProbes probes = probesFactory.getProbes(getContext().getIdentity(), getInternalMachines()); if (status == WorkspaceStatus.RUNNING) { probeScheduler.schedule(probes, consumer); } else { probeScheduler.schedule( probes, consumer, () -> { try { return getStatus(); } catch (InfrastructureException e) { throw new RuntimeException(e.getMessage()); } }); } } @Inject  KubernetesInternalRuntime(
      @Named("che.infra.kubernetes.workspace_start_timeout_min") int workspaceStartTimeoutMin,
      @Named("che.infra.kubernetes.ingress_start_timeout_min") int ingressStartTimeoutMin,
      NoOpURLRewriter urlRewriter,
      UnrecoverablePodEventListenerFactory unrecoverableEventListenerFactory,
      ServersCheckerFactory serverCheckerFactory,
      WorkspaceVolumesStrategy volumesStrategy,
      ProbeScheduler probeScheduler,
      WorkspaceProbesFactory probesFactory,
      RuntimeEventsPublisher eventPublisher,
      KubernetesSharedPool sharedPool,
      KubernetesRuntimeStateCache runtimeStates,
      KubernetesMachineCache machines,
      StartSynchronizerFactory startSynchronizerFactory,
      Set<InternalEnvironmentProvisioner> internalEnvironmentProvisioners,
      KubernetesEnvironmentProvisioner<E> kubernetesEnvironmentProvisioner,
      SidecarToolingProvisioner<E> toolingProvisioner,
      RuntimeHangingDetector runtimeHangingDetector,
      PreviewUrlCommandProvisioner previewUrlCommandProvisioner,
      SecretAsContainerResourceProvisioner secretAsContainerResourceProvisioner,
      KubernetesServerResolverFactory kubernetesServerResolverFactory,
      RuntimeCleaner runtimeCleaner,
      CheNamespace cheNamespace,
      Tracer tracer,
      @Assisted KubernetesRuntimeContext<E> context,
      @Assisted KubernetesNamespace namespace); void scheduleRuntimeStateChecks(); CompletableFuture<Void> waitRunningAsync(
      List<CompletableFuture<?>> toCancelFutures, KubernetesMachineImpl machine); @Override Map<String, ? extends KubernetesMachineImpl> getInternalMachines(); @Override List<? extends Command> getCommands(); @Override Map<String, String> getProperties(); @Override WorkspaceStatus getStatus(); void scheduleServersCheckers(); boolean isConsistent();  }
@Test public void shouldScheduleServerCheckersForRunningRuntime() throws Exception { runtimeStatesCache.putIfAbsent( new KubernetesRuntimeState( internalRuntime.getContext().getIdentity(), WorkspaceStatus.RUNNING, emptyList())); internalRuntime.scheduleServersCheckers(); verify(probesScheduler).schedule(any(), any()); }
@Test public void shouldScheduleServerCheckersForStartingRuntime() throws Exception { runtimeStatesCache.putIfAbsent( new KubernetesRuntimeState( internalRuntime.getContext().getIdentity(), WorkspaceStatus.STARTING, emptyList())); internalRuntime.scheduleServersCheckers(); verify(probesScheduler).schedule(any(), any(), any()); }
@Test(dataProvider = "nonStartingRunningStatuses") public void shouldNotScheduleServerCheckersIfRuntimeIsNotStartingOrRunning(WorkspaceStatus status) throws Exception { runtimeStatesCache.putIfAbsent( new KubernetesRuntimeState( internalRuntime.getContext().getIdentity(), status, emptyList())); internalRuntime.scheduleServersCheckers(); verifyZeroInteractions(probesScheduler); }