aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBonkur, Venkat (vb8416) <vb8416@att.com>2019-09-18 02:22:37 -0400
committerBonkur, Venkat (vb8416) <vb8416@att.com>2019-09-18 02:26:01 -0400
commit1ad915ff0a4678d6a5f918f39ea42c18b620f7bb (patch)
tree11228f1bd5f37b50db3d2018329a5f6ed28dfd4c
parente288bedf6a7b83c6127cbb1bc4281084cdbc218e (diff)
Add SO Update Check if SDC activities deployment end point server Up for custom worlflows
Make changes to verify if SDC activities deployment end point(mso.asdc.config.activity.endpoint) server up for custom workflows Issue-ID: SO-2348 Signed-off-by: Bonkur, Venkat (vb8416) <vb8416@att.com> Change-Id: I3b90b6d8e95681a685b23dfaa2f65596532e5b0e
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java13
-rw-r--r--asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java10
-rw-r--r--asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java2
3 files changed, 17 insertions, 8 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
index 7f1c1968c1..d60c377730 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
@@ -65,7 +65,7 @@ public class DeployActivitySpecs {
logger.warn("The hostname for SDC activities deployment is not configured in SO");
return;
}
- if (!checkHttpOk(hostname)) {
+ if (!checkHttpServerUp(hostname)) {
logger.warn("The sdc end point is not alive");
return;
}
@@ -144,21 +144,22 @@ public class DeployActivitySpecs {
return;
}
- public boolean checkHttpOk(String host) {
+ public boolean checkHttpServerUp(String host) {
URL url = null;
- boolean isOk = false;
+ boolean isUp = false;
int responseCode = 0;
try {
url = new URL(host);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setConnectTimeout(5000);
responseCode = connection.getResponseCode();
} catch (Exception e) {
logger.warn("Exception on connecting to SDC WFD endpoint: " + e.getMessage());
}
- if (responseCode == HttpStatus.SC_OK) {
- isOk = true;
+ if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_NOT_FOUND) {
+ isUp = true;
}
- return isOk;
+ return isUp;
}
}
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
index b41fbaf658..75ab089719 100644
--- a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
+++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
@@ -29,7 +29,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Spy;
import org.onap.so.asdc.BaseTest;
import org.onap.so.asdc.activity.DeployActivitySpecs;
import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
@@ -50,6 +52,10 @@ public class DeployActivitySpecsITTest extends BaseTest {
@Autowired
private DeployActivitySpecs deployActivitySpecs;
+ @InjectMocks
+ @Spy
+ DeployActivitySpecs deployActivitySpecsM;
+
@Test
public void deployActivitySpecsIT_Test() throws Exception {
ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
@@ -100,7 +106,9 @@ public class DeployActivitySpecsITTest extends BaseTest {
put(urlPathMatching(urlPath)).willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(org.springframework.http.HttpStatus.OK.value())));
- deployActivitySpecs.deployActivities();
+ String host = "http://localhost:8090";
+ when(deployActivitySpecsM.checkHttpServerUp(host)).thenReturn(false);
+ deployActivitySpecsM.deployActivities();
verify(0, putRequestedFor(urlEqualTo(urlPath)));
}
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
index 7a876a67a2..6d88ab6630 100644
--- a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
+++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
@@ -71,7 +71,7 @@ public class DeployActivitySpecsTest {
new ArrayList<org.onap.so.db.catalog.beans.ActivitySpec>();
catalogActivitySpecList.add(catalogActivitySpec);
when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("http://testEndpoint");
- doReturn(true).when(deployActivitySpecs).checkHttpOk("http://testEndpoint");
+ doReturn(true).when(deployActivitySpecs).checkHttpServerUp("http://testEndpoint");
when(activitySpecRepository.findAll()).thenReturn(catalogActivitySpecList);
doReturn("testActivityId").when(activitySpecsActions).createActivitySpec(Mockito.any(), Mockito.any());
doReturn(true).when(activitySpecsActions).certifyActivitySpec(Mockito.any(), Mockito.any());