use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.KubernetesServerResolverFactory in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method setup.
@BeforeMethod
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
runtimeStatesCache = new MapBasedRuntimeStateCache();
machinesCache = new MapBasedMachinesCache();
eventPublisher = new RuntimeEventsPublisher(eventService);
serverResolverFactory = new KubernetesServerResolverFactory(pathTransformInverter, "che-host", MULTI_HOST_STRATEGY, WorkspaceExposureType.NATIVE.getConfigValue());
startSynchronizer = spy(new StartSynchronizer(eventService, 5, IDENTITY));
when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
internalRuntime = new KubernetesInternalRuntime<>(13, 5, new URLRewriter.NoOpURLRewriter(), unrecoverablePodEventListenerFactory, serverCheckerFactory, volumesStrategy, probesScheduler, workspaceProbesFactory, eventPublisher, new KubernetesSharedPool(new NoopExecutorServiceWrapper()), runtimeStatesCache, machinesCache, startSynchronizerFactory, ImmutableSet.of(internalEnvironmentProvisioner), kubernetesEnvironmentProvisioner, toolingProvisioner, runtimeHangingDetector, previewUrlCommandProvisioner, secretAsContainerResourceProvisioner, serverResolverFactory, runtimeCleaner, cheNamespace, tracer, context, namespace);
when(context.getEnvironment()).thenReturn(k8sEnv);
when(context.getRuntime()).thenReturn(internalRuntime);
when(serverCheckerFactory.create(any(), anyString(), any())).thenReturn(serversChecker);
when(context.getIdentity()).thenReturn(IDENTITY);
doNothing().when(namespace).cleanUp();
when(namespace.services()).thenReturn(services);
when(namespace.ingresses()).thenReturn(ingresses);
when(namespace.deployments()).thenReturn(deployments);
when(namespace.secrets()).thenReturn(secrets);
when(namespace.configMaps()).thenReturn(configMaps);
doReturn(ImmutableMap.of(M1_NAME, mock(InternalMachineConfig.class), M2_NAME, mock(InternalMachineConfig.class))).when(k8sEnv).getMachines();
final Map<String, Service> allServices = ImmutableMap.of(SERVICE_NAME, mockService());
final Ingress ingress = mockIngress();
final Map<String, Ingress> allIngresses = ImmutableMap.of(INGRESS_NAME, ingress);
when(services.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(ingresses.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(ingresses.wait(anyString(), anyLong(), any(), any())).thenReturn(ingress);
when(deployments.deploy(any(Pod.class))).thenAnswer(inv -> inv.getArgument(0));
when(deployments.deploy(any(Deployment.class))).thenAnswer(inv -> {
Deployment d = inv.getArgument(0);
Pod pod = new Pod();
pod.setSpec(d.getSpec().getTemplate().getSpec());
pod.setMetadata(d.getSpec().getTemplate().getMetadata());
return pod;
});
when(k8sEnv.getServices()).thenReturn(allServices);
when(k8sEnv.getIngresses()).thenReturn(allIngresses);
when(k8sEnv.getPodsCopy()).thenReturn(podsMap);
when(k8sEnv.getCommands()).thenReturn(new ArrayList<>(singletonList(envCommand)));
when(deployments.waitRunningAsync(any())).thenReturn(CompletableFuture.completedFuture(null));
when(serversChecker.startAsync(any())).thenReturn(CompletableFuture.completedFuture(null));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.KubernetesServerResolverFactory in project devspaces-images by redhat-developer.
the class KubernetesInternalRuntimeTest method setup.
@BeforeMethod
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
runtimeStatesCache = new MapBasedRuntimeStateCache();
machinesCache = new MapBasedMachinesCache();
eventPublisher = new RuntimeEventsPublisher(eventService);
serverResolverFactory = new KubernetesServerResolverFactory(pathTransformInverter, "che-host", MULTI_HOST_STRATEGY, WorkspaceExposureType.NATIVE.getConfigValue());
startSynchronizer = spy(new StartSynchronizer(eventService, 5, IDENTITY));
when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
internalRuntime = new KubernetesInternalRuntime<>(13, 5, new URLRewriter.NoOpURLRewriter(), unrecoverablePodEventListenerFactory, serverCheckerFactory, volumesStrategy, probesScheduler, workspaceProbesFactory, eventPublisher, new KubernetesSharedPool(new NoopExecutorServiceWrapper()), runtimeStatesCache, machinesCache, startSynchronizerFactory, ImmutableSet.of(internalEnvironmentProvisioner), kubernetesEnvironmentProvisioner, toolingProvisioner, runtimeHangingDetector, previewUrlCommandProvisioner, secretAsContainerResourceProvisioner, serverResolverFactory, runtimeCleaner, cheNamespace, tracer, context, namespace);
when(context.getEnvironment()).thenReturn(k8sEnv);
when(context.getRuntime()).thenReturn(internalRuntime);
when(serverCheckerFactory.create(any(), anyString(), any())).thenReturn(serversChecker);
when(context.getIdentity()).thenReturn(IDENTITY);
doNothing().when(namespace).cleanUp();
when(namespace.services()).thenReturn(services);
when(namespace.ingresses()).thenReturn(ingresses);
when(namespace.deployments()).thenReturn(deployments);
when(namespace.secrets()).thenReturn(secrets);
when(namespace.configMaps()).thenReturn(configMaps);
doReturn(ImmutableMap.of(M1_NAME, mock(InternalMachineConfig.class), M2_NAME, mock(InternalMachineConfig.class))).when(k8sEnv).getMachines();
final Map<String, Service> allServices = ImmutableMap.of(SERVICE_NAME, mockService());
final Ingress ingress = mockIngress();
final Map<String, Ingress> allIngresses = ImmutableMap.of(INGRESS_NAME, ingress);
when(services.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(ingresses.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(ingresses.wait(anyString(), anyLong(), any(), any())).thenReturn(ingress);
when(deployments.deploy(any(Pod.class))).thenAnswer(inv -> inv.getArgument(0));
when(deployments.deploy(any(Deployment.class))).thenAnswer(inv -> {
Deployment d = inv.getArgument(0);
Pod pod = new Pod();
pod.setSpec(d.getSpec().getTemplate().getSpec());
pod.setMetadata(d.getSpec().getTemplate().getMetadata());
return pod;
});
when(k8sEnv.getServices()).thenReturn(allServices);
when(k8sEnv.getIngresses()).thenReturn(allIngresses);
when(k8sEnv.getPodsCopy()).thenReturn(podsMap);
when(k8sEnv.getCommands()).thenReturn(new ArrayList<>(singletonList(envCommand)));
when(deployments.waitRunningAsync(any())).thenReturn(CompletableFuture.completedFuture(null));
when(serversChecker.startAsync(any())).thenReturn(CompletableFuture.completedFuture(null));
}
Aggregations