From 7de549e5589d5e98a798e65752396627f6990fe1 Mon Sep 17 00:00:00 2001 From: ramverma Date: Fri, 17 Aug 2018 20:38:03 +0100 Subject: Adding health check endpoint to distribution * Adding health check REST endpoint to distribution service. * Adding isAlive field to DistributionActivator to fetch the health status. * Adding parameter group for rest server parameters. * Adding DistributionRestController for hosting all the rest endpoints in distribution service. * Adding DistributionRestServer to manage lifecycle of distribution rest server. * Adding ParameterValidationUtils utility class for common validations. Plan is to move this class to policy-common for wider use later. * Adding test cases for all new code added. * Refering common classes from policy/common Change-Id: I246d57133ed1f0c3548bcdee173d7b64fb368abc Issue-ID: POLICY-1035 Signed-off-by: ramverma --- .../parameters/DistributionConfigParameters.json | 6 +++ ...ibutionConfigParameters_EmptyPolicyDecoder.json | 6 +++ ...utionConfigParameters_EmptyPolicyForwarder.json | 6 +++ ...tionConfigParameters_EmptyReceptionHandler.json | 6 +++ .../DistributionConfigParameters_InvalidName.json | 6 +++ ...ConfigParameters_InvalidPolicyDecoderClass.json | 6 +++ ...nConfigParameters_InvalidPolicyDecoderType.json | 6 +++ ...nfigParameters_InvalidPolicyForwarderClass.json | 6 +++ ...onfigParameters_InvalidPolicyForwarderType.json | 6 +++ ...figParameters_InvalidReceptionHandlerClass.json | 6 +++ ...nfigParameters_InvalidReceptionHandlerType.json | 6 +++ ...tionConfigParameters_InvalidRestServerHost.json | 53 ++++++++++++++++++++++ ...ConfigParameters_InvalidRestServerPassword.json | 53 ++++++++++++++++++++++ ...tionConfigParameters_InvalidRestServerPort.json | 53 ++++++++++++++++++++++ ...tionConfigParameters_InvalidRestServerUser.json | 53 ++++++++++++++++++++++ ...stributionConfigParameters_NoPolicyDecoder.json | 6 +++ ...ributionConfigParameters_NoPolicyForwarder.json | 6 +++ ...ibutionConfigParameters_NoReceptionHandler.json | 8 +++- .../resources/parameters/MinimumParameters.json | 6 +++ .../test/resources/parameters/NoParameters.json | 6 +++ 20 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json create mode 100644 main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json create mode 100644 main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json create mode 100644 main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json (limited to 'main/src/test/resources/parameters') diff --git a/main/src/test/resources/parameters/DistributionConfigParameters.json b/main/src/test/resources/parameters/DistributionConfigParameters.json index bcf8b263..7ebab314 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json index a53dc05f..940f9018 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyDecoder.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json index b88fda2a..b596f064 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyPolicyForwarder.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json index 45368be1..74733007 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandler.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ } } \ No newline at end of file diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json index aae53f50..f31a396b 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidName.json @@ -1,5 +1,11 @@ { "name":" ", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json index c1ad0a9e..cc43e378 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json index 26f470ea..c4c73eea 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json index a194e958..899fccab 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json index 895e7d55..5e262c05 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json index a368a5b6..4ff308c2 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json index bf0db3e6..a6be01ee 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":" ", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json new file mode 100644 index 00000000..b59074d2 --- /dev/null +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerHost.json @@ -0,0 +1,53 @@ +{ + "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, + "receptionHandlerParameters":{ + "SDCReceptionHandler":{ + "receptionHandlerType":"SDC", + "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler", + "pssdConfiguration":{ + "asdcAddress": "localhost", + "messageBusAddress": [ + "a.com", + "b.com", + "c.com" + ], + "user": "tbdsdc-1480", + "password": "tbdsdc-1480", + "pollingInterval":20, + "pollingTimeout":30, + "consumerId": "policy-id", + "artifactTypes": [ + "TOSCA_CSAR", + "HEAT" + ], + "consumerGroup": "policy-group", + "environmentName": "environmentName", + "keystorePath": "null", + "keystorePassword": "null", + "activeserverTlsAuth": false, + "isFilterinEmptyResources": true, + "isUseHttpsWithDmaap": false + }, + "pluginHandlerParameters":{ + "policyDecoders":{ + "TOSCADecoder":{ + "decoderType":"TOSCA", + "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx" + } + }, + "policyForwarders":{ + "PAPEngineForwarder":{ + "forwarderType":"PAPEngine", + "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder" + } + } + } + } + } +} diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json new file mode 100644 index 00000000..7161dee3 --- /dev/null +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPassword.json @@ -0,0 +1,53 @@ +{ + "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"" + }, + "receptionHandlerParameters":{ + "SDCReceptionHandler":{ + "receptionHandlerType":"SDC", + "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler", + "pssdConfiguration":{ + "asdcAddress": "localhost", + "messageBusAddress": [ + "a.com", + "b.com", + "c.com" + ], + "user": "tbdsdc-1480", + "password": "tbdsdc-1480", + "pollingInterval":20, + "pollingTimeout":30, + "consumerId": "policy-id", + "artifactTypes": [ + "TOSCA_CSAR", + "HEAT" + ], + "consumerGroup": "policy-group", + "environmentName": "environmentName", + "keystorePath": "null", + "keystorePassword": "null", + "activeserverTlsAuth": false, + "isFilterinEmptyResources": true, + "isUseHttpsWithDmaap": false + }, + "pluginHandlerParameters":{ + "policyDecoders":{ + "TOSCADecoder":{ + "decoderType":"TOSCA", + "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx" + } + }, + "policyForwarders":{ + "PAPEngineForwarder":{ + "forwarderType":"PAPEngine", + "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder" + } + } + } + } + } +} diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json new file mode 100644 index 00000000..aa480745 --- /dev/null +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerPort.json @@ -0,0 +1,53 @@ +{ + "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":-1, + "userName":"healthcheck", + "password":"zb!XztG34" + }, + "receptionHandlerParameters":{ + "SDCReceptionHandler":{ + "receptionHandlerType":"SDC", + "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler", + "pssdConfiguration":{ + "asdcAddress": "localhost", + "messageBusAddress": [ + "a.com", + "b.com", + "c.com" + ], + "user": "tbdsdc-1480", + "password": "tbdsdc-1480", + "pollingInterval":20, + "pollingTimeout":30, + "consumerId": "policy-id", + "artifactTypes": [ + "TOSCA_CSAR", + "HEAT" + ], + "consumerGroup": "policy-group", + "environmentName": "environmentName", + "keystorePath": "null", + "keystorePassword": "null", + "activeserverTlsAuth": false, + "isFilterinEmptyResources": true, + "isUseHttpsWithDmaap": false + }, + "pluginHandlerParameters":{ + "policyDecoders":{ + "TOSCADecoder":{ + "decoderType":"TOSCA", + "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx" + } + }, + "policyForwarders":{ + "PAPEngineForwarder":{ + "forwarderType":"PAPEngine", + "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder" + } + } + } + } + } +} diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json new file mode 100644 index 00000000..d58c035b --- /dev/null +++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidRestServerUser.json @@ -0,0 +1,53 @@ +{ + "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"", + "password":"zb!XztG34" + }, + "receptionHandlerParameters":{ + "SDCReceptionHandler":{ + "receptionHandlerType":"SDC", + "receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler", + "pssdConfiguration":{ + "asdcAddress": "localhost", + "messageBusAddress": [ + "a.com", + "b.com", + "c.com" + ], + "user": "tbdsdc-1480", + "password": "tbdsdc-1480", + "pollingInterval":20, + "pollingTimeout":30, + "consumerId": "policy-id", + "artifactTypes": [ + "TOSCA_CSAR", + "HEAT" + ], + "consumerGroup": "policy-group", + "environmentName": "environmentName", + "keystorePath": "null", + "keystorePassword": "null", + "activeserverTlsAuth": false, + "isFilterinEmptyResources": true, + "isUseHttpsWithDmaap": false + }, + "pluginHandlerParameters":{ + "policyDecoders":{ + "TOSCADecoder":{ + "decoderType":"TOSCA", + "decoderClassName":"org.onap.policy.distribution.reception.decoding.pdpx.PolicyDecoderToscaPdpx" + } + }, + "policyForwarders":{ + "PAPEngineForwarder":{ + "forwarderType":"PAPEngine", + "forwarderClassName":"org.onap.policy.distribution.forwarding.pap.engine.XacmlPapServletPolicyForwarder" + } + } + } + } + } +} diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json index 06d18674..530a86d8 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyDecoder.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json index d8343b19..6b6d6771 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_NoPolicyForwarder.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json b/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json index 8b0997ca..b91e95d8 100644 --- a/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json +++ b/main/src/test/resources/parameters/DistributionConfigParameters_NoReceptionHandler.json @@ -1,3 +1,9 @@ { - "name":"SDCDistributionGroup" + "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + } } \ No newline at end of file diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json index 18cd529c..95359b88 100644 --- a/main/src/test/resources/parameters/MinimumParameters.json +++ b/main/src/test/resources/parameters/MinimumParameters.json @@ -1,5 +1,11 @@ { "name":"SDCDistributionGroup", + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + }, "receptionHandlerParameters":{ "SDCReceptionHandler":{ "receptionHandlerType":"SDC", diff --git a/main/src/test/resources/parameters/NoParameters.json b/main/src/test/resources/parameters/NoParameters.json index 7a73a41b..6b0805d3 100644 --- a/main/src/test/resources/parameters/NoParameters.json +++ b/main/src/test/resources/parameters/NoParameters.json @@ -1,2 +1,8 @@ { + "restServerParameters":{ + "host":"0.0.0.0", + "port":6969, + "userName":"healthcheck", + "password":"zb!XztG34" + } } \ No newline at end of file -- cgit 1.2.3-korg