diff options
Diffstat (limited to 'adapters/mso-requests-db-adapter/src')
4 files changed, 31 insertions, 41 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql new file mode 100644 index 0000000000..5635a1eb80 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql @@ -0,0 +1,13 @@ +use requestdb; + +CREATE TABLE IF NOT EXISTS cloud_api_requests( +`ID` INT(13) NOT NULL AUTO_INCREMENT, +`REQUEST_BODY` LONGTEXT NOT NULL, +`CLOUD_IDENTIFIER` VARCHAR(200) NULL, +`SO_REQUEST_ID` VARCHAR(45) NOT NULL, +`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`ID`), +CONSTRAINT fk_cloud_api_req_infra_requests + FOREIGN KEY (SO_REQUEST_ID) + REFERENCES infra_active_requests (REQUEST_ID)) +ENGINE = InnoDB DEFAULT CHARSET=latin1;
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java index 514e5ad923..9faba0df67 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java @@ -50,35 +50,10 @@ public class HealthCheckHandlerTest extends RequestsAdapterBase { @Test public void testHealthcheck() throws JSONException { - TestAppender.events.clear(); HttpEntity<String> entity = new HttpEntity<String>(null, headers); - ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - for (ILoggingEvent logEvent : TestAppender.events) - if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") - && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") - && logEvent.getMarker() != null && logEvent.getMarker() != null - && logEvent.getMarker().getName().equals("EXIT")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); - assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } - TestAppender.events.clear(); } private String createURLWithPort(String uri) { diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java index 3b737c6768..03df115574 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java @@ -25,6 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.requestsdb.RequestsAdapterBase; import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.db.request.beans.CloudApiRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; @@ -41,9 +42,9 @@ import java.util.Map; import java.util.HashMap; import java.util.ArrayList; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertFalse; @@ -87,6 +88,14 @@ public class RequestsDbClientTest extends RequestsAdapterBase { infraActiveRequests.setRequestAction("someaction"); infraActiveRequests .setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances"); + List<CloudApiRequests> cloudApiRequests = new ArrayList<>(); + CloudApiRequests cloudRequest = new CloudApiRequests(); + cloudRequest.setCloudIdentifier("heatstackanme/id"); + cloudRequest.setId(1); + cloudRequest.setRequestBody("requestBody"); + cloudRequest.setRequestId(infraActiveRequests.getRequestId()); + cloudApiRequests.add(cloudRequest); + infraActiveRequests.setCloudApiRequests(cloudApiRequests); requestsDbClient.save(infraActiveRequests); } @@ -96,7 +105,8 @@ public class RequestsDbClientTest extends RequestsAdapterBase { private void verifyInfraActiveRequests(InfraActiveRequests infraActiveRequestsResponse) { - assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log")); + assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log") + .ignoring("cloudApiRequests.created").ignoring("cloudApiRequests.id")); } @Test @@ -113,7 +123,6 @@ public class RequestsDbClientTest extends RequestsAdapterBase { verifyInfraActiveRequests(infraActiveRequestsResponse); } - @Test public void checkVnfIdStatusTest() { InfraActiveRequests infraActiveRequestsResponse = @@ -182,7 +191,7 @@ public class RequestsDbClientTest extends RequestsAdapterBase { public void getInfraActiveRequestbyRequestIdWhereRequestUrlNullTest() { // requestUrl setup to null and save infraActiveRequests.setRequestUrl(null); - requestsDbClient.save(infraActiveRequests); + requestsDbClient.updateInfraActiveRequests(infraActiveRequests); InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId()); verifyInfraActiveRequests(infraActiveRequestsResponse); diff --git a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml index d1596cd374..a63bd27378 100644 --- a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml +++ b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml @@ -1,18 +1,7 @@ <configuration> - <property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}"/> - <property name="p_lvl" value="%level"/> - <property name="p_log" value="%logger"/> - <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/> - <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_thr" value="%thread"/> - <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> - <pattern>${pattern}</pattern> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> </encoder> </appender> @@ -44,6 +33,10 @@ <logger name="ch.vorburger" level="WARN" additivity="false"> <appender-ref ref="STDOUT" /> </logger> + + <logger name="org.hibernate" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> <root level="WARN"> |