Search in sources :

Example 1 with OpenShiftServerResolverFactory

use of org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory in project che-server by eclipse-che.

the class OpenShiftInternalRuntimeTest method setup.

@BeforeMethod
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
    serverResolverFactory = new OpenShiftServerResolverFactory("che-host", MULTI_HOST_STRATEGY, WorkspaceExposureType.NATIVE.getConfigValue());
    internalRuntime = new OpenShiftInternalRuntime(13, 5, new URLRewriter.NoOpURLRewriter(), unrecoverablePodEventListenerFactory, serverCheckerFactory, volumesStrategy, probesScheduler, workspaceProbesFactory, new RuntimeEventsPublisher(eventService), mock(KubernetesSharedPool.class), runtimeStateCache, machinesCache, startSynchronizerFactory, ImmutableSet.of(internalEnvironmentProvisioner), kubernetesEnvironmentProvisioner, toolingProvisioner, runtimeHangingDetector, previewUrlCommandProvisioner, secretAsContainerResourceProvisioner, serverResolverFactory, runtimeCleaner, cheNamespace, tracer, context, project);
    when(context.getEnvironment()).thenReturn(osEnv);
    when(serverCheckerFactory.create(any(), anyString(), any())).thenReturn(serversChecker);
    when(context.getIdentity()).thenReturn(IDENTITY);
    doNothing().when(project).cleanUp();
    when(project.services()).thenReturn(services);
    when(project.routes()).thenReturn(routes);
    when(project.secrets()).thenReturn(secrets);
    when(project.configMaps()).thenReturn(configMaps);
    when(project.deployments()).thenReturn(deployments);
    doReturn(ImmutableMap.of(M1_NAME, mock(InternalMachineConfig.class), M2_NAME, mock(InternalMachineConfig.class))).when(osEnv).getMachines();
    allServices = ImmutableMap.of(SERVICE_NAME, mockService());
    allRoutes = ImmutableMap.of(SERVICE_NAME, mockRoute());
    final Container container = mockContainer(CONTAINER_NAME_1, EXPOSED_PORT_1, INTERNAL_PORT);
    final ImmutableMap<String, Pod> allPods = ImmutableMap.of(POD_NAME, mockPod(ImmutableList.of(container)));
    when(services.create(any())).thenAnswer(a -> a.getArguments()[0]);
    when(routes.create(any())).thenAnswer(a -> a.getArguments()[0]);
    when(deployments.deploy(any(Pod.class))).thenAnswer(a -> a.getArguments()[0]);
    when(osEnv.getServices()).thenReturn(allServices);
    when(osEnv.getRoutes()).thenReturn(allRoutes);
    when(osEnv.getPodsCopy()).thenReturn(allPods);
    when(osEnv.getSecrets()).thenReturn(ImmutableMap.of("secret", new Secret()));
    when(osEnv.getConfigMaps()).thenReturn(ImmutableMap.of("configMap", new ConfigMap()));
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) Container(io.fabric8.kubernetes.api.model.Container) Pod(io.fabric8.kubernetes.api.model.Pod) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) RuntimeEventsPublisher(org.eclipse.che.workspace.infrastructure.kubernetes.util.RuntimeEventsPublisher) OpenShiftServerResolverFactory(org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with OpenShiftServerResolverFactory

use of org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory in project devspaces-images by redhat-developer.

the class OpenShiftInternalRuntimeTest method setup.

@BeforeMethod
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
    serverResolverFactory = new OpenShiftServerResolverFactory("che-host", MULTI_HOST_STRATEGY, WorkspaceExposureType.NATIVE.getConfigValue());
    internalRuntime = new OpenShiftInternalRuntime(13, 5, new URLRewriter.NoOpURLRewriter(), unrecoverablePodEventListenerFactory, serverCheckerFactory, volumesStrategy, probesScheduler, workspaceProbesFactory, new RuntimeEventsPublisher(eventService), mock(KubernetesSharedPool.class), runtimeStateCache, machinesCache, startSynchronizerFactory, ImmutableSet.of(internalEnvironmentProvisioner), kubernetesEnvironmentProvisioner, toolingProvisioner, runtimeHangingDetector, previewUrlCommandProvisioner, secretAsContainerResourceProvisioner, serverResolverFactory, runtimeCleaner, cheNamespace, tracer, context, project);
    when(context.getEnvironment()).thenReturn(osEnv);
    when(serverCheckerFactory.create(any(), anyString(), any())).thenReturn(serversChecker);
    when(context.getIdentity()).thenReturn(IDENTITY);
    doNothing().when(project).cleanUp();
    when(project.services()).thenReturn(services);
    when(project.routes()).thenReturn(routes);
    when(project.secrets()).thenReturn(secrets);
    when(project.configMaps()).thenReturn(configMaps);
    when(project.deployments()).thenReturn(deployments);
    doReturn(ImmutableMap.of(M1_NAME, mock(InternalMachineConfig.class), M2_NAME, mock(InternalMachineConfig.class))).when(osEnv).getMachines();
    allServices = ImmutableMap.of(SERVICE_NAME, mockService());
    allRoutes = ImmutableMap.of(SERVICE_NAME, mockRoute());
    final Container container = mockContainer(CONTAINER_NAME_1, EXPOSED_PORT_1, INTERNAL_PORT);
    final ImmutableMap<String, Pod> allPods = ImmutableMap.of(POD_NAME, mockPod(ImmutableList.of(container)));
    when(services.create(any())).thenAnswer(a -> a.getArguments()[0]);
    when(routes.create(any())).thenAnswer(a -> a.getArguments()[0]);
    when(deployments.deploy(any(Pod.class))).thenAnswer(a -> a.getArguments()[0]);
    when(osEnv.getServices()).thenReturn(allServices);
    when(osEnv.getRoutes()).thenReturn(allRoutes);
    when(osEnv.getPodsCopy()).thenReturn(allPods);
    when(osEnv.getSecrets()).thenReturn(ImmutableMap.of("secret", new Secret()));
    when(osEnv.getConfigMaps()).thenReturn(ImmutableMap.of("configMap", new ConfigMap()));
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) Container(io.fabric8.kubernetes.api.model.Container) Pod(io.fabric8.kubernetes.api.model.Pod) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) RuntimeEventsPublisher(org.eclipse.che.workspace.infrastructure.kubernetes.util.RuntimeEventsPublisher) OpenShiftServerResolverFactory(org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 Container (io.fabric8.kubernetes.api.model.Container)2 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 Secret (io.fabric8.kubernetes.api.model.Secret)2 RuntimeEventsPublisher (org.eclipse.che.workspace.infrastructure.kubernetes.util.RuntimeEventsPublisher)2 OpenShiftServerResolverFactory (org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 BeforeMethod (org.testng.annotations.BeforeMethod)2