This is an automated email from the ASF dual-hosted git repository. ofuks pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push: new afeab1a [DLAB-1389] Added endpoint status (#505) afeab1a is described below commit afeab1a0c78d3c430ecf5cc67d5dbb61b23eb8e2 Author: ofuks <54886119+of...@users.noreply.github.com> AuthorDate: Thu Dec 26 16:46:52 2019 +0200 [DLAB-1389] Added endpoint status (#505) * [DLAB-1389] Added endpoint status --- .../backendapi/ProvisioningServiceApplication.java | 3 ++ .../healthcheck/ProvisioningHealthCheck.java | 30 +++++++++++ .../resources/ProvisioningHealthCheckResource.java | 47 +++++++++++++++++ services/self-service/self-service.yml | 3 ++ .../com/epam/dlab/backendapi/dao/EndpointDAO.java | 24 +++++++++ .../epam/dlab/backendapi/dao/EndpointDAOImpl.java | 39 +++++++++++++- .../epam/dlab/backendapi/domain/EndpointDTO.java | 31 ++++++++++- .../backendapi/resources/EndpointResource.java | 36 ++++++++++++- .../endpoint/CheckEndpointStatusScheduler.java | 60 ++++++++++++++++++++++ .../dlab/backendapi/service/EndpointService.java | 8 ++- .../service/impl/EndpointServiceImpl.java | 44 ++++++++++++++-- .../service/impl/ComputationalServiceImplTest.java | 2 +- .../service/impl/ExploratoryServiceImplTest.java | 2 +- .../service/impl/GitCredentialServiceImplTest.java | 2 +- .../impl/ImageExploratoryServiceImplTest.java | 2 +- .../InfrastructureTemplateServiceBaseTest.java | 2 +- .../service/impl/LibraryServiceImplTest.java | 2 +- 17 files changed, 324 insertions(+), 13 deletions(-) diff --git a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/ProvisioningServiceApplication.java b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/ProvisioningServiceApplication.java index e4fd269..5cc0d2d 100644 --- a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/ProvisioningServiceApplication.java +++ b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/ProvisioningServiceApplication.java @@ -24,6 +24,7 @@ import com.epam.dlab.auth.UserInfo; import com.epam.dlab.backendapi.core.DirectoriesCreator; import com.epam.dlab.backendapi.core.DockerWarmuper; import com.epam.dlab.backendapi.core.response.handlers.ComputationalConfigure; +import com.epam.dlab.backendapi.healthcheck.ProvisioningHealthCheck; import com.epam.dlab.backendapi.modules.CloudModuleConfigurator; import com.epam.dlab.backendapi.modules.ModuleFactory; import com.epam.dlab.backendapi.resources.*; @@ -128,6 +129,7 @@ public class ProvisioningServiceApplication extends Application<ProvisioningServ environment.lifecycle().manage(injector.getInstance(RestoreCallbackHandlerServiceImpl.class)); } environment.lifecycle().manage(injector.getInstance(DockerWarmuper.class)); + environment.healthChecks().register("ProvisioningHealthCheck", new ProvisioningHealthCheck()); JerseyEnvironment jersey = environment.jersey(); @@ -144,6 +146,7 @@ public class ProvisioningServiceApplication extends Application<ProvisioningServ jersey.register(injector.getInstance(KeyResource.class)); jersey.register(injector.getInstance(CallbackHandlerResource.class)); jersey.register(injector.getInstance(ProjectResource.class)); + jersey.register(new ProvisioningHealthCheckResource(environment.healthChecks())); } } diff --git a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/healthcheck/ProvisioningHealthCheck.java b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/healthcheck/ProvisioningHealthCheck.java new file mode 100644 index 0000000..75fcb47 --- /dev/null +++ b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/healthcheck/ProvisioningHealthCheck.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.epam.dlab.backendapi.healthcheck; + +import com.codahale.metrics.health.HealthCheck; + +public class ProvisioningHealthCheck extends HealthCheck { + + @Override + protected Result check() { + return Result.healthy(); + } +} \ No newline at end of file diff --git a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ProvisioningHealthCheckResource.java b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ProvisioningHealthCheckResource.java new file mode 100644 index 0000000..cf93523 --- /dev/null +++ b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/ProvisioningHealthCheckResource.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.epam.dlab.backendapi.resources; + +import com.codahale.metrics.health.HealthCheckRegistry; +import com.epam.dlab.auth.UserInfo; +import io.dropwizard.auth.Auth; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/healthcheck") +@Produces(MediaType.APPLICATION_JSON) +public class ProvisioningHealthCheckResource { + private static final String HEALTH_CHECK= "ProvisioningHealthCheck"; + + private HealthCheckRegistry registry; + + public ProvisioningHealthCheckResource(HealthCheckRegistry registry) { + this.registry = registry; + } + + @GET + public Response status(@Auth UserInfo ui) { + return Response.ok(registry.runHealthCheck(HEALTH_CHECK)).build(); + } +} \ No newline at end of file diff --git a/services/self-service/self-service.yml b/services/self-service/self-service.yml index ab6dfd9..9edca97 100644 --- a/services/self-service/self-service.yml +++ b/services/self-service/self-service.yml @@ -155,6 +155,9 @@ schedulers: checkProjectQuoteScheduler: enabled: true cron: "0 * * ? * * *" + checkEndpointStatusScheduler: + enabled: true + cron: "0 */15 * ? * *" guacamole: diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAO.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAO.java index 9b85bc3..bb2597b 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAO.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAO.java @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package com.epam.dlab.backendapi.dao; import com.epam.dlab.backendapi.domain.EndpointDTO; @@ -7,9 +26,14 @@ import java.util.Optional; public interface EndpointDAO { List<EndpointDTO> getEndpoints(); + + List<EndpointDTO> getEndpointsWithStatus(String status); + Optional<EndpointDTO> get(String name); void create(EndpointDTO endpointDTO); + void updateEndpointStatus(String name, String status); + void remove(String name); } diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAOImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAOImpl.java index a614773..5dc9e46 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAOImpl.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/dao/EndpointDAOImpl.java @@ -1,6 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package com.epam.dlab.backendapi.dao; import com.epam.dlab.backendapi.domain.EndpointDTO; +import org.bson.Document; import org.bson.conversions.Bson; import java.util.List; @@ -11,6 +31,8 @@ import static com.mongodb.client.model.Filters.eq; public class EndpointDAOImpl extends BaseDAO implements EndpointDAO { private static final String ENDPOINTS_COLLECTION = "endpoints"; + private static final String ENDPOINT_NAME_FIELD = "name"; + private static final String ENDPOINT_STATUS_FIELD = "status"; @Override public List<EndpointDTO> getEndpoints() { @@ -18,6 +40,11 @@ public class EndpointDAOImpl extends BaseDAO implements EndpointDAO { } @Override + public List<EndpointDTO> getEndpointsWithStatus(String status) { + return find(ENDPOINTS_COLLECTION, endpointStatusCondition(status), EndpointDTO.class); + } + + @Override public Optional<EndpointDTO> get(String name) { return findOne(ENDPOINTS_COLLECTION, endpointCondition(name), EndpointDTO.class); } @@ -28,11 +55,21 @@ public class EndpointDAOImpl extends BaseDAO implements EndpointDAO { } @Override + public void updateEndpointStatus(String name, String status) { + final Document updatedFiled = new Document(ENDPOINT_STATUS_FIELD, status); + updateOne(ENDPOINTS_COLLECTION, endpointCondition(name), new Document(SET, updatedFiled)); + } + + @Override public void remove(String name) { deleteOne(ENDPOINTS_COLLECTION, endpointCondition(name)); } private Bson endpointCondition(String name) { - return eq("name", name); + return eq(ENDPOINT_NAME_FIELD, name); + } + + private Bson endpointStatusCondition(String status) { + return eq(ENDPOINT_STATUS_FIELD, status); } } diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/EndpointDTO.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/EndpointDTO.java index 378d71b..c5a2d40 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/EndpointDTO.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/EndpointDTO.java @@ -1,10 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package com.epam.dlab.backendapi.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; -import javax.annotation.RegEx; @Data @JsonIgnoreProperties(ignoreUnknown = true) @@ -16,4 +34,15 @@ public class EndpointDTO { private final String account; @JsonProperty("endpoint_tag") private final String tag; + private final EndpointStatus status; + + public static EndpointDTO withEndpointStatus(EndpointDTO endpointDTO) { + return new EndpointDTO(endpointDTO.getName(), endpointDTO.getUrl(), endpointDTO.getAccount(), + endpointDTO.getTag(), EndpointDTO.EndpointStatus.ACTIVE); + } + + public enum EndpointStatus { + ACTIVE, + INACTIVE + } } diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/EndpointResource.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/EndpointResource.java index 3a6d9de..71873eb 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/EndpointResource.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/EndpointResource.java @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package com.epam.dlab.backendapi.resources; import com.epam.dlab.auth.UserInfo; @@ -52,7 +71,7 @@ public class EndpointResource { @Consumes(MediaType.APPLICATION_JSON) @POST public Response createEndpoint(@Parameter(hidden = true) @Auth UserInfo userInfo, EndpointDTO endpointDTO) { - endpointService.create(endpointDTO); + endpointService.create(userInfo, endpointDTO); final URI uri = uriInfo.getRequestUriBuilder().path(endpointDTO.getName()).build(); return Response .ok() @@ -122,4 +141,19 @@ public class EndpointResource { endpointService.remove(userInfo, name, withResources); return Response.ok().build(); } + + @Operation(summary = "Check whether endpoint url is valid", tags = "endpoint") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Valid endpoint url"), + @ApiResponse(responseCode = "404", description = "Endpoint url is not valid"), + }) + @GET + @Path("url/{url}") + @Produces(MediaType.APPLICATION_JSON) + public Response checkEndpointUrl(@Parameter(hidden = true) @Auth UserInfo userInfo, + @Parameter(description = "Endpoint url") + @PathParam("url") String url) { + endpointService.checkEndpointUrl(userInfo, url); + return Response.ok().build(); + } } diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/schedulers/endpoint/CheckEndpointStatusScheduler.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/schedulers/endpoint/CheckEndpointStatusScheduler.java new file mode 100644 index 0000000..658370a --- /dev/null +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/schedulers/endpoint/CheckEndpointStatusScheduler.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.epam.dlab.backendapi.schedulers.endpoint; + +import com.epam.dlab.auth.UserInfo; +import com.epam.dlab.backendapi.domain.EndpointDTO; +import com.epam.dlab.backendapi.schedulers.internal.Scheduled; +import com.epam.dlab.backendapi.service.EndpointService; +import com.epam.dlab.backendapi.service.SecurityService; +import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import org.quartz.Job; +import org.quartz.JobExecutionContext; + +@Scheduled("checkEndpointStatusScheduler") +@Slf4j +public class CheckEndpointStatusScheduler implements Job { + + @Inject + private EndpointService endpointService; + @Inject + private SecurityService securityService; + + @Override + public void execute(JobExecutionContext jobExecutionContext) { + UserInfo serviceUser = securityService.getServiceAccountInfo("admin"); + endpointService.getEndpointsWithStatus(EndpointDTO.EndpointStatus.ACTIVE).stream() + .filter(endpoint -> checkUrl(serviceUser, endpoint)) + .peek(e -> log.warn("Failed connecting to endpoint {}, url: \'{}\'", e.getName(), e.getUrl())) + .forEach(e -> endpointService.updateEndpointStatus(e.getName(), EndpointDTO.EndpointStatus.INACTIVE)); + } + + private boolean checkUrl(UserInfo serviceUser, EndpointDTO endpoint) { + try { + endpointService.checkEndpointUrl(serviceUser, endpoint.getUrl()); + } catch (Exception e) { + return true; + } + return false; + } + + +} diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/EndpointService.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/EndpointService.java index 9e26da7..456d330 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/EndpointService.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/EndpointService.java @@ -10,13 +10,19 @@ import java.util.List; public interface EndpointService { List<EndpointDTO> getEndpoints(); + List<EndpointDTO> getEndpointsWithStatus(EndpointDTO.EndpointStatus status); + EndpointResourcesDTO getEndpointResources(String endpoint); EndpointDTO get(String name); - void create(EndpointDTO endpointDTO); + void create(UserInfo userInfo, EndpointDTO endpointDTO); + + void updateEndpointStatus(String name, EndpointDTO.EndpointStatus status); void remove(UserInfo userInfo, String name, boolean withResources); void removeEndpointInAllProjects(UserInfo userInfo, String endpointName, List<ProjectDTO> projects); + + void checkEndpointUrl(UserInfo userInfo, String url); } diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java index adb9c86..169857d 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java @@ -8,26 +8,38 @@ import com.epam.dlab.backendapi.domain.EndpointResourcesDTO; import com.epam.dlab.backendapi.domain.ProjectDTO; import com.epam.dlab.backendapi.service.EndpointService; import com.epam.dlab.backendapi.service.ProjectService; +import com.epam.dlab.constants.ServiceConsts; import com.epam.dlab.dto.UserInstanceDTO; import com.epam.dlab.dto.UserInstanceStatus; +import com.epam.dlab.exceptions.DlabException; import com.epam.dlab.exceptions.ResourceConflictException; import com.epam.dlab.exceptions.ResourceNotFoundException; +import com.epam.dlab.rest.client.RESTService; import com.google.inject.Inject; +import com.google.inject.name.Named; +import lombok.extern.slf4j.Slf4j; +import javax.ws.rs.core.Response; import java.util.Arrays; import java.util.Collections; import java.util.List; +@Slf4j public class EndpointServiceImpl implements EndpointService { + private static final String HEALTHCHECK = "healthcheck"; private final EndpointDAO endpointDAO; private final ProjectService projectService; private final ExploratoryDAO exploratoryDAO; + private final RESTService provisioningService; @Inject - public EndpointServiceImpl(EndpointDAO endpointDAO, ProjectService projectService, ExploratoryDAO exploratoryDAO) { + public EndpointServiceImpl(EndpointDAO endpointDAO, ProjectService projectService, ExploratoryDAO exploratoryDAO, + @Named(ServiceConsts.PROVISIONING_SERVICE_NAME) RESTService provisioningService) { + this.endpointDAO = endpointDAO; this.projectService = projectService; this.exploratoryDAO = exploratoryDAO; + this.provisioningService = provisioningService; } @Override @@ -36,6 +48,11 @@ public class EndpointServiceImpl implements EndpointService { } @Override + public List<EndpointDTO> getEndpointsWithStatus(EndpointDTO.EndpointStatus status) { + return endpointDAO.getEndpointsWithStatus(status.name()); + } + + @Override public EndpointResourcesDTO getEndpointResources(String endpoint) { List<UserInstanceDTO> exploratories = exploratoryDAO.fetchExploratoriesByEndpointWhereStatusNotIn(endpoint, Arrays.asList(UserInstanceStatus.TERMINATED, UserInstanceStatus.FAILED)); @@ -52,15 +69,21 @@ public class EndpointServiceImpl implements EndpointService { } @Override - public void create(EndpointDTO endpointDTO) { + public void create(UserInfo userInfo, EndpointDTO endpointDTO) { + checkEndpointUrl(userInfo, endpointDTO.getUrl()); if (!endpointDAO.get(endpointDTO.getName()).isPresent()) { - endpointDAO.create(endpointDTO); + endpointDAO.create(EndpointDTO.withEndpointStatus(endpointDTO)); } else { throw new ResourceConflictException("Endpoint with passed name already exist in system"); } } @Override + public void updateEndpointStatus(String name, EndpointDTO.EndpointStatus status) { + endpointDAO.updateEndpointStatus(name, status.name()); + } + + @Override public void remove(UserInfo userInfo, String name, boolean withResources) { List<ProjectDTO> projects = projectService.getProjectsByEndpoint(name); checkProjectEndpointResourcesStatuses(projects, name); @@ -76,6 +99,21 @@ public class EndpointServiceImpl implements EndpointService { projects.forEach(project -> projectService.terminateEndpoint(userInfo, endpointName, project.getName())); } + @Override + public void checkEndpointUrl(UserInfo userInfo, String url) { + Response response; + try { + response = provisioningService.get(url + HEALTHCHECK, userInfo.getAccessToken(), Response.class); + } catch (Exception e) { + log.error("Cannot connect to url \'{}\'", url); + throw new DlabException(String.format("Cannot connect to url \'%s\'", url), e); + } + if (response.getStatus() != 200) { + log.warn("Endpoint url {} is not valid", url); + throw new ResourceNotFoundException(String.format("Endpoint url \'%s\' is not valid", url)); + } + } + private void checkProjectEndpointResourcesStatuses(List<ProjectDTO> projects, String endpoint) { boolean isTerminationEnabled = projects.stream().anyMatch(p -> !projectService.checkExploratoriesAndComputationalProgress(p.getName(), Collections.singletonList(endpoint)) || diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ComputationalServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ComputationalServiceImplTest.java index de9ddd8..33821e6 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ComputationalServiceImplTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ComputationalServiceImplTest.java @@ -736,7 +736,7 @@ public class ComputationalServiceImplTest { } private EndpointDTO endpointDTO() { - return new EndpointDTO("test", "url", "", null); + return new EndpointDTO("test", "url", "", null, EndpointDTO.EndpointStatus.ACTIVE); } diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImplTest.java index 3c7de87..f37071a 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImplTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImplTest.java @@ -589,7 +589,7 @@ public class ExploratoryServiceImplTest { } private EndpointDTO endpointDTO() { - return new EndpointDTO("test", "url", "", null); + return new EndpointDTO("test", "url", "", null, EndpointDTO.EndpointStatus.ACTIVE); } private ProjectDTO getProjectDTO() { diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/GitCredentialServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/GitCredentialServiceImplTest.java index f6191a1..cc1b6ad 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/GitCredentialServiceImplTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/GitCredentialServiceImplTest.java @@ -168,6 +168,6 @@ public class GitCredentialServiceImplTest { } private EndpointDTO endpointDTO() { - return new EndpointDTO("test", "url", "", null); + return new EndpointDTO("test", "url", "", null, EndpointDTO.EndpointStatus.ACTIVE); } } diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ImageExploratoryServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ImageExploratoryServiceImplTest.java index 51eeeee..8082eb7 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ImageExploratoryServiceImplTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/ImageExploratoryServiceImplTest.java @@ -321,6 +321,6 @@ public class ImageExploratoryServiceImplTest { } private EndpointDTO endpointDTO() { - return new EndpointDTO("test", "url", "", null); + return new EndpointDTO("test", "url", "", null, EndpointDTO.EndpointStatus.ACTIVE); } } diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceBaseTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceBaseTest.java index 01dbff6..cf18f82 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceBaseTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/InfrastructureTemplateServiceBaseTest.java @@ -201,6 +201,6 @@ public class InfrastructureTemplateServiceBaseTest { } private EndpointDTO endpointDTO() { - return new EndpointDTO("test", "url", "", null); + return new EndpointDTO("test", "url", "", null, EndpointDTO.EndpointStatus.ACTIVE); } } diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java index 4a076f8..7a9f734 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java @@ -420,7 +420,7 @@ public class LibraryServiceImplTest { } private EndpointDTO endpointDTO() { - return new EndpointDTO("test", "url", "", null); + return new EndpointDTO("test", "url", "", null, EndpointDTO.EndpointStatus.ACTIVE); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org