Commit 32e580e0 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added check to test the was trying to connect to sure-tosca

parent 4abc6571
......@@ -167,7 +167,8 @@ public class DRIPService {
return toscaTemplate;
}
void deleteActions(ToscaTemplate toscaTemplate) throws ApiException, TypeExeption {
void deleteActions(ToscaTemplate toscaTemplate) throws ApiException, TypeExeption, IOException {
helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplateMap vmTopology : vmTopologies){
CloudsStormSubTopology.StatusEnum status = helper.getVMTopologyTemplateStatus(vmTopology);
......
......@@ -28,6 +28,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
......@@ -37,12 +39,14 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.Swagger2SpringBoot;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.configuration.MongoConfig;
import nl.uva.sne.drip.model.tosca.Credential;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
......@@ -73,6 +77,9 @@ public class ServiceTests {
private WebApplicationContext wac;
private MockMvc mockMvc;
@Value("${sure-tosca.base.path}")
private String sureToscaBasePath;
private static final MongodStarter starter = MongodStarter.getDefaultInstance();
private static MongodExecutable _mongodExe;
private static MongodProcess _mongod;
......@@ -213,6 +220,7 @@ public class ServiceTests {
*/
@Test
public void testToscaTemplateServiceDeleteByID() {
if (isServiceUp(sureToscaBasePath)) {
try {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "deleteByID");
if (toscaTemplateID == null) {
......@@ -236,6 +244,21 @@ public class ServiceTests {
}
}
}
public static Boolean isServiceUp(String serviceBasePath) {
try {
URL serviceUrl = new URL(serviceBasePath);
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
//Set request to header to reduce load as Subirkumarsao said.
connection.setRequestMethod("HEAD");
int code = connection.getResponseCode();
} catch (IOException ex) {
return false;
}
return true;
}
/**
* Test of getAllIds method, of class ToscaTemplateService.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment