diff options
Diffstat (limited to 'runtime')
8 files changed, 441 insertions, 110 deletions
diff --git a/runtime/extra/sql/bulkload/create-db.sql b/runtime/extra/sql/bulkload/create-db.sql index ea4d97c1b..5fa34ca04 100644 --- a/runtime/extra/sql/bulkload/create-db.sql +++ b/runtime/extra/sql/bulkload/create-db.sql @@ -7,5 +7,9 @@ USE `cldsdb4`; DROP USER 'clds'; CREATE USER 'clds'; GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION; +CREATE DATABASE `controlloop`; +USE `controlloop`; +DROP USER 'policy'; +CREATE USER 'policy'; +GRANT ALL on controlloop.* to 'policy' identified by 'P01icY' with GRANT OPTION; FLUSH PRIVILEGES; - diff --git a/runtime/pom.xml b/runtime/pom.xml index 444bc325e..3a8ece35b 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -97,6 +97,9 @@ <ui.react.src>ui-react</ui.react.src> <ui.react.lib.src>ui-react-lib</ui.react.lib.src> <npm.publish.url>https://nexus3.onap.org/repository/npm.snapshot/</npm.publish.url> + + <!-- This property triggers generation of the Swagger documents --> + <swagger.generation.phase>post-integration-test</swagger.generation.phase> </properties> <profiles> @@ -152,6 +155,7 @@ </properties> </profile> </profiles> + <dependencyManagement> <dependencies> <dependency> @@ -555,94 +559,7 @@ </executions> </plugin> - <!-- Read the swagger.json file and the definition from SwaggerConfig.java; generate - a list of .adoc files containing the APIs info in more structured way --> - <plugin> - <groupId>io.github.swagger2markup</groupId> - <artifactId>swagger2markup-maven-plugin</artifactId> - <version>1.3.3</version> - <dependencies> - <dependency> - <groupId>io.github.swagger2markup</groupId> - <artifactId>swagger2markup-import-files-ext</artifactId> - <version>1.3.3</version> - </dependency> - <dependency> - <groupId>io.github.swagger2markup</groupId> - <artifactId>swagger2markup-spring-restdocs-ext</artifactId> - <version>1.3.3</version> - </dependency> - </dependencies> - <configuration> - <swaggerInput>${project.build.directory}/swagger/swagger.json</swaggerInput> - <outputDir>${project.build.directory}/asciidoc/generated</outputDir> - <config> - <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage> - </config> - </configuration> - <executions> - <execution> - <phase>post-integration-test</phase> - <goals> - <goal>convertSwagger2markup</goal> - </goals> - </execution> - </executions> - </plugin> - - <!-- Run the generated asciidoc through Asciidoctor to generate other documentation - types, such as PDFs or HTML5 --> - <plugin> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctor-maven-plugin</artifactId> - <version>1.5.7.1</version> - <dependencies> - <dependency> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctorj-pdf</artifactId> - <version>1.5.0-alpha.10.1</version> - </dependency> - </dependencies> - <configuration> - <sourceDirectory>${project.basedir}/src/main/resources/asciidoc</sourceDirectory> - <sourceDocumentName>swagger.adoc</sourceDocumentName> - <attributes> - <doctype>book</doctype> - <toc>left</toc> - <toclevels>3</toclevels> - <numbered/> - <hardbreaks/> - <sectlinks/> - <sectanchors/> - <generated>${project.build.directory}/asciidoc/generated</generated> - </attributes> - </configuration> - <executions> - <execution> - <id>output-html</id> - <phase>post-integration-test</phase> - <goals> - <goal>process-asciidoc</goal> - </goals> - <configuration> - <backend>html5</backend> - <outputDirectory>${project.build.directory}/swagger</outputDirectory> - </configuration> - </execution> - <execution> - <id>output-pdf</id> - <phase>post-integration-test</phase> - <goals> - <goal>process-asciidoc</goal> - </goals> - <configuration> - <backend>pdf</backend> - <outputDirectory>${project.build.directory}/swagger</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> <plugin> <groupId>org.codehaus.groovy.maven</groupId> <artifactId>gmaven-plugin</artifactId> diff --git a/runtime/src/main/resources/asciidoc/swagger.adoc b/runtime/src/main/resources/asciidoc/swagger.adoc deleted file mode 100644 index 6896747fd..000000000 --- a/runtime/src/main/resources/asciidoc/swagger.adoc +++ /dev/null @@ -1,4 +0,0 @@ -include::{generated}/overview.adoc[] -include::{generated}/paths.adoc[] -include::{generated}/security.adoc[] -include::{generated}/definitions.adoc[]
\ No newline at end of file diff --git a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 4b07f6458..677ec64c9 100644 --- a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -1475,7 +1475,7 @@ <constant>application/json</constant> </setHeader> <setProperty name="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">true</simple> + <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:get-service-template"/> <to @@ -1509,7 +1509,7 @@ <route> <removeHeaders pattern="*"/> <setProperty name="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">true</simple> + <simple resultType="java.lang.Boolean">false</simple> </setProperty> <setHeader name="Content-Type"> <constant>application/json</constant> @@ -1543,6 +1543,50 @@ </route> </post> + <delete uri="/v2/toscaControlLoop/decommissionToscaTemplate" + type="java.lang.String" + consumes="plain/text" + outType="java.lang.String" + produces="application/json" + bindingMode="off"> + <route> + <removeHeaders pattern="*" + excludePattern="name|version|requestId"/> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <doTry> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Delete Tosca Service Template')"/> + <to + uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')"/> + <to uri="direct:decommission-service-template"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> + <log loggingLevel="ERROR" + message="Decommissioning of Tosca Service Template FAILED"/> + + <setHeader name="CamelHttpResponseCode"> + <constant>500</constant> + </setHeader> + <setBody> + <simple>Decommissioning Tosca Service Template FAILED</simple> + </setBody> + </doCatch> + </doTry> + </route> + </delete> + <get uri="/v2/toscaControlLoop/getToscaInstantiation" outType="java.lang.String" bindingMode="off" produces="application/json"> <route> <doTry> @@ -1610,6 +1654,111 @@ </route> </get> + <get uri="/v2/toscaControlLoop/getElementDefinitions" outType="java.lang.String" bindingMode="off" produces="application/json"> + <route> + <removeHeaders pattern="*" + excludePattern="name|version|requestId"/> + <doTry> + <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Json Schema ')"/> + <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')"/> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> + <to uri="direct:get-element-definitions"/> + <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> + <log loggingLevel="ERROR" + message="GET Element Definitions request failed: ${exception.stacktrace}"/> + <setHeader name="CamelHttpResponseCode"> + <constant>500</constant> + </setHeader> + <setBody> + <simple>GET JSON Schema FAILED</simple> + </setBody> + </doCatch> + </doTry> + </route> + </get> + + <get uri="/v2/toscaControlLoop/getControlLoopDefinitions" outType="java.lang.String" bindingMode="off" produces="application/json"> + <route> + <removeHeaders pattern="*" + excludePattern="name|version|requestId"/> + <doTry> + <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Json Schema ')"/> + <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')"/> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> + <to uri="direct:get-control-loop-definitions"/> + <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> + <log loggingLevel="ERROR" + message="GET Control Loop Definitions request failed: ${exception.stacktrace}"/> + <setHeader name="CamelHttpResponseCode"> + <constant>500</constant> + </setHeader> + <setBody> + <simple>GET Control Loop Definitions FAILED</simple> + </setBody> + </doCatch> + </doTry> + </route> + </get> + + <get uri="/v2/toscaControlLoop/getCommonOrInstanceProperties" outType="java.lang.String" bindingMode="off" produces="application/json"> + <route> + <removeHeaders pattern="*" + excludePattern="name|version|requestId|common"/> + <doTry> + <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Common Properties ')"/> + <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')"/> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:get-common-or-instance-properties"/> + <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> + <log loggingLevel="ERROR" + message="GET Common Or Instance Properties request failed: ${exception.stacktrace}"/> + <setHeader name="CamelHttpResponseCode"> + <constant>500</constant> + </setHeader> + <setBody> + <simple>GET Common Properties FAILED</simple> + </setBody> + </doCatch> + </doTry> + </route> + </get> + <post uri="/v2/toscaControlLoop/postToscaInstantiation" type="java.lang.String" consumes="plain/text" diff --git a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml index 6ee2572b3..ff39200b7 100644 --- a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml +++ b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml @@ -54,6 +54,37 @@ </doFinally> </doTry> </route> + <route id="decommission-service-template"> + <from uri="direct:decommission-service-template"/> + <doTry> + <log loggingLevel="INFO" + message="Decommissioning the tosca service template"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Controlloop', 'Decommissioning the tosca service template')"/> + <setHeader name="CamelHttpMethod"> + <constant>DELETE</constant> + </setHeader> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setProperty name="name"> + <simple>${header.name}</simple> + </setProperty> + <setProperty name="version"> + <simple>${header.version}</simple> + </setProperty> + <log loggingLevel="INFO" + message="Endpoint to send Tosca Service Template: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission"></log> + <toD + uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission?name=${exchangeProperty[name]}&version=${exchangeProperty[version]}&bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> <route id="get-tosca-instantiation"> <from uri="direct:get-tosca-instantiation"/> <doTry> @@ -157,4 +188,82 @@ </doFinally> </doTry> </route> + <route id="get-element-definitions"> + <from uri="direct:get-element-definitions"/> + <doTry> + <log loggingLevel="INFO" + message="Getting the Control Loop Element Definitions"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('ControlLoop', 'Getting the Controlloop Element Definitions')"/> + <setHeader name="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get Json Schema: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/elements"></log> + <toD + uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/elements?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> + <route id="get-control-loop-definitions"> + <from uri="direct:get-control-loop-definitions"/> + <doTry> + <log loggingLevel="INFO" + message="Getting the Control Loop Definitions"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('ControlLoop', 'Getting the Controlloop Element Definitions')"/> + <setHeader name="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get Json Schema: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/elements"></log> + <toD + uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission? bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> + <route id="get-common-or-instance-properties"> + <from uri="direct:get-common-or-instance-properties"/> + <doTry> + <log loggingLevel="INFO" + message="Getting Common Or Instance Properties"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('ControlLoop', 'Getting Common Or Instance Properties')"/> + <setHeader name="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader name="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setProperty name="common"> + <simple>${header.common}</simple> + </setProperty> + <log loggingLevel="INFO" + message="Endpoint to get Common Or Instance Properties: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/getCommonOrInstanceProperties"></log> + <toD + uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/getCommonOrInstanceProperties?common=${exchangeProperty[common]}&bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> </routes> diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java index 7616d7a49..f4e171174 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java @@ -102,4 +102,96 @@ public class RuntimeCommissioningResponseTestItCase { assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) .is2xxSuccessful()).isTrue(); } + + @Test + public void testDecommissioningOfToscaServiceTemplateStatus() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send("direct:decommission-service-template", ExchangeBuilder.anExchange(camelContext) + .withProperty("name", "ToscaServiceTemplate") + .withProperty("version", "1.0.0") + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } + + @Test + public void testGetControlLoopDefinitions() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send("direct:get-control-loop-definitions", ExchangeBuilder.anExchange(camelContext) + .withProperty("name", "ToscaServiceTemplate") + .withProperty("version", "1.0.0") + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } + + @Test + public void testGetControlLoopElementDefinitions() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send("direct:get-element-definitions", ExchangeBuilder.anExchange(camelContext) + .withProperty("name", "ToscaServiceTemplate") + .withProperty("version", "1.0.0") + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } + + @Test + public void testGetCommonOrInstancePropertiesCommonTrue() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send("direct:get-common-or-instance-properties", ExchangeBuilder.anExchange(camelContext) + .withProperty("name", "ToscaServiceTemplate") + .withProperty("version", "1.0.0") + .withProperty("common", true) + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } + + @Test + public void testGetCommonOrInstancePropertiesCommonFalse() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send("direct:get-common-or-instance-properties", ExchangeBuilder.anExchange(camelContext) + .withProperty("name", "ToscaServiceTemplate") + .withProperty("version", "1.0.0") + .withProperty("common", false) + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } + + @Test + public void testGetCommonOrInstancePropertiesCommonMissing() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send("direct:get-common-or-instance-properties", ExchangeBuilder.anExchange(camelContext) + .withProperty("name", "ToscaServiceTemplate") + .withProperty("version", "1.0.0") + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } } diff --git a/runtime/src/test/resources/http-cache/example/node_template.json b/runtime/src/test/resources/http-cache/example/node_template.json new file mode 100644 index 000000000..fdbfe8563 --- /dev/null +++ b/runtime/src/test/resources/http-cache/example/node_template.json @@ -0,0 +1,44 @@ +{ + "org.onap.domain.pmsh.PMSHControlLoopDefinition": { + "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.ControlLoop", + "type_version": "1.0.0", + "properties": { + "elements": [ + { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + } + ], + "provider": "Ericsson" + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.ControlLoop", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", + "defined_version": "1.2.3" + } +} diff --git a/runtime/src/test/resources/http-cache/third_party_proxy.py b/runtime/src/test/resources/http-cache/third_party_proxy.py index 1aaf4024d..013388197 100644 --- a/runtime/src/test/resources/http-cache/third_party_proxy.py +++ b/runtime/src/test/resources/http-cache/third_party_proxy.py @@ -107,6 +107,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): def _get_cached_header_file_name(self,cached_file_folder): return "%s/.header" % (cached_file_folder,) + def _create_cache(self, generated_json, cached_file_folder, cached_file_header, cached_file_content): + print "jsonGenerated: " + generated_json + if not os.path.exists(cached_file_folder): + os.makedirs(cached_file_folder, 0775) + with open(cached_file_header, 'w+') as f: + f.write("{\"Content-Length\": \"" + str(len(generated_json)) + "\", \"Content-Type\": \"application/json\"}") + with open(cached_file_content, 'w+') as f: + f.write(generated_json) + def _execute_content_generated_cases(self,http_type): print("Testing special cases, cache files will be sent to :" +TMP_ROOT) cached_file_folder = self._get_cached_file_folder_name(TMP_ROOT) @@ -274,14 +283,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): print ("cached file folder for onap is %s: ", cached_file_folder) print "self.path start with /onap/controlloop/v2/commission/, generating response json..." jsonGenerated = "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\"data_types\": {},\"node_types\": {}, \"policy_types\": {}, \"topology_template\": {}, \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}" - print "jsonGenerated: " + jsonGenerated - if not os.path.exists(cached_file_folder): - os.makedirs(cached_file_folder, 0777) - - with open(cached_file_header, 'w+') as f: - f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}") - with open(cached_file_content, 'w+') as f: - f.write(jsonGenerated) + self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True elif (self.path.startswith("/onap/controlloop/v2/commission/toscaServiceTemplateSchema")) and http_type == "GET": if not _file_available: @@ -289,14 +291,27 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): print ("cached file folder for onap is %s: ", cached_file_folder) print "self.path start with /onap/controlloop/v2/commission/, generating response json..." jsonGenerated = "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\"data_types\": {},\"node_types\": {}, \"policy_types\": {}, \"topology_template\": {}, \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}" - print "jsonGenerated: " + jsonGenerated - if not os.path.exists(cached_file_folder): - os.makedirs(cached_file_folder, 0777) - - with open(cached_file_header, 'w+') as f: - f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}") - with open(cached_file_content, 'w+') as f: - f.write(jsonGenerated) + self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) + return True + elif (self.path.startswith("/onap/controlloop/v2/commission/elements")) and http_type == "GET": + if not _file_available: + print "self.path start with /commission/elements Control Loop Elements, generating response json..." + jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSH_DCAEMicroservice\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]" + self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) + return True + elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "GET": + if not _file_available: + print "self.path start with /commission control loop definition, generating response json..." + #jsondata = json.loads(self.data_string) + jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSHControlLoopDefinition\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]" + self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) + return True + elif (self.path.startswith("/onap/controlloop/v2/commission/getCommonOrInstanceProperties")) and http_type == "GET": + if not _file_available: + print "self.path start with /commission getting common properties, generating response json..." + with open("example/node_template.json", "r") as f: + jsonGenerated = f.read() + self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "POST": print "self.path start with POST /onap/controlloop/v2/commission, copying body to response ..." @@ -307,6 +322,11 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): with open(cached_file_content, 'w+') as f: f.write(self.data_string) return True + elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "DELETE": + print "self.path start with /commission Decommissioning, generating response json..." + jsonGenerated = "{\"errorDetails\": null,\"affectedControlLoopDefinitions\": [{ \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\" }]}" + self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) + return True else: return False |