Search in sources :

Example 81 with InfrastructureException

use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.

the class ServersCheckerTest method awaitShouldReturnOnFirstUnavailability.

@Test(timeOut = 5000)
public void awaitShouldReturnOnFirstUnavailability() throws Exception {
    CompletableFuture<String> future1 = spy(new CompletableFuture<>());
    CompletableFuture<String> future2 = spy(new CompletableFuture<>());
    CompletableFuture<String> future3 = spy(new CompletableFuture<>());
    when(connectionChecker.getReportCompFuture()).thenReturn(future1).thenReturn(future2).thenReturn(future3);
    checker.startAsync(readinessHandler);
    future2.completeExceptionally(new InfrastructureException("error"));
    try {
        checker.await();
        fail();
    } catch (InfrastructureException ignored) {
        verify(future1, never()).complete(anyString());
        verify(future2, never()).complete(anyString());
        verify(future3, never()).complete(anyString());
        verify(future1, never()).completeExceptionally(any(Throwable.class));
        verify(future2).completeExceptionally(any(Throwable.class));
        verify(future3, never()).completeExceptionally(any(Throwable.class));
    }
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) Test(org.testng.annotations.Test)

Example 82 with InfrastructureException

use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.

the class ServersCheckerTest method throwsExceptionIfAnyServerIsNotAvailable.

@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "oops!")
public void throwsExceptionIfAnyServerIsNotAvailable() throws InfrastructureException {
    doThrow(new InfrastructureException("oops!")).when(connectionChecker).checkOnce(any());
    checker.checkOnce(ref -> {
    });
}
Also used : InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) Test(org.testng.annotations.Test)

Example 83 with InfrastructureException

use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.

the class RecipeRetriever method prepareURL.

private URL prepareURL(String location) throws InfrastructureException {
    URI uri;
    try {
        uri = new URI(location);
    } catch (URISyntaxException e) {
        LOG.debug(e.getLocalizedMessage(), e);
        throw new InfrastructureException("Location of recipe downloading is not supported because it is not a valid URI");
    }
    // if URI to this server add token to access protected API
    boolean addToken = isTokenNeeded(uri);
    UriBuilder uriBuilder = makeURIAbsolute(uri);
    if (addToken) {
        addToken(uriBuilder);
    }
    try {
        return uriBuilder.build().toURL();
    } catch (MalformedURLException e) {
        LOG.debug(e.getLocalizedMessage(), e);
        throw new InfrastructureException("Constructing URL for downloading recipe failed");
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) UriBuilder(jakarta.ws.rs.core.UriBuilder) URI(java.net.URI) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException)

Example 84 with InfrastructureException

use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.

the class PluginFQNParser method parsePluginFQNs.

private Collection<PluginFQN> parsePluginFQNs(String attribute) throws InfrastructureException {
    String[] plugins = splitAttribute(attribute);
    if (plugins.length == 0) {
        return emptyList();
    }
    List<PluginFQN> collectedFQNs = new ArrayList<>();
    for (String plugin : plugins) {
        PluginFQN pFQN = parsePluginFQN(plugin);
        String pluginKey = firstNonNull(pFQN.getReference(), pFQN.getId());
        if (collectedFQNs.stream().anyMatch(p -> pluginKey.equals(p.getId()) || pluginKey.equals(p.getReference()))) {
            throw new InfrastructureException(format("Invalid Che tooling plugins configuration: plugin %s is duplicated", // even if different registries
            pluginKey));
        }
        collectedFQNs.add(pFQN);
    }
    return collectedFQNs;
}
Also used : ExtendedPluginFQN(org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN) PluginFQN(org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN) ArrayList(java.util.ArrayList) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException)

Example 85 with InfrastructureException

use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.

the class PluginFQNParser method parsePluginFQN.

public ExtendedPluginFQN parsePluginFQN(String plugin) throws InfrastructureException {
    String url;
    String id;
    String publisher;
    String name;
    String version;
    URI registryURI = null;
    Matcher matcher = PLUGIN_PATTERN.matcher(plugin);
    if (matcher.matches()) {
        url = matcher.group("url");
        id = matcher.group("id");
        publisher = matcher.group("publisher");
        name = matcher.group("name");
        version = matcher.group("version");
    } else {
        throw new InfrastructureException(format(INCORRECT_PLUGIN_FORMAT_TEMPLATE, plugin));
    }
    if (!isNullOrEmpty(url)) {
        if (isNullOrEmpty(id)) {
            // reference only
            return new ExtendedPluginFQN(url);
        } else {
            // registry + id
            try {
                registryURI = new URI(url);
            } catch (URISyntaxException e) {
                throw new InfrastructureException(format("Plugin registry URL '%s' is invalid. Problematic plugin entry: '%s'", url, plugin));
            }
        }
    }
    return new ExtendedPluginFQN(registryURI, id, publisher, name, version);
}
Also used : Matcher(java.util.regex.Matcher) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ExtendedPluginFQN(org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException)

Aggregations

InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)242 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)64 Test (org.testng.annotations.Test)56 KubernetesInfrastructureException (org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInfrastructureException)44 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)42 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)38 CompletableFuture (java.util.concurrent.CompletableFuture)36 ExecutionException (java.util.concurrent.ExecutionException)36 TimeoutException (java.util.concurrent.TimeoutException)32 ServerException (org.eclipse.che.api.core.ServerException)32 Pod (io.fabric8.kubernetes.api.model.Pod)30 Map (java.util.Map)26 ValidationException (org.eclipse.che.api.core.ValidationException)22 Traced (org.eclipse.che.commons.annotation.Traced)20 Container (io.fabric8.kubernetes.api.model.Container)18 List (java.util.List)18 Set (java.util.Set)18 Inject (javax.inject.Inject)18 RuntimeStartInterruptedException (org.eclipse.che.api.workspace.server.spi.RuntimeStartInterruptedException)18 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)18