Merge "Remove unnecessary stuff from oam directory of A1 controller"
authorJohn Keeney <John.Keeney@est.tech>
Thu, 23 Apr 2020 13:47:34 +0000 (13:47 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 23 Apr 2020 13:47:34 +0000 (13:47 +0000)
100 files changed:
docs/policy-agent-api.rst
docs/sdnc-a1-controller-api.rst
near-rt-ric-simulator/auto-test/.gitignore [deleted file]
near-rt-ric-simulator/auto-test/FTC1.sh [deleted file]
near-rt-ric-simulator/common/test_env.sh [deleted file]
near-rt-ric-simulator/common/testcase_common.sh [deleted file]
near-rt-ric-simulator/nearric-service/.gitignore [deleted file]
near-rt-ric-simulator/nearric-service/pom.xml [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/ApplicationConfig.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/NearRicApplication.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/SwaggerConfiguration.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/controller/A1PApi.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/controller/A1PApiController.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/model/PolicyInstance.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/model/PolicyType.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/service/A1PApiService.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/service/A1PApiServiceImpl.java [deleted file]
near-rt-ric-simulator/nearric-service/src/main/resources/application.properties [deleted file]
near-rt-ric-simulator/nearric-service/test/.gitignore [deleted file]
near-rt-ric-simulator/nearric-service/test/pi-template.json [deleted file]
near-rt-ric-simulator/nearric-service/test/populate.sh [deleted file]
near-rt-ric-simulator/nearric-service/test/pt-template.json [deleted file]
near-rt-ric-simulator/nearric-service/test/test-api.sh [deleted file]
near-rt-ric-simulator/pom.xml [deleted file]
near-rt-ric-simulator/simulator-group/consul_cbs/config.json [deleted file]
near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_config.hcl [deleted file]
near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl [deleted file]
near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose-template.yml [deleted file]
near-rt-ric-simulator/simulator-group/consul_cbs/start.sh [deleted file]
near-rt-ric-simulator/simulator-group/dashboard/docker-compose.yml [deleted file]
near-rt-ric-simulator/simulator-group/ric/cleanConsul.py [deleted file]
near-rt-ric-simulator/simulator-group/ric/docker-compose.yml [deleted file]
near-rt-ric-simulator/simulator-group/ric/prepareConsul.py [deleted file]
near-rt-ric-simulator/simulator-group/simulators-start.sh [deleted file]
pom.xml
test/.gitignore [moved from near-rt-ric-simulator/.gitignore with 100% similarity]
test/LICENSES.txt [moved from near-rt-ric-simulator/LICENSES.txt with 100% similarity]
test/auto-test/.gitignore [new file with mode: 0644]
test/auto-test/Dockerize_test.sh [moved from near-rt-ric-simulator/auto-test/Dockerize_test.sh with 95% similarity]
test/auto-test/FTC10.sh [new file with mode: 0755]
test/auto-test/FTC100.sh [new file with mode: 0755]
test/auto-test/FTC200.sh [new file with mode: 0755]
test/auto-test/FTC300.sh [new file with mode: 0755]
test/auto-test/FTC310.sh [new file with mode: 0755]
test/auto-test/FTC320.sh [new file with mode: 0755]
test/auto-test/FTC500.sh [new file with mode: 0755]
test/auto-test/FTC_SDNC.sh [new file with mode: 0755]
test/auto-test/README.md [moved from near-rt-ric-simulator/auto-test/README.md with 100% similarity]
test/auto-test/Suite-interfaces.sh [new file with mode: 0755]
test/auto-test/testdata/OSC/1.json [new file with mode: 0644]
test/auto-test/testdata/OSC/2.json [new file with mode: 0644]
test/auto-test/testdata/OSC/pi1_template.json [new file with mode: 0644]
test/auto-test/testdata/OSC/pi2_template.json [new file with mode: 0644]
test/auto-test/testdata/OSC/sim_1.json [new file with mode: 0644]
test/auto-test/testdata/OSC/sim_2.json [new file with mode: 0644]
test/auto-test/testdata/STD/EMPTYTYPE.json [new file with mode: 0644]
test/auto-test/testdata/STD/pi1_template.json [new file with mode: 0644]
test/auto-test/utils/pa-logviewer.sh [new file with mode: 0755]
test/common/README.md [moved from near-rt-ric-simulator/common/README.md with 100% similarity]
test/common/agent_api_functions.sh [new file with mode: 0644]
test/common/compare_json.py [new file with mode: 0644]
test/common/controller_api_functions.sh [new file with mode: 0644]
test/common/count_json_elements.py [new file with mode: 0644]
test/common/create_rics_json.py [new file with mode: 0644]
test/common/do_curl_function.sh [new file with mode: 0755]
test/common/extract_sdnc_reply.py [new file with mode: 0644]
test/common/ricsimulator_api_functions.sh [new file with mode: 0644]
test/common/test_env.sh [new file with mode: 0755]
test/common/testcase_common.sh [new file with mode: 0755]
test/common/testsuite_common.sh [new file with mode: 0644]
test/cr/.gitignore [new file with mode: 0644]
test/cr/Dockerfile [new file with mode: 0644]
test/cr/README.md [new file with mode: 0644]
test/cr/basic_test.sh [new file with mode: 0755]
test/cr/cr-build-start.sh [new file with mode: 0755]
test/cr/cr.py [new file with mode: 0644]
test/cr/requirements.txt [new file with mode: 0644]
test/mrstub/.gitignore [new file with mode: 0644]
test/mrstub/Dockerfile [new file with mode: 0644]
test/mrstub/README.md [new file with mode: 0644]
test/mrstub/basic_test.sh [new file with mode: 0755]
test/mrstub/mr.py [new file with mode: 0644]
test/mrstub/mrstub-build-start.sh [new file with mode: 0755]
test/mrstub/requirements.txt [new file with mode: 0644]
test/simulator-group/.gitignore [new file with mode: 0644]
test/simulator-group/consul_cbs/consul/cbs_config.hcl [new file with mode: 0644]
test/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl [new file with mode: 0644]
test/simulator-group/consul_cbs/docker-compose.yml [new file with mode: 0644]
test/simulator-group/consul_cbs/start.sh [new file with mode: 0755]
test/simulator-group/control_panel/docker-compose.yml [new file with mode: 0644]
test/simulator-group/cr/docker-compose.yml [new file with mode: 0644]
test/simulator-group/mr/docker-compose.yml [new file with mode: 0644]
test/simulator-group/policy_agent/docker-compose.yml [new file with mode: 0644]
test/simulator-group/ric/.gitignore [new file with mode: 0644]
test/simulator-group/ric/cleanConsul.py [new file with mode: 0644]
test/simulator-group/ric/docker-compose.yml [new file with mode: 0644]
test/simulator-group/ric/prepareConsul.py [new file with mode: 0644]
test/simulator-group/sdnc/docker-compose.yml [moved from near-rt-ric-simulator/simulator-group/sdnc/docker-compose.yml with 87% similarity]
test/simulator-group/sim-monitor-start.sh [new file with mode: 0755]
test/simulator-group/sim-monitor.js [new file with mode: 0644]

index 4792bef..7161bdf 100644 (file)
@@ -60,11 +60,6 @@ The Policy Agent NBI has four distinct parts, described in the sections below:
 * Near-RT RIC Repository
 * Health Check
 
-.. contents:: Operations
-   :depth: 4
-   :local:
-
-
 Service Management
 ==================
 
@@ -89,58 +84,53 @@ Service Management Operations
 PUT
 +++
 
-  Register a service.
-
-  **URL path:**
-    /service
-
-  **Parameters:**
-
-    None.
+Register a service.
 
-  **Body:**  (*Required*)
-      A JSON object (ServiceRegistrationInfo): ::
+**URL path:**
+  /service
 
-        {
-          "callbackUrl": "string",         (An empty string means the service will never get any callbacks.)
-          "keepAliveIntervalSeconds": 0,   (0 means the service will always be considered alive.)
-          "serviceName": "string"          (Required, must be unique.)
-        }
-
-  **Responses:**
+**Parameters:**
+  None.
 
-    200:
-          Service updated.
+**Body:**  (*Required*)
+    A JSON object (ServiceRegistrationInfo): ::
 
-    201:
-          Service created.
-
-    400:
-          The ServiceRegistrationInfo is not accepted.
+      {
+        "callbackUrl": "string",         (An empty string means the service will never get any callbacks.)
+        "keepAliveIntervalSeconds": 0,   (0 means the service will always be considered alive.)
+        "serviceName": "string"          (Required, must be unique.)
+      }
 
-  **Examples:**
+**Responses:**
+  200:
+        Service updated.
+  201:
+        Service created.
+  400:
+        The ServiceRegistrationInfo is not accepted.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X PUT "http://localhost:8081/service" -H "Content-Type: application/json" -d "{
-          \"callbackUrl\": \"URL\",
-          \"keepAliveIntervalSeconds\": 0,
-          \"serviceName\": \"existing\"
-        }"
+    curl -X PUT "http://localhost:8081/service" -H "Content-Type: application/json" -d '{
+        "callbackUrl": "URL",
+        "keepAliveIntervalSeconds": 0,
+        "serviceName": "existing"
+      }'
 
-    Result:
-      201: ::
+  Result:
+    201: ::
 
-         OK
+       OK
 
-    Call: ::
+  **Call**: ::
 
-       curl -X PUT "http://localhost:8081/service" -H  "Content-Type: application/json" -d "{}"
+     curl -X PUT "http://localhost:8081/service" -H  "Content-Type: application/json" -d "{}"
 
-    Result:
-       400: ::
+  Result:
+     400: ::
 
-         Missing mandatory parameter 'serviceName'
+       Missing mandatory parameter 'serviceName'
 
 /services
 ~~~~~~~~~
@@ -148,98 +138,90 @@ PUT
 GET
 +++
 
-  Query service information.
-
-  **URL path:**
-    /services?name=<service-name>
-
-  **Parameters:**
-
-    name: (*Optional*)
-      The name of the service.
-
-  **Responses:**
+Query service information.
 
-    200:
-          Array of JSON objects (ServiceStatus). ::
+**URL path:**
+  /services?name=<service-name>
 
-           {
-               "callbackUrl": "string",             (Callback URL)
-               "keepAliveIntervalSeconds": 0,       (Policy keep alive interval)
-               "serviceName": "string",             (Identity of the service)
-               "timeSinceLastActivitySeconds": 0    (Time since last invocation by the service)
-           }
+**Parameters:**
+  name: (*Optional*)
+    The name of the service.
 
-    404:
-          Service is not found.
+**Responses:**
+  200:
+        Array of JSON objects (ServiceStatus). ::
 
-  **Examples:**
+         {
+             "callbackUrl": "string",             (Callback URL)
+             "keepAliveIntervalSeconds": 0,       (Policy keep alive interval)
+             "serviceName": "string",             (Identity of the service)
+             "timeSinceLastActivitySeconds": 0    (Time since last invocation by the service)
+         }
+  404:
+        Service is not found.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/services?name=existing"
+    curl -X GET "http://localhost:8081/services?name=existing"
 
-    Result:
-      200: ::
+  Result:
+    200: ::
 
-         [
-           {
-             "serviceName":"existing",
-             "keepAliveIntervalSeconds":0,
-             "timeSinceLastActivitySeconds":7224,
-             "callbackUrl":"URL"
-           }
-        ]
+       [
+         {
+           "serviceName":"existing",
+           "keepAliveIntervalSeconds":0,
+           "timeSinceLastActivitySeconds":7224,
+           "callbackUrl":"URL"
+         }
+      ]
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/services?name=nonexistent"
+    curl -X GET "http://localhost:8081/services?name=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-         Service not found
+       Service not found
 
 DELETE
 ++++++
 
-  Delete a service.
-
-  **URL path:**
-    /services?name=<service-name>
+Delete a service.
 
-  **Parameters:**
+**URL path:**
+  /services?name=<service-name>
 
-    name: (*Required*)
-      The name of the service.
+**Parameters:**
+  name: (*Required*)
+    The name of the service.
 
-  **Responses:**
+**Responses:**
+  204:
+        OK
+  404:
+        Service not found.
 
-    204:
-          OK
+**Examples:**
+  **Call**: ::
 
-    404:
-          Service not found.
+    curl -X DELETE "http://localhost:8081/services?name=existing"
 
-  **Examples:**
+  Result:
+    204: ::
 
-    Call: ::
+       OK
 
-      curl -X DELETE "http://localhost:8081/services?name=existing"
+  **Call**: ::
 
-    Result:
-      204: ::
+    curl -X DELETE "http://localhost:8081/services?name=nonexistent"
 
-         OK
+  Result:
+     404: ::
 
-    Call: ::
-
-      curl -X DELETE "http://localhost:8081/services?name=nonexistent"
-
-    Result:
-       404: ::
-
-         Could not find service: nonexistent
+       Could not find service: nonexistent
 
 /services/keepalive
 ~~~~~~~~~~~~~~~~~~~
@@ -247,43 +229,39 @@ DELETE
 PUT
 +++
 
-  Heart beat from a service.
-
-  **URL path:**
-    /services/keepalive?name=<service-name>
-
-  **Parameters:**
+Heart beat from a service.
 
-    name: (*Required*)
-      The name of the service.
+**URL path:**
+  /services/keepalive?name=<service-name>
 
-  **Responses:**
+**Parameters:**
+  name: (*Required*)
+    The name of the service.
 
-    200:
-          OK
+**Responses:**
+  200:
+        OK
+  404:
+        Service is not found.
 
-    404:
-          Service is not found.
+**Examples:**
+  **Call**: ::
 
-  **Examples:**
+    curl -X PUT "http://localhost:8081/services/keepalive?name=existing"
 
-    Call: ::
+  Result:
+    200: ::
 
-      curl -X PUT "http://localhost:8081/services/keepalive?name=existing"
+       OK
 
-    Result:
-      200: ::
+  **Call**: ::
 
-         OK
+    curl -X PUT "http://localhost:8081/services/keepalive?name=nonexistent"
 
-    Call: ::
+  Result:
+     404: ::
 
-      curl -X PUT "http://localhost:8081/services/keepalive?name=nonexistent"
-
-    Result:
-       404: ::
-
-         Could not find service: nonexistent
+       Could not find service: nonexistent
 
 .. _policy-management:
 
@@ -318,47 +296,44 @@ A policy type defines a name and a JSON schema that constrains the content of a
 GET
 +++
 
-  Query policy type names.
-
-  **URL path:**
-    /policy_types?ric=<name-of-ric>
-
-  **Parameters:**
-
-    ric: (*Optional*)
-      The name of the Near |nbh| RT |nbsp| RIC to get types for.
+Query policy type names.
 
-  **Responses:**
+**URL path:**
+  /policy_types?ric=<name-of-ric>
 
-    200:
-          Array of policy type names.
+**Parameters:**
+  ric: (*Optional*)
+    The name of the Near |nbh| RT |nbsp| RIC to get types for.
 
-    404:
-          Near |nbh| RT |nbsp| RIC is not found.
+**Responses:**
 
-  **Examples:**
+  200:
+        Array of policy type names.
+  404:
+        Near |nbh| RT |nbsp| RIC is not found.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policy_types"
+    curl -X GET "http://localhost:8081/policy_types"
 
-    Result:
-      200: ::
+  Result:
+    200: ::
 
-         [
-           "STD_PolicyModelUnconstrained_0.2.0",
-           "Example_QoETarget_1.0.0",
-           "ERIC_QoSNudging_0.2.0"
-        ]
+       [
+         "STD_PolicyModelUnconstrained_0.2.0",
+         "Example_QoETarget_1.0.0",
+         "ERIC_QoSNudging_0.2.0"
+      ]
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policy_types?ric=nonexistent"
+    curl -X GET "http://localhost:8081/policy_types?ric=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-         org.oransc.policyagent.exceptions.ServiceException: Could not find ric: nonexistent
+       org.oransc.policyagent.exceptions.ServiceException: Could not find ric: nonexistent
 
 /policy_schema
 ~~~~~~~~~~~~~~
@@ -366,87 +341,83 @@ GET
 GET
 +++
 
-  Returns one policy type schema definition.
+Returns one policy type schema definition.
 
-  **URL path:**
-    /policy_schema?id=<name-of-type>
+**URL path:**
+  /policy_schema?id=<name-of-type>
 
-   **Parameters:**
+**Parameters:**
+  id: (*Required*)
+    The ID of the policy type to get the definition for.
 
-    id: (*Required*)
-      The ID of the policy type to get the definition for.
+**Responses:**
+  200:
+        Policy schema as JSON schema.
+  404:
+        Policy type is not found.
 
-  **Responses:**
+**Examples:**
+  **Call**: ::
 
-    200:
-          Policy schema as JSON schema.
+    curl -X GET "http://localhost:8081/policy_schema?id=STD_PolicyModelUnconstrained_0.2.0"
 
-    404:
-          Policy type is not found.
+  Result:
+    200: ::
 
-  **Examples:**
-
-    Call: ::
-
-      curl -X GET "http://localhost:8081/policy_schema?id=STD_PolicyModelUnconstrained_0.2.0"
-
-    Result:
-      200: ::
-
-        {
-          "$schema": "http://json-schema.org/draft-07/schema#",
-          "title": "STD_PolicyModelUnconstrained_0.2.0",
-          "description": "Standard model of a policy with unconstrained scope id combinations",
-          "type": "object",
-          "properties": {
-           "scope": {
-              "type": "object",
-              "properties": {
-                "ueId": {"type": "string"},
-                "groupId": {"type": "string"}
-              },
-              "minProperties": 1,
-              "additionalProperties": false
+      {
+        "$schema": "http://json-schema.org/draft-07/schema#",
+        "title": "STD_PolicyModelUnconstrained_0.2.0",
+        "description": "Standard model of a policy with unconstrained scope id combinations",
+        "type": "object",
+        "properties": {
+         "scope": {
+            "type": "object",
+            "properties": {
+              "ueId": {"type": "string"},
+              "groupId": {"type": "string"}
             },
-            "qosObjectives": {
+            "minProperties": 1,
+            "additionalProperties": false
+          },
+          "qosObjectives": {
+            "type": "object",
+            "properties": {
+              "gfbr": {"type": "number"},
+              "mfbr": {"type": "number"}
+            },
+            "additionalProperties": false
+          },
+          "resources": {
+            "type": "array",
+            "items": {
               "type": "object",
               "properties": {
-                "gfbr": {"type": "number"},
-                "mfbr": {"type": "number"}
-              },
-              "additionalProperties": false
-            },
-            "resources": {
-              "type": "array",
-              "items": {
-                "type": "object",
-                "properties": {
-                  "cellIdList": {
-                    "type": "array",
-                    "minItems": 1,
-                    "uniqueItems": true,
-                    "items": {
-                      "type": "string"
-                    }
-                  },
-                "additionalProperties": false,
-                "required": ["cellIdList"]
-              }
+                "cellIdList": {
+                  "type": "array",
+                  "minItems": 1,
+                  "uniqueItems": true,
+                  "items": {
+                    "type": "string"
+                  }
+                },
+              "additionalProperties": false,
+              "required": ["cellIdList"]
             }
-          },
-          "minProperties": 1,
-          "additionalProperties": false,
-          "required": ["scope"]
-        }
+          }
+        },
+        "minProperties": 1,
+        "additionalProperties": false,
+        "required": ["scope"]
+      }
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policy_schema?id=nonexistent"
+    curl -X GET "http://localhost:8081/policy_schema?id=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-         org.oransc.policyagent.exceptions.ServiceException: Could not find type: nonexistent
+       org.oransc.policyagent.exceptions.ServiceException: Could not find type: nonexistent
 
 /policy_schemas
 ~~~~~~~~~~~~~~~
@@ -454,72 +425,69 @@ GET
 GET
 +++
 
-  Returns policy type schema definitions.
-
-  **URL path:**
-    /policy_schemas?ric=<name-of-ric>
+Returns policy type schema definitions.
 
-   **Parameters:**
+**URL path:**
+  /policy_schemas?ric=<name-of-ric>
 
-    ric: (*Optional*)
-      The name of the Near |nbh| RT |nbsp| RIC to get the definitions for.
+**Parameters:**
+  ric: (*Optional*)
+    The name of the Near |nbh| RT |nbsp| RIC to get the definitions for.
 
-  **Responses:**
+**Responses:**
+  200:
+        An array of policy schemas as JSON schemas.
+  404:
+        Near |nbh| RT |nbsp| RIC is not found.
 
-    200:
-          An array of policy schemas as JSON schemas.
+**Examples:**
+  **Call**: ::
 
-    404:
-          Near |nbh| RT |nbsp| RIC is not found.
+    curl -X GET "http://localhost:8081/policy_schemas"
 
-  **Examples:**
+  Result:
+    200: ::
 
-    Call: ::
-
-      curl -X GET "http://localhost:8081/policy_schemas"
-
-    Result:
-      200: ::
+      [{
+        "$schema": "http://json-schema.org/draft-07/schema#",
+        "title": "STD_PolicyModelUnconstrained_0.2.0",
+        "description": "Standard model of a policy with unconstrained scope id combinations",
+        "type": "object",
+        "properties": {
+         "scope": {
+            "type": "object",
+            .
+            .
+            .
+        "additionalProperties": false,
+        "required": ["scope"]
+      },
+       .
+       .
+       .
+      {
+        "$schema": "http://json-schema.org/draft-07/schema#",
+        "title": "Example_QoETarget_1.0.0",
+        "description": "Example QoE Target policy type",
+        "type": "object",
+        "properties": {
+         "scope": {
+            "type": "object",
+            .
+            .
+            .
+        "additionalProperties": false,
+        "required": ["scope"]
+      }]
 
-        [{
-          "$schema": "http://json-schema.org/draft-07/schema#",
-          "title": "STD_PolicyModelUnconstrained_0.2.0",
-          "description": "Standard model of a policy with unconstrained scope id combinations",
-          "type": "object",
-          "properties": {
-           "scope": {
-              "type": "object",
-              .
-              .
-              .
-          "additionalProperties": false,
-          "required": ["scope"]
-        },
-         .
-         .
-         .
-        {
-          "$schema": "http://json-schema.org/draft-07/schema#",
-          "title": "Example_QoETarget_1.0.0",
-          "description": "Example QoE Target policy type",
-          "type": "object",
-          "properties": {
-           "scope": {
-              "type": "object",
-              .
-              .
-              .
-          "additionalProperties": false,
-          "required": ["scope"]
-        }]
+  **Call**: ::
 
-    Call:
-      curl -X GET "http://localhost:8081/policy_schemas?ric=nonexistent"
+    curl -X GET "http://localhost:8081/policy_schemas?ric=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-         org.oransc.policyagent.exceptions.ServiceException: Could not find ric: nonexistent
+       org.oransc.policyagent.exceptions.ServiceException: Could not find ric: nonexistent
 
 Policy
 ------
@@ -542,89 +510,83 @@ policy it has created. There are only two exceptions, see below:
 GET
 +++
 
-  Query policies.
-
-  **URL path:**
-    /policies?ric=<name-of-ric>&service=<name-of-service>&type=<name-of-type>
-
-  **Parameters:**
-
-    ric: (*Optional*)
-      The name of the Near |nbh| RT |nbsp| RIC to get policies for.
-
-    service: (*Optional*)
-      The name of the service to get policies for.
-
-    type: (*Optional*)
-      The name of the policy type to get policies for.
+Query policies.
 
-  **Responses:**
+**URL path:**
+  /policies?ric=<name-of-ric>&service=<name-of-service>&type=<name-of-type>
 
-    200:
-          Array of JSON objects (PolicyInfo). ::
+**Parameters:**
+  ric: (*Optional*)
+    The name of the Near |nbh| RT |nbsp| RIC to get policies for.
+  service: (*Optional*)
+    The name of the service to get policies for.
+  type: (*Optional*)
+    The name of the policy type to get policies for.
 
-            {
-              "id": "string",              (Identity of the policy)
-              "json": "object",            (The configuration of the policy)
-              "lastModified": "string",    (Timestamp, last modification time)
-              "ric": "string",             (Identity of the target Near |nbh| RT |nbsp| RIC)
-              "service": "string",         (The name of the service owning the policy)
-              "type": "string"             (Name of the policy type)
-            }
-
-    404:
-          Near |nbh| RT |nbsp| RIC or policy type not found.
+**Responses:**
+  200:
+        Array of JSON objects (PolicyInfo). ::
 
-  **Examples:**
+          {
+            "id": "string",              (Identity of the policy)
+            "json": "object",            (The configuration of the policy)
+            "lastModified": "string",    (Timestamp, last modification time)
+            "ric": "string",             (Identity of the target Near |nbh| RT |nbsp| RIC)
+            "service": "string",         (The name of the service owning the policy)
+            "type": "string"             (Name of the policy type)
+          }
+  404:
+        Near |nbh| RT |nbsp| RIC or policy type not found.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policies?ric=existing"
+    curl -X GET "http://localhost:8081/policies?ric=existing"
 
-    Result:
-      200: ::
+  Result:
+    200: ::
 
-         [
-           {
-             "id": "Policy 1",
-             "json": {
-               "scope": {
-                 "ueId": "UE 1",
-                 "groupId": "Group 1"
-               },
-               "qosObjectives": {
-                 "gfbr": 1,
-                 "mfbr": 2
-               },
-               "cellId": "Cell 1"
+       [
+         {
+           "id": "Policy 1",
+           "json": {
+             "scope": {
+               "ueId": "UE 1",
+               "groupId": "Group 1"
              },
-             "lastModified": "Wed, 01 Apr 2020 07:45:45 GMT",
-             "ric": "existing",
-             "service": "Service 1",
-             "type": "STD_PolicyModelUnconstrained_0.2.0"
-           },
-           {
-             "id": "Policy 2",
-             "json": {
-                 .
-                 .
-                 .
+             "qosObjectives": {
+               "gfbr": 1,
+               "mfbr": 2
              },
-             "lastModified": "Wed, 01 Apr 2020 07:45:45 GMT",
-             "ric": "existing",
-             "service": "Service 2",
-             "type": "Example_QoETarget_1.0.0"
-           }
-        ]
+             "cellId": "Cell 1"
+           },
+           "lastModified": "Wed, 01 Apr 2020 07:45:45 GMT",
+           "ric": "existing",
+           "service": "Service 1",
+           "type": "STD_PolicyModelUnconstrained_0.2.0"
+         },
+         {
+           "id": "Policy 2",
+           "json": {
+               .
+               .
+               .
+           },
+           "lastModified": "Wed, 01 Apr 2020 07:45:45 GMT",
+           "ric": "existing",
+           "service": "Service 2",
+           "type": "Example_QoETarget_1.0.0"
+         }
+      ]
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policies?type=nonexistent"
+    curl -X GET "http://localhost:8081/policies?type=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-         Policy type not found
+       Policy type not found
 
 /policy
 ~~~~~~~
@@ -632,180 +594,162 @@ GET
 GET
 +++
 
-  Returns a policy configuration.
-
-  **URL path:**
-    /policy?id=<policy-id>
+Returns a policy configuration.
 
-  **Parameters:**
+**URL path:**
+  /policy?id=<policy-id>
 
-    id: (*Required*)
-      The ID of the policy instance.
-
-  **Responses:**
-
-    200:
-          JSON object containing policy information. ::
-
-            {
-              "id": "string",                  (ID of policy)
-              "json": "object",                (JSON with policy data speified by the type)
-              "ownerServiceName": "string",    (Name of the service that created the policy)
-              "ric": "string",                 (Name of the Near |nbh| RT |nbsp| RIC where the policy resides)
-              "type": "string",                (Name of the policy type of the policy)
-              "lastModified"                   (Timestamp, last modification time)
-            }
+**Parameters:**
+  id: (*Required*)
+    The ID of the policy instance.
 
-    404:
-          Policy is not found.
+**Responses:**
+  200:
+        JSON object containing policy information. ::
 
-  **Examples:**
+          {
+            "id": "string",                  (ID of policy)
+            "json": "object",                (JSON with policy data speified by the type)
+            "ownerServiceName": "string",    (Name of the service that created the policy)
+            "ric": "string",                 (Name of the Near |nbh| RT |nbsp| RIC where the policy resides)
+            "type": "string",                (Name of the policy type of the policy)
+            "lastModified"                   (Timestamp, last modification time)
+          }
+  404:
+        Policy is not found.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policy?id=Policy 1"
+    curl -X GET "http://localhost:8081/policy?id=Policy 1"
 
-    Result:
-      200: ::
+  Result:
+    200: ::
 
-         {
-           "id": "Policy 1",
-           "json", {
-             "scope": {
-               "ueId": "UE1 ",
-               "cellId": "Cell 1"
-             },
-             "qosObjectives": {
-               "gfbr": 319.5,
-               "mfbr": 782.75,
-               "priorityLevel": 268.5,
-               "pdb": 44.0
-             },
-             "qoeObjectives": {
-               "qoeScore": 329.0,
-               "initialBuffering": 27.75,
-               "reBuffFreq": 539.0,
-               "stallRatio": 343.0
-             },
-             "resources": []
+       {
+         "id": "Policy 1",
+         "json", {
+           "scope": {
+             "ueId": "UE1 ",
+             "cellId": "Cell 1"
            },
-           "ownerServiceName": "Service 1",
-           "ric": "ric1",
-           "type": "STD_PolicyModelUnconstrained_0.2.0",
-           "lastModified": "Wed, 01 Apr 2020 07:45:45 GMT"
-         }
+           "qosObjectives": {
+             "gfbr": 319.5,
+             "mfbr": 782.75,
+             "priorityLevel": 268.5,
+             "pdb": 44.0
+           },
+           "qoeObjectives": {
+             "qoeScore": 329.0,
+             "initialBuffering": 27.75,
+             "reBuffFreq": 539.0,
+             "stallRatio": 343.0
+           },
+           "resources": []
+         },
+         "ownerServiceName": "Service 1",
+         "ric": "ric1",
+         "type": "STD_PolicyModelUnconstrained_0.2.0",
+         "lastModified": "Wed, 01 Apr 2020 07:45:45 GMT"
+       }
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/policy?id=nonexistent"
+    curl -X GET "http://localhost:8081/policy?id=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-         Policy is not found
+       Policy is not found
 
 PUT
 +++
 
-  Create/Update a policy. **Note!** Calls to this method will also trigger "*Keep Alive*" for a service which has a
-  "*Keep Alive Interval*" registered.
-
-  **URL path:**
-    /policy?id=<policy-id>&ric=<name-of-ric>&service=<name-of-service>&type=<name-of-policy-type>
-
-  **Parameters:**
-
-    id: (*Required*)
-      The ID of the policy instance.
-
-    ric: (*Required*)
-      The name of the Near |nbh| RT |nbsp| RIC where the policy will be created.
-
-    service: (*Required*)
-      The name of the service creating the policy.
-
-    type: (*Optional*)
-      The name of the policy type.
-
-  **Body:** (*Required*)
-      A JSON object containing the data specified by the type.
-
-  **Responses:**
-
-    200:
-          Policy updated.
-
-    201:
-          Policy created.
-
-    404:
-          Near |nbh| RT |nbsp| RIC or policy type is not found.
-
-    423:
-          Near |nbh| RT |nbsp| RIC is not operational.
-
-  **Examples:**
-
-    Call: ::
-
-      curl -X PUT "http://localhost:8081/policy?id=Policy%201&ric=ric1&service=Service%201&type=STD_PolicyModelUnconstrained_0.2.0"
-        -H  "Content-Type: application/json"
-        -d "{
-              \"scope\": {
-                \"ueId\": \"UE 1\",
-                \"cellId\": \"Cell 1\"
-              },
-              \"qosObjectives\": {
-                \"gfbr\": 319.5,
-                \"mfbr\": 782.75,
-                \"priorityLevel\": 268.5,
-                \"pdb\": 44.0
-              },
-              \"qoeObjectives\": {
-                \"qoeScore\": 329.0,
-                \"initialBuffering\": 27.75,
-                \"reBuffFreq\": 539.0,
-                \"stallRatio\": 343.0
-              },
-              \"resources\": []
-            }"
+Create/Update a policy. **Note!** Calls to this method will also trigger "*Keep Alive*" for a service which has a
+"*Keep Alive Interval*" registered.
+
+**URL path:**
+  /policy?id=<policy-id>&ric=<name-of-ric>&service=<name-of-service>&type=<name-of-policy-type>
+
+**Parameters:**
+  id: (*Required*)
+    The ID of the policy instance.
+  ric: (*Required*)
+    The name of the Near |nbh| RT |nbsp| RIC where the policy will be created.
+  service: (*Required*)
+    The name of the service creating the policy.
+  type: (*Optional*)
+    The name of the policy type.
+
+**Body:** (*Required*)
+    A JSON object containing the data specified by the type.
+
+**Responses:**
+  200:
+        Policy updated.
+  201:
+        Policy created.
+  404:
+        Near |nbh| RT |nbsp| RIC or policy type is not found.
+  423:
+        Near |nbh| RT |nbsp| RIC is not operational.
+
+**Examples:**
+  **Call**: ::
+
+    curl -X PUT "http://localhost:8081/policy?id=Policy%201&ric=ric1&service=Service%201&type=STD_PolicyModelUnconstrained_0.2.0"
+      -H  "Content-Type: application/json"
+      -d '{
+            "scope": {
+              "ueId": "UE 1",
+              "cellId": "Cell 1"
+            },
+            "qosObjectives": {
+              "gfbr": 319.5,
+              "mfbr": 782.75,
+              "priorityLevel": 268.5,
+              "pdb": 44.0
+            },
+            "qoeObjectives": {
+              "qoeScore": 329.0,
+              "initialBuffering": 27.75,
+              "reBuffFreq": 539.0,
+              "stallRatio": 343.0
+            },
+            "resources": []
+          }'
 
-    Result:
-      200
+  Result:
+    200
 
 DELETE
 ++++++
 
-  Deletes a policy. **Note!** Calls to this method will also trigger "*Keep Alive*" for a service which has a
-  "*Keep Alive Interval*" registered.
-
-  **URL path:**
-    /policy?id=<policy-id>
-
-  **Parameters:**
-
-    id: (*Required*)
-      The ID of the policy instance.
+Deletes a policy. **Note!** Calls to this method will also trigger "*Keep Alive*" for a service which has a
+"*Keep Alive Interval*" registered.
 
-  **Responses:**
+**URL path:**
+  /policy?id=<policy-id>
 
-    204:
-          Policy deleted.
+**Parameters:**
+  id: (*Required*)
+    The ID of the policy instance.
 
-    404:
-          Policy is not found.
+**Responses:**
+  204:
+        Policy deleted.
+  404:
+        Policy is not found.
+  423:
+        Near |nbh| RT |nbsp| RIC is not operational.
 
-    423:
-          Near |nbh| RT |nbsp| RIC is not operational.
+**Examples:**
+  **Call**: ::
 
-  **Examples:**
+    curl -X DELETE "http://localhost:8081/policy?id=Policy 1"
 
-    Call: ::
-
-      curl -X DELETE "http://localhost:8081/policy?id=Policy 1"
-
-    Result:
-      204
+  Result:
+    204
 
 /policy_ids
 ~~~~~~~~~~~
@@ -813,53 +757,47 @@ DELETE
 GET
 +++
 
-  Query policy type IDs.
-
-  **URL path:**
-    /policy_ids?ric=<name-of-ric>&service=<name-of-service>&type=<name-of-policy-type>
-
-  **Parameters:**
-
-    ric: (*Optional*)
-      The name of the Near |nbh| RT |nbsp| RIC to get policies for.
+Query policy type IDs.
 
-    service: (*Optional*)
-      The name of the service to get policies for.
+**URL path:**
+  /policy_ids?ric=<name-of-ric>&service=<name-of-service>&type=<name-of-policy-type>
 
-    type: (*Optional*)
-      The name of the policy type to get policies for.
+**Parameters:**
+  ric: (*Optional*)
+    The name of the Near |nbh| RT |nbsp| RIC to get policies for.
+  service: (*Optional*)
+    The name of the service to get policies for.
+  type: (*Optional*)
+    The name of the policy type to get policies for.
 
-  **Responses:**
+**Responses:**
+  200:
+        Array of policy type names.
+  404:
+        RIC or policy type not found.
 
-    200:
-          Array of policy type names.
+**Examples:**
+  **Call**: ::
 
-    404:
-          RIC or policy type not found.
+    curl -X GET "http://localhost:8081/policy_ids"
 
-  **Examples:**
+  Result:
+    200: ::
 
-    Call: ::
+       [
+         "Policy 1",
+         "Policy 2",
+         "Policy 3"
+      ]
 
-      curl -X GET "http://localhost:8081/policy_ids"
+  **Call**: ::
 
-    Result:
-      200: ::
+    curl -X GET "http://localhost:8081/policy_ids?ric=nonexistent"
 
-         [
-           "Policy 1",
-           "Policy 2",
-           "Policy 3"
-        ]
+  Result:
+     404: ::
 
-    Call: ::
-
-      curl -X GET "http://localhost:8081/policy_ids?ric=nonexistent"
-
-    Result:
-       404: ::
-
-         Ric not found
+       Ric not found
 
 /policy_status
 ~~~~~~~~~~~~~~
@@ -867,23 +805,20 @@ GET
 GET
 +++
 
-  Returns the status of a policy.
-
-  **URL path:**
-    /policy_status?id=<policy-id>
-
-  **Parameters:**
+Returns the status of a policy.
 
-    id: (*Required*)
-      The ID of the policy.
+**URL path:**
+  /policy_status?id=<policy-id>
 
-  **Responses:**
+**Parameters:**
+  id: (*Required*)
+    The ID of the policy.
 
-    200:
-          JSON object with policy status.
-
-    404:
-          Policy not found.
+**Responses:**
+  200:
+        JSON object with policy status.
+  404:
+        Policy not found.
 
 Near-RT RIC Repository
 ======================
@@ -901,41 +836,37 @@ Near-RT RIC
 GET
 +++
 
-  Returns the name of a Near |nbh| RT |nbsp| RIC managing a specific Mananged Element.
-
-   **URL path:**
-    /ric?managedElementId=<id-of-managed-element>
-
-  **Parameters:**
-
-    managedElementId: (*Required*)
-      The ID of the Managed Element.
-
-  **Responses:**
+Returns the name of a Near |nbh| RT |nbsp| RIC managing a specific Mananged Element.
 
-    200:
-          Name of the Near |nbh| RT |nbsp| RIC managing the Managed Element.
+ **URL path:**
+  /ric?managedElementId=<id-of-managed-element>
 
-    404:
-          No Near |nbh| RT |nbsp| RIC manages the given Managed Element.
+**Parameters:**
+  managedElementId: (*Required*)
+    The ID of the Managed Element.
 
-  **Examples:**
+**Responses:**
+  200:
+        Name of the Near |nbh| RT |nbsp| RIC managing the Managed Element.
+  404:
+        No Near |nbh| RT |nbsp| RIC manages the given Managed Element.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/ric?managedElementId=Node 1"
+    curl -X GET "http://localhost:8081/ric?managedElementId=Node 1"
 
-    Result:
-      200: ::
+  Result:
+    200: ::
 
-        Ric 1
+      Ric 1
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/ric?managedElementId=notmanaged"
+    curl -X GET "http://localhost:8081/ric?managedElementId=notmanaged"
 
-    Result:
-       404
+  Result:
+     404
 
 /rics
 ~~~~~
@@ -943,83 +874,79 @@ GET
 GET
 +++
 
-  Query Near |nbh| RT |nbsp| RIC information.
+Query Near |nbh| RT |nbsp| RIC information.
 
  **URL path:**
-    /rics?policyType=<name-of-policy-type>
+ **URL path:**
+  /rics?policyType=<name-of-policy-type>
 
-  **Parameters:**
+**Parameters:**
+  policyType: (*Optional*)
+    The name of the policy type.
 
-    policyType: (*Optional*)
-      The name of the policy type.
+**Responses:**
+  200:
+        Array of JSON objects containing Near |nbh| RT |nbsp| RIC information. ::
 
-  **Responses:**
-
-    200:
-          Array of JSON objects containing Near |nbh| RT |nbsp| RIC information. ::
-
-            [
-              {
-                "managedElementIds": [
-                  "string"
-                ],
-                "policyTypes": [
-                  "string"
-                ],
-                "ricName": "string",
-                "state": "string"
-              }
-            ]
-
-    404:
-          Policy type is not found.
-
-  **Examples:**
+          [
+            {
+              "managedElementIds": [
+                "string"
+              ],
+              "policyTypes": [
+                "string"
+              ],
+              "ricName": "string",
+              "state": "string"
+            }
+          ]
+  404:
+        Policy type is not found.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/rics?policyType=STD_PolicyModelUnconstrained_0.2.0"
+    curl -X GET "http://localhost:8081/rics?policyType=STD_PolicyModelUnconstrained_0.2.0"
 
-    Result:
-      200: ::
+  Result:
+    200: ::
 
-        [
-          {
-            "managedElementIds": [
-              "ME 1",
-              "ME 2"
-            ],
-            "policyTypes": [
-              "STD_PolicyModelUnconstrained_0.2.0",
-              "Example_QoETarget_1.0.0",
-              "ERIC_QoSNudging_0.2.0"
-            ],
-            "ricName": "Ric 1",
-            "state": "AVAILABLE"
-          },
-            .
-            .
-            .
-          {
-            "managedElementIds": [
-              "ME 3"
-            ],
-            "policyTypes": [
-              "STD_PolicyModelUnconstrained_0.2.0"
-            ],
-            "ricName": "Ric X",
-            "state": "UNAVAILABLE"
-          }
-        ]
+      [
+        {
+          "managedElementIds": [
+            "ME 1",
+            "ME 2"
+          ],
+          "policyTypes": [
+            "STD_PolicyModelUnconstrained_0.2.0",
+            "Example_QoETarget_1.0.0",
+            "ERIC_QoSNudging_0.2.0"
+          ],
+          "ricName": "Ric 1",
+          "state": "AVAILABLE"
+        },
+          .
+          .
+          .
+        {
+          "managedElementIds": [
+            "ME 3"
+          ],
+          "policyTypes": [
+            "STD_PolicyModelUnconstrained_0.2.0"
+          ],
+          "ricName": "Ric X",
+          "state": "UNAVAILABLE"
+        }
+      ]
 
-    Call: ::
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/rics?policyType=nonexistent"
+    curl -X GET "http://localhost:8081/rics?policyType=nonexistent"
 
-    Result:
-       404: ::
+  Result:
+     404: ::
 
-        Policy type not found
+      Policy type not found
 
 Health Check
 ============
@@ -1035,28 +962,25 @@ Health Check
 GET
 +++
 
-  Returns the status of the Policy Agent.
-
-   **URL path:**
-    /status
-
-  **Parameters:**
-
-    None.
+Returns the status of the Policy Agent.
 
-  **Responses:**
+ **URL path:**
+  /status
 
-    200:
-          Service is living.
+**Parameters:**
+  None.
 
-  **Examples:**
+**Responses:**
+  200:
+        Service is living.
 
-    Call: ::
+**Examples:**
+  **Call**: ::
 
-      curl -X GET "http://localhost:8081/status"
+    curl -X GET "http://localhost:8081/status"
 
-    Result:
-      200
+  Result:
+    200
 
 ****************
 A1 through DMaaP
index d10f5e5..fb6f177 100644 (file)
@@ -16,9 +16,12 @@ SDNC A1 Controller
 
 The A1 of a Near |nbh| RT |nbsp| RIC can be used through the SDNC A1 Controller.
 
-Any version of the A1 API can be used. A call to the SDNC A1 Controller always contains the actual URL to the
-Near |nbh| RT |nbsp| RIC, so here any of the supported API versions can be used. The controller just calls the provided
-URL with the provided data.
+The OSC A1 Controller supports using multiple versions of A1 API southbound. By passing the full URL for each southbound
+A1 operation the problem of version-specific URL formats is avoided.
+
+Since different versions of A1 operations may use different data formats for data payloads for similar REST requests and
+responses the data formatting requirements are flexible, so version-specific encoding/decoding is handled by the service
+that requests the A1 operation.
 
 Get Policy Type
 ~~~~~~~~~~~~~~~
@@ -26,107 +29,117 @@ Get Policy Type
 POST
 ++++
 
-  Gets a policy type.
+Gets a policy type.
 
-   **URL path:**
-    /restconf/operations/A1-ADAPTER-API:getA1PolicyType
+Definition
+""""""""""
 
-  **Parameters:**
+**URL path:**
 
-    None.
+/restconf/operations/A1-ADAPTER-API:getA1PolicyType
 
-  **Body:** (*Required*)
+**Parameters:**
 
-      A JSON. ::
+None.
 
-        {
-          "input": {
-            "near-rt-ric-url": "<url-to-near-rt-ric-to-get-type>"
-          }
-        }
+**Body:** (*Required*)
 
-  **Responses:**
+A JSON object. ::
 
-    200:
-      A JSON where the body tag contains the JSON object of the policy type. ::
+  {
+    "input": {
+      "near-rt-ric-url": "<url-to-near-rt-ric-to-get-type>"
+    }
+  }
 
-        {
-          "output": {
-            "http-status": "integer",
-            "body": "{
-              <policy-type>
-            }"
-          }
-        }
+**Responses:**
 
-  **Examples:**
+200:
 
-    Call: ::
+A JSON object where the body tag contains the JSON object of the policy type. ::
 
-      curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyType"
-      -H "Content-Type: application/json" -d "{
-        \"input\": {
-          \"near-rt-ric-url\": \"http://nearRtRic-sim1:8085/a1-p/policytypes/11\"
-        }
+  {
+    "output": {
+      "http-status": "integer",
+      "body": "{
+        <policy-type>
       }"
-
-    Result:
-      200 ::
-
-        {
-          "output": {
-            "http-status": 200,
-            "body": "{
-              "$schema": "http://json-schema.org/draft-07/schema#",
-              "title": "Example_QoETarget_1.0.0",
-              "description": "Example QoE Target policy type",
-              "type": "object",
-              "properties": {
-                "scope": {
-                  "type": "object",
-                  "properties": {
-                    "ueId": {
-                      "type": "string"
-                    },
-                    "sliceId": {
-                      "type": "string"
-                    },
-                    "qosId": {
-                      "type": "string"
-                    },
-                    "cellId": {
-                      "type": "string"
-                    }
-                  },
-                  "additionalProperties": false,
-                  "required": [
-                    "ueId",
-                    "sliceId"
-                  ]
-                },
-                "statement": {
-                  "type": "object",
-                  "properties": {
-                    "qoeScore": {
-                      "type": "number"
-                    },
-                    "initialBuffering": {
-                      "type": "number"
-                    },
-                    "reBuffFreq": {
-                      "type": "number"
-                    },
-                    "stallRatio": {
-                      "type": "number"
-                    }
-                  },
-                  "minProperties": 1,
-                  "additionalProperties": false
-                }
+    }
+  }
+
+Examples
+""""""""
+
+Get a policy type from a Near |nbh| RT |nbsp| RIC that is using the OSC 2.1.0 version. The STD 1.1.3 version does not
+support types, so this function is not available for that version.
+
+**Call**: ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyType"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://nearRtRic-sim1:8085/a1-p/policytypes/11"
+      }
+    }'
+
+**Result**:
+
+200: ::
+
+  {
+    "output": {
+      "http-status": 200,
+      "body": "{
+        \"$schema\": \"http://json-schema.org/draft-07/schema#\",
+        \"title\": \"Example_QoETarget_1.0.0\",
+        \"description\": \"Example QoE Target policy type\",
+        \"type\": \"object\",
+        \"properties\": {
+          \"scope\": {
+            \"type\": \"object\",
+            \"properties\": {
+              \"ueId\": {
+                \"type\": \"string\"
+              },
+              \"sliceId\": {
+                \"type\": \"string\"
+              },
+              \"qosId\": {
+                \"type\": \"string\"
+              },
+              \"cellId\": {
+                \"type\": \"string\"
+              }
+            },
+            \"additionalProperties\": false,
+            \"required\": [
+              \"ueId\",
+              \"sliceId\"
+            ]
+          },
+          \"statement\": {
+            \"type\": \"object\",
+            \"properties\": {
+              \"qoeScore\": {
+                \"type\": \"number\"
+              },
+              \"initialBuffering\": {
+                \"type\": \"number\"
+              },
+              \"reBuffFreq\": {
+                \"type\": \"number\"
+              },
+              \"stallRatio\": {
+                \"type\": \"number\"
               }
-            }
+            },
+            \"minProperties\": 1,
+            \"additionalProperties\": false
           }
-        }"
+        }
+      }"
+    }
+  }
 
 Put Policy
 ~~~~~~~~~~
@@ -134,62 +147,91 @@ Put Policy
 POST
 ++++
 
-  Creates or updates a policy instance.
+Creates or updates a policy instance.
 
-   **URL path:**
-    /restconf/operations/A1-ADAPTER-API:putA1Policy
+Definition
+""""""""""
 
-  **Parameters:**
+**URL path:**
 
-    None.
+/restconf/operations/A1-ADAPTER-API:putA1Policy
 
-  **Body:** (*Required*)
+**Parameters:**
 
-      A JSON where the body tag contains the JSON object of the policy. ::
+None.
 
-        {
-          "input": {
-            "near-rt-ric-url": "<url-to-near-rt-ric-to-put-policy>",
-            "body": "object"
-          }
-        }
+**Body:** (*Required*)
 
-  **Responses:**
+A JSON object where the body tag contains the JSON object of the policy. ::
 
-    200:
-      A JSON with the response. ::
+  {
+    "input": {
+      "near-rt-ric-url": "<url-to-near-rt-ric-to-put-policy>",
+      "body": "<policy-as-json-string>"
+    }
+  }
 
-        {
-          "output": {
-            "http-status": "integer"
-          }
-        }
+**Responses:**
 
-  **Examples:**
+200:
 
-    Call: ::
+A JSON object with the response. ::
 
-      curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyType"
-      -H "Content-Type: application/json" -d "{
-        \"input\": {
-          \"near-rt-ric-url\": \"http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/3d2157af-6a8f-4a7c-810f-38c2f824bf12\",
-          \"body\": \"{
-            \"blocking_rate\":20,
-            \"enforce\":true,
-            \"trigger_threshold\":10,
-            \"window_length\":10
-          }\"
-        }
-      }"
+  {
+    "output": {
+      "http-status": "integer"
+    }
+  }
+
+Examples
+""""""""
 
-    Result:
-      200 ::
+**Call**:
 
-        {
-          "output": {
-            "http-status": 200
+Create a policy in a Near |nbh| RT |nbsp| RIC that is using the OSC 2.1.0 version. ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:putA1Policy"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/5000",
+        "body": "{
+          "blocking_rate":20,
+          "enforce":true,
+          "trigger_threshold":10,
+          "window_length":10
+        }"
+      }
+    }'
+
+Create a policy in a Near |nbh| RT |nbsp| RIC that is using the STD 1.1.3 version. ::
+
+    curl -X POST http://localhost:8282/restconf/operations/A1-ADAPTER-API:putA1Policy
+    -H Content-Type:application/json -d '{
+      "input": {
+        "near-rt-ric-url": "http://ricsim_g2_1:8085/A1-P/v1/policies/5000",
+        "body": "{
+          "scope": {
+            "ueId": "ue5000",
+            "qosId": "qos5000"
+          },
+          "qosObjective": {
+            "priorityLevel": 5000
           }
-        }
+        }"
+      }
+    }'
+
+**Result**:
+
+The result is the same irrespective of which API that is used.
+
+200: ::
+
+  {
+    "output": {
+      "http-status": 200
+    }
+  }
 
 Get Policy
 ~~~~~~~~~~
@@ -197,64 +239,122 @@ Get Policy
 POST
 ++++
 
-  Gets a policy instance.
+Gets a policy instance.
 
-   **URL path:**
-    /restconf/operations/A1-ADAPTER-API:getA1Policy
+Definition
+""""""""""
 
-  **Parameters:**
+**URL path:**
 
-    None.
+/restconf/operations/A1-ADAPTER-API:getA1Policy
 
-  **Body:** (*Required*)
+**Parameters:**
 
-      A JSON. ::
+None.
 
-        {
-          "input": {
-            "near-rt-ric-url": "<url-to-near-rt-ric-to-get-policy>"
-          }
-        }
+**Body:** (*Required*)
 
-  **Responses:**
+A JSON object. ::
 
-    200:
-      A JSON where the body tag contains the JSON object of the policy. ::
+  {
+    "input": {
+      "near-rt-ric-url": "<url-to-near-rt-ric-to-get-policy>"
+    }
+  }
 
-        {
-          "output": {
-            "http-status": "integer",
-            "body": "{
-              <policy>
-            }"
-          }
-        }
+**Responses:**
 
-  **Examples:**
+200:
+  A JSON object where the body tag contains the JSON object of the policy. ::
 
-    Call: ::
+    {
+      "output": {
+        "http-status": "integer",
+        "body": "{
+          <result>
+        }"
+      }
+    }
 
-      curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1Policy"
-      -H "Content-Type: application/json" -d "{
-        \"input\": {
-          \"near-rt-ric-url\": \"http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/3d2157af-6a8f-4a7c-810f-38c2f824bf12\"
-        }
-      }"
+Examples
+""""""""
 
-    Result:
-      200 ::
-
-        {
-          "output": {
-            "http-status": 200,
-            "body": "{
-              \"blocking_rate\": 20,
-              \"enforce\": true,
-              \"trigger_threshold\": 10,
-              \"window_length\": 10
-            }"
-          }
-        }
+**Call**:
+
+Get **all** policy IDs from a Near |nbh| RT |nbsp| RIC that is using the OSC 2.1.0 version. ::
+
+    curl -X POST http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1Policy
+    -H Content-Type:application/json -d '{
+      "input": {
+        "near-rt-ric-url":"http://ricsim_g1_1:8085/a1-p/policytypes/11/policies"
+      }
+    }'
+
+Get **all** policy IDs from a Near |nbh| RT |nbsp| RIC that is using the STD 1.1.3 version. ::
+
+    curl -X POST http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1Policy
+    -H Content-Type:application/json -d '{
+      "input": {
+        "near-rt-ric-url":"http://ricsim_g2_1:8085/A1-P/v1/policies"
+      }
+    }'
+
+**Result**:
+
+The result is the same irrespective of which API that is used.
+
+200: ::
+
+  {
+    "output": {
+      "http-status":200,
+      "body":"[
+        \"5000\",
+          .
+          .
+          .
+        \"6000\"
+      ]"
+    }
+  }
+
+**Call**:
+
+Get **a specific** policy from a Near |nbh| RT |nbsp| RIC that is using the OSC 2.1.0 version. ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1Policy"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/5000"
+      }
+    }'
+
+Get **a specific** policy from a Near |nbh| RT |nbsp| RIC that is using the STD 1.1.3 version. ::
+
+    curl -X POST http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyType
+    -H Content-Type:application/json -d '{
+      "input": {
+        "near-rt-ric-url":"http://ricsim_g2_1:8085/A1-P/v1/policies/5000"
+      }
+    }'
+
+**Result**:
+
+The result is the same irrespective of which API that is used.
+
+200: ::
+
+  {
+    "output": {
+      "http-status": 200,
+      "body": "{
+        \"blocking_rate\": 20,
+        \"enforce\": true,
+        \"trigger_threshold\": 10,
+        \"window_length\": 10
+      }"
+    }
+  }
 
 Delete Policy
 ~~~~~~~~~~~~~
@@ -262,55 +362,75 @@ Delete Policy
 POST
 ++++
 
-  Deletes a policy instance.
+Deletes a policy instance.
 
-   **URL path:**
-    /restconf/operations/A1-ADAPTER-API:deleteA1Policy
+Definition
+""""""""""
 
-  **Parameters:**
+**URL path:**
 
-    None.
+/restconf/operations/A1-ADAPTER-API:deleteA1Policy
 
-  **Body:** (*Required*)
+**Parameters:**
 
-      A JSON. ::
+None.
 
-        {
-          "input": {
-            "near-rt-ric-url": "<url-to-near-rt-ric-to-delete-policy>"
-          }
-        }
+**Body:** (*Required*)
 
-  **Responses:**
+A JSON object. ::
 
-    200:
-      A JSON with the response. ::
+  {
+    "input": {
+      "near-rt-ric-url": "<url-to-near-rt-ric-to-delete-policy>"
+    }
+  }
 
-        {
-          "output": {
-            "http-status": "integer"
-          }
-        }
+**Responses:**
 
-  **Examples:**
+200:
 
-    Call: ::
+A JSON object with the response. ::
 
-      curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:deleteA1Policy"
-      -H "Content-Type: application/json" -d "{
-        \"input\": {
-          \"near-rt-ric-url\": \"http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/3d2157af-6a8f-4a7c-810f-38c2f824bf12\"
-        }
-      }"
+  {
+    "output": {
+      "http-status": "integer"
+    }
+  }
 
-    Result:
-      200 ::
+Examples
+""""""""
 
-        {
-          "output": {
-            "http-status": 202
-          }
-        }
+**Call**:
+
+Delete a policy from a Near |nbh| RT |nbsp| RIC that is using the OSC 2.1.0 version. ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:deleteA1Policy"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/5000"
+      }
+    }'
+
+Delete a policy from a Near |nbh| RT |nbsp| RIC that is using the STD 1.1.3 version. ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:deleteA1Policy"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://ricsim_g2_1:8085/A1-P/v1/policies/5000"
+      }
+    }'
+
+**Result**:
+
+The result is the same irrespective of which API that is used.
+
+200: ::
+
+  {
+    "output": {
+      "http-status": 202
+    }
+  }
 
 Get Policy Status
 ~~~~~~~~~~~~~~~~~
@@ -318,60 +438,93 @@ Get Policy Status
 POST
 ++++
 
-  Get the status of a policy instance.
+Get the status of a policy instance.
 
-   **URL path:**
-    /restconf/operations/A1-ADAPTER-API:getA1PolicyStatus
+Definition
+""""""""""
 
-  **Parameters:**
+**URL path:**
 
-    None.
+/restconf/operations/A1-ADAPTER-API:getA1PolicyStatus
 
-  **Body:** (*Required*)
+**Parameters:**
 
-      A JSON. ::
+None.
 
-        {
-          "input": {
-            "near-rt-ric-url": "<url-to-near-rt-ric-to-get-policy-status>"
-          }
-        }
+**Body:** (*Required*)
 
-  **Responses:**
+A JSON object. ::
 
-    200:
-      A JSON where the body tag contains the JSON object with the policy status according to the API version used. ::
+  {
+    "input": {
+      "near-rt-ric-url": "<url-to-near-rt-ric-to-get-policy-status>"
+    }
+  }
 
-        {
-          "output": {
-            "http-status": "integer",
-            "body": "{
-              <policy-status-object>
-            }"
-          }
-        }
+**Responses:**
 
-  **Examples:**
+200:
 
-    Call: ::
+A JSON object where the body tag contains the JSON object with the policy status according to the API version used. ::
 
-      curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyStatus"
-      -H "Content-Type: application/json" -d "{
-        \"input\": {
-          \"near-rt-ric-url\": \"http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/3d2157af-6a8f-4a7c-810f-38c2f824bf12/status\"
-        }
+  {
+    "output": {
+      "http-status": "integer",
+      "body": "{
+        <policy-status-object>
       }"
+    }
+  }
 
-    Result:
-      200 ::
-
-        {
-          "output": {
-            "http-status": 200,
-            "body": "{
-              "instance_status": "IN EFFECT",
-              "has_been_deleted": "true",
-              "created_at": "Wed, 01 Apr 2020 07:45:45 GMT"
-            }"
-          }
-        }
+Examples
+""""""""
+
+**Call**:
+
+Get the policy status for a specific policy from a Near |nbh| RT |nbsp| RIC that is using the OSC 2.1.0 version. ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyStatus"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://nearRtRic-sim1:8085/a1-p/policytypes/11/policies/5000/status"
+      }
+    }'
+
+**Result**:
+
+200: ::
+
+  {
+    "output": {
+      "http-status": 200,
+      "body": "{
+        \"instance_status\": \"IN EFFECT\",
+        \"has_been_deleted\": \"true\",
+        \"created_at\": \"Wed, 01 Apr 2020 07:45:45 GMT\"
+      }"
+    }
+  }
+
+**Call**:
+
+Get the policy status for a specific policy from a Near |nbh| RT |nbsp| RIC that is using the STD 1.1.3 version. ::
+
+    curl -X POST "http://localhost:8282/restconf/operations/A1-ADAPTER-API:getA1PolicyStatus"
+    -H "Content-Type: application/json" -d '{
+      "input": {
+        "near-rt-ric-url": "http://ricsim_g2_1:8085/A1-P/v1/policies/5000/status"
+      }
+    }'
+
+**Result**:
+
+200: ::
+
+  {
+    "output": {
+      "http-status": 200,
+      "body": "{
+        \"enforceStatus\": \"UNDEFINED\"
+      }"
+    }
+  }
diff --git a/near-rt-ric-simulator/auto-test/.gitignore b/near-rt-ric-simulator/auto-test/.gitignore
deleted file mode 100644 (file)
index 1c5ae4e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-logs
-.tmp_*
\ No newline at end of file
diff --git a/near-rt-ric-simulator/auto-test/FTC1.sh b/near-rt-ric-simulator/auto-test/FTC1.sh
deleted file mode 100755 (executable)
index 7c614a4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-
-TC_ONELINE_DESCR="Auto test for Policy Agent refreshing configurations from consul/cbs"
-
-. ../common/testcase_common.sh $1
-
-#### TEST BEGIN ####
-
-clean_containers
-
-start_simulators
-
-consul_config_app         "../simulator-group/consul_cbs/config.json"
-
-start_policy_agent
-
-check_policy_agent_logs
-
-#### TEST COMPLETE ####
-
-store_logs          END
-
diff --git a/near-rt-ric-simulator/common/test_env.sh b/near-rt-ric-simulator/common/test_env.sh
deleted file mode 100755 (executable)
index 82afa16..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-
-# Set the images for the Policy Agent app to use for the auto tests. Do not add the image tag.
-#
-# Local Policy Agent image and tag, shall point to locally built image (non-nexus path)
-export POLICY_AGENT_LOCAL_IMAGE=o-ran-sc/nonrtric-policy-agent
-# Remote image
-export POLICY_AGENT_REMOTE_IMAGE=nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent
-# SDNC A1 Adapter remote image
-export SDNC_A1_ADAPTER_IMAGE=nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1-controller:1.7.4
-# Dashboard remote image
-export DASHBOARD_IMAGE=nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-dashboard:1.0.1
-
-# Common env var for auto-test.
-
-POLICY_AGENT_PORT=8081
-POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log"  #Path the application log in the Policy Agent container
-DOCKER_SIM_NWNAME="nonrtric-docker-net"                       #Name of docker private network
-CONSUL_HOST="consul-server"                                   #Host name of consul
-CONSUL_PORT=8500                                              #Port number of consul
-CONFIG_BINDING_SERVICE="config-binding-service"               #Host name of CBS
-PA_APP_BASE="policy-agent"                                    #Base name for Policy Agent container
diff --git a/near-rt-ric-simulator/common/testcase_common.sh b/near-rt-ric-simulator/common/testcase_common.sh
deleted file mode 100755 (executable)
index b4ceb0d..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-#!/usr/bin/env bash
-
-. ../common/test_env.sh
-
-echo "Test case started as: ${BASH_SOURCE[$i+1]} "$1 $2 $3
-echo "Numbers of ric simulator started" $2
-
-# This is a script that contains all the functions needed for auto test
-# Arg: local | remote (1, 2, 3, 4....)
-
-STARTED_POLICY_AGENT="" #Policy Agent app names added to this var to keep track of started container in the script
-START_ARG=$1
-IMAGE_TAG="1.0.0-SNAPSHOT"
-IMAGE_TAG_REMOTE="latest"
-RIC_NUMBER=$2
-SDNC=$3
-
-if [ $# -lt 1 ] || [ $# -gt 4 ]; then
-       echo "Expected arg: local  | remote  and numbers of the rics and SDNC "
-       exit 1
-elif [ $1 == "local" ]; then
-       if [ -z $POLICY_AGENT_LOCAL_IMAGE ]; then
-               echo "POLICY_AGENT_LOCAL_IMAGE not set in test_env"
-               exit 1
-       fi
-       POLICY_AGENT_IMAGE=$POLICY_AGENT_LOCAL_IMAGE":"$IMAGE_TAG
-elif [ $1 == "remote" ]; then
-    if [ -z $POLICY_AGENT_REMOTE_IMAGE ]; then
-        echo "POLICY_AGENT_REMOTE_IMAGE not set in test_env"
-        exit 1
-    fi
-    POLICY_AGENT_IMAGE=$POLICY_AGENT_REMOTE_IMAGE":"$IMAGE_TAG_REMOTE
-fi
-
-# Set a description string for the test case
-if [ -z "$TC_ONELINE_DESCR" ]; then
-       TC_ONELINE_DESCR="<no-description>"
-       echo "No test case description found, TC_ONELINE_DESCR should be set on in the test script , using "$TC_ONELINE_DESCR
-fi
-
-ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh)
-
-
-# Create the logs dir if not already created in the current dir
-if [ ! -d "logs" ]; then
-    mkdir logs
-fi
-
-TESTLOGS=$PWD/logs
-
-mkdir -p $TESTLOGS/$ATC
-
-TCLOG=$TESTLOGS/$ATC/TC.log
-exec &>  >(tee ${TCLOG})
-
-#Variables for counting tests as well as passed and failed tests
-RES_TEST=0
-RES_PASS=0
-RES_FAIL=0
-TCTEST_START=$SECONDS
-
-echo "-------------------------------------------------------------------------------------------------"
-echo "-----------------------------------      Test case: "$ATC
-echo "-----------------------------------      Started:   "$(date)
-echo "-------------------------------------------------------------------------------------------------"
-echo "-- Description: "$TC_ONELINE_DESCR
-echo "-------------------------------------------------------------------------------------------------"
-echo "-----------------------------------      Test case setup      -----------------------------------"
-
-
-if [ -z "$SIM_GROUP" ]; then
-               SIM_GROUP=$PWD/../simulator-group
-               if [ ! -d  $SIM_GROUP ]; then
-                       echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the integration repo, but failed."
-                       echo "Please set the SIM_GROUP manually in the test_env.sh"
-                       exit 1
-               else
-                       echo "SIM_GROUP auto set to: " $SIM_GROUP
-               fi
-elif [ $SIM_GROUP = *simulator_group ]; then
-                       echo "Env var SIM_GROUP does not seem to point to dir 'simulator-group' in the integration repo, check test_env.sh"
-                       exit 1
-fi
-
-echo ""
-
-if [ $1 !=  "manual-container" ] && [ $1 !=  "manual-app" ]; then
-       #echo -e "Policy Agent image tag set to: \033[1m" $IMAGE_TAG"\033[0m"
-       echo "Configured image for Policy Agent app(s) (${1}): "$POLICY_AGENT_IMAGE
-       tmp_im=$(docker images ${POLICY_AGENT_IMAGE} | grep -v REPOSITORY)
-
-       if [ $1 == "local" ]; then
-               if [ -z "$tmp_im" ]; then
-                       echo "Local image (non nexus) "$POLICY_AGENT_IMAGE" does not exist in local registry, need to be built"
-                       exit 1
-               else
-                       echo -e "Policy Agent local image: \033[1m"$tmp_im"\033[0m"
-                       echo "If the Policy Agent image seem outdated, rebuild the image and run the test again."
-               fi
-       elif [ $1 == "remote" ]; then
-           if [ -z "$tmp_im" ]; then
-                       echo "Pulling Policy Agent image from nexus: "$POLICY_AGENT_IMAGE
-                       docker pull $POLICY_AGENT_IMAGE  > /dev/null
-                       tmp_im=$(docker images ${POLICY_AGENT_IMAGE} | grep -v REPOSITORY)
-                       if [ -z "$tmp_im" ]; then
-                               echo "Image could not be pulled"
-                               exit 1
-                       fi
-                       echo -e "Policy Agent image: \033[1m"$tmp_im"\033[0m"
-               else
-                       echo -e "Policy Agent image: \033[1m"$tmp_im"\033[0m"
-                       echo "!! If the Policy Agent image seem outdated, consider removing it from your docker registry and run the test again."
-               fi
-       fi
-fi
-
-echo ""
-
-echo "Building images for the simulators"
-if [ -z "$SIM_DIR" ]; then
-               SIM_DIR=$(find . -type d -path "*a1-interface/near-rt-ric-simulator/scripts*" 2>/dev/null -print -quit)
-               if [ ! -d  $SIM_DIR ]; then
-                       echo "Trying to set env var SIM_DIR to dir 'a1-interface/near-rt-ric-simulator/scripts' in the sim repo, but failed."
-                       echo "It might be that you did not download the repository of the Near-rt-ric simulator.In that case, run the command:"
-                       echo "git clone 'https://gerrit.o-ran-sc.org/oransc/sim/a1-interface'"
-                       echo "Otherwise, please set the SIM_DIR manually in the test_env.sh"
-                       exit 1
-               else
-                       echo "SIM_DIR auto set to: " $SIM_DIR
-               fi
-fi
-cd $SIM_DIR
-docker build -t ric-simulator:latest . &> /dev/null
-cd $curdir
-
-echo ""
-
-echo "Local registry images for simulators:"
-echo "Consul:             " $(docker images | grep consul)
-echo "CBS:                " $(docker images | grep platform.configbinding.app)
-echo "RIC:                " $(docker images | grep ric-simulator)
-echo ""
-
-
-__consul_config() {
-
-       appname=$PA_APP_BASE
-
-       echo "Configuring consul for " $appname " from " $1
-       curl -s http://127.0.0.1:${CONSUL_PORT}/v1/kv/${appname}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$1 >/dev/null
-}
-
-
-consul_config_app() {
-
-    __consul_config $1
-
-}
-
-
-
-start_ric_simulator() {
-
-  DOCKER_SIM_NWNAME="nonrtric-docker-net"
-  echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
-  docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
-
-  echo "start ric simulator"
-  curdir=$PWD
-  cd $SIM_GROUP
-  cd ric/
-
-  docker-compose up --scale ric-simulator=$RIC_NUMBER -d
-
-  cd $curdir
-       echo ""
-}
-
-start_dashboard() {
-
-  DOCKER_SIM_NWNAME="nonrtric-docker-net"
-  echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
-  docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
-
-  echo "start Control Panel"
-  curdir=$PWD
-  cd $SIM_GROUP
-  cd dashboard/
-
-  docker-compose up -d
-
-  cd $curdir
-       echo ""
-}
-
-start_sdnc() {
-
-  if [ $SDNC == "sdnc" ]; then
-    DOCKER_SIM_NWNAME="nonrtric-docker-net"
-    echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
-    docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
-
-    echo "start sdnc"
-    curdir=$PWD
-    cd $SIM_GROUP
-    cd sdnc/
-
-    docker-compose up -d a1-controller
-
-    cd $curdir
-         echo ""
-       fi
-}
-
-prepare_consul_config() {
-  echo "prepare consul config"
-  curdir=$PWD
-  cd $SIM_GROUP
-  cd ric/
-
-  python3 cleanConsul.py
-  python3 prepareConsul.py
-
-  cd $curdir
-       echo ""
-
-
-}
-
-
-# Start all simulators in the simulator group
-start_simulators() {
-
-       echo "Starting all simulators"
-       curdir=$PWD
-       cd $SIM_GROUP
-
-       $SIM_GROUP/simulators-start.sh
-       cd $curdir
-       echo ""
-}
-
-
-
-clean_containers() {
-       echo "Stopping all containers, Policy Agent app(s) and simulators with name prefix 'policy-agent'"
-       docker stop $(docker ps -q --filter name=/policy-agent) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'policy-agent'"
-       docker rm $(docker ps -a -q --filter name=/policy-agent) &> /dev/null
-       echo "Stopping all containers, Policy Agent app(s) and simulators with name prefix 'ric-simulator'"
-       docker stop $(docker ps -q --filter name=ric-simulator) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'ric-simulator'"
-       docker rm $(docker ps -a -q --filter name=ric-simulator) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'dashboard'"
-       docker rm $(docker ps -a -q --filter name=dashboard) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'a1-controller'"
-       docker rm $(docker ps -a -q --filter name=a1-controller) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'sdnc_db_container'"
-       docker rm $(docker ps -a -q --filter name=sdnc_db_container) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'cbs'"
-       docker rm $(docker ps -a -q --filter name=polman_cbs) &> /dev/null
-       echo "Removing all containers, Policy Agent app and simulators with name prefix 'consul'"
-       docker rm $(docker ps -a -q --filter name=polman_consul) &> /dev/null
-       echo "Removing unused docker networks with substring 'nonrtric' in network name"
-       docker network rm $(docker network ls -q --filter name=nonrtric)
-       echo ""
-}
-
-start_policy_agent() {
-
-       appname=$PA_APP_BASE
-
-       if [ $START_ARG == "local" ] || [ $START_ARG == "remote" ]; then
-               __start_policy_agent_image $appname
-       fi
-}
-
-__start_policy_agent_image() {
-
-       appname=$1
-       localport=$POLICY_AGENT_PORT
-
-       echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
-
-       docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
-
-       echo "Starting Policy Agent: " $appname " with ports mapped to " $localport " in docker network "$DOCKER_SIM_NWNAME
-       docker run -d -p $localport":8081" --network=$DOCKER_SIM_NWNAME -e CONSUL_HOST=$CONSUL_HOST -e CONSUL_PORT=$CONSUL_PORT -e CONFIG_BINDING_SERVICE=$CONFIG_BINDING_SERVICE -e HOSTNAME=$appname --name $appname $POLICY_AGENT_IMAGE
-       #docker run -d -p 8081:8081 --network=nonrtric-docker-net -e CONSUL_HOST=CONSUL_HOST=$CONSUL_HOST -e CONSUL_PORT=$CONSUL_PORT -e CONFIG_BINDING_SERVICE=$CONFIG_BINDING_SERVICE -e HOSTNAME=policy-agent
-       sleep 3
-       set +x
-       pa_started=false
-       for i in {1..10}; do
-               if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]
-                       then
-                               echo " Image: $(docker inspect --format '{{ .Config.Image }}' ${appname})"
-                               echo "Policy Agent container ${appname} running"
-                               pa_started=true
-                               break
-                       else
-                               sleep $i
-               fi
-       done
-       if ! [ $pa_started  ]; then
-               echo "Policy Agent container ${appname} could not be started"
-               exit 1
-       fi
-
-       pa_st=false
-       echo "Waiting for Policy Agent ${appname} service status..."
-       for i in {1..10}; do
-               result="$(__do_curl http://127.0.0.1:${localport}/status)"
-               if [ $? -eq 0 ]; then
-                       echo "Policy Agent ${appname} responds to service status: " $result
-                       echo "Policy Agent is alive."
-                       pa_st=true
-                       break
-               else
-                       sleep $i
-               fi
-       done
-
-       if [ "$pa_st" = "false"  ]; then
-               echo "Policy Agent ${appname} did not respond to service status"
-               exit 1
-       fi
-}
-
-check_policy_agent_logs() {
-
-               appname=$PA_APP_BASE
-               tmp=$(docker ps | grep $appname)
-               if ! [ -z "$tmp" ]; then  #Only check logs for running Policy Agent apps
-                       __check_policy_agent_log $appname
-               fi
-
-}
-
-__check_policy_agent_log() {
-       echo "Checking $1 log $POLICY_AGENT_LOGPATH for WARNINGs and ERRORs"
-       foundentries=$(docker exec -it $1 grep WARN /var/log/policy-agent/application.log | wc -l)
-       if [ $? -ne  0 ];then
-               echo "  Problem to search $1 log $POLICY_AGENT_LOGPATH"
-       else
-               if [ $foundentries -eq 0 ]; then
-                       echo "  No WARN entries found in $1 log $POLICY_AGENT_LOGPATH"
-               else
-                       echo -e "  Found \033[1m"$foundentries"\033[0m WARN entries in $1 log $POLICY_AGENT_LOGPATH"
-               fi
-       fi
-       foundentries=$(docker exec -it $1 grep ERR $POLICY_AGENT_LOGPATH | wc -l)
-       if [ $? -ne  0 ];then
-               echo "  Problem to search $1 log $POLICY_AGENT_LOGPATH"
-       else
-               if [ $foundentries -eq 0 ]; then
-                       echo "  No ERR entries found in $1 log $POLICY_AGENT_LOGPATH"
-               else
-                       echo -e "  Found \033[1m"$foundentries"\033[0m ERR entries in $1 log $POLICY_AGENT_LOGPATH"
-               fi
-       fi
-}
-
-store_logs() {
-       if [ $# != 1 ]; then
-       __print_err "need one arg, <file-prefix>"
-               exit 1
-       fi
-       echo "Storing all container logs and Policy Agent app log using prefix: "$1
-
-       docker logs polman_consul > $TESTLOGS/$ATC/$1_consul.log 2>&1
-       docker logs polman_cbs > $TESTLOGS/$ATC/$1_cbs.log 2>&1
-}
-
-__do_curl() {
-       res=$(curl -skw "%{http_code}" $1)
-       http_code="${res:${#res}-3}"
-       if [ ${#res} -eq 3 ]; then
-               echo "<no-response-from-server>"
-               return 1
-       else
-               if [ $http_code -lt 200 ] && [ $http_code -gt 299]; then
-                       echo "<not found, resp:${http_code}>"
-                       return 1
-               fi
-               if [ $# -eq 2 ]; then
-                       echo "${res:0:${#res}-3}" | xargs
-               else
-                       echo "${res:0:${#res}-3}"
-               fi
-
-               return 0
-       fi
-}
-
diff --git a/near-rt-ric-simulator/nearric-service/.gitignore b/near-rt-ric-simulator/nearric-service/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/near-rt-ric-simulator/nearric-service/pom.xml b/near-rt-ric-simulator/nearric-service/pom.xml
deleted file mode 100644 (file)
index dd21d57..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ============LICENSE_START=======================================================
-   Copyright (C) 2019 Nordix Foundation.
-  ================================================================================
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-
-  SPDX-License-Identifier: Apache-2.0
-  ============LICENSE_END=========================================================
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.oran.nearric</groupId>
-               <artifactId>nearric-simulator</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
-       </parent>
-       <artifactId>nearric-service</artifactId>
-       <name>${project.artifactId}</name>
-
-       <properties>
-               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-               <okhttp-version>2.7.5</okhttp-version>
-               <gson-version>2.8.1</gson-version>
-               <dockerfile-maven-version>1.4.2</dockerfile-maven-version>
-       </properties>
-       <dependencies>
-               <dependency>
-                       <groupId>org.oran.nearric</groupId>
-                       <artifactId>a1-med-api</artifactId>
-                       <version>1.0.0-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-web</artifactId>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.springframework.boot</groupId>
-                                       <artifactId>spring-boot-starter-logging</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-data-jpa</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-actuator</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-test</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-devtools</artifactId>
-                       <scope>runtime</scope>
-               </dependency>
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>io.swagger</groupId>
-                       <artifactId>swagger-jaxrs</artifactId>
-                       <version>1.5.0</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.directory.studio</groupId>
-                       <artifactId>org.apache.commons.io</artifactId>
-                       <version>2.4</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.googlecode.json-simple</groupId>
-                       <artifactId>json-simple</artifactId>
-                       <version>1.1.1</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>io.springfox</groupId>
-                       <artifactId>springfox-swagger-ui</artifactId>
-                       <version>2.6.1</version>
-                       <scope>compile</scope>
-               </dependency>
-               <dependency>
-                       <groupId>io.springfox</groupId>
-                       <artifactId>springfox-swagger2</artifactId>
-                       <version>2.6.1</version>
-                       <scope>compile</scope>
-               </dependency>
-               <dependency>
-                       <groupId>com.fasterxml.jackson.core</groupId>
-                       <artifactId>jackson-databind</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>com.h2database</groupId>
-                       <artifactId>h2</artifactId>
-               </dependency>
-               <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
-               <dependency>
-                       <groupId>commons-beanutils</groupId>
-                       <artifactId>commons-beanutils</artifactId>
-                       <version>1.9.3</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.modelmapper</groupId>
-                       <artifactId>modelmapper</artifactId>
-                       <version>2.3.0</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.squareup.okio</groupId>
-                       <artifactId>okio</artifactId>
-                       <version>1.13.0</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.squareup.okhttp</groupId>
-                       <artifactId>okhttp</artifactId>
-                       <version>${okhttp-version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.squareup.okhttp</groupId>
-                       <artifactId>logging-interceptor</artifactId>
-                       <version>${okhttp-version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.google.code.gson</groupId>
-                       <artifactId>gson</artifactId>
-                       <version>${gson-version}</version>
-               </dependency>
-        <dependency>
-            <groupId>com.github.java-json-tools</groupId>
-            <artifactId>json-schema-validator</artifactId>
-            <version>2.2.11</version>
-        </dependency>
-       </dependencies>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.springframework.boot</groupId>
-                               <artifactId>spring-boot-maven-plugin</artifactId>
-                               <configuration>
-                                       <mainClass>org.onap.nearric.simulator.config.NearRicApplication</mainClass>
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <goals>
-                                                       <goal>repackage</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-            <plugin>
-                <groupId>io.fabric8</groupId>
-                <artifactId>docker-maven-plugin</artifactId>
-                <version>0.30.0</version>
-                <configuration>
-                    <verbose>true</verbose>
-                    <!-- environment variables supplied by Jenkins -->
-                    <pushRegistry>${env.CONTAINER_PUSH_REGISTRY}</pushRegistry>
-                    <images>
-                        <image>
-                            <!-- Specify a tag to avoid default tag "latest" -->
-                            <!-- Avoid maven artifact name here -->
-                            <name>o-ran-sc/nonrtric-nearric-simulator:${project.version}</name>
-                            <build>
-                                <from>openjdk:11-jre-slim</from>
-                                <tags>
-                                    <!-- Add tag with build number -->
-                                    <tag>${project.version}</tag>
-                                </tags>
-                                <assembly>
-                                    <descriptorRef>artifact</descriptorRef>
-                                </assembly>
-                                <cmd>
-                                    <!-- Include maven dir on classpath for prop files -->
-                                    <exec>
-                                        <arg>java</arg>
-                                        <arg>-Xms128m</arg>
-                                        <arg>-Xmx256m</arg>
-                                        <arg>-cp</arg>
-                                        <arg>maven:maven/${project.artifactId}-${project.version}.${project.packaging}</arg>
-                                        <arg>-Dloader.main=org.onap.nearric.simulator.config.NearRicApplication</arg>
-                                        <arg>-Djava.security.egd=file:/dev/./urandom</arg>
-                                        <arg>org.springframework.boot.loader.PropertiesLauncher</arg>
-                                    </exec>
-                                </cmd>
-                            </build>
-                        </image>
-                    </images>
-                </configuration>
-                <!-- build Docker images in install phase, push in deploy phase -->
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>build</goal>
-                            <goal>push</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>javax.activation</groupId>
-                        <artifactId>activation</artifactId>
-                        <version>1.1.1</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
-               </plugins>
-       </build>
-</project>
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/ApplicationConfig.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/ApplicationConfig.java
deleted file mode 100644 (file)
index 3c634cc..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.config;
-
-import java.util.HashMap;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * This class provides all the configuration for the Spring boot application
- * 
- * @author lathishbabu.ganesan@est.tech
- *
- */
-@Configuration
-public class ApplicationConfig {
-
-  private final HashMap<Integer, Object> policyTypeCache = new HashMap<>();
-
-  @Bean
-  public HashMap<Integer, Object> getPolicyTypeCache() {
-    return policyTypeCache;
-  }
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/NearRicApplication.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/NearRicApplication.java
deleted file mode 100644 (file)
index 5b21d1a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.config;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.ComponentScan;
-
-/**
- * This is the Spring Boot Application
- * 
- * @author lathishbabu.ganesan@est.tech
- *
- */
-
-@SpringBootApplication
-@ComponentScan({"org.oransc", "org.onap"})
-@EnableCaching
-public class NearRicApplication {
-  public static void main(final String[] args) {
-    SpringApplication.run(NearRicApplication.class, args);
-  }
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/SwaggerConfiguration.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/config/SwaggerConfiguration.java
deleted file mode 100644 (file)
index f77c189..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.config;
-
-import org.onap.nearric.simulator.controller.A1PApiController;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-/**
- * This class provides all the configuration for the Spring boot application
- * 
- * @author lathishbabu.ganesan@est.tech
- *
- */
-@Configuration
-@EnableSwagger2
-public class SwaggerConfiguration {
-  @Bean
-  public Docket apiDocket() {
-    return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("org.onap.nearric.simulator"))
-        .paths(PathSelectors.any()).build();
-  }
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/controller/A1PApi.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/controller/A1PApi.java
deleted file mode 100644 (file)
index 4f8b31e..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-/**
- * NOTE: This class is auto generated by the swagger code generator program (3.0.8).
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
-package org.onap.nearric.simulator.controller;
-
-import org.oransc.ric.a1med.api.model.InlineResponse200;
-import org.oransc.ric.a1med.api.model.PolicyTypeSchema;
-import io.swagger.annotations.*;
-import org.springframework.http.ResponseEntity;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RequestPart;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.validation.Valid;
-import javax.validation.constraints.*;
-import java.util.List;
-import java.util.Map;
-@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-10-04T13:41:42.802+01:00[Europe/Dublin]")
-@Api(value = "a1-p", description = "the a1-p API")
-public interface A1PApi {
-
-    @ApiOperation(value = "", nickname = "a1ControllerCreateOrReplacePolicyInstance", notes = "Create or replace a policy instance of type policy_type_id. The schema of the PUT body is defined by the create_schema field of the policy type. ", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 201, message = "Policy instance created "),
-        @ApiResponse(code = 400, message = "Bad PUT body for this policy instance "),
-        @ApiResponse(code = 404, message = "There is no policy type with this policy_type_id ") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}",
-        consumes = { "application/json" },
-        method = RequestMethod.PUT)
-    ResponseEntity<Void> a1ControllerCreateOrReplacePolicyInstance(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId,@ApiParam(value = ""  )  @Valid @RequestBody Object body);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerCreatePolicyType", notes = "Create a new policy type . Replace is not currently allowed; to replace, for now do a DELETE and then a PUT again. ", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 201, message = "policy type successfully created"),
-        @ApiResponse(code = 400, message = "illegal ID, or object already existed") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}",
-        consumes = { "application/json" },
-        method = RequestMethod.PUT)
-    ResponseEntity<Void> a1ControllerCreatePolicyType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = ""  )  @Valid @RequestBody PolicyTypeSchema body);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerDeletePolicyInstance", notes = "Delete this policy instance ", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 204, message = "policy instance successfully deleted "),
-        @ApiResponse(code = 404, message = "there is no policy instance with this policy_instance_id or there is no policy type with this policy_type_id ") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}",
-        method = RequestMethod.DELETE)
-    ResponseEntity<Void> a1ControllerDeletePolicyInstance(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerDeletePolicyType", notes = "Delete this policy type. Can only be performed if there are no instances of this type ", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 204, message = "policy type successfully deleted "),
-        @ApiResponse(code = 400, message = "Policy type cannot be deleted because there are instances All instances must be removed before a policy type can be deleted "),
-        @ApiResponse(code = 404, message = "policy type not found ") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}",
-        method = RequestMethod.DELETE)
-    ResponseEntity<Void> a1ControllerDeletePolicyType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerGetAllInstancesForType", notes = "get a list of all policy instance ids for this policy type id", response = String.class, responseContainer = "List", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 200, message = "list of all policy instance ids for this policy type id", response = String.class, responseContainer = "List") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}/policies",
-        produces = { "application/json" }, 
-        method = RequestMethod.GET)
-    ResponseEntity<List<String>> a1ControllerGetAllInstancesForType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerGetAllPolicyTypes", notes = "Get a list of all registered policy type ids", response = Integer.class, responseContainer = "List", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 200, message = "list of all registered policy type ids", response = Integer.class, responseContainer = "List") })
-    @RequestMapping(value = "/a1-p/policytypes/",
-        produces = { "application/json" }, 
-        method = RequestMethod.GET)
-    ResponseEntity<List<Integer>> a1ControllerGetAllPolicyTypes();
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerGetHealthcheck", notes = "Perform a healthcheck on a1 ", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 200, message = "A1 is healthy. Anything other than a 200 should be considered a1 as failing ") })
-    @RequestMapping(value = "/a1-p/healthcheck",
-        method = RequestMethod.GET)
-    ResponseEntity<Void> a1ControllerGetHealthcheck();
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerGetPolicyInstance", notes = "Retrieve the policy instance ", response = Object.class, tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 200, message = "The policy instance. the schema of this object is defined by the create_schema field of the policy type ", response = Object.class),
-        @ApiResponse(code = 404, message = "there is no policy instance with this policy_instance_id or there is no policy type with this policy_type_id ") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}",
-        produces = { "application/json" }, 
-        method = RequestMethod.GET)
-    ResponseEntity<Object> a1ControllerGetPolicyInstance(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerGetPolicyInstanceStatus", notes = "Retrieve the policy instance status across all handlers of the policy ", response = InlineResponse200.class, responseContainer = "List", tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 200, message = "The policy instance status. Returns a vector of statuses, where each contains a handler_id (opaque id of a RIC component that implements this policy) and the policy status as returned by that handler ", response = InlineResponse200.class, responseContainer = "List"),
-        @ApiResponse(code = 404, message = "there is no policy instance with this policy_instance_id or there is no policy type with this policy_type_id ") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}/status",
-        produces = { "application/json" }, 
-        method = RequestMethod.GET)
-    ResponseEntity<List<InlineResponse200>> a1ControllerGetPolicyInstanceStatus(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId);
-
-
-    @ApiOperation(value = "", nickname = "a1ControllerGetPolicyType", notes = "Get this policy type ", response = PolicyTypeSchema.class, tags={ "A1 Mediator", })
-    @ApiResponses(value = { 
-        @ApiResponse(code = 200, message = "policy type successfully found", response = PolicyTypeSchema.class),
-        @ApiResponse(code = 404, message = "policy type not found ") })
-    @RequestMapping(value = "/a1-p/policytypes/{policy_type_id}",
-        produces = { "application/json" }, 
-        method = RequestMethod.GET)
-    ResponseEntity<PolicyTypeSchema> a1ControllerGetPolicyType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId);
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/controller/A1PApiController.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/controller/A1PApiController.java
deleted file mode 100644 (file)
index d33e6c6..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.controller;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
-
-import org.apache.commons.beanutils.BeanUtils;
-import org.onap.nearric.simulator.model.PolicyType;
-import org.onap.nearric.simulator.service.A1PApiServiceImpl;
-import org.oransc.ric.a1med.api.model.InlineResponse200;
-import org.oransc.ric.a1med.api.model.PolicyTypeSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import io.swagger.annotations.ApiParam;
-
-/**
- * This class provides all the operation performed by A1 API.
- * 
- * @author lathishbabu.ganesan@est.tech
- *
- */
-@RestController
-public class A1PApiController implements A1PApi {
-
-  private static final Logger log = LoggerFactory.getLogger(A1PApiController.class);
-
-  private final ObjectMapper objectMapper;
-
-  private final HttpServletRequest request;
-
-  //@Autowired
-  private A1PApiServiceImpl a1pApiService;
-  //private A1PApiService a1pApiService;
-
-  @Autowired
-  public A1PApiController(ObjectMapper objectMapper, HttpServletRequest request) {
-      this.objectMapper = objectMapper;
-      this.request = request;
-      a1pApiService = new A1PApiServiceImpl();
-      a1pApiService.set(objectMapper, request);
-  }
-
-  //Reset policy db
-  @RequestMapping(value = "reset",
-          method = RequestMethod.GET)
-  public void reset() {
-         a1pApiService.reset();
-  }
-  
-  public ResponseEntity<Void> a1ControllerCreateOrReplacePolicyInstance(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId,@ApiParam(value = ""  )  @Valid @RequestBody Object body) {
-      return a1pApiService.createReplaceInstance(policyTypeId, policyInstanceId, body);
-  }
-
-  public ResponseEntity<Void> a1ControllerCreatePolicyType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = ""  )  @Valid @RequestBody PolicyTypeSchema body) {
-       return a1pApiService.createReplaceType(policyTypeId, body);
-  }
-
-  public ResponseEntity<Void> a1ControllerDeletePolicyInstance(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId) {
-       return a1pApiService.deleteInstance(policyTypeId, policyInstanceId);
-  }
-
-  public ResponseEntity<Void> a1ControllerDeletePolicyType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId) {
-       return a1pApiService.deleteType(policyTypeId);
-  }
-
-  public ResponseEntity<List<String>> a1ControllerGetAllInstancesForType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId) {
-      return a1pApiService.getAllInstanceForType(policyTypeId);
-  }
-
-  public ResponseEntity<List<Integer>> a1ControllerGetAllPolicyTypes() {
-       return a1pApiService.getAllTypes();
-  }
-
-  public ResponseEntity<Void> a1ControllerGetHealthcheck() {
-      return new ResponseEntity<Void>(HttpStatus.OK);
-  }
-
-  public ResponseEntity<Object> a1ControllerGetPolicyInstance(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId) {
-      return a1pApiService.getPolicyInstance(policyTypeId, policyInstanceId);
-  }
-
-  public ResponseEntity<List<InlineResponse200>> a1ControllerGetPolicyInstanceStatus(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId,@ApiParam(value = "",required=true) @PathVariable("policy_instance_id") String policyInstanceId) {
-       return a1pApiService.getStatus(policyTypeId, policyInstanceId);
-  }
-
-  public ResponseEntity<PolicyTypeSchema> a1ControllerGetPolicyType(@ApiParam(value = "",required=true) @PathVariable("policy_type_id") Integer policyTypeId) {
-      return a1pApiService.getPolicyTypeSchema(policyTypeId);
-  }
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/model/PolicyInstance.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/model/PolicyInstance.java
deleted file mode 100644 (file)
index ca797d4..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-
-  public class PolicyInstance implements Serializable {
-    /**
-     * 
-     */
-    private static final long serialVersionUID = -4903894058377154039L;
-       private String policyInstanceId;
-       private Object jsonObject;
-       
-       public PolicyInstance(String policyInstanceId, Object jsonObject) {
-               this.policyInstanceId = policyInstanceId;
-               this.jsonObject = jsonObject;
-       }
-
-       public Object getJson() {
-               return jsonObject;
-       }
-       
-       public String getInstanceId() {
-               return policyInstanceId;
-       }
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/model/PolicyType.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/model/PolicyType.java
deleted file mode 100644 (file)
index 5429cab..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import org.oransc.ric.a1med.api.model.PolicyTypeSchema;
-
-public class PolicyType implements Serializable {
-
-       /**
-        * 
-        */
-       private static final long serialVersionUID = 8719589957000170141L;
-       private Integer policyTypeId;
-       private PolicyTypeSchema policyTypeSchema;
-       private HashMap<String, PolicyInstance> policyInstances = new HashMap<String, PolicyInstance>();
-
-       public PolicyType(Integer policyTypeId, PolicyTypeSchema policyTypeSchema) {
-               this.policyTypeId = policyTypeId;
-               this.policyTypeSchema = policyTypeSchema;
-       }
-
-       public int getNumberInstances() {
-               return policyInstances.size();
-       }
-
-       public PolicyInstance getInstance(String policyInstanceId) {
-               return policyInstances.get(policyInstanceId);
-       }
-
-       public void delete(String policyInstanceId) {
-               policyInstances.remove(policyInstanceId);
-       }
-
-       public PolicyTypeSchema getSchema() {
-               return policyTypeSchema;
-       }
-
-       public void createReplaceInstance(String policyTypeId, PolicyInstance policyInstance) {
-               policyInstances.put(policyTypeId, policyInstance);
-       }
-
-       public Set<String> getInstances() {
-               return policyInstances.keySet();
-       }
-
-       public Integer getTypeId() {
-               return policyTypeId;
-       }
-
-}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/service/A1PApiService.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/service/A1PApiService.java
deleted file mode 100644 (file)
index b875ec7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.service;
-
-import org.onap.nearric.simulator.model.PolicyType;
-import org.oransc.ric.a1med.api.model.PolicyTypeSchema;
-
-/**
- * @author lathishbabu.ganesan@est.tech
- *
- */
-
-public interface A1PApiService {
-
-  public void getHealthCheck();
-
-  public void getPolicyTypes();
-
-  public PolicyType getPolicyType(Integer policyTypeId);
-
-  public void deletePolicyTypeId();
-
-  public void putPolicyType(Integer policyTypeId, PolicyTypeSchema policyTypeSchema);
-
-  public void getPolicyInstances();
-
-  public void getPolicyInstanceId();
-
-  public void deletePolicyInstanceId();
-
-  public void putPolicyInstance(Integer policyTypeId, String policyInstanceId, Object body);
-
-  public void getPolicyInstanceIdStatus();
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/service/A1PApiServiceImpl.java b/near-rt-ric-simulator/nearric-service/src/main/java/org/onap/nearric/simulator/service/A1PApiServiceImpl.java
deleted file mode 100644 (file)
index a79cfa4..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.nearric.simulator.service;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.nearric.simulator.model.PolicyInstance;
-import org.onap.nearric.simulator.model.PolicyType;
-import org.oransc.ric.a1med.api.model.InlineResponse200;
-import org.oransc.ric.a1med.api.model.PolicyTypeSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingMessage;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-/**
- * This class provides the service implementation of all the A1 operation
- * 
- * @author lathishbabu.ganesan@est.tech
- *
- */
-
-@Service
-public class A1PApiServiceImpl {
-
-       private static final Logger log = LoggerFactory.getLogger(A1PApiServiceImpl.class);
-
-       private HashMap<String, PolicyType> policyTypes = new HashMap<String, PolicyType>();
-
-       private ObjectMapper objectMapper = null;
-
-       private HttpServletRequest request = null;
-
-       public boolean validateSchema(String jsonData, String jsonSchema) {
-               ProcessingReport report = null;
-               boolean result = false;
-               try {
-                       log.info("Applying schema: @<@<" + jsonSchema + ">@>@ to data: #<#<" + jsonData + ">#>#");
-                       JsonNode schemaNode = JsonLoader.fromString(jsonSchema);
-                       JsonNode data = JsonLoader.fromString(jsonData);
-                       JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
-                       JsonSchema schema = factory.getJsonSchema(schemaNode);
-                       report = schema.validate(data);
-               } catch (JsonParseException jpex) {
-                       log.info("Error. Something went wrong trying to parse json data: #<#<" + jsonData
-                                       + ">#># or json schema: @<@<" + jsonSchema + ">@>@. Are the double quotes included? "
-                                       + jpex.getMessage());
-               } catch (ProcessingException pex) {
-                       log.info("Error. Something went wrong trying to process json data: #<#<" + jsonData
-                                       + ">#># with json schema: @<@<" + jsonSchema + ">@>@ " + pex.getMessage());
-               } catch (IOException e) {
-                       log.info("Error. Something went wrong trying to read json data: #<#<" + jsonData
-                                       + ">#># or json schema: @<@<" + jsonSchema + ">@>@");
-               }
-               if (report != null) {
-                       Iterator<ProcessingMessage> iter = report.iterator();
-                       while (iter.hasNext()) {
-                               ProcessingMessage pm = iter.next();
-                               log.info("Processing Message: " + pm.getMessage());
-                       }
-                       result = report.isSuccess();
-               }
-               log.info("Result=" + result);
-               return result;
-       }
-
-       public A1PApiServiceImpl() {
-       }
-
-       public void set(ObjectMapper objectMapper, HttpServletRequest request) {
-               this.objectMapper = objectMapper;
-               this.request = request;
-       }
-       
-    public void reset() {
-       log.info("Resetting db");
-       policyTypes.clear();
-    }
-
-       public ResponseEntity<Void> createReplaceType(Integer policyTypeId, PolicyTypeSchema policyTypeSchema) {
-               log.info("createReplaceType - policyTypeId: " + policyTypeId);
-               log.info("createReplaceType - policyTypeSchema: " + policyTypeSchema);
-
-               if (policyTypeId == null || policyTypeSchema == null || policyTypeSchema.getName() == null) {
-                       log.info("createReplaceType - bad parameters");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-
-               if (policyTypeSchema.getPolicyTypeId().intValue() != policyTypeId.intValue()) {
-                       log.info("createReplaceType - policytype id mismatch between request and policyTypeSchema");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-
-               if (policyTypes.containsKey(policyTypeId.toString())) {
-                       log.info("createReplaceType - policytype already exists");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-
-               PolicyType policyType = new PolicyType(policyTypeId, policyTypeSchema);
-               policyTypes.put(policyTypeId.toString(), policyType);
-               log.info("createReplaceType - created ok");
-
-               return new ResponseEntity<Void>(HttpStatus.CREATED);
-       }
-
-       public ResponseEntity<Void> deleteType(Integer policyTypeId) {
-               log.info("deleteType - policyTypeId: " + policyTypeId);
-
-               if (policyTypeId == null) {
-                       log.info("deleteType - bad parameter");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-
-               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-
-               if (policyType == null) {
-                       log.info("deleteType - policytype does not exists");
-                       return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
-               }
-
-               if (policyType.getNumberInstances() > 0) {
-                       log.info("deleteType - cannot delete, instances exists");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-               policyTypes.remove(policyTypeId.toString());
-
-               log.info("deleteType - deleted ok");
-               return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
-       }
-
-       public ResponseEntity<Void> deleteInstance(Integer policyTypeId, String policyInstanceId) {
-
-               log.info("deleteInstance - policyTypeId: " + policyTypeId);
-               log.info("deleteInstance - policyInstanceId: " + policyInstanceId);
-
-               if (policyTypeId == null || policyInstanceId == null) {
-                       log.info("deleteInstance - bad parameters");
-                       return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
-               }
-
-               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-
-               if (policyType == null) {
-                       log.info("deleteType - policytype does not exists");
-                       return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
-               }
-               PolicyInstance policyInstance = policyType.getInstance(policyInstanceId);
-               if (policyInstance == null) {
-                       log.info("deleteType - instance does not exists");
-                       return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
-               }
-               policyType.delete(policyInstanceId);
-
-               log.info("deleteInstance - deleted ok");
-               return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
-
-       }
-
-       public ResponseEntity<PolicyTypeSchema> getPolicyTypeSchema(Integer policyTypeId) {
-               log.info("getPolicyTypeSchema - policyTypeId: " + policyTypeId);
-
-               if (policyTypeId == null) {
-                       log.info("getPolicyTypeSchema - bad parameter");
-                       return new ResponseEntity<PolicyTypeSchema>(HttpStatus.NOT_FOUND);
-               }
-
-               String accept = request.getHeader("Accept");
-               if (accept != null && accept.contains("application/json")) {
-                       String res = null;
-                       try {
-                               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-
-                               if (policyType == null) {
-                                       log.info("getPolicyTypeSchema - policytype does not exists");
-                                       return new ResponseEntity<PolicyTypeSchema>(HttpStatus.NOT_FOUND);
-                               }
-
-                               String json = null;
-                               PolicyTypeSchema schema = policyType.getSchema();
-                               String createSchema = "{}";
-                               try {
-                                       // Convert Map to JSON
-                                       json = objectMapper.writeValueAsString(schema);
-                                       // Print JSON output
-                                       log.info("getPolicyTypeSchema - schema: " + json);
-
-                                       createSchema = objectMapper.writeValueAsString(schema.getCreateSchema());
-                                       log.info("getPolicyTypeSchema - createSchema: " + createSchema);
-                               } catch (Exception e) {
-                                       e.printStackTrace();
-                                       log.info("getPolicyTypeSchema - schema corrupt");
-                                       return new ResponseEntity<PolicyTypeSchema>(HttpStatus.INTERNAL_SERVER_ERROR);
-                               }
-                               res = "{\n  \"name\" : \"" + schema.getName() + "\",\n  \"description\" : \"" + schema.getDescription()
-                                               + "\",\n  \"create_schema\" : " + createSchema + ",\n  \"policy_type_id\" : "
-                                               + schema.getPolicyTypeId().intValue() + "\n}";
-                               log.info("getPolicyTypeSchema - json schema: " + res);
-                               return new ResponseEntity<PolicyTypeSchema>(objectMapper.readValue(res, PolicyTypeSchema.class),
-                                               HttpStatus.OK);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               log.info("getPolicyTypeSchema - Couldn't serialize response for content type application/json");
-                               return new ResponseEntity<PolicyTypeSchema>(HttpStatus.INTERNAL_SERVER_ERROR);
-                       }
-               }
-               log.info("getPolicyTypeSchema - not implemented");
-               return new ResponseEntity<PolicyTypeSchema>(HttpStatus.NOT_IMPLEMENTED);
-       }
-
-       public ResponseEntity<List<Integer>> getAllTypes() {
-               log.info("getAllTypes");
-               
-               String accept = request.getHeader("Accept");
-               if (accept != null && accept.contains("application/json")) {
-                       try {
-                               Set<String> types = policyTypes.keySet();
-                               String res = "";
-                               for (Iterator<String> iterator = types.iterator(); iterator.hasNext();) {
-                                       String tid = (String) iterator.next();
-                                       if (res.length() > 0) {
-                                               res = res + ",";
-                                       }
-                                       res = res + tid;
-                               }
-                               return new ResponseEntity<List<Integer>>(objectMapper.readValue("[" + res + "]", List.class),
-                                               HttpStatus.OK);
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                               log.info("getAllTypes - Couldn't serialize response for content type application/json");
-                               return new ResponseEntity<List<Integer>>(HttpStatus.INTERNAL_SERVER_ERROR);
-                       }
-               }
-               log.info("getAllTypes - not implemented");
-               return new ResponseEntity<List<Integer>>(HttpStatus.NOT_IMPLEMENTED);
-       }
-
-       public ResponseEntity<Void> createReplaceInstance(Integer policyTypeId, String policyInstanceId, Object body) {
-               log.info("createReplaceInstance -  policyTypeId:" + policyTypeId);
-               log.info("createReplaceInstance -  policyInstanceId:" + policyInstanceId);
-               log.info("createReplaceInstance -  body:" + body);
-
-               if (policyTypeId == null || policyInstanceId == null || body == null) {
-                       log.info("createReplaceInstance - bad parameter");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-
-               log.info("createReplaceInstance -  bodyclass:" + body.getClass().toString());
-
-               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-
-               if (policyType == null) {
-                       log.info("createReplaceInstance - policytype does not exists");
-                       return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
-               }
-
-               // Create json string from schema
-               String createSchema = null;
-               try {
-                       PolicyTypeSchema schema = policyType.getSchema();
-                       // Convert Map to JSON
-                       String json = objectMapper.writeValueAsString(schema);
-                       // Print JSON output
-                       log.info("createReplaceInstance - schema - json: " + json);
-                       createSchema = objectMapper.writeValueAsString(schema.getCreateSchema());
-                       log.info("createReplaceInstance - createSchema - string: " + createSchema);
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       log.info("createReplaceInstance - schema corrupt");
-                       return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR);
-               }
-
-               // Create json string from instance
-               String jsonInstance = null;
-               try {
-                       log.info("createReplaceInstance - raw: " + body);
-                       // Convert Map to JSON
-                       jsonInstance = objectMapper.writeValueAsString(body);
-                       // Print JSON output
-                       log.info("createReplaceInstance - instance: " + jsonInstance);
-
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       log.info("createReplaceInstance - instancce corrupt");
-                       return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR);
-               }
-
-               if (!validateSchema(jsonInstance, createSchema)) {
-                       log.info("createReplaceInstance - schema validation failed");
-                       return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
-               }
-               PolicyInstance policyInstance = new PolicyInstance(policyInstanceId, body);
-               policyType.createReplaceInstance(policyInstanceId, policyInstance);
-
-               log.info("createReplaceInstance - created/replaced ok");
-               return new ResponseEntity<Void>(HttpStatus.CREATED);
-
-       }
-
-       public ResponseEntity<List<String>> getAllInstanceForType(Integer policyTypeId) {
-               log.info("getAllInstanceForType -  policyTypeId:" + policyTypeId);
-
-               if (policyTypeId == null) {
-                       log.info("getAllInstanceForType - bad parameter");
-                       return new ResponseEntity<List<String>>(HttpStatus.NOT_FOUND);
-               }
-
-               String accept = request.getHeader("Accept");
-               if (accept != null && accept.contains("application/json")) {
-                       try {
-                               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-                               if (policyType == null) {
-                                       log.info("getAllInstanceForType - policytype does not exists");
-                                       return new ResponseEntity<List<String>>(HttpStatus.NOT_FOUND);
-                               }
-                               Set<String> instances = policyType.getInstances();
-                               String res = "";
-                               for (Iterator iterator = instances.iterator(); iterator.hasNext();) {
-                                       String iid = (String) iterator.next();
-                                       iid = "\"" + iid + "\"";
-                                       if (res.length() > 0) {
-                                               res = res + ",";
-                                       }
-                                       res = res + iid;
-                               }
-                               log.info("getAllInstanceForType - " + res);
-                               return new ResponseEntity<List<String>>(objectMapper.readValue("[" + res + "]", List.class),
-                                               HttpStatus.OK);
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                               log.info("getAllInstanceForType - Couldn't serialize response for content type application/json");
-                               return new ResponseEntity<List<String>>(HttpStatus.INTERNAL_SERVER_ERROR);
-                       }
-               }
-               log.info("getAllInstanceForType - not implemented");
-               return new ResponseEntity<List<String>>(HttpStatus.NOT_IMPLEMENTED);
-
-       }
-
-       public ResponseEntity<Object> getPolicyInstance(Integer policyTypeId, String policyInstanceId) {
-               log.info("getPolicyInstance -  policyTypeId:" + policyTypeId);
-               log.info("getPolicyInstance -  policyInstanceId:" + policyInstanceId);
-
-               if (policyTypeId == null || policyInstanceId == null) {
-                       log.info("getPolicyInstance - bad parameter");
-                       return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
-               }
-
-               String accept = request.getHeader("Accept");
-               if (accept != null && accept.contains("application/json")) {
-                       try {
-                               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-                               if (policyType == null) {
-                                       log.info("getPolicyInstance - policytype does not exists");
-                                       return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
-                               }
-                               PolicyInstance policyInstance = policyType.getInstance(policyInstanceId);
-                               if (policyInstance == null) {
-                                       log.info("getPolicyInstance - policyinstance does not exists");
-                                       return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
-                               }
-
-                               String json = null;
-                               try {
-                                       log.info("getPolicyInstance - rawschema: " + policyInstance.getJson());
-                                       // Convert Map to JSON
-                                       json = objectMapper.writeValueAsString(policyInstance.getJson());
-                                       // Print JSON output
-                                       log.info("getPolicyInstance - schema: " + json);
-
-                               } catch (Exception e) {
-                                       e.printStackTrace();
-                                       log.info("getPolicyInstance - schema corrupt");
-                                       return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
-                               }
-
-                               return new ResponseEntity<Object>(objectMapper.readValue(json, Object.class), HttpStatus.OK);
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                               log.info("getPolicyInstance - policyinstance corrupt");
-                               return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
-                       }
-               }
-
-               return new ResponseEntity<Object>(HttpStatus.NOT_IMPLEMENTED);
-       }
-
-       public ResponseEntity<List<InlineResponse200>> getStatus(Integer policyTypeId, String policyInstanceId) {
-               log.info("getStatus -  policyTypeId:" + policyTypeId);
-               log.info("getStatus -  policyInstanceId:" + policyInstanceId);
-
-               if (policyTypeId == null || policyInstanceId == null) {
-                       log.info("getStatus - bad parameters");
-                       return new ResponseEntity<List<InlineResponse200>>(HttpStatus.NOT_FOUND);
-               }
-
-               String accept = request.getHeader("Accept");
-               if (accept != null && accept.contains("application/json")) {
-                       try {
-                               PolicyType policyType = policyTypes.get(policyTypeId.toString());
-                               if (policyType == null) {
-                                       log.info("getStatus - policytype does not exists");
-                                       return new ResponseEntity<List<InlineResponse200>>(HttpStatus.NOT_FOUND);
-                               }
-                               PolicyInstance policyInstance = policyType.getInstance(policyInstanceId);
-                               if (policyInstance == null) {
-                                       log.info("getStatus - policyinstance does not exists");
-                                       return new ResponseEntity<List<InlineResponse200>>(HttpStatus.NOT_FOUND);
-                               }
-
-                               return new ResponseEntity<List<InlineResponse200>>(
-                                               objectMapper.readValue("[ {\n  \"handler_id\" : \"NearRTRIC-1\",\n  \"status\" : \"enforced\"\n} ]",
-                                                               List.class),
-                                               HttpStatus.OK);
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                               log.info("getStatus - Couldn't serialize response for content type application/json");
-                               return new ResponseEntity<List<InlineResponse200>>(HttpStatus.INTERNAL_SERVER_ERROR);
-                       }
-               }
-
-               return new ResponseEntity<List<InlineResponse200>>(HttpStatus.NOT_IMPLEMENTED);
-       }
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/src/main/resources/application.properties b/near-rt-ric-simulator/nearric-service/src/main/resources/application.properties
deleted file mode 100644 (file)
index b6c85b5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# ========================LICENSE_START=================================
-# %%
-# Copyright (C) 2019 Nordix Foundation
-# %%
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ========================LICENSE_END===================================
-spring.security.user.name=admin
-spring.security.user.password=admin
-spring.jackson.property-naming-strategy=SNAKE_CASE
\ No newline at end of file
diff --git a/near-rt-ric-simulator/nearric-service/test/.gitignore b/near-rt-ric-simulator/nearric-service/test/.gitignore
deleted file mode 100644 (file)
index aab4112..0000000
+++ /dev/null
@@ -1 +0,0 @@
-.tmp*
diff --git a/near-rt-ric-simulator/nearric-service/test/pi-template.json b/near-rt-ric-simulator/nearric-service/test/pi-template.json
deleted file mode 100644 (file)
index a6c6bdc..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-{ "scope": {"ue_id": "1","flow_id": "3"},
-  "statement" : {"gfbr": "l", "mfbr": "2", "priority_level": "3", "pdb": "4"},
-  "policy_id": "pi-XXXX"
-}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/nearric-service/test/populate.sh b/near-rt-ric-simulator/nearric-service/test/populate.sh
deleted file mode 100755 (executable)
index 378fee8..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-echo "Usage: populate.sh [<host:port>]"
-
-HOST_PORT="localhost:8080"
-
-if [ $# == 1 ]; then
-       echo "Setting host and port from cmd line: "$1
-       HOST_PORT=$1
-fi
-
-echo "======================================="
-echo "Using host and port:" $HOST_PORT
-echo "======================================="
-
-
-PT_MAX=10
-PI_MAX=20
-PI_ID=0
-pt=0
-while [ $pt -lt $PT_MAX ]; do
-    pi=0
-    PATTERN="s/XXXX/${pt}/g"
-    sed $PATTERN pt-template.json > .tmp.json
-    curl -v -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'$HOST_PORT'/a1-p/policytypes/'$pt
-    while [ $pi -lt $PI_MAX ]; do  
-        echo $pt"--"$pi"-"$PI_ID
-        
-        PATTERN="s/XXXX/${PI_ID}/g"
-        sed $PATTERN pi-template.json > .tmp.json
-        curl -v -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'$HOST_PORT'/a1-p/policytypes/'$pt'/policies/'$PI_ID
-        let pi=pi+1
-        let PI_ID=PI_ID+1
-    done
-    let pt=pt+1
-done
-
-curl -v --header 'Accept: application/json'  'http://'$HOST_PORT'/a1-p/policytypes/'
-curl -v --header 'Accept: application/json'  'http://'$HOST_PORT'/a1-p/policytypes/1/policies'
diff --git a/near-rt-ric-simulator/nearric-service/test/pt-template.json b/near-rt-ric-simulator/nearric-service/test/pt-template.json
deleted file mode 100644 (file)
index 8fa16b1..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-{
-  "description": "Policy type XXXX",
-  "name": "PT XXXX",
-  "policy_type_id": XXXX,
-  "create_schema":
-
-
-  {
-    "$id": "https://est.tech/policy-type.schema.json",
-    "$schema": "http://json-schema.org/draft-07/schema#",
-    "title": "Policy type schema XXXX",
-    "description": "Policy type schema for qos",
-    "type": "object",
-    "properties": {
-      "policy_id": {
-        "description": "Identity of the policy",
-        "type": "string"},
-      "scope": {
-        "type": "object",
-        "properties": {
-          "ue_id": {
-            "description": "User identity",
-            "type": "string"},
-          "flow_id": {
-            "description": "Identity of the flow",
-            "type": "string"}
-        }, "required": ["ue_id", "flow_id"]
-      },
-      "statement": {
-        "type": "object",
-        "properties": {
-          "gfbr": {
-            "description": "Guaranteed Flow Bit Rate",
-            "type": "string"},
-          "mfbr": {
-            "description": "Maximum Flow Bit Rate",
-            "type": "string"},
-          "priority_level": {
-            "description": "Priority Level",
-            "type": "string"},
-          "pdb": {
-            "description": "Packet Delay Budget",
-            "type": "string"}
-        }, "required": ["gfbr", "mfbr", "priority_level", "pdb"]
-      }
-    }, "required": ["policy_id", "scope", "statement"]
-  }
-
-}
diff --git a/near-rt-ric-simulator/nearric-service/test/test-api.sh b/near-rt-ric-simulator/nearric-service/test/test-api.sh
deleted file mode 100755 (executable)
index fd6b1d0..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/bin/bash
-
-#Script for basic testing of the A1 simulator API
-#Note: policy is reset before test
-
-HOST_PORT="localhost:8080"
-
-echo "Usage: populate.sh [<host:port>]"
-
-HOST_PORT="localhost:8080"
-
-if [ $# == 1 ]; then
-       echo "Setting host and port from cmd line: "$1
-       HOST_PORT=$1
-fi
-
-echo "======================================="
-echo "Using host and port:" $HOST_PORT
-echo "======================================="
-
-echo "======================================="
-echo "Resetting db"
-curl 'http://'$HOST_PORT'/reset'
-echo "======================================="
-
-#Create a policy type
-create_pt() {
-    PATTERN="s/XXXX/${1}/g"
-    sed $PATTERN pt-template.json > .tmp.json
-    res=$(curl -sw "%{http_code}" -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'${HOST_PORT}'/a1-p/policytypes/'$1)
-       http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-}
-
-get_pt() {
-    res=$(curl -sw "%{http_code}" --header 'Accept: application/json'  'http://'${HOST_PORT}'/a1-p/policytypes/'$1)
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-    echo "Response: " ${res:0:${#res}-3}
-}
-
-get_pts() {
-    res=$(curl -sw "%{http_code}" --header 'Accept: application/json'  'http://'${HOST_PORT}'/a1-p/policytypes/')
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-    echo "Response: " ${res:0:${#res}-3}
-}
-
-del_pt() {
-    res=$(curl -sw "%{http_code}" -X DELETE --header 'Accept: */*'  'http://'${HOST_PORT}'/a1-p/policytypes/'$1)
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code  
-}
-
-get_pis() {
-    res=$(curl -sw "%{http_code}" --header 'Accept: application/json'  'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies')
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-    echo "Response: " ${res:0:${#res}-3}
-}
-
-create_pi() {
-    PATTERN="s/XXXX/${2}/g"
-    sed $PATTERN pi-template.json > .tmp.json
-    res=$(curl -sw "%{http_code}" -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'${HOST_PORT}'/a1-p/policytypes/'$1'/policies/'$2)
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-}
-
-get_pi() {
-    res=$(curl -sw "%{http_code}" --header 'Accept: application/json'  'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies/'$2)
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-    echo "Response: " ${res:0:${#res}-3}
-}
-
-del_pi() {
-    res=$(curl -sw "%{http_code}" -X DELETE --header 'Accept: application/json'  'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies/'$2)
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code 
-}
-
-stat_pi() {
-    res=$(curl -sw "%{http_code}" --header 'Accept: application/json'  'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies/'$2'/status')
-    http_code="${res:${#res}-3}"
-    echo "Response code: " $http_code
-    echo "Response: " ${res:0:${#res}-3}
-}
-
-
-echo "== Create policy type 23"
-create_pt 23
-echo "== Get policy type 23"
-get_pt 23
-echo "== Create policy type 23 again"
-create_pt 23
-echo "== Create policy type 24"
-create_pt 24
-echo "== Get all policy types"
-get_pts
-echo "== Delete policy type 24"
-del_pt 24
-echo "== Delete policy type 24 again"
-del_pt 24
-echo "== Get all policy types"
-get_pts
-echo "== Get all policy instancess for type 23"
-get_pis 23
-echo "== Create policy instance 16 for type 23"
-create_pi 23 16
-echo "== Create policy instance 16 for type 23 again"
-create_pi 23 16
-echo "== Get policy instance 16 for type 23"
-get_pi 23 16
-echo "== Get missing policy instance 17 for type 23"
-get_pi 23 17
-echo "== Create policy instance 18 for type 23"
-create_pi 23 18
-echo "== Get all policy instances for type 23"
-get_pis 23
-echo "== Delete policy instance 18 for type 23"
-del_pi 23 18
-echo "== Get all policy instances for type 23"
-get_pis 23
-echo "== Get status for policy instance 16 for type 23"
-stat_pi 23 16
diff --git a/near-rt-ric-simulator/pom.xml b/near-rt-ric-simulator/pom.xml
deleted file mode 100644 (file)
index 5836853..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ============LICENSE_START=======================================================
-   Copyright (C) 2019 Nordix Foundation.
-  ================================================================================
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-
-  SPDX-License-Identifier: Apache-2.0
-  ============LICENSE_END=========================================================
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.oran.nearric</groupId>
-  <artifactId>nearric-simulator</artifactId>
-  <version>1.0.1-SNAPSHOT</version>
-  <packaging>pom</packaging>
-  <name>${project.artifactId}</name>
-
-  <parent>
-    <groupId>org.springframework.boot</groupId>
-    <artifactId>spring-boot-starter-parent</artifactId>
-    <version>2.1.9.RELEASE</version>
-    <relativePath />
-  </parent>
-
-  <properties>
-    <spring.boot.version>2.1.9.RELEASE</spring.boot.version>
-    <java.version>11</java.version>
-    <docker-maven-plugin.version>0.30.0</docker-maven-plugin.version>
-  </properties>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-dependencies</artifactId>
-        <version>${spring.boot.version}</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-context</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-web</artifactId>
-    </dependency>
-  </dependencies>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <release>${java.version}</release>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/config.json b/near-rt-ric-simulator/simulator-group/consul_cbs/config.json
deleted file mode 100644 (file)
index 52acc38..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-{
-    "ric": [
-        {
-            "name": "ric_ric-simulator_3",
-            "baseUrl": "http://ric_ric-simulator_3:8085/",
-            "managedElementIds": [
-                "kista_ric_ric-simulator_3",
-                "stockholm_ric_ric-simulator_3"
-            ]
-        },
-        {
-            "name": "ric_ric-simulator_2",
-            "baseUrl": "http://ric_ric-simulator_2:8085/",
-            "managedElementIds": [
-                "kista_ric_ric-simulator_2",
-                "stockholm_ric_ric-simulator_2"
-            ]
-        },
-        {
-            "name": "ric_ric-simulator_1",
-            "baseUrl": "http://ric_ric-simulator_1:8085/",
-            "managedElementIds": [
-                "kista_ric_ric-simulator_1",
-                "stockholm_ric_ric-simulator_1"
-            ]
-        }
-    ],
-    "streams_publishes": {
-        "dmaap_publisher": {
-            "type": "message_router",
-            "dmaap_info": {
-                "topic_url": "http://message-router:3905/events/A1-POLICY-AGENT-WRITE"
-            }
-        }
-    },
-    "streams_subscribes": {
-        "dmaap_subscriber": {
-            "type": "message_router",
-            "dmaap_info": {
-                "topic_url": "http://message-router:3905/events/A1-POLICY-AGENT-READ/users/policy-agent"
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_config.hcl b/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_config.hcl
deleted file mode 100644 (file)
index d36ae56..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#server = true
-#bootstrap = true
-#client_addr = "0.0.0.0"
-
-service  {
-  # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
-  # should be passed to Policy Agent app with this value
-  Name = "config-binding-service"
-  # Host name where CBS is running
-  Address = "config-binding-service"
-  # Port number where CBS is running
-  Port = 10000
-}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl b/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl
deleted file mode 100644 (file)
index 63be3d4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-service {
-  # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
-  # should be passed to Policy Agent app with this value
-  # This is only to be used when contacting cbs via local host
-  # (typicall when Policy Agent is executed as an application without a container)
-  Name = "config-binding-service-localhost"
-  # Host name where CBS is running
-  Address = "localhost"
-  # Port number where CBS is running
-  Port = 10000
-}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose-template.yml b/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose-template.yml
deleted file mode 100644 (file)
index c2d07de..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-version: '3'
-
-networks:
-  nonrtric-docker-net:
-    external:
-      name: nonrtric-docker-net
-
-services:
-
-  consul-server:
-    networks:
-      - nonrtric-docker-net
-    container_name: polman_consul
-    image: docker.io/consul:1.4.4
-    ports:
-      - "8500:8500"
-    volumes:
-      - ./consul/:/consul/config
-
-  config-binding-service:
-    networks:
-      - nonrtric-docker-net
-    container_name: polman_cbs
-    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:2.3.0
-    ports:
-      - "10000:10000"
-    environment:
-      - CONSUL_HOST=consul-server
-    depends_on:
-      - consul-server
-
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/start.sh b/near-rt-ric-simulator/simulator-group/consul_cbs/start.sh
deleted file mode 100755 (executable)
index ed4f9e6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-DOCKER_SIM_NWNAME="nonrtric-docker-net"
-echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
-docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
-
-docker-compose -f docker-compose-template.yml config > docker-compose.yml
-
-docker-compose up -d
-
-CONSUL_PORT=8500
-
-APP="policy-agent"
-JSON_FILE="config.json"
-
-curl -s -v  http://127.0.0.1:${CONSUL_PORT}/v1/kv/${APP}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$JSON_FILE
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/dashboard/docker-compose.yml b/near-rt-ric-simulator/simulator-group/dashboard/docker-compose.yml
deleted file mode 100644 (file)
index ef4ecd3..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-networks:
-  nonrtric-docker-net:
-    external:
-      name: nonrtric-docker-net
-services:
-  dashboard:
-    image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-dashboard:1.0.1
-
-    networks:
-      nonrtric-docker-net: null
-    ports:
-    - 8080:8080
-version: '3.0'
-
-
diff --git a/near-rt-ric-simulator/simulator-group/ric/cleanConsul.py b/near-rt-ric-simulator/simulator-group/ric/cleanConsul.py
deleted file mode 100644 (file)
index 1e40416..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-import json
-import subprocess
-import os
-
-print("Clean old ric configurations in Consul config file")
-
-p = os.path.abspath('..')
-consul_config = p + '/consul_cbs' + '/config.json'
-
-
-def write_json(data, filename=consul_config):
-    with open(filename, 'w') as f:
-        json.dump(data, f, indent=4)
-
-
-with open(consul_config) as json_file:
-    clean = json.load(json_file)
-    clean['ric'] = []
-
-
-write_json(clean)
-print("Clean old ric configurations from Consul config file, done")
-
-
diff --git a/near-rt-ric-simulator/simulator-group/ric/docker-compose.yml b/near-rt-ric-simulator/simulator-group/ric/docker-compose.yml
deleted file mode 100644 (file)
index e45e0e4..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-networks:
-  nonrtric-docker-net:
-    external:
-      name: nonrtric-docker-net
-services:
-  ric-simulator:
-    image: ric-simulator:latest
-    networks:
-      nonrtric-docker-net: null
-    ports:
-    - 8085/tcp
-version: '3.0'
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/ric/prepareConsul.py b/near-rt-ric-simulator/simulator-group/ric/prepareConsul.py
deleted file mode 100644 (file)
index 5cb482b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-import json
-import subprocess
-import os
-
-print("Update fresh ric configuration in Consul configuration file")
-
-p = os.path.abspath('..')
-consul_config = p + '/consul_cbs' + '/config.json'
-
-
-def write_json(data, filename=consul_config):
-    with open(filename, 'w') as f:
-        json.dump(data, f, indent=4)
-
-
-def bash_command(cmd):
-    result = []
-    sp = subprocess.Popen(['/bin/bash', '-c', cmd], stdout=subprocess.PIPE)
-    for line in sp.stdout.readlines():
-        result.append(line.decode().strip())
-    return result
-
-
-command = "docker ps | grep simulator | awk '{print $NF}'"
-
-ric_list = bash_command(command)
-
-with open(consul_config) as json_file:
-    data = json.load(json_file)
-    temp = data['ric']
-    for ric in ric_list:
-        y = {"name": ric,
-             "baseUrl": "http://" + ric + ":8085/",
-             "managedElementIds": [
-                 "kista_" + ric,
-                 "stockholm_" + ric
-             ]
-             }
-        temp.append(y)
-
-
-write_json(data)
-print("Update Consul config file with fresh ric configuration,  done")
diff --git a/near-rt-ric-simulator/simulator-group/simulators-start.sh b/near-rt-ric-simulator/simulator-group/simulators-start.sh
deleted file mode 100755 (executable)
index adcf621..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-
-DOCKER_SIM_NWNAME="nonrtric-docker-net"
-echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
-docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
-docker-compose -f consul_cbs/docker-compose-template.yml config > docker-compose.yml
-
-docker-compose up -d
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 840cb0f..facc920 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,6 @@
     <modules>
         <module>policy-agent</module>
         <module>sdnc-a1-controller</module>
-        <module>near-rt-ric-simulator</module>
     </modules>
     <build>
         <plugins>
diff --git a/test/auto-test/.gitignore b/test/auto-test/.gitignore
new file mode 100644 (file)
index 0000000..6215d91
--- /dev/null
@@ -0,0 +1,10 @@
+logs
+.tmp_*
+.http*
+.p.json
+.tmp.json
+.docker-images-table
+.image-list
+.tmp.curl.json
+.consul*
+.ext.consul*
similarity index 95%
rename from near-rt-ric-simulator/auto-test/Dockerize_test.sh
rename to test/auto-test/Dockerize_test.sh
index 34532c9..dec3217 100755 (executable)
@@ -16,7 +16,7 @@ start_simulators
 
 consul_config_app         "../simulator-group/consul_cbs/config.json"
 
-start_dashboard
+start_control_panel
 
 start_sdnc
 
diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh
new file mode 100755 (executable)
index 0000000..8808895
--- /dev/null
@@ -0,0 +1,170 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+TC_ONELINE_DESCR="Basic use case, register rapp, create/update policy, delete policy, de-register rapp using both STD and OSC interface over REST and Dmaap"
+
+. ../common/testcase_common.sh $@
+. ../common/agent_api_functions.sh
+
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
+clean_containers
+
+start_ric_simulators  ricsim_g1 3 OSC_2.1.0
+
+start_ric_simulators  ricsim_g2 5 STD_1.1.3
+
+start_mr
+
+start_cr
+
+start_consul_cbs
+
+prepare_consul_config      NOSDNC  ".consul_config.json"
+consul_config_app                  ".consul_config.json"
+
+start_control_panel
+
+#start_sdnc
+
+start_policy_agent
+
+use_agent_rest
+
+api_get_status 200
+
+sim_print ricsim_g1_1 interface
+
+sim_print ricsim_g2_1 interface
+
+sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+api_equal json:policy_types 2 60
+
+
+# Create policies
+use_agent_rest
+
+api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1"
+
+api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1
+
+sim_equal ricsim_g1_1 num_instances 1
+
+
+use_agent_dmaap
+
+api_put_policy 201 "rapp1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1
+
+sim_equal ricsim_g1_1 num_instances 2
+
+
+use_agent_rest
+
+api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1
+
+sim_equal ricsim_g2_1 num_instances 1
+
+
+use_agent_dmaap
+
+api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1
+
+sim_equal ricsim_g2_1 num_instances 2
+
+
+#Update policies
+use_agent_rest
+
+api_put_service 200 "rapp1" 3600 "$CR_PATH/callbacks/1"
+
+api_put_policy 200 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1
+
+sim_equal ricsim_g1_1 num_instances 2
+
+
+use_agent_dmaap
+
+api_put_policy 200 "rapp1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1
+
+sim_equal ricsim_g1_1 num_instances 2
+
+
+use_agent_rest
+
+
+api_put_policy 200 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1
+
+sim_equal ricsim_g2_1 num_instances 2
+
+
+use_agent_dmaap
+
+api_put_policy 200 "rapp1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1
+
+sim_equal ricsim_g2_1 num_instances 2
+
+# Check policies
+api_get_policy 200 2000 testdata/OSC/pi1_template.json
+api_get_policy 200 3000 testdata/OSC/pi1_template.json
+api_get_policy 200 2100 testdata/STD/pi1_template.json
+api_get_policy 200 3100 testdata/STD/pi1_template.json
+
+# Remove policies
+
+use_agent_dmaap
+api_delete_policy 204 2000
+use_agent_rest
+api_delete_policy 204 3000
+use_agent_dmaap
+api_delete_policy 204 2100
+use_agent_rest
+api_delete_policy 204 3100
+
+sim_equal ricsim_g1_1 num_instances 0
+sim_equal ricsim_g2_1 num_instances 0
+
+# Check policy removal
+use_agent_rest
+api_get_policy 404 2000
+api_get_policy 404 3000
+api_get_policy 404 2100
+api_get_policy 404 3100
+
+# Remove the service
+use_agent_dmaap
+api_delete_services 204 "rapp1"
+
+api_get_services 404 "rapp1"
+
+
+
+check_policy_agent_logs
+
+#### TEST COMPLETE ####
+
+store_logs          END
+
+print_result
\ No newline at end of file
diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh
new file mode 100755 (executable)
index 0000000..79fdd49
--- /dev/null
@@ -0,0 +1,324 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+
+TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/without SDNC A1 Controller"
+
+. ../common/testcase_common.sh  $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+. ../common/controller_api_functions.sh
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
+# Tested variants of REST/DMAAP/SDNC config
+TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
+
+
+for interface in $TESTED_VARIANTS ; do
+
+    echo "#####################################################################"
+    echo "#####################################################################"
+    echo "### Testing agent: "$interface
+    echo "#####################################################################"
+    echo "#####################################################################"
+
+
+    # Clean container and start all needed containers #
+    clean_containers
+
+    start_ric_simulators ricsim_g1 1  OSC_2.1.0
+    start_ric_simulators ricsim_g2 1  STD_1.1.3
+
+    start_mr
+
+    start_cr
+
+    start_consul_cbs
+
+    if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+        prepare_consul_config      SDNC    ".consul_config.json"
+    else
+        prepare_consul_config      NOSDNC  ".consul_config.json"
+    fi
+
+    consul_config_app                      ".consul_config.json"
+
+    start_control_panel
+
+    if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+        start_sdnc
+    fi
+
+    start_policy_agent
+
+    if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
+        use_agent_dmaap
+    else
+        use_agent_rest
+    fi
+
+
+    cr_equal received_callbacks 0
+    mr_equal requests_submitted 0
+
+    sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+    sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
+
+    api_equal json:rics 2 60
+
+    api_equal json:policy_schemas 3 120
+
+    api_equal json:policy_types 3
+
+    api_equal json:policies 0
+
+    api_equal json:policy_ids 0
+
+
+
+
+    echo "############################################"
+    echo "############## Health check ################"
+    echo "############################################"
+
+    api_get_status 200
+
+    echo "############################################"
+    echo "##### Service registry and supervision #####"
+    echo "############################################"
+
+    api_get_services 404 "rapp1"
+
+    api_put_service 201 "rapp1" 1000 "$CR_PATH/1"
+
+    api_put_service 200 "rapp1" 2000 "$CR_PATH/1"
+
+
+    api_put_service 400 "rapp2" -1 "$CR_PATH/2"
+
+    api_put_service 400 "rapp2" "wrong" "$CR_PATH/2"
+
+    api_put_service 400 "rapp2" 100 "/test"
+
+    api_put_service 400 "rapp2" 100 "test-path"
+
+    api_put_service 201 "rapp2" 300 "ftp://localhost:80/test"
+
+    api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
+
+    api_get_service_ids 200 "rapp1" "rapp2"
+
+
+    api_put_service 201 "rapp3" 5000 "$CR_PATH/3"
+
+
+    api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
+
+
+    api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
+
+    api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3"
+
+    api_get_services 200
+
+    echo -e $YELLOW"TR2"$EYELLOW
+    api_put_services_keepalive 201 "rapp1"
+    echo -e $YELLOW"TR2"$EYELLOW
+    api_put_services_keepalive 201 "rapp3"
+
+    api_put_services_keepalive 200 "rapp1"
+
+    api_put_services_keepalive 200 "rapp3"
+
+    api_put_services_keepalive 404 "rapp5"
+
+    api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
+
+    api_delete_services 204 "rapp1"
+
+    api_get_service_ids 200 "rapp2" "rapp3"
+
+
+    api_put_service 201 "rapp1" 50 "$CR_PATH/1"
+
+    api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
+
+
+    api_delete_services 204 "rapp1"
+    api_delete_services 204 "rapp3"
+
+    api_equal json:services 1
+
+    api_delete_services 204 "rapp2"
+
+    api_equal json:services 0
+
+
+    echo "############################################"
+    echo "############## RIC Repository ##############"
+    echo "############################################"
+
+    api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
+
+    api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
+
+    api_get_rics 404 47
+
+    api_get_rics 404 "test"
+
+
+    api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
+
+    api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
+
+    api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
+
+    api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
+
+    api_get_ric 404 test
+
+
+    echo "############################################"
+    echo "########### A1 Policy Management ###########"
+    echo "############################################"
+    echo -e $YELLOW"TR9"$EYELLOW
+    api_get_policy_schema 200 1 testdata/OSC/1.json
+    echo -e $YELLOW"TR9"$EYELLOW
+    api_get_policy_schema 200 2 testdata/OSC/2.json
+
+    api_get_policy_schema 404 3
+    echo -e $YELLOW"TR9"$EYELLOW
+    api_get_policy_schemas 200 NORIC testdata/OSC/1.json testdata/OSC/2.json NOFILE
+    echo -e $YELLOW"TR9"$EYELLOW
+    api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1.json testdata/OSC/2.json
+
+    api_get_policy_schemas 200 ricsim_g2_1 NOFILE
+
+    api_get_policy_schemas 404 test
+
+
+
+    api_get_policy_types 200 NORIC 1 2 EMPTY
+
+    api_get_policy_types 200 ricsim_g1_1 1 2
+
+    api_get_policy_types 200 ricsim_g2_1 EMPTY
+
+    api_get_policy_types 404 dummy-ric
+
+
+
+    api_put_service 201 "rapp10" 3600 "$CR_PATH/1"
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
+
+    api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
+    api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
+
+    api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+    api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+
+    VAL='NOT IN EFFECT'
+    api_get_policy_status 200 5000 OSC "$VAL" "false"
+    api_get_policy_status 200 5100 STD "UNDEFINED"
+
+
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_equal json:policies 2
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_equal json:policy_ids 2
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
+
+    api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
+
+
+    api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_get_policy_ids 200 NORIC NOSERVICE 1 5000
+
+    api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
+
+    api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
+
+
+    api_get_policy 200 5000 testdata/OSC/pi1_template.json
+
+    api_get_policy 200 5100 testdata/STD/pi1_template.json
+
+
+
+    api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json
+
+
+
+
+    echo -e $YELLOW"TR10"$EYELLOW
+    api_delete_policy 404 2000
+
+    api_delete_policy 404 1500
+
+    api_delete_policy 204 5000
+
+    api_equal json:policies 1
+
+    api_equal json:policy_ids 1
+
+    api_delete_policy 204 5100
+
+    api_equal json:policies 0
+
+    api_equal json:policy_ids 0
+
+    cr_equal received_callbacks 0
+
+    if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
+        mr_greater requests_submitted 0
+        VAL=$(mr_read requests_submitted)
+        mr_equal requests_fetched $VAL
+        mr_equal responses_submitted $VAL
+        mr_equal responses_fetched $VAL
+        mr_equal current_requests 0
+        mr_equal current_responses 0
+    else
+        mr_equal requests_submitted 0
+    fi
+
+    check_policy_agent_logs
+    check_control_panel_logs
+
+    store_logs          $interface
+
+done
+
+#### TEST COMPLETE ####
+
+
+print_result
+
+auto_clean_containers
diff --git a/test/auto-test/FTC200.sh b/test/auto-test/FTC200.sh
new file mode 100755 (executable)
index 0000000..2f62c56
--- /dev/null
@@ -0,0 +1,158 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+
+TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive"
+
+. ../common/testcase_common.sh  $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
+
+#### TEST BEGIN ####
+
+clean_containers
+
+start_ric_simulators ricsim_g1 1  OSC_2.1.0
+
+start_mr
+
+start_cr
+
+start_consul_cbs
+
+prepare_consul_config      NOSDNC  ".consul_config.json"
+consul_config_app                  ".consul_config.json"
+
+start_control_panel
+
+#start_sdnc
+
+start_policy_agent
+
+use_agent_rest
+
+#Verify no callbacks or dmaap messages has been sent
+cr_equal received_callbacks 0
+mr_equal requests_submitted 0
+
+#Check agent alive
+api_get_status 200
+
+#Print simulator interface version
+sim_print ricsim_g1_1 interface
+
+api_put_service 201 "rapp1" 15 "$CR_PATH/rapp1"
+
+api_get_services 200 "rapp1" 15 "$CR_PATH/rapp1"
+
+api_put_service 201 "rapp2" 120 "$CR_PATH/rapp2"
+
+api_get_services 200 "rapp2" 120 "$CR_PATH/rapp2"
+
+api_put_service 200 "rapp1" 50 "$CR_PATH/rapp1"
+api_put_service 200 "rapp2" 180 "$CR_PATH/rapp2"
+
+api_get_services 200 "rapp1" 50 "$CR_PATH/rapp1"
+api_get_services 200 "rapp2" 180 "$CR_PATH/rapp2"
+
+api_get_service_ids 200 "rapp1" "rapp2"
+
+sleep_wait 30 "Waiting for keep alive timeout"
+
+api_get_services 200 "rapp1" 50 "$CR_PATH/rapp1"
+api_get_services 200 "rapp2" 180 "$CR_PATH/rapp2"
+
+sleep_wait 100 "Waiting for keep alive timeout"
+
+api_get_services 404 "rapp1"
+api_get_services 200 "rapp2" 180 "$CR_PATH/rapp2"
+
+api_delete_services 204 "rapp2"
+
+api_get_services 404 "rapp1"
+api_get_services 404 "rapp2"
+
+api_put_service 201 "rapp3" 60 "$CR_PATH/rapp3"
+
+api_get_services 200 "rapp3" 60 "$CR_PATH/rapp3"
+
+sleep_wait 30 "Waiting for keep alive timeout"
+
+api_put_service 200 "rapp3" 60 "$CR_PATH/rapp3"
+
+sleep_wait 100 "Waiting for keep alive timeout"
+
+api_get_services 404 "rapp3"
+
+api_put_service 201 "rapp4" 120 "$CR_PATH/rapp4"
+
+sleep_wait 60 "Waiting for keep alive timeout"
+
+api_get_services 200 "rapp4" 120 "$CR_PATH/rapp4"
+
+api_put_services_keepalive 200 "rapp4"
+
+sleep_wait 90 "Waiting for keep alive timeout"
+
+api_get_services 200 "rapp4" 120 "$CR_PATH/rapp4"
+
+api_delete_services 204 "rapp4"
+
+api_get_services 404 "rapp4"
+
+api_get_services 404 "rapp1"
+api_get_services 404 "rapp2"
+api_get_services 404 "rapp3"
+
+api_get_service_ids 200
+
+api_delete_services 404 "rapp1"
+api_delete_services 404 "rapp2"
+api_delete_services 404 "rapp3"
+api_delete_services 404 "rapp4"
+
+api_put_services_keepalive 404 "rapp1"
+api_put_services_keepalive 404 "rapp2"
+api_put_services_keepalive 404 "rapp3"
+api_put_services_keepalive 404 "rapp4"
+
+api_get_service_ids 200
+
+
+
+cr_equal received_callbacks 0
+mr_equal requests_submitted 0
+
+check_policy_agent_logs
+check_control_panel_logs
+
+#### TEST COMPLETE ####
+
+store_logs          END
+
+print_result
+
+auto_clean_containers
\ No newline at end of file
diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh
new file mode 100755 (executable)
index 0000000..3b07f60
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST"
+
+. ../common/testcase_common.sh  $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
+clean_containers
+
+start_ric_simulators ricsim_g1 4 OSC_2.1.0
+
+start_mr
+
+start_cr
+
+start_consul_cbs
+
+prepare_consul_config      NOSDNC  ".consul_config.json"
+consul_config_app                  ".consul_config.json"
+
+start_control_panel
+
+
+start_policy_agent
+
+use_agent_rest
+
+api_get_status 200
+
+sim_print ricsim_g1_1 interface
+
+sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+api_equal json:policy_types 1 120  #Wait for the agent to refresh types from the simulator
+
+api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1"
+
+api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 10000
+
+sim_equal ricsim_g1_1 num_instances 10000
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+sim_equal ricsim_g1_1 num_instances 0
+
+sim_equal ricsim_g1_1 num_instances 10000 300
+
+api_delete_policy 204 2435
+
+api_delete_policy 204 8693
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+sim_equal ricsim_g1_1 num_instances 9998 300
+
+
+check_policy_agent_logs
+
+#### TEST COMPLETE ####
+
+store_logs          END
+
+print_result
\ No newline at end of file
diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh
new file mode 100755 (executable)
index 0000000..0edd82e
--- /dev/null
@@ -0,0 +1,172 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+TC_ONELINE_DESCR="Repeatedly create and delete 10000 policies in each RICs for 24h. Via agent REST"
+
+. ../common/testcase_common.sh  $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+# Number of RICs per interface type (OSC and STD)
+NUM_RICS=4
+# Number of policy instances per RIC
+NUM_INSTANCES=10000
+
+clean_containers
+
+start_ric_simulators ricsim_g1 4 OSC_2.1.0
+
+start_ric_simulators ricsim_g2 4 STD_1.1.3
+
+start_mr
+
+start_cr
+
+start_consul_cbs
+
+prepare_consul_config      NOSDNC  ".consul_config.json"
+consul_config_app                  ".consul_config.json"
+
+start_control_panel
+
+start_policy_agent
+
+use_agent_rest
+
+api_get_status 200
+
+echo "Print the interface for group 1 simulators, shall be OSC"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_print ricsim_g1_$i interface
+done
+
+echo "Print the interface for group 2 simulators, shall be STD"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_print ricsim_g2_$i interface
+done
+
+echo "Load policy type in group 1 simulators"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
+done
+
+echo "Check the number of instances in  group 1 simulators, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g1_$i num_instances 0
+done
+
+echo "Check the number of instances in  group 2 simulators, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g2_$i num_instances 0
+done
+
+echo "Wait for the agent to refresh types from the simulator"
+api_equal json:policy_types 2 120
+
+echo "Check the number of types in the agent for each ric is 1"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   api_equal json:policy_types?ric=ricsim_g1_$i 1 120
+done
+
+echo "Register a service"
+api_put_service 201 "rapp1" 0 "$CR_PATH/1"
+
+TEST_DURATION=$((24*3600))
+TEST_START=$SECONDS
+
+while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
+
+    echo ""
+    echo "#########################################################################################################"
+    echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds (24h)."$EBOLD
+    echo "#########################################################################################################"
+    echo ""
+
+
+    echo "Create 10000 instances in each OSC RIC"
+    INSTANCE_ID=200000
+    INSTANCES=0
+    for ((i=1; i<=$NUM_RICS; i++))
+    do
+        api_put_policy 201 "rapp1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
+        sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
+        INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
+        INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
+    done
+
+    api_equal json:policy_ids $INSTANCES
+
+    echo "Create 10000 instances in each OSC RIC"
+    for ((i=1; i<=$NUM_RICS; i++))
+    do
+        api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
+        sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
+        INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
+        INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
+    done
+
+    api_equal json:policy_ids $INSTANCES
+
+
+    echo "Delete all instances in each OSC RIC"
+
+    INSTANCE_ID=200000
+    for ((i=1; i<=$NUM_RICS; i++))
+    do
+        api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
+        INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
+        sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
+        INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
+    done
+
+    api_equal json:policy_ids $INSTANCES
+
+    echo "Delete all instances in each STD RIC"
+    INSTANCE_ID=200000
+    for ((i=1; i<=$NUM_RICS; i++))
+    do
+        api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
+        INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
+        sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
+        INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
+    done
+
+    api_equal json:policy_ids 0
+done
+
+
+check_policy_agent_logs
+
+#### TEST COMPLETE ####
+
+store_logs          END
+
+print_result
\ No newline at end of file
diff --git a/test/auto-test/FTC320.sh b/test/auto-test/FTC320.sh
new file mode 100755 (executable)
index 0000000..2b1b96a
--- /dev/null
@@ -0,0 +1,202 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+TC_ONELINE_DESCR="Create and delete 50 policies in each 50 RICs, 25 STD version, 25 OSC version. Via agent REST"
+
+. ../common/testcase_common.sh  $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+# Number of RICs
+NUM_RICS=25
+# Number of instances per RIC
+NUM_INST=50
+
+# Clean and start all containers
+clean_containers
+
+start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
+
+start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
+
+start_mr
+
+start_cr
+
+start_consul_cbs
+
+prepare_consul_config      NOSDNC  ".consul_config.json"
+consul_config_app                  ".consul_config.json"
+
+start_control_panel
+
+start_policy_agent
+
+use_agent_rest
+
+set_agent_debug
+
+# Main tests
+
+echo "Checking agent is alive"
+api_get_status 200
+
+
+echo "Print the interface for group 1 simulators, shall be OSC"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_print ricsim_g1_$i interface
+done
+
+echo "Print the interface for group 2 simulators, shall be STD"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_print ricsim_g2_$i interface
+done
+
+echo "Checking the number of policy instances in each group 1 simulator, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g1_$i num_instances 0
+done
+
+echo "Checking the number of policy instances in each group 2 simulator, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g1_$i num_instances 0
+done
+
+echo "Load policy type 1 in each group 1 simulator"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
+done
+
+echo "Checking the number of policy types in each group 1 simulator, shall be 1"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g1_$i num_types 1
+done
+
+echo "Checking the number of policy types in each group 2 simulator, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g2_$i num_types 0
+done
+
+echo "Check the number of rics, shall be the configured number: ""$(($NUM_RICS*2))"
+api_equal json:rics "$(($NUM_RICS*2))" 120
+
+api_equal json:policy_types 2 120  #Wait for the agent to refresh types from the simulator
+
+sleep_wait 120 "Wait for the agent to refresh the types from all rics"
+
+echo "Check the number of types in the agent for each group 1 rics, shall be 1"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   api_equal json:policy_types?ric=ricsim_g1_$i 1
+done
+
+echo "Check the number of types in the agent for each group 2 rics, shall be 1"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   api_equal json:policy_types?ric=ricsim_g2_$i 1
+done
+
+echo "Register the service"
+api_put_service 201 "rapp1" 0 "$CR_PATH/1"
+
+echo "Loading "$NUM_INST" policies in each group 1 ric"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   inst=$((1000000+$i*$NUM_INST))
+   api_put_policy 201 "rapp1" ricsim_g1_$i 1 $inst testdata/OSC/pi1_template.json $NUM_INST
+done
+
+echo "Loading "$NUM_INST" policies in each group 2 ric"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   inst=$((2000000+$i*$NUM_INST))
+   api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $inst testdata/STD/pi1_template.json $NUM_INST
+done
+
+echo "Check the number of types in the agent for each group 1 rics, shall be 1"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   api_equal json:policy_types?ric=ricsim_g1_$i 1
+done
+
+echo "Check the number of types in the agent for each group 2 rics, shall be 1"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   api_equal json:policy_types?ric=ricsim_g2_$i 1
+done
+
+echo "Checking the number of policy instances in each group 1 simulator, shall be "$NUM_INST
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g1_$i num_instances 50
+done
+
+echo "Checking the number of policy instances in each group 2 simulator, shall be "$NUM_INST
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g2_$i num_instances 50
+done
+
+echo "Deleting "$NUM_INST" policies in each group 1 ric"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   inst=$((1000000+$i*$NUM_INST))
+   api_delete_policy 201 $NUM_INST
+done
+
+echo "Deleting "$NUM_INST" policies in each group 2 ric"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   inst=$((2000000+$i*$NUM_INST))
+   api_delete_policy 201 $NUM_INST
+done
+
+echo "Checking the number of policy instances in each group 1 simulator, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g1_$i num_instances 50
+done
+
+echo "Checking the number of policy instances in each group 1 simulator, shall be 0"
+for ((i=1; i<=$NUM_RICS; i++))
+do
+   sim_equal ricsim_g2_$i num_instances 50
+done
+
+
+check_policy_agent_logs
+
+#### TEST COMPLETE ####
+
+store_logs          END
+
+print_result
\ No newline at end of file
diff --git a/test/auto-test/FTC500.sh b/test/auto-test/FTC500.sh
new file mode 100755 (executable)
index 0000000..41c0824
--- /dev/null
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+
+TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API"
+
+. ../common/testcase_common.sh  $@
+. ../common/controller_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+#### TEST BEGIN ####
+
+# Clean container and start all needed containers #
+clean_containers
+
+start_ric_simulators ricsim_g1 1  OSC_2.1.0
+start_ric_simulators ricsim_g2 1  STD_1.1.3
+
+start_sdnc
+
+# API tests
+echo -e $YELLOW"TR13"$EYELLOW
+controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1
+
+sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+
+controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1
+controller_api_get_A1_policy_ids 200 STD ricsim_g2_1
+
+controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1
+controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+controller_api_put_A1_policy 202 OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json
+controller_api_put_A1_policy 201 STD ricsim_g2_1 5000   testdata/STD/pi1_template.json
+
+controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000
+controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000
+
+controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000
+controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000
+
+VAL='NOT IN EFFECT'
+controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "false"
+controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED"
+
+controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000
+controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000
+
+
+
+store_logs          END
+
+#### TEST COMPLETE ####
+
+print_result
+
+auto_clean_containers
\ No newline at end of file
diff --git a/test/auto-test/FTC_SDNC.sh b/test/auto-test/FTC_SDNC.sh
new file mode 100755 (executable)
index 0000000..0a8dce5
--- /dev/null
@@ -0,0 +1,94 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+TC_ONELINE_DESCR="Create 1 policy with SDNC and 1 policy without SDNC over agent REST"
+
+. ../common/testcase_common.sh  $@
+. ../common/agent_api_functions.sh
+
+#### TEST BEGIN ####
+
+VARIANTS="NOSDNC SDNC"
+
+for TEST in $VARIANTS ; do
+
+
+    clean_containers
+
+    start_ric_simulators ricsim_g1 1 OSC_2.1.0
+    start_ric_simulators ricsim_g2 1 STD_1.1.3
+
+    start_mr
+
+    start_cr
+
+    start_consul_cbs
+
+    prepare_consul_config      $TEST  ".consul_config.json"
+    consul_config_app                  ".consul_config.json"
+
+    start_control_panel
+
+    if [ $TEST == "SDNC" ]; then
+        start_sdnc
+    fi
+
+    start_policy_agent
+
+
+    set_agent_debug
+
+    use_agent_rest
+
+    echo "Using: "$TEST
+
+    api_get_status 200
+
+    sim_print ricsim_g1_1 interface
+    sim_print ricsim_g2_1 interface
+
+    sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+    api_equal json:policy_types 2 120  #Wait for the agent to refresh types from the simulator
+
+    api_put_service 201 "rapp1" 3600 "http://callback-receiver:8090/callbacks/1"
+
+    api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 10
+
+    api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 3000 testdata/STD/pi1_template.json 10
+
+    sim_equal ricsim_g1_1 num_instances 10
+    sim_equal ricsim_g2_1 num_instances 10
+
+
+    check_policy_agent_logs
+    check_control_panel_logs
+
+    store_logs          $TEST
+
+    echo ""
+    echo -e $BOLD"Test complete for variant: "$TEST $EBOLD
+    echo ""
+
+done
+
+#### TEST COMPLETE ####
+
+print_result
+
diff --git a/test/auto-test/Suite-interfaces.sh b/test/auto-test/Suite-interfaces.sh
new file mode 100755 (executable)
index 0000000..38eb83a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+TS_ONELINE_DESCR="Test suite - interface testing. Agent REST and SNDC controller resconf"
+
+. ../common/testsuite_common.sh
+
+suite_setup
+
+############# TEST CASES #################
+
+./FTC10.sh $1
+./FTC500.sh $1
+
+##########################################
+
+suite_complete
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/1.json b/test/auto-test/testdata/OSC/1.json
new file mode 100644 (file)
index 0000000..5fe68ce
--- /dev/null
@@ -0,0 +1,40 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "title": "OSC_Type1_1.0.0",
+  "description": "Type 1 policy type",
+  "type": "object",
+  "properties": {
+    "scope": {
+      "type": "object",
+      "properties": {
+        "ueId": {
+          "type": "string"
+        },
+        "qosId": {
+          "type": "string"
+        }
+      },
+      "additionalProperties": false,
+      "required": [
+        "ueId",
+        "qosId"
+      ]
+    },
+    "qosObjective": {
+      "type": "object",
+      "properties": {
+        "priorityLevel": {
+          "type": "number"
+        }
+      },
+      "additionalProperties": false,
+      "required": [
+        "priorityLevel"
+      ]
+    }
+  },
+  "additionalProperties": false,
+  "required": [
+    "scope", "qosObjective"
+  ]
+}
diff --git a/test/auto-test/testdata/OSC/2.json b/test/auto-test/testdata/OSC/2.json
new file mode 100644 (file)
index 0000000..9f8a4d4
--- /dev/null
@@ -0,0 +1,36 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "title": "OSC_Type2_1.0.0",
+  "description": "Type 2 policy type",
+  "type": "object",
+  "properties": {
+    "scope": {
+      "type": "object",
+      "properties": {
+        "sliceId": {
+          "type": "string"
+        }
+      },
+      "additionalProperties": false,
+      "required": [
+        "sliceId"
+      ]
+    },
+    "qoeObjectives": {
+      "type": "object",
+      "properties": {
+        "qoeScore": {
+          "type": "number"
+        }
+      },
+      "additionalProperties": false,
+      "required": [
+        "qoeScore"
+      ]
+    }
+  },
+  "additionalProperties": false,
+  "required": [
+    "scope", "qoeObjectives"
+  ]
+}
diff --git a/test/auto-test/testdata/OSC/pi1_template.json b/test/auto-test/testdata/OSC/pi1_template.json
new file mode 100644 (file)
index 0000000..7795808
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "scope": {
+      "ueId": "ueXXX",
+      "qosId": "qosXXX"
+    },
+    "qosObjective": {
+      "priorityLevel": XXX
+    }
+  }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/pi2_template.json b/test/auto-test/testdata/OSC/pi2_template.json
new file mode 100644 (file)
index 0000000..c8ac887
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "scope": {
+      "sliceId": "sliceXXX"
+    },
+    "qoeObjectives": {
+      "qoeScore": XXX
+    }
+  }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/sim_1.json b/test/auto-test/testdata/OSC/sim_1.json
new file mode 100644 (file)
index 0000000..537d86f
--- /dev/null
@@ -0,0 +1,45 @@
+{
+  "name": "pt1",
+  "description": "pt1 policy type",
+  "policy_type_id": 1,
+  "create_schema": {
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "OSC_Type1_1.0.0",
+    "description": "Type 1 policy type",
+    "type": "object",
+    "properties": {
+      "scope": {
+        "type": "object",
+        "properties": {
+          "ueId": {
+            "type": "string"
+          },
+          "qosId": {
+            "type": "string"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "ueId",
+          "qosId"
+        ]
+      },
+      "qosObjective": {
+        "type": "object",
+        "properties": {
+          "priorityLevel": {
+            "type": "number"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "priorityLevel"
+        ]
+      }
+    },
+    "additionalProperties": false,
+    "required": [
+      "scope", "qosObjective"
+    ]
+  }
+}
diff --git a/test/auto-test/testdata/OSC/sim_2.json b/test/auto-test/testdata/OSC/sim_2.json
new file mode 100644 (file)
index 0000000..a9eb8f3
--- /dev/null
@@ -0,0 +1,41 @@
+{
+  "name": "pt2",
+  "description": "Pt2 policy type",
+  "policy_type_id": 1,
+  "create_schema": {
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "OSC_Type2_1.0.0",
+    "description": "Type 2 policy type",
+    "type": "object",
+    "properties": {
+      "scope": {
+        "type": "object",
+        "properties": {
+          "sliceId": {
+            "type": "string"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "sliceId"
+        ]
+      },
+      "qoeObjectives": {
+        "type": "object",
+        "properties": {
+          "qoeScore": {
+            "type": "number"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "qoeScore"
+        ]
+      }
+    },
+    "additionalProperties": false,
+    "required": [
+      "scope", "qoeObjectives"
+    ]
+  }
+}
diff --git a/test/auto-test/testdata/STD/EMPTYTYPE.json b/test/auto-test/testdata/STD/EMPTYTYPE.json
new file mode 100644 (file)
index 0000000..9e26dfe
--- /dev/null
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/test/auto-test/testdata/STD/pi1_template.json b/test/auto-test/testdata/STD/pi1_template.json
new file mode 100644 (file)
index 0000000..2a87513
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "scope": {
+    "ueId": "ueXXX",
+    "qosId": "qosXXX"
+  },
+  "qosObjective": {
+    "priorityLevel": XXX
+  }
+}
\ No newline at end of file
diff --git a/test/auto-test/utils/pa-logviewer.sh b/test/auto-test/utils/pa-logviewer.sh
new file mode 100755 (executable)
index 0000000..562bbea
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+#Setup trace on
+
+curl http://localhost:8081/actuator/loggers/org.oransc.policyagent.clients.AsyncRestClient -X POST  -H 'Content-Type: application/json' -d '{"configuredLevel":"debug"}'
+
+docker logs -f policy-agent-container
\ No newline at end of file
diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh
new file mode 100644 (file)
index 0000000..312eacb
--- /dev/null
@@ -0,0 +1,1078 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# This is a script that contains specific test functions for Policy Agent API
+
+### API functiond towards the Policy Agent
+
+# Generic function to query the agent via the REST or DMAAP interface.
+# Used by all other agent api test functions
+# REST or DMAAP is controlled of the base url of $ADAPTER
+# arg: GET|PUT|POST|DELETE <url> [<file>]
+# (Not for test scripts)
+__do_curl_to_agent() {
+    echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       paramError=0
+
+    if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+               paramError=1
+    else
+               timeout=""
+               oper=""
+               file=''
+               httpcode=" -sw %{http_code}"
+               accept=''
+               content=''
+
+               if [ $# -gt 2 ]; then
+                       content=" -H Content-Type:application/json"
+               fi
+               if [ $1 == "GET" ]; then
+                       oper="GET"
+                       if [ $# -ne 2 ];then
+                               paramError=1
+                       fi
+               elif [ $1 == "PUT" ]; then
+                       oper="PUT"
+                       if [ $# -eq 3 ]; then
+                               file=" --data-binary @$3"
+                       fi
+                       accept=" -H accept:application/json"
+               elif [ $1 == "POST" ]; then
+                       oper="POST"
+                       accept=" -H accept:*/*"
+                       if [ $# -ne 2 ];then
+                               paramError=1
+                       fi
+               elif [ $1 == "DELETE" ]; then
+                       oper="DELETE"
+                       if [ $# -ne 2 ];then
+                               paramError=1
+                       fi
+               else
+                       paramError=1
+               fi
+       fi
+
+    if [ $paramError -eq 1 ]; then
+               ((RES_CONF_FAIL++))
+        echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG
+        echo "-Expected: GET|PUT|POST|DELETE <url> [<file>]" >> $HTTPLOG
+        echo "-Returning response 000" >> $HTTPLOG
+        echo "-000"
+        return 1
+    fi
+
+    if [ $ADAPTER == $RESTBASE ]; then
+        url=" "${ADAPTER}${2}
+        oper=" -X "$oper
+        curlString="curl"${oper}${timeout}${httpcode}${accept}${content}${url}${file}
+        echo " CMD: "$curlString >> $HTTPLOG
+               if [ $# -eq 3 ]; then
+                       echo " FILE: $(<$3)" >> $HTTPLOG
+               fi
+
+               # Do retry for configured response codes, otherwise only one attempt
+               maxretries=5
+               while [ $maxretries -ge 0 ]; do
+
+                       let maxretries=maxretries-1
+                       res=$($curlString)
+                       retcode=$?
+                       if [ $retcode -ne 0 ]; then
+                               echo " RETCODE: "$retcode >> $HTTPLOG
+                               echo "000"
+                               return 1
+                       fi
+                       retry=0
+                       echo " RESP: "$res >> $HTTPLOG
+                       status=${res:${#res}-3}
+                       if [ ! -z "${AGENT_RETRY_CODES}" ]; then
+                               for retrycode in $AGENT_RETRY_CODES; do
+                                       if [ $retrycode -eq $status ]; then
+                                               echo -e $RED" Retrying (according to set codes for retry), got status $status....."$ERED  >> $HTTPLOG
+                                               sleep 1
+                                               retry=1
+                                       fi
+                               done
+                       fi
+                       if [ $retry -eq 0 ]; then
+                               maxretries=-1
+                       fi
+               done
+        echo $res
+        return 0
+    else
+        requestUrl=$2
+        if [ $1 == "PUT" ] && [ $# -eq 3 ]; then
+            payload="$(cat $3 | tr -d '\n' | tr -d ' ' )"
+            echo "payload: "$payload >> $HTTPLOG
+            file=" --data-binary "$payload
+        fi
+               #urlencode the request url since it will be carried by send-request url
+               requestUrl=$(python -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))"  "$2")
+        url=" "${ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper}
+        curlString="curl -X POST${timeout}${httpcode}${content}${url}${file}"
+        echo " CMD: "$curlString >> $HTTPLOG
+        res=$($curlString)
+        retcode=$?
+        if [ $retcode -ne 0 ]; then
+            echo " RETCODE: "$retcode >> $HTTPLOG
+            echo "000"
+            return 1
+        fi
+        echo " RESP: "$res >> $HTTPLOG
+        status=${res:${#res}-3}
+        if [ $status -ne 200 ]; then
+            echo "000"
+            return 1
+        fi
+        cid=${res:0:${#res}-3}
+        url=" "${ADAPTER}"/receive-response?correlationid="${cid}
+        curlString="curl -X GET"${timeout}${httpcode}${url}
+        echo " CMD: "$curlString >> $HTTPLOG
+        res=$($curlString)
+        retcode=$?
+        if [ $retcode -ne 0 ]; then
+            echo " RETCODE: "$retcode >> $HTTPLOG
+            echo "000"
+            return 1
+        fi
+        echo " RESP: "$res >> $HTTPLOG
+        status=${res:${#res}-3}
+               TS=$SECONDS
+               # wait of the reply from the agent...
+        while [ $status -eq 204 ]; do
+                       if [ $(($SECONDS - $TS)) -gt 90 ]; then
+                echo " RETCODE: (timeout after 90s)" >> $HTTPLOG
+                echo "000"
+                return 1
+                       fi
+            sleep 1
+            echo " CMD: "$curlString >> $HTTPLOG
+            res=$($curlString)
+            if [ $retcode -ne 0 ]; then
+                echo " RETCODE: "$retcode >> $HTTPLOG
+                echo "000"
+                return 1
+            fi
+            echo " RESP: "$res >> $HTTPLOG
+            status=${res:${#res}-3}
+        done
+        if [ $status -eq 200 ]; then
+            body=${res:0:${#res}-3}
+            echo $body
+            return 0
+        fi
+        echo "Status not 200, returning response 000" >> $HTTPLOG
+        echo "0000"
+        return 1
+    fi
+}
+
+
+#########################################################
+#### Test case functions A1 Policy management service
+#########################################################
+
+# This function compare the size, towards a target value, of a json array returned from <url> of the Policy Agent.
+# This is done immediately by setting PASS or FAIL or wait up to and optional timeout before setting PASS or FAIL
+# args: json:<url> <target-value> [<timeout-in-seconds]
+# (Function for test scripts)
+api_equal() {
+    echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+               if [[ $1 == "json:"* ]]; then
+                       __var_test "Policy Agent" $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT"/" $1 "=" $2 $3
+                       return 0
+               fi
+       fi
+
+       ((RES_CONF_FAIL++))
+       __print_err "needs two or three args: json:<json-array-param> <target-value> [ timeout ]" $@
+       return 1
+}
+
+# API Test function: GET /policies
+# args: <response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-ype-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <template-file>]*]
+# (Function for test scripts)
+api_get_policies() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+       paramError=0
+       if [ $# -lt 4 ]; then
+               paramError=1
+       elif [ $# -eq 5 ] && [ $5 != "NOID" ]; then
+               paramError=1
+       elif [ $# -gt 4 ] && [ $(($#%5)) -ne 4 ]; then
+               paramError=1
+       fi
+
+    if [ $paramError -ne 0 ]; then
+        __print_err "<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-ype-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <template-file>]*]" $@
+        return 1
+    fi
+       queryparams=""
+       if [ $2 != "NORIC" ]; then
+               queryparams="?ric="$2
+       fi
+       if [ $3 != "NOSERVICE" ]; then
+               if [ -z $queryparams ]; then
+                       queryparams="?service="$3
+               else
+                       queryparams=$queryparams"&service="$3
+               fi
+       fi
+       if [ $4 != "NOTYPE" ]; then
+               if [ -z $queryparams ]; then
+                       queryparams="?type="$4
+               else
+                       queryparams=$queryparams"&type="$4
+               fi
+       fi
+
+       query="/policies"$queryparams
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -gt 4 ]; then
+               if [ $# -eq 5 ] && [ $5 == "NOID" ]; then
+                       targetJson="["
+               else
+                       body=${res:0:${#res}-3}
+                       targetJson="["
+                       arr=(${@:5})
+
+                       for ((i=0; i<$(($#-4)); i=i+5)); do
+
+                               if [ "$targetJson" != "[" ]; then
+                                       targetJson=$targetJson","
+                               fi
+                               targetJson=$targetJson"{\"id\":\"${arr[$i]}\",\"lastModified\":\"????\",\"ric\":\"${arr[$i+1]}\",\"service\":\"${arr[$i+2]}\",\"type\":"
+                               if [ "${arr[$i+3]}" == "EMPTY" ]; then
+                                       targetJson=$targetJson"\"\","
+                               else
+                                       targetJson=$targetJson"\"${arr[$i+3]}\","
+                               fi
+                               file=".p.json"
+                               sed 's/XXX/'${arr[$i]}'/g' ${arr[$i+4]} > $file
+                               json=$(cat $file)
+                               targetJson=$targetJson"\"json\":"$json"}"
+                       done
+               fi
+
+               targetJson=$targetJson"]"
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body" "id")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+
+}
+
+# API Test function: GET /policy
+#args: <response-code>  <policy-id> [<template-file>]
+# (Function for test scripts)
+api_get_policy() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+        __print_err "<response-code>  <policy-id> [<template-file>] " $@
+        return 1
+    fi
+
+       query="/policy?id=$2"
+       res="$(__do_curl_to_agent GET $query)"
+       status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -eq 3 ]; then
+               #Create a policy json to compare with
+               body=${res:0:${#res}-3}
+               file=".p.json"
+               sed 's/XXX/'${2}'/g' $3 > $file
+               targetJson=$(< $file)
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API Test function: PUT /policy
+# args: <response-code> <service-name> <ric-id> <policytype-id> <policy-id> <template-file> [<count>]
+# (Function for test scripts)
+api_put_policy() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 6 ] || [ $# -gt 7 ]; then
+        __print_err "<response-code> <service-name> <ric-id> <policytype-id> <policy-id> <template-file> [<count>]" $@
+        return 1
+    fi
+
+       ric=$3
+       count=0
+       max=1
+
+       if [ $# -eq 7 ]; then
+               max=$7
+       fi
+
+       pid=$5
+       file=$6
+
+       while [ $count -lt $max ]; do
+               query="/policy?id=$pid&ric=$ric&service=$2"
+
+               if [ $4 == "NOTYPE" ]; then
+                       query="/policy?id=$pid&ric=$ric&service=$2"
+               else
+                       query="/policy?id=$pid&ric=$ric&service=$2&type=$4"
+               fi
+
+               file=".p.json"
+               sed 's/XXX/'${pid}'/g' $6 > $file
+       res="$(__do_curl_to_agent PUT $query $file)"
+       status=${res:${#res}-3}
+               echo -ne " Creating "$count"("$max")\033[0K\r"
+
+               if [ $status -ne $1 ]; then
+                       let pid=$pid+1
+                       echo " Created "$count"?("$max")"
+                       echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+
+               let pid=$pid+1
+               let count=$count+1
+               echo -ne " Created  "$count"("$max")\033[0K\r"
+       done
+       echo ""
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+
+# API Test function: DELETE /policy
+# args: <response-code> <policy-id> [count]
+# (Function for test scripts)
+api_delete_policy() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+        __print_err "<response-code> <policy-id> [count]" $@
+        return 1
+    fi
+
+       count=0
+       max=1
+
+       if [ $# -eq 3 ]; then
+               max=$3
+       fi
+
+       pid=$2
+
+       while [ $count -lt $max ]; do
+               query="/policy?id="$pid
+               res="$(__do_curl_to_agent DELETE $query)"
+               status=${res:${#res}-3}
+               echo -ne " Deleting "$count"("$max")\033[0K\r"
+
+               if [ $status -ne $1 ]; then
+                       echo " Deleted "$count"?("$max")"
+                       echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+               let pid=$pid+1
+               let count=$count+1
+               echo -ne " Deleted  "$count"("$max")\033[0K\r"
+       done
+       echo ""
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API Test function: GET /policy_ids
+# args: <response-code> <ric-id>|NORIC <service-id>|NOSERVICE <type-id>|NOTYPE ([<policy-instance-id]*|NOID)
+# (Function for test scripts)
+api_get_policy_ids() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 4 ]; then
+               __print_err "<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <type-id>|NOTYPE ([<policy-instance-id]*|NOID)" $@
+               return 1
+       fi
+
+       queryparams=""
+
+       if [ $2 != "NORIC" ]; then
+               queryparams="?ric="$2
+       fi
+
+       if [ $3 != "NOSERVICE" ]; then
+               if [ -z $queryparams ]; then
+                       queryparams="?service="$3
+               else
+                       queryparams=$queryparams"&service="$3
+               fi
+       fi
+       if [ $4 != "NOTYPE" ]; then
+               if [ -z $queryparams ]; then
+                       queryparams="?type="$4
+               else
+                       queryparams=$queryparams"&type="$4
+               fi
+       fi
+
+       query="/policy_ids"$queryparams
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -gt 4 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+
+               for pid in ${@:5} ; do
+                       if [ "$targetJson" != "[" ]; then
+                               targetJson=$targetJson","
+                       fi
+                       if [ $pid != "NOID" ]; then
+                               targetJson=$targetJson"\"$pid\""
+                       fi
+               done
+
+               targetJson=$targetJson"]"
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API Test function: GET /policy_schema
+# args: <response-code> <policy-type-id> [<schema-file>]
+# (Function for test scripts)
+api_get_policy_schema() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+        __print_err "<response-code> <policy-type-id> [<schema-file>]" $@
+        return 1
+    fi
+
+       query="/policy_schema?id=$2"
+       res="$(__do_curl_to_agent GET $query)"
+       status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -eq 3 ]; then
+
+               body=${res:0:${#res}-3}
+
+               targetJson=$(< $3)
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API Test function: GET /policy_schemas
+# args: <response-code>  <ric-id>|NORIC [<schema-file>|NOFILE]*
+# (Function for test scripts)
+api_get_policy_schemas() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 2 ]; then
+        __print_err "<response-code> <ric-id>|NORIC [<schema-file>|NOFILE]*" $@
+        return 1
+    fi
+
+       query="/policy_schemas"
+       if [ $2 != "NORIC" ]; then
+               query=$query"?ric="$2
+       fi
+
+       res="$(__do_curl_to_agent GET $query)"
+       status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -gt 2 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+
+               for file in ${@:3} ; do
+                       if [ "$targetJson" != "[" ]; then
+                               targetJson=$targetJson","
+                       fi
+                       if [ $file == "NOFILE" ]; then
+                               targetJson=$targetJson"{}"
+                       else
+                               targetJson=$targetJson$(< $3)
+                       fi
+               done
+
+               targetJson=$targetJson"]"
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API Test function: GET /policy_status
+# arg: <response-code> <policy-id> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)
+# (Function for test scripts)
+api_get_policy_status() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+    if [ $# -lt 4 ] || [ $# -gt 5 ]; then
+               __print_err "<response-code> <policy-id> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)" $@
+               return 1
+       fi
+
+       targetJson=""
+
+       if [ $3 == "STD" ]; then
+               targetJson="{\"enforceStatus\":\"$4\""
+               if [ $# -eq 5 ]; then
+                       targetJson=$targetJson",\"reason\":\"$5\""
+               fi
+               targetJson=$targetJson"}"
+       elif [ $3 == "OSC" ]; then
+               targetJson="{\"instance_status\":\"$4\""
+               if [ $# -eq 5 ]; then
+                       targetJson=$targetJson",\"has_been_deleted\":\"$5\""
+               fi
+               targetJson=$targetJson",\"created_at\":\"????\"}"
+       else
+               __print_err "<response-code> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)" $@
+               return 1
+       fi
+
+       query="/policy_status?id="$2
+
+       res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       echo "TARGET JSON: $targetJson" >> $HTTPLOG
+       body=${res:0:${#res}-3}
+       res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+       if [ $res -ne 0 ]; then
+               echo -e $RED" FAIL, returned body not correct"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API Test function: GET /policy_types
+# args: <response-code> [<ric-id>|NORIC [<policy-type-id>|EMPTY [<policy-type-id>]*]]
+# (Function for test scripts)
+api_get_policy_types() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 1 ]; then
+               __print_err "<response-code> [<ric-id>|NORIC [<policy-type-id>|EMPTY [<policy-type-id>]*]]" $@
+               return 1
+       fi
+
+       if [ $# -eq 1 ]; then
+               query="/policy_types"
+       elif [ $2 == "NORIC" ]; then
+               query="/policy_types"
+       else
+               query="/policy_types?ric=$2"
+       fi
+
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -gt 2 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+
+               for pid in ${@:3} ; do
+                       if [ "$targetJson" != "[" ]; then
+                               targetJson=$targetJson","
+                       fi
+                       if [ $pid == "EMPTY" ]; then
+                               pid=""
+                       fi
+                       targetJson=$targetJson"\"$pid\""
+               done
+
+               targetJson=$targetJson"]"
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+#########################################################
+#### Test case functions Health check
+#########################################################
+
+# API Test function: GET /status
+# args: <response-code>
+# (Function for test scripts)
+api_get_status() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+    if [ $# -ne 1 ]; then
+               __print_err "<response-code>" $@
+               return 1
+       fi
+    query="/status"
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+#########################################################
+#### Test case functions RIC Repository
+#########################################################
+
+# API Test function: GET /ric
+# args: <reponse-code> <management-element-id> [<ric-id>]
+# (Function for test scripts)
+api_get_ric() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+    if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+               __print_err "<reponse-code> <management-element-id> [<ric-id>]" $@
+               return 1
+       fi
+
+       query="/ric?managedElementId="$2
+
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -eq 3 ]; then
+               body=${res:0:${#res}-3}
+               if [ "$body" != "$3" ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API test function: GET /rics
+# args: <reponse-code> <policy-type-id>|NOTYPE [<space-separate-string-of-ricinfo>]
+# example of <space-separate-string-of-ricinfo> = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4 ricsim_g1_1:me2_........."
+# format of ric-info:  <ric-id>:<list-of-mes>:<list-of-policy-type-ids>
+# (Function for test scripts)
+api_get_rics() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 2 ]; then
+               __print_err "<reponse-code> <policy-type-id>|NOTYPE [<space-separate-string-of-ricinfo>]" $@
+               return 1
+       fi
+
+       query="/rics"
+       if [ $2 != "NOTYPE" ]; then
+       query="/rics?policyType="$2
+       fi
+
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -gt 2 ]; then
+               body=${res:0:${#res}-3}
+               res=$(python ../common/create_rics_json.py ".tmp_rics.json" "$3" )
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, could not create target ric info json"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+
+               targetJson=$(<.tmp_rics.json)
+       echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+##################################################################
+#### API Test case functions Service registry and supervision ####
+##################################################################
+
+# API test function: PUT /service
+# args: <response-code>  <service-name> <keepalive-timeout> <callbackurl>
+# (Function for test scripts)
+api_put_service() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+    if [ $# -ne 4 ]; then
+        __print_err "<response-code>  <service-name> <keepalive-timeout> <callbackurl>" $@
+        return 1
+    fi
+
+    query="/service"
+    json="{\"callbackUrl\": \""$4"\",\"keepAliveIntervalSeconds\": \""$3"\",\"serviceName\": \""$2"\"}"
+    file=".tmp.json"
+       echo "$json" > $file
+
+    res="$(__do_curl_to_agent PUT $query $file)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API test function: GET /services
+#args: <response-code> [ (<query-service-name> <target-service-name> <keepalive-timeout> <callbackurl>) | (NOSERVICE <target-service-name> <keepalive-timeout> <callbackurl> [<target-service-name> <keepalive-timeout> <callbackurl>]* )]
+# (Function for test scripts)
+api_get_services() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+       #Number of accepted parameters: 1, 2, 4, 7, 10, 13,...
+       paramError=1
+       if [ $# -eq 1 ]; then
+               paramError=0
+       elif [ $# -eq 2 ] && [ $2 != "NOSERVICE" ]; then
+               paramError=0
+       elif [ $# -eq 5 ]; then
+               paramError=0
+       elif [ $# -gt 5 ] && [ $2 == "NOSERVICE" ]; then
+               argLen=$(($#-2))
+               if [ $(($argLen%3)) -eq 0 ]; then
+                       paramError=0
+               fi
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> [ (<query-service-name> <target-service-name> <keepalive-timeout> <callbackurl>) | (NOSERVICE <target-service-name> <keepalive-timeout> <callbackurl> [<target-service-name> <keepalive-timeout> <callbackurl>]* )]" $@
+               return 1
+       fi
+
+    query="/services"
+
+    if [ $# -gt 1 ] && [ $2 != "NOSERVICE" ]; then
+       query="/services?name="$2
+       fi
+
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $# -gt 2 ]; then
+               variableArgCount=$(($#-2))
+               body=${res:0:${#res}-3}
+       targetJson="["
+               shift; shift;
+               cntr=0
+               while [ $cntr -lt $variableArgCount ]; do
+                       servicename=$1; shift;
+                       timeout=$1; shift;
+                       callback=$1; shift;
+                       if [ $cntr -gt 0 ]; then
+                               targetJson=$targetJson","
+                       fi
+                       # timeSinceLastActivitySeconds value cannot be checked since value varies
+                       targetJson=$targetJson"{\"serviceName\": \""$servicename"\",\"keepAliveIntervalSeconds\": "$timeout",\"timeSinceLastActivitySeconds\":\"????\",\"callbackUrl\": \""$callback"\"}"
+                       let cntr=cntr+3
+               done
+               targetJson=$targetJson"]"
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body" "serviceName")
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API test function: GET /services  (only checking service names)
+# args: <response-code> [<service-name>]*"
+# (Function for test scripts)
+api_get_service_ids() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -lt 1 ]; then
+               __print_err "<response-code> [<service-name>]*" $@
+               return 1
+       fi
+
+    query="/services"
+    res="$(__do_curl_to_agent GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       body=${res:0:${#res}-3}
+       targetJson="["
+       for rapp in ${@:2} ; do
+               if [ "$targetJson" != "[" ]; then
+                       targetJson=$targetJson","
+               fi
+               targetJson=$targetJson"{\"callbackUrl\":\"????\",\"keepAliveIntervalSeconds\":\"????\",\"serviceName\":\""$rapp"\",\"timeSinceLastActivitySeconds\":\"????\"}"
+       done
+
+       targetJson=$targetJson"]"
+       echo "TARGET JSON: $targetJson" >> $HTTPLOG
+       res=$(python ../common/compare_json.py "$targetJson" "$body" "serviceName")
+
+       if [ $res -ne 0 ]; then
+               echo -e $RED" FAIL, returned body not correct"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API test function: DELETE /services
+# args: <response-code> <service-name>
+# (Function for test scripts)
+api_delete_services() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -ne 2 ]; then
+               __print_err "<response-code> <service-name>" $@
+               return 1
+       fi
+
+    query="/services?name="$2
+    res="$(__do_curl_to_agent DELETE $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# API test function: PUT /services/keepalive
+# args: <response-code> <service-name>
+# (Function for test scripts)
+api_put_services_keepalive() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    if [ $# -ne 2 ]; then
+               __print_err "<response-code> <service-name>" $@
+               return 1
+       fi
+
+    query="/services/keepalive?name="$2
+    res="$(__do_curl_to_agent PUT $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
diff --git a/test/common/compare_json.py b/test/common/compare_json.py
new file mode 100644 (file)
index 0000000..7110f48
--- /dev/null
@@ -0,0 +1,65 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+import os
+import json
+import sys
+
+# Deep compare of two json obects
+# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter
+# Any included json array will be sorted before comparison
+# An optional array key can be given to sort array of objects containing that key
+
+def comparejson(jsonTarget,jsonResult,arrayKey):
+
+    if isinstance(jsonTarget, dict):
+        if (len(jsonTarget) != len(jsonResult)):
+            return 1
+        for key in jsonTarget.keys():
+            if (jsonResult.get(key) is None):
+                return 1
+            if (comparejson(jsonTarget.get(key), jsonResult.get(key), arrayKey) != 0):
+                return 1
+    elif isinstance(jsonTarget, list):
+        if (len(jsonTarget) != len(jsonResult)):
+            return 1
+        if (arrayKey is None):
+            jsonTarget.sort()
+            jsonResult.sort()
+        else:
+            jsonTarget.sort(key=lambda k: k[arrayKey])
+            jsonResult.sort(key=lambda k: k[arrayKey])
+
+        for i in range(len(jsonTarget)):
+            if (comparejson(jsonTarget[i], jsonResult[i], arrayKey) != 0):
+                return 1
+    else:
+        if (jsonTarget != "????") and (jsonTarget != jsonResult):
+            return 1
+    return 0
+
+try:
+    jsonTarget = json.loads(sys.argv[1])
+    jsonResult = json.loads(sys.argv[2])
+    arrayKey = None
+    if (len(sys.argv) > 3):
+        arrayKey = sys.argv[3]
+    print(comparejson(jsonTarget,jsonResult,arrayKey))
+
+except Exception as e:
+    print (1)
+sys.exit()
\ No newline at end of file
diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh
new file mode 100644 (file)
index 0000000..ed298f1
--- /dev/null
@@ -0,0 +1,352 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# This is a script that contains specific test functions for A1 Controller API
+
+# Generic function to query the RICs via the A1-controller API.
+# args: <operation> <url> [<body>]
+# <operation>: getA1Policy,putA1Policy,getA1PolicyType,deleteA1Policy,getA1PolicyStatus
+# response: <json-body><3-digit-response-code>
+# (Not for test scripts)
+__do_curl_to_controller() {
+    echo " (${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+    if [ $# -ne 2 ] && [ $# -ne 3 ]; then
+               ((RES_CONF_FAIL++))
+        echo "-Incorrect number of parameters to __do_curl_to_controller " $@ >> $HTTPLOG
+        echo "-Expected: <operation> <url> [<body>]" >> $HTTPLOG
+        echo "-Returning response 000" >> $HTTPLOG
+        echo "000"
+        return 1
+    fi
+    if [ $# -eq 2 ]; then
+        json='{"input":{"near-rt-ric-url":"'$2'"}}'
+    else
+        # Escape quotes in the body
+        body=$(echo "$3" | sed 's/"/\\"/g')
+        json='{"input":{"near-rt-ric-url":"'$2'","body":"'"$body"'"}}'
+    fi
+    echo "$json" > .sndc.payload.json
+    echo "  FILE: $json"  >> $HTTPLOG
+    curlString="curl -sw %{http_code} -X POST http://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_EXTERNAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sndc.payload.json"
+    echo "  CMD: "$curlString >> $HTTPLOG
+    res=$($curlString)
+    retcode=$?
+    echo "  RESP: "$res >> $HTTPLOG
+    if [ $retcode -ne 0 ]; then
+        echo "  RETCODE: "$retcode >> $HTTPLOG
+        echo "000"
+        return 1
+    fi
+
+       status=${res:${#res}-3}
+
+    if [ $status -ne 200 ]; then
+        echo "000"
+        return 1
+    fi
+    body=${res:0:${#res}-3}
+    echo "$body" > .sdnc-reply.json
+    res=$(python ../common/extract_sdnc_reply.py .sdnc-reply.json)
+    echo "  EXTRACED BODY+CODE: "$res >> $HTTPLOG
+    echo "$res"
+    return 0
+}
+
+# Controller API Test function: getA1Policy (return ids only)
+# arg: <response-code> (OSC <ric-id> <policy-type-id> [ <policy-id> [<policy-id>]* ]) | ( STD <ric-id> [ <policy-id> [<policy-id>]* ] )
+# (Function for test scripts)
+controller_api_get_A1_policy_ids() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    paramError=1
+    if [ $# -gt 3 ] && [ $2 == "OSC" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies"
+               paramError=0
+    elif [ $# -gt 2 ] && [ $2 == "STD" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies"
+        paramError=0
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> (OSC <ric-id> <policy-type-id> [ <policy-id> [<policy-id>]* ]) | ( STD <ric-id> [ <policy-id> [<policy-id>]* ] )" $@
+               return 1
+       fi
+
+    res=$(__do_curl_to_controller getA1Policy "$url")
+    retcode=$?
+    status=${res:${#res}-3}
+
+    if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+    body=${res:0:${#res}-3}
+
+       targetJson="["
+    start=4
+    if [ $2 == "OSC" ]; then
+        start=5
+    fi
+    for pid in ${@:$start} ; do
+        if [ "$targetJson" != "[" ]; then
+            targetJson=$targetJson","
+        fi
+        targetJson=$targetJson"\"$pid\""
+    done
+    targetJson=$targetJson"]"
+
+       echo " TARGET JSON: $targetJson" >> $HTTPLOG
+
+       res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+       if [ $res -ne 0 ]; then
+               echo -e $RED" FAIL, returned body not correct"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+
+# Controller API Test function: getA1PolicyType
+# arg: <response-code> OSC <ric-id> <policy-type-id> [<policy-type-file>]
+# (Function for test scripts)
+controller_api_get_A1_policy_type() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    paramError=1
+    if [ $# -gt 3 ] && [ $2 == "OSC" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4"
+               paramError=0
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> OSC <ric-id> <policy-type-id> [<policy-type-file>]" $@
+               return 1
+       fi
+
+    res=$(__do_curl_to_controller getA1PolicyType "$url")
+    retcode=$?
+    status=${res:${#res}-3}
+
+    if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+    body=${res:0:${#res}-3}
+
+       if [ $# -eq 5 ]; then
+
+               body=${res:0:${#res}-3}
+
+               targetJson=$(< $5)
+               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# Controller API Test function: deleteA1Policy
+# arg: <response-code> (STD <ric-id> <policy-id>) | (OSC <ric-id> <policy-type-id> <policy-id>)
+# (Function for test scripts)
+controller_api_delete_A1_policy() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    paramError=1
+    if [ $# -eq 5 ] && [ $2 == "OSC" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5"
+               paramError=0
+    elif [ $# -eq 4 ] && [ $2 == "STD" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4"
+        paramError=0
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> (STD <ric-id> <policy-id>) | (OSC <ric-id> <policy-type-id> <policy-id>)" $@
+               return 1
+       fi
+
+    res=$(__do_curl_to_controller deleteA1Policy "$url")
+    retcode=$?
+    status=${res:${#res}-3}
+
+    if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+# Controller API Test function: putA1Policy
+# arg: <response-code> (STD <ric-id> <policy-id> <template-file> ) | (OSC <ric-id> <policy-type-id> <policy-id> <template-file>)
+# (Function for test scripts)
+controller_api_put_A1_policy() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    paramError=1
+    if [ $# -eq 6 ] && [ $2 == "OSC" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5"
+        body=$(sed 's/XXX/'${5}'/g' $6)
+
+               paramError=0
+    elif [ $# -eq 5 ] && [ $2 == "STD" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4"
+        body=$(sed 's/XXX/'${4}'/g' $5)
+        paramError=0
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> (STD <ric-id> <policy-id>) | (OSC <ric-id> <policy-type-id> <policy-id>)" $@
+               return 1
+       fi
+
+    res=$(__do_curl_to_controller putA1Policy "$url" "$body")
+    retcode=$?
+    status=${res:${#res}-3}
+
+    if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
+
+
+# Controller API Test function: getA1PolicyStatus
+# arg: <response-code> (STD <ric-id> <policy-id> <enforce-status> [<reason>]) | (OSC <ric-id> <policy-type-id> <policy-id> <instance-status> <has-been-deleted>)
+# (Function for test scripts)
+controller_api_get_A1_policy_status() {
+       echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+
+    targetJson=""
+    paramError=1
+    if [ $# -ge 5 ] && [ $2 == "OSC" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5/status"
+        if [ $# -gt 5 ]; then
+            targetJson="{\"instance_status\":\"$6\""
+            targetJson=$targetJson",\"has_been_deleted\":\"$7\""
+            targetJson=$targetJson",\"created_at\":\"????\"}"
+        fi
+               paramError=0
+    elif [ $# -ge 4 ] && [ $2 == "STD" ]; then
+        url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4/status"
+        if [ $# -gt 4 ]; then
+            targetJson="{\"enforceStatus\":\"$5\""
+            if [ $# -eq 6 ]; then
+                targetJson=$targetJson",\"reason\":\"$6\""
+            fi
+            targetJson=$targetJson"}"
+        fi
+        paramError=0
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> (STD <ric-id> <policy-id> <enforce-status> [<reason>]) | (OSC <ric-id> <policy-type-id> <policy-id> <instance-status> <has-been-deleted>)" $@
+               return 1
+       fi
+
+    res=$(__do_curl_to_controller getA1PolicyStatus "$url")
+    retcode=$?
+    status=${res:${#res}-3}
+
+    if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ $status -ne $1 ]; then
+               echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+               ((RES_FAIL++))
+               return 1
+       fi
+
+       if [ ! -z "$targetJson" ]; then
+
+               body=${res:0:${#res}-3}
+               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL, returned body not correct"$ERED
+                       ((RES_FAIL++))
+                       return 1
+               fi
+       fi
+
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+       return 0
+}
\ No newline at end of file
diff --git a/test/common/count_json_elements.py b/test/common/count_json_elements.py
new file mode 100644 (file)
index 0000000..936e3f8
--- /dev/null
@@ -0,0 +1,35 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+import os
+import json
+import sys
+
+# Print the length of json array, -1 will be printed in any problem is encountered
+
+try:
+    with open(sys.argv[1]) as json_file:
+        jsonarray = json.load(json_file)
+
+        if isinstance(jsonarray, list):
+            print(len(jsonarray))
+        else:
+            print(-1)
+
+except Exception as e:
+    print(-1)
+sys.exit()
\ No newline at end of file
diff --git a/test/common/create_rics_json.py b/test/common/create_rics_json.py
new file mode 100644 (file)
index 0000000..d6a095b
--- /dev/null
@@ -0,0 +1,63 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+import os
+import json
+import sys
+import re
+
+
+
+#Create a ric info json, example input: ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:1,2,4 ricsim_g1_2:kista_ricsim_g1_2,stockholm_ricsim_g1_2:2
+#Format of string <ric-id>:<comma-separated-list-of-me's>:<comma-separated-list-of-policy-type-ids>
+#To indicate that no types exist, use 'NOTYPE'. Ex. ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:NOTYPE
+#To indicate that special STD zero length name type, use 'EMPTYTYPE'. Ex. ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:EMPTYTYPE
+#Save in indicated file
+
+try:
+    file_name = sys.argv[1]
+    ric_string = sys.argv[2]
+    ric_string=ric_string.strip()
+    ric_string = re.sub(' +',' ',ric_string)
+    ric_arr=[]
+    rics=ric_string.split(' ')
+    for i in range(len(rics)):
+        ricDict={}
+        items=rics[i].split(':')
+        ricDict['ricName']=items[0]
+        ricDict['managedElementIds']=items[1].split(',')
+        if (items[2] == "EMPTYTYPE"):
+            empty_arr=[]
+            empty_arr.append("")
+            ricDict['policyTypes']=empty_arr
+        elif (items[2] == "NOTYPE"):
+            empty_arr=[]
+            ricDict['policyTypes']=empty_arr
+        else:
+            ricDict['policyTypes']=items[2].split(',')
+        ricDict['state']=items[3]
+        ric_arr.append(ricDict)
+
+    with open(file_name, 'w') as f:
+        json.dump(ric_arr, f)
+
+    print(0)
+
+except Exception as e:
+    print(str(e))
+    print(1)
+sys.exit()
\ No newline at end of file
diff --git a/test/common/do_curl_function.sh b/test/common/do_curl_function.sh
new file mode 100755 (executable)
index 0000000..e1d890d
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+
+
+# Function to execute curl towards a container (or process) and compare + print result
+# Intended use is for basic test scripts where testing is done with curl and the returned response and payload need to be checked.
+# args: GET|PUT|POST|DELETE <url> <target-response-code> [<json-file>]
+# All calls made to 'localhost:'<port>.
+# Expects env PORT set to intended port number
+# Expects env RESULT to contain the target response body.
+#   RESULT="*" means that returned payload is not checked, may container any text
+#   RESULT="<text>" menans that the returned payload has to match the <text> exactly
+#   RESULT="json:<returned-payload>" means that the returned json payload is compared with the expected result (order of json keys and index is irrelevant)
+# Env BODY contains the response body after the call
+# Any error will stop script execution
+# How to use in a test script:  source this file into your bash test script to the make the function available.
+
+do_curl() {
+    echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+    if [ $# -lt 3 ]; then
+        echo "Need 3 or more parameters, <http-operation> <url> <response-code> [file]: "$@
+        echo "Exting test script....."
+        exit 1
+    fi
+    curlstr="curl -X "$1" -sw %{http_code} localhost:$PORT$2 -H accept:*/*"
+    if [ $# -gt 3 ]; then
+        curlstr=$curlstr" -H Content-Type:application/json --data-binary @"$4
+    fi
+    echo "  CMD:"$curlstr
+    res=$($curlstr)
+    status=${res:${#res}-3}
+    body=${res:0:${#res}-3}
+    export body
+    if [ $status -ne $3 ]; then
+        echo "  Error status:"$status" Expected status: "$3
+        echo "  Body: "$body
+        echo "Exting test script....."
+        exit 1
+    else
+        echo "  OK, code: "$status"     (Expected)"
+        echo "  Body: "$body
+        if [ "$RESULT" == "*" ]; then
+            echo "  Body contents not checked"
+        elif [[ "$RESULT" == "json:"* ]]; then
+            result=${RESULT:5:${#RESULT}}
+            #Find dir of the common dir
+            DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+            res=$(python ${DIR}/compare_json.py "$result" "$body")
+            if [ $res -eq 0 ]; then
+                echo "  Body as expected"
+            else
+                echo "  Expected json body: "$result
+                echo "Exiting....."
+                exit 1
+            fi
+        else
+            body="$(echo $body | tr -d '\n' )"
+            if [ "$RESULT" == "$body" ]; then
+                echo "  Body as expected"
+            else
+                echo "  Expected body: "$RESULT
+                echo "Exiting....."
+                exit 1
+            fi
+        fi
+    fi
+}
\ No newline at end of file
diff --git a/test/common/extract_sdnc_reply.py b/test/common/extract_sdnc_reply.py
new file mode 100644 (file)
index 0000000..cb80e5e
--- /dev/null
@@ -0,0 +1,41 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+import os
+import json
+import sys
+
+# Extract the response code and optional response message body from and SDNC A1 Controller API reply
+
+try:
+    with open(sys.argv[1]) as json_file:
+        reply = json.load(json_file)
+
+        output=reply['output']
+        status=str(output['http-status'])
+        while(len(status) < 3):
+            status="0"+status
+        resp=status
+        if ( 'body' in output.keys()):
+            body=str(output['body'])
+            bodyJson=json.loads(body)
+            resp=str(json.dumps(bodyJson))+str(status)
+        print(resp)
+
+except Exception as e:
+    print("000")
+sys.exit()
\ No newline at end of file
diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh
new file mode 100644 (file)
index 0000000..049e43d
--- /dev/null
@@ -0,0 +1,203 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+
+### Admin API functions for the RIC simulator
+
+
+# Excute a curl cmd towards a ricsimulator and check the response code.
+# args: <expected-response-code> <curl-cmd-string> [<file>]
+__execute_curl_to_sim() {
+       echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
+       echo " CMD: $2" >> $HTTPLOG
+       if [ $# -eq 3 ]; then
+               echo " FILE: $(<$3)"  >> $HTTPLOG
+       fi
+       res="$($2)"
+       echo " RESP: $res" >> $HTTPLOG
+       retcode=$?
+    if [ $retcode -ne 0 ]; then
+               echo " RETCODE: "$retcode
+        echo -e $RED"  ERROR - fatal error when executing curl."$ERED
+        return 1
+    fi
+    status=${res:${#res}-3}
+    if [ $status -eq $1 ]; then
+        echo -e $GREEN" OK"$EGREEN
+        return 0
+    fi
+    echo -e $RED"  ERROR - expected http response: "$1" but got http response: "$status $ERED
+    return 1
+}
+
+# Tests if a variable value in the ricsimulator is equal to a target value and and optional timeout.
+# Arg: <ric-id> <variable-name> <target-value> - This test set pass or fail depending on if the variable is
+# equal to the target or not.
+# Arg: <ric-id> <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
+# before setting pass or fail depending on if the variable value becomes equal to the target
+# value or not.
+# (Function for test scripts)
+sim_equal() {
+
+       if [ $# -eq 3 ] || [ $# -eq 4 ]; then
+               app=$1
+               port=$(__find_sim_port $app)
+               __var_test $app "$LOCALHOST$port/counter/" $2 "=" $3 $4
+               return 0
+       else
+               ((RES_CONF_FAIL++))
+               __print_err "needs three or four args: <ric-id> <sim-param> <target-value> [ timeout ]"
+               return 1
+       fi
+}
+
+# Print a variable value from the RIC sim.
+# args: <ric-id> <variable-name>
+# (Function for test scripts)
+sim_print() {
+
+       if [ $# != 2 ]; then
+               ((RES_CONF_FAIL++))
+       __print_err "need two args, <ric-id> <sim-param>" $@
+               exit 1
+       fi
+       app=$1
+       port=$(__find_sim_port $app)
+       echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $LOCALHOST$port/counter/$2)"$EBOLD
+}
+
+# Simulator API: Put a policy type in a ric
+# args: <response-code> <ric-id> <policy-type-id> <policy-type-file>
+# (Function for test scripts)
+sim_put_policy_type() {
+       echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+       if [ $# -ne 4 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "<response-code> <ric-id> <policy-type-id> <policy-type-file>" $@
+               return 1
+       fi
+       app=$2
+       res=$(__find_sim_port $app)
+
+    curlString="curl -X PUT -sw %{http_code} $LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4
+
+       __execute_curl_to_sim $1 "$curlString" $4
+       return $?
+}
+
+# DSimulator API: Delete a policy type in a ric
+# <response-code> <ric-id> <policy-type-id>
+# (Function for test scripts)
+sim_delete_policy_type() {
+       echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+       if [ $# -ne 3 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "<response-code> <ric-id> <policy_type_id>" $@
+               return 1
+       fi
+       app=$2
+       res=$(__find_sim_port $app)
+
+    curlString="curl -X DELETE -sw %{http_code} $LOCALHOST"$res"/policytype?id="$3
+
+    __execute_curl_to_sim $1 "$curlString"
+       return $?
+}
+
+# Simulator API: Delete instances (and status), for one ric
+# <response-code> <ric-id>
+# (Function for test scripts)
+sim_post_delete_instances() {
+       echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+       if [ $# -ne 2 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "<response-code> <ric-id>" $@
+               return 1
+       fi
+       app=$2
+       res=$(__find_sim_port $app)
+
+    curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/deleteinstances"
+
+    __execute_curl_to_sim $1 "$curlString"
+       return $?
+}
+
+# Simulator API: Delete all (instances/types/statuses/settings), for one ric
+# <response-code> <ric-id>
+# (Function for test scripts)
+sim_post_delete_all() {
+       echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+       if [ $# -ne 3 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "<response-code> <numericic-id>" $@
+               return 1
+       fi
+       app=$2
+       res=$(__find_sim_port $app)
+
+    curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/deleteall"
+
+    __execute_curl_to_sim $1 "$curlString"
+       return $?
+}
+
+# Simulator API: Set (or reset) response code for next A1 message, for one ric
+# <response-code> <ric-id> [<forced_response_code>]
+# (Function for test scripts)
+sim_post_forcedresponse() {
+       echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+       if [ $# -ne 3 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "<response-code> <ric-id> <forced_response_code>" $@
+               return 1
+       fi
+       app=$2
+       res=$(__find_sim_port $app)
+
+    curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/forceresponse"
+       if [ $# -eq 3 ]; then
+               curlString=$curlString"?code="$3
+       fi
+
+    __execute_curl_to_sim $1 "$curlString"
+       return $?
+}
+
+# Simulator API: Set (or reset) A1 response delay, for one ric
+# <response-code> <ric-id> [<delay-in-seconds>]
+# (Function for test scripts)
+sim_post_forcedelay() {
+       echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+       if [ $# -ne 3 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "<response-code> <ric-id> [<delay-in-seconds>]" $@
+               return 1
+       fi
+       app=$2
+       res=$(__find_sim_port $app)
+
+    curlString="curl -X POST -sw %{http_code} $LOCALHOST$res/delay"
+       if [ $# -eq 3 ]; then
+               curlString=$curlString"?delay="$3
+       fi
+
+    __execute_curl_to_sim $1 "$curlString"
+       return $?
+}
\ No newline at end of file
diff --git a/test/common/test_env.sh b/test/common/test_env.sh
new file mode 100755 (executable)
index 0000000..3bda601
--- /dev/null
@@ -0,0 +1,135 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# Set up the image and tags for the test. Do not add the image tag to the image names.
+
+# NOTE: A env var for each container is created by the test script.
+# This var will point to the local or remote var depending on how
+# the test script is started. The name format is <container-name>_IMAGE, ie with 'LOCAL' or 'REMOTE'.
+
+# Local Policy Agent image and tag
+POLICY_AGENT_LOCAL_IMAGE="o-ran-sc/nonrtric-policy-agent"
+POLICY_AGENT_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT"
+# Remote Policy Agent image and tag
+POLICY_AGENT_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent"
+POLICY_AGENT_REMOTE_IMAGE_TAG="1.0.0"
+
+
+# Control Panel local image and tag
+CONTROL_PANEL_LOCAL_IMAGE="o-ran-sc/nonrtric-controlpanel"
+CONTROL_PANEL_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT"
+# Control Panel remote image and tag
+CONTROL_PANEL_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel"
+CONTROL_PANEL_REMOTE_IMAGE_TAG="1.0.0"
+
+
+# SDNC A1 Controller local image and tag
+SDNC_A1_CONTROLLER_LOCAL_IMAGE="o-ran-sc/nonrtric-a1-controller"
+SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT"
+# SDNC A1 Controller remote image and tag
+SDNC_A1_CONTROLLER_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1-controller"
+SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="1.7.4"
+
+
+#SDNC DN remote image and tag
+SDNC_DB_REMOTE_IMAGE="mysql/mysql-server"
+SDNC_DB_REMOTE_IMAGE_TAG="5.6"
+#No local image for DB, remote image always used
+
+
+# Near RT RIC Simulator local image and tag
+RIC_SIM_LOCAL_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator"
+RIC_SIM_LOCAL_IMAGE_TAG="latest"
+# Near RT RIC Simulator remote image and tag
+RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator"
+RIC_SIM_REMOTE_IMAGE_TAG="1.0.1"
+
+
+#Consul remote image and tag
+CONSUL_REMOTE_IMAGE="consul"
+CONSUL_REMOTE_IMAGE_TAG="1.7.2"
+#No local image for Consul, remote image always used
+
+
+#CBS remote image and tag
+CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app"
+CBS_REMOTE_IMAGE="onap/org.onap.dcaegen2.platform.configbinding.app-app"
+CBS_REMOTE_IMAGE_TAG="2.3.0"
+#No local image for CBS, remote image always used
+
+
+#MR stub image and tag
+MRSTUB_LOCAL_IMAGE="mrstub"
+MRSTUB_LOCAL_IMAGE_TAG="latest"
+#No remote image for MR stub, local image always used
+
+#Callback receiver image and tag
+CR_LOCAL_IMAGE="callback-receiver"
+CR_LOCAL_IMAGE_TAG="latest"
+#No remote image for CR, local image always used
+
+# Common env var for auto-test. Vars used by docker-compose need to be exported
+export DOCKER_SIM_NWNAME="nonrtric-docker-net"                  # Name of docker private network
+
+export POLICY_AGENT_EXTERNAL_PORT=8081                          # Policy Agent container external port (host -> container)
+export POLICY_AGENT_INTERNAL_PORT=8081                          # Policy Agent container internal port (container -> container)
+export POLICY_AGENT_APP_NAME="policy-agent"                     # Name for Policy Agent container
+POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log"    # Path the application log in the Policy Agent container
+
+export MR_EXTERNAL_PORT=3905                                    # MR stub container external port (host -> container)
+export MR_INTERNAL_PORT=3905                                    # MR stub container internal port (container -> container)
+export MR_APP_NAME="message-router"                             # Name for the MR
+
+export CR_EXTERNAL_PORT=8090                                    # Callback receiver container external port (host -> container)
+export CR_INTERNAL_PORT=8090                                    # Callback receiver container internal port (container -> container)
+export CR_APP_NAME="callback-receiver"                          # Name for the Callback receiver
+
+export CONSUL_HOST="consul-server"                              # Host name of consul
+export CONSUL_EXTERNAL_PORT=8500                                # Consul container external port (host -> container)
+export CONSUL_INTERNAL_PORT=8500                                # Consul container internal port (container -> container)
+export CONSUL_APP_NAME="polman-consul"                          # Name for consul container
+
+export CBS_APP_NAME="polman-cbs"                                # Name for CBS container
+export CBS_EXTERNAL_PORT=10000                                  # CBS container external port (host -> container)
+export CBS_INTERNAL_PORT=10000                                  # CBS container internal port (container -> container)
+export CONFIG_BINDING_SERVICE="config-binding-service"          # Host name of CBS
+
+export RIC_SIM_BASE="g"                                         # Base name of the RIC Simulator container, shall be the group code
+                                                                # Note, a prefix is added to each container name by the .env file in the 'ric' dir
+RIC_SIM_PREFIX="ricsim"                                         # Prefix added to ric container name, added in the .env file in the 'ric' dir
+export RIC_SIM_INTERNAL_PORT=8085                               # RIC Simulator container internal port (container -> container).
+                                                                # (externl ports allocated by docker)
+
+export SDNC_APP_NAME="a1-controller"                            # Name of the SNDC A1 Controller container
+export SDNC_EXTERNAL_PORT=8282                                  # SNDC A1 Controller container external port (host -> container)
+export SDNC_INTERNAL_PORT=8181                                  # SNDC A1 Controller container internal port (container -> container)
+export SDNC_DB_APP_NAME="sdnc-db"                               # Name of the SDNC DB container
+SDNC_USER="admin"                                               # SDNC username
+SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"          # SNDC PWD
+SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:"             # Base url path for SNDC API
+
+export CONTROL_PANEL_APP_NAME="control-panel"                   # Name of the Control Panel container
+export CONTROL_PANEL_EXTERNAL_PORT=8080                         # Control Panel container external port (host -> container)
+export CONTROL_PANEL_INTERNAL_PORT=8080                         # Control Panel container external port (host -> container)
+CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log"         # Path the application log in the Control Panel container
+
+RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT         # Base url to the R-APP interface
+DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT                  # Base url to the Dmaap adapter
+ADAPTER=$RESTBASE                                               # Adapter holds the address the agent R-APP interface (REST OR DMAAP)
+                                                                # The values of this var is swiched between the two base url when needed
\ No newline at end of file
diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh
new file mode 100755 (executable)
index 0000000..088995f
--- /dev/null
@@ -0,0 +1,1358 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# This is a script that contains all the functions needed for auto test
+# Arg: local|remote|remote-remove [auto-clean]
+
+#Formatting for 'echo' cmd
+BOLD="\033[1m"
+EBOLD="\033[0m"
+RED="\033[31m\033[1m"
+ERED="\033[0m"
+GREEN="\033[32m\033[1m"
+EGREEN="\033[0m"
+YELLOW="\033[33m\033[1m"
+EYELLOW="\033[0m"
+
+# Just resetting any previous echo formatting...
+echo -ne $EBOLD$ERED$EGREEN
+
+# source test environment variables
+. ../common/test_env.sh
+
+echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@
+
+#Vars for A1 interface version and container count
+G1_A1_VERSION=""
+G2_A1_VERSION=""
+G3_A1_VERSION=""
+G1_COUNT=0
+G2_COUNT=0
+G3_COUNT=0
+
+#Localhost constant
+LOCALHOST="http://localhost:"
+
+# Make curl retries for http response codes set in this env var, space separated list of codes
+AGENT_RETRY_CODES=""
+
+# Var to hold 'auto' in case containers shall be stopped when test case ends
+AUTO_CLEAN=""
+
+# Set a description string for the test case
+if [ -z "$TC_ONELINE_DESCR" ]; then
+       TC_ONELINE_DESCR="<no-description>"
+       echo "No test case description found, TC_ONELINE_DESCR should be set on in the test script , using "$TC_ONELINE_DESCR
+fi
+
+# Counter for test suites
+if [ -f .tmp_tcsuite_ctr ]; then
+       tmpval=$(< .tmp_tcsuite_ctr)
+       ((tmpval++))
+       echo $tmpval > .tmp_tcsuite_ctr
+fi
+
+# Create a test case id, ATC (Auto Test Case), from the name of the test case script.
+# FTC1.sh -> ATC == FTC1
+ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh)
+
+# Create the logs dir if not already created in the current dir
+if [ ! -d "logs" ]; then
+    mkdir logs
+fi
+TESTLOGS=$PWD/logs
+
+# Create a http message log for this testcase
+HTTPLOG=$PWD"/.httplog_"$ATC".txt"
+echo "" > $HTTPLOG
+
+# Create a log dir for the test case
+mkdir -p $TESTLOGS/$ATC
+
+# Clear the log dir for the test case
+rm $TESTLOGS/$ATC/*.log &> /dev/null
+rm $TESTLOGS/$ATC/*.txt &> /dev/null
+rm $TESTLOGS/$ATC/*.json &> /dev/null
+
+# Log all output from the test case to a TC log
+TCLOG=$TESTLOGS/$ATC/TC.log
+exec &>  >(tee ${TCLOG})
+
+#Variables for counting tests as well as passed and failed tests
+RES_TEST=0
+RES_PASS=0
+RES_FAIL=0
+RES_CONF_FAIL=0
+
+#Var for measuring execution time
+TCTEST_START=$SECONDS
+
+echo "-------------------------------------------------------------------------------------------------"
+echo "-----------------------------------      Test case: "$ATC
+echo "-----------------------------------      Started:   "$(date)
+echo "-------------------------------------------------------------------------------------------------"
+echo "-- Description: "$TC_ONELINE_DESCR
+echo "-------------------------------------------------------------------------------------------------"
+echo "-----------------------------------      Test case setup      -----------------------------------"
+
+echo -e $BOLD"Checking configured image setting for this test case"$EBOLD
+
+#Temp var to check for image variable name errors
+IMAGE_ERR=0
+#Create a file with image info for later printing as a table
+image_list_file=".image-list"
+echo -e " Container\tImage\ttag" > $image_list_file
+
+# Check if image env var is set and if so export the env var with image to use (used by docker compose files)
+# arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name>
+__check_image_var() {
+       if [ $# -ne 5 ]; then
+               echo "Expected arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name>"
+               ((IMAGE_ERR++))
+               return
+       fi
+       tmp=${1}"\t"
+       #Create var from the input var names
+       image="${!4}"
+       tag="${!5}"
+
+       if [ -z $image ]; then
+               echo -e $RED"\$"$4" not set in test_env"$ERED
+               ((IMAGE_ERR++))
+               echo ""
+               tmp=$tmp"<no-image>\t"
+       else
+               tmp=$tmp$image"\t"
+       fi
+       if [ -z $tag ]; then
+               echo -e $RED"\$"$5" not set in test_env"$ERED
+               ((IMAGE_ERR++))
+               echo ""
+               tmp=$tmp"<no-tag>\t"
+       else
+               tmp=$tmp$tag
+       fi
+       echo -e "$tmp" >> $image_list_file
+       #Export the env var
+       export "${3}"=$image":"$tag
+
+       #echo " Configured image for ${1} (script start arg=${2}): "$image":"$tag
+}
+
+# Check that image env setting are available
+echo ""
+if [ $# -lt 1 ] || [ $# -gt 2 ]; then
+       echo "Expected arg: local|remote|remote-remove [auto-clean]"
+       exit 1
+elif [ $1 == "local" ]; then
+
+       #Local agent image
+       __check_image_var " Policy Agent" $1 "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
+
+       #Local Control Panel image
+       __check_image_var " Control Panel" $1 "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG"
+
+       #Local SNDC image
+       __check_image_var " SDNC A1 Controller" $1 "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG"
+
+       #Local ric sim image
+       __check_image_var " RIC Simulator" $1 "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
+
+elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
+
+       #Remote agent image
+       __check_image_var " Policy Agent" $1 "POLICY_AGENT_IMAGE" "POLICY_AGENT_REMOTE_IMAGE" "POLICY_AGENT_REMOTE_IMAGE_TAG"
+
+       #Remote Control Panel image
+       __check_image_var " Control Panel" $1 "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE_TAG"
+
+       #Remote SDNC image
+       __check_image_var " SDNC A1 Controller" $1 "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG"
+
+       #Remote ric sim image
+       __check_image_var " RIC Simulator" $1 "RIC_SIM_IMAGE" "RIC_SIM_REMOTE_IMAGE" "RIC_SIM_REMOTE_IMAGE_TAG"
+
+else
+       echo "Expected arg: local|remote|remote-remove [auto-clean]"
+       exit 1
+fi
+
+if [ $# -eq 2 ]; then
+       if [ $2 == "auto-clean" ]; then
+               echo "Stting automatic cleaning of container when test case ends"
+               AUTO_CLEAN="auto"
+       else
+               echo "Expected arg: local|remote|remote-remove [auto-clean]"
+               exit 1
+       fi
+fi
+
+# These images are not built as part of this project official images, just check that env vars are set correctly
+__check_image_var " Message Router" $1 "MRSTUB_IMAGE" "MRSTUB_LOCAL_IMAGE" "MRSTUB_LOCAL_IMAGE_TAG"
+__check_image_var " Callback Receiver" $1 "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_IMAGE_TAG"
+__check_image_var " Consul" $1 "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG"
+__check_image_var " CBS" $1 "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG"
+__check_image_var " SDNC DB" $1 "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG"
+
+#Errors in image setting - exit
+if [ $IMAGE_ERR -ne 0 ]; then
+       exit 1
+fi
+
+#Print a tables of the image settings
+echo -e $BOLD"Images configured for start arg: "$1 $EBOLD
+column -t -s $'\t' $image_list_file
+
+echo ""
+
+
+#Set the SIM_GROUP var
+echo -e $BOLD"Setting var to main dir of all container/simulator scripts"$EBOLD
+if [ -z "$SIM_GROUP" ]; then
+       SIM_GROUP=$PWD/../simulator-group
+       if [ ! -d  $SIM_GROUP ]; then
+               echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the nontrtric repo, but failed."
+               echo -e $RED"Please set the SIM_GROUP manually in the test_env.sh"$ERED
+               exit 1
+       else
+               echo " SIM_GROUP auto set to: " $SIM_GROUP
+       fi
+elif [ $SIM_GROUP = *simulator_group ]; then
+       echo -e $RED"Env var SIM_GROUP does not seem to point to dir 'simulator-group' in the repo, check common/test_env.sh"$ERED
+       exit 1
+else
+       echo " SIM_GROUP env var already set to: " $SIM_GROUP
+fi
+
+echo ""
+
+#Temp var to check for image pull errors
+IMAGE_ERR=0
+
+#Function to check if image exist and stop+remove the container+pull new images as needed
+#args <script-start-arg> <descriptive-image-name> <container-base-name> <image-with-tag>
+__check_and_pull_image() {
+
+       echo -e " Checking $BOLD$2$EBOLD container(s) with basename: $BOLD$3$EBOLD using image: $BOLD$4$EBOLD"
+       format_string="\"{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}\""
+       tmp_im=$(docker images --format $format_string ${4})
+
+       if [ $1 == "local" ]; then
+               if [ -z "$tmp_im" ]; then
+                       echo -e "  "$2" (local image): \033[1m"$4"\033[0m $RED does not exist in local registry, need to be built (or manually pulled)"$ERED
+                       ((IMAGE_ERR++))
+                       return 1
+               else
+                       echo -e "  "$2" (local image): \033[1m"$4"\033[0m "$GREEN"OK"$EGREEN
+               fi
+       elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
+               if [ $1 == "remote-remove" ]; then
+                       echo -ne "  Attempt to stop and remove container(s), if running - \033[0K\r"
+                       tmp="$(docker ps -aq --filter name=${3})"
+                       if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
+                               docker stop $tmp &> /dev/null
+                               if [ $? -ne 0 ]; then
+                                       ((IMAGE_ERR++))
+                                       echo ""
+                                       echo -e $RED"  Container(s) could not be stopped - try manual stopping the container(s)"$ERED
+                                       return 1
+                               fi
+                       fi
+                       echo -ne "  Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"\033[0K\r"
+                       tmp="$(docker ps -aq --filter name=${3})" &> /dev/null
+                       if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
+                               docker rm $tmp &> /dev/null
+                               if [ $? -ne 0 ]; then
+                                       ((IMAGE_ERR++))
+                                       echo ""
+                                       echo -e $RED"  Container(s) could not be removed - try manual removal of the container(s)"$ERED
+                                       return 1
+                               fi
+                       fi
+                       echo -e "  Attempt to stop and remove container(s), if running - "$GREEN"stopped removed"$EGREEN
+                       echo -ne "  Removing image - \033[0K\r"
+                       tmp="$(docker images -q ${4})" &> /dev/null
+                       if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
+                               docker rmi $4 &> /dev/null
+                               if [ $? -ne 0 ]; then
+                                       ((IMAGE_ERR++))
+                                       echo ""
+                                       echo -e $RED"  Image could not be removed - try manual removal of the image"$ERED
+                                       return 1
+                               fi
+                               echo -e "  Removing image - "$GREEN"removed"$EGREEN
+                       else
+                               echo -e "  Removing image - "$GREEN"image not in repository"$EGREEN
+                       fi
+                       tmp_im=""
+               fi
+               if [ -z "$tmp_im" ]; then
+                       echo -ne "  Pulling image\033[0K\r"
+                       docker pull $4   > /dev/null
+                       tmp_im=$(docker images ${4} | grep -v REPOSITORY)
+                       if [ -z "$tmp_im" ]; then
+                               echo ""
+                               echo -e "  Pulling image -$RED could not be pulled"$ERED
+                               ((IMAGE_ERR++))
+                               return 1
+                       fi
+                       echo -e "  Pulling image -$GREEN Pulled $EGREEN"
+               else
+                       echo -e "  Pulling image -$GREEN OK $EGREEN(exists in local repository)"
+               fi
+       fi
+       return 0
+}
+
+
+echo -e $BOLD"Pulling configured images, if needed"$EBOLD
+
+app="Policy Agent";             __check_and_pull_image $1 "$app" $POLICY_AGENT_APP_NAME $POLICY_AGENT_IMAGE
+app="Non-RT RIC Control Panel"; __check_and_pull_image $1 "$app" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_IMAGE
+app="SDNC A1 Controller";       __check_and_pull_image $1 "$app" $SDNC_APP_NAME $SDNC_A1_CONTROLLER_IMAGE
+app="Near-RT RIC Simulator";    __check_and_pull_image $1 "$app" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE $RIC_SIM_IMAGE
+
+app="Consul";                   __check_and_pull_image $1 "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
+app="CBS";                      __check_and_pull_image $1 "$app" $CBS_APP_NAME $CBS_IMAGE
+app="SDNC DB";                  __check_and_pull_image $1 "$app" $SDNC_APP_NAME $SDNC_DB_IMAGE
+
+# MR stub image not checked, will be built by this script - only local image
+# CR stub image not checked, will be built by this script - only local image
+
+
+#Errors in image setting - exit
+if [ $IMAGE_ERR -ne 0 ]; then
+       echo ""
+       echo "#################################################################################################"
+       echo -e $RED"One or more images could not be pulled or containers using the images could not be stopped/removed"$ERED
+       echo "#################################################################################################"
+       echo ""
+       exit 1
+fi
+
+echo ""
+
+echo -e $BOLD"Building images needed for test"$EBOLD
+
+curdir=$PWD
+cd $curdir
+cd ../mrstub
+echo " Building mrstub image: mrstub:latest"
+docker build -t mrstub . &> /dev/null
+if [ $? -eq 0 ]; then
+       echo -e  $GREEN" Build Ok"$EGREEN
+else
+       echo -e $RED" Build Failed"$ERED
+       ((RES_CONF_FAIL++))
+fi
+cd $curdir
+
+cd ../cr
+echo " Building Callback Receiver image: callback-receiver:latest"
+docker build -t callback-receiver . &> /dev/null
+if [ $? -eq 0 ]; then
+       echo -e  $GREEN" Build Ok"$EGREEN
+else
+       echo -e $RED" Build Failed"$ERED
+       ((RES_CONF_FAIL++))
+fi
+cd $curdir
+
+echo ""
+
+# Create a table of the images used in the script
+echo -e $BOLD"Local docker registry images used in the this test script"$EBOLD
+
+docker_tmp_file=.docker-images-table
+format_string="{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}"
+echo -e " Application\tRepository\tTag\tCreated Since\tSize" > $docker_tmp_file
+echo -e " Policy Agent\t$(docker images --format $format_string $POLICY_AGENT_IMAGE)" >>   $docker_tmp_file
+echo -e " Control Panel\t$(docker images --format $format_string $CONTROL_PANEL_IMAGE)" >>   $docker_tmp_file
+echo -e " SDNC A1 Controller\t$(docker images --format $format_string $SDNC_A1_CONTROLLER_IMAGE)" >>   $docker_tmp_file
+echo -e " RIC Simulator\t$(docker images --format $format_string $RIC_SIM_IMAGE)" >>   $docker_tmp_file
+echo -e " Message Router\t$(docker images --format $format_string $MRSTUB_IMAGE)" >>   $docker_tmp_file
+echo -e " Callback Receiver\t$(docker images --format $format_string $CR_IMAGE)" >>   $docker_tmp_file
+echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >>   $docker_tmp_file
+echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >>   $docker_tmp_file
+echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >>   $docker_tmp_file
+
+column -t -s $'\t' $docker_tmp_file
+
+echo ""
+
+echo -e $BOLD"======================================================="$EBOLD
+echo -e $BOLD"== Common test setup completed -  test script begins =="$EBOLD
+echo -e $BOLD"======================================================="$EBOLD
+echo ""
+
+# Function to print the test result, shall be the last cmd in a test script
+# args: -
+# (Function for test scripts)
+print_result() {
+
+       TCTEST_END=$SECONDS
+       duration=$((TCTEST_END-TCTEST_START))
+
+       echo "-------------------------------------------------------------------------------------------------"
+       echo "-------------------------------------     Test case: "$ATC
+       echo "-------------------------------------     Ended:     "$(date)
+       echo "-------------------------------------------------------------------------------------------------"
+       echo "-- Description: "$TC_ONELINE_DESCR
+       echo "-- Execution time: " $duration " seconds"
+       echo "-------------------------------------------------------------------------------------------------"
+       echo "-------------------------------------     RESULTS"
+       echo ""
+
+
+       total=$((RES_PASS+RES_FAIL))
+       if [ $RES_TEST -eq 0 ]; then
+               echo -e "\033[1mNo tests seem to have been executed. Check the script....\033[0m"
+               echo -e "\033[31m\033[1m ___  ___ ___ ___ ___ _____   ___ _   ___ _   _   _ ___ ___ \033[0m"
+               echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_   _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
+               echo -e "\033[31m\033[1m\__ \ (__|   /| ||  _/ | |   | _/ _ \ | || |_| |_| |   / _| \033[0m"
+               echo -e "\033[31m\033[1m|___/\___|_|_\___|_|   |_|   |_/_/ \_\___|____\___/|_|_\___|\033[0m"
+       elif [ $total != $RES_TEST ]; then
+               echo -e "\033[1mTotal number of tests does not match the sum of passed and failed tests. Check the script....\033[0m"
+               echo -e "\033[31m\033[1m ___  ___ ___ ___ ___ _____   ___ _   ___ _   _   _ ___ ___ \033[0m"
+               echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_   _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
+               echo -e "\033[31m\033[1m\__ \ (__|   /| ||  _/ | |   | _/ _ \ | || |_| |_| |   / _| \033[0m"
+               echo -e "\033[31m\033[1m|___/\___|_|_\___|_|   |_|   |_/_/ \_\___|____\___/|_|_\___|\033[0m"
+       elif [ $RES_CONF_FAIL -ne 0 ]; then
+               echo -e "\033[1mOne or more configure regest has failed. Check the script log....\033[0m"
+               echo -e "\033[31m\033[1m ___  ___ ___ ___ ___ _____   ___ _   ___ _   _   _ ___ ___ \033[0m"
+               echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_   _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
+               echo -e "\033[31m\033[1m\__ \ (__|   /| ||  _/ | |   | _/ _ \ | || |_| |_| |   / _| \033[0m"
+               echo -e "\033[31m\033[1m|___/\___|_|_\___|_|   |_|   |_/_/ \_\___|____\___/|_|_\___|\033[0m"
+       elif [ $RES_PASS = $RES_TEST ]; then
+               echo -e "All tests \033[32m\033[1mPASS\033[0m"
+               echo -e "\033[32m\033[1m  ___  _   ___ ___ \033[0m"
+               echo -e "\033[32m\033[1m | _ \/_\ / __/ __| \033[0m"
+               echo -e "\033[32m\033[1m |  _/ _ \\__ \__ \\ \033[0m"
+               echo -e "\033[32m\033[1m |_|/_/ \_\___/___/ \033[0m"
+               echo ""
+
+               # Update test suite counter
+               if [ -f .tmp_tcsuite_pass_ctr ]; then
+                       tmpval=$(< .tmp_tcsuite_pass_ctr)
+                       ((tmpval++))
+                       echo $tmpval > .tmp_tcsuite_pass_ctr
+               fi
+               if [ -f .tmp_tcsuite_pass ]; then
+                       echo " - "$ATC " -- "$TC_ONELINE_DESCR"  Execution time: "$duration" seconds" >> .tmp_tcsuite_pass
+               fi
+       else
+               echo -e "One or more tests with status  \033[31m\033[1mFAIL\033[0m "
+               echo -e "\033[31m\033[1m  ___ _   ___ _    \033[0m"
+               echo -e "\033[31m\033[1m | __/_\ |_ _| |   \033[0m"
+               echo -e "\033[31m\033[1m | _/ _ \ | || |__ \033[0m"
+               echo -e "\033[31m\033[1m |_/_/ \_\___|____|\033[0m"
+               echo ""
+               # Update test suite counter
+               if [ -f .tmp_tcsuite_fail_ctr ]; then
+                       tmpval=$(< .tmp_tcsuite_fail_ctr)
+                       ((tmpval++))
+                       echo $tmpval > .tmp_tcsuite_fail_ctr
+               fi
+               if [ -f .tmp_tcsuite_fail ]; then
+                       echo " - "$ATC " -- "$TC_ONELINE_DESCR"  Execution time: "$duration" seconds" >> .tmp_tcsuite_fail
+               fi
+       fi
+
+       echo "++++ Number of tests:          "$RES_TEST
+       echo "++++ Number of passed tests:   "$RES_PASS
+       echo "++++ Number of failed tests:   "$RES_FAIL
+       echo ""
+       echo "++++ Number of failed configs: "$RES_CONF_FAIL
+       echo "-------------------------------------     Test case complete    ---------------------------------"
+       echo "-------------------------------------------------------------------------------------------------"
+       echo ""
+}
+
+#####################################################################
+###### Functions for start, configuring, stoping, cleaning etc ######
+#####################################################################
+
+
+# Stop and remove all containers
+# args: -
+# (Function for test scripts)
+clean_containers() {
+
+       echo -e $BOLD"Stopping and removing all running containers, by container name"$EBOLD
+
+       CONTAINTER_NAMES=("Policy Agent           " $POLICY_AGENT_APP_NAME\
+                                         "Non-RT RIC Simulator(s)" $RIC_SIM_PREFIX\
+                                         "Message Router         " $MR_APP_NAME\
+                                         "Callback Receiver      " $CR_APP_NAME\
+                                         "Control Panel          " $CONTROL_PANEL_APP_NAME\
+                                         "SDNC A1 Controller     " $SDNC_APP_NAME\
+                                         "SDNC DB                " $SDNC_DB_APP_NAME\
+                                         "CBS                    " $CBS_APP_NAME\
+                                         "Consul                 " $CONSUL_APP_NAME)
+
+       nw=0 # Calc max width of container name, to make a nice table
+       for (( i=1; i<${#CONTAINTER_NAMES[@]} ; i+=2 )) ; do
+               if [ ${#CONTAINTER_NAMES[i]} -gt $nw ]; then
+                       nw=${#CONTAINTER_NAMES[i]}
+               fi
+       done
+
+       for (( i=0; i<${#CONTAINTER_NAMES[@]} ; i+=2 )) ; do
+               APP="${CONTAINTER_NAMES[i]}"
+               CONTR="${CONTAINTER_NAMES[i+1]}"
+               for((w=${#CONTR}; w<$nw; w=w+1)); do
+                       CONTR="$CONTR "
+               done
+               echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}\033[0K\r"
+               docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null
+               echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}\033[0K\r"
+               docker rm $(docker ps -qa --filter name=${CONTR}) &> /dev/null
+               echo -e  " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}"
+       done
+
+       echo ""
+}
+
+# Function stop and remove all container in the end of the test script, if the arg 'auto-clean' is given at test script start
+# args: -
+# (Function for test scripts)
+auto_clean_containers() {
+       echo
+       if [ "$AUTO_CLEAN" == "auto" ]; then
+               echo -e $BOLD"Initiating automatic cleaning of started containers"$EBOLD
+               clean_containers
+       fi
+}
+
+# Function to sleep a test case for a numner of seconds. Prints the optional text args as info
+# args: <sleep-time-in-sec> [any-text-in-quoteds-to-printed]
+# (Function for test scripts)
+sleep_wait() {
+
+       echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD
+       if [ $# -lt 1 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "need at least one arg, <sleep-time-in-sec> [any-text-to-printed]" $@
+               exit 1
+       fi
+       #echo "---- Sleep for " $1 " seconds ---- "$2
+       start=$SECONDS
+       duration=$((SECONDS-start))
+       while [ $duration -lt $1 ]; do
+               echo -ne "  Slept for ${duration} seconds\033[0K\r"
+               sleep 1
+               duration=$((SECONDS-start))
+       done
+       echo -ne "  Slept for ${duration} seconds\033[0K\r"
+       echo ""
+}
+
+# Print error info for the call in the parent script (test case). Arg: <error-message-to-print>
+# Not to be called from the test script itself.
+__print_err() {
+    echo -e $RED ${FUNCNAME[1]} " "$1" " ${BASH_SOURCE[2]} " line" ${BASH_LINENO[1]} $ERED
+       if [ $# -gt 1 ]; then
+               echo -e $RED" Got: "${FUNCNAME[1]} ${@:2} $ERED
+       fi
+}
+
+
+# Helper function to get a the port of a specific ric simulatpor
+# args: <ric-id>
+# (Not for test scripts)
+__find_sim_port() {
+    name=$1" " #Space appended to prevent matching 10 if 1 is desired....
+    cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'"
+       res=$(eval $cmdstr)
+       if [[ "$res" =~ ^[0-9]+$ ]]; then
+               echo $res
+       else
+               echo "0"
+    fi
+}
+
+# Function to create the docker network for the test
+# Not to be called from the test script itself.
+__create_docker_network() {
+       tmp=$(docker network ls -q --filter name=$DOCKER_SIM_NWNAME)
+       if [ $? -ne 0 ]; then
+               echo -e $RED" Could not check if docker network $DOCKER_SIM_NWNAME exists"$ERED
+               return 1
+       fi
+       if [ -z tmp ]; then
+               echo -e "Creating docker network:$BOLD $DOCKER_SIM_NWNAME $EBOLD"
+               docker network create $DOCKER_SIM_NWNAME
+               if [ $? -ne 0 ]; then
+                       echo -e $RED" Could not create docker network $DOCKER_SIM_NWNAME"$ERED
+                       return 1
+               fi
+       else
+               echo -e " Docker network $DOCKER_SIM_NWNAME already exists$GREEN OK $EGREEN"
+       fi
+}
+
+# Check if container is started by calling url on localhost using a port, expects response code 2XX
+# args: <container-name> <port> <url>
+# Not to be called from the test script itself.
+__check_container_start() {
+       if [ $# -ne 3 ]; then
+               ((RES_CONF_FAIL++))
+               __print_err "need 3 args, <container-name> <port> <url>" $@
+               return 1
+       fi
+       echo -ne " Container $BOLD$1$EBOLD starting\033[0K\r"
+       appname=$1
+       localport=$2
+       url=$3
+       pa_started=false
+       for i in {1..10}; do
+               if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]; then
+                               echo -e " Container $BOLD$1$EBOLD$GREEN running$EGREEN on$BOLD image $(docker inspect --format '{{ .Config.Image }}' ${appname}) $EBOLD"
+                               pa_started=true
+                               break
+                       else
+                               sleep $i
+               fi
+       done
+       if ! [ $pa_started  ]; then
+               ((RES_CONF_FAIL++))
+               echo ""
+               echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED
+               return 1
+       fi
+       if [ $localport -eq 0 ]; then
+               while [ $localport -eq 0 ]; do
+                       echo -ne " Waiting for container ${appname} to publish its ports...\033[0K\r"
+                       localport=$(__find_sim_port $appname)
+                       sleep 1
+                       echo -ne " Waiting for container ${appname} to publish its ports...retrying....\033[0K\r"
+               done
+               echo -ne " Waiting for container ${appname} to publish its ports...retrying....$GREEN OK $EGREEN"
+               echo ""
+       fi
+
+       pa_st=false
+       echo -ne " Waiting for container ${appname} service status...\033[0K\r"
+       for i in {1..20}; do
+               result="$(__do_curl $LOCALHOST${localport}${url})"
+               if [ $? -eq 0 ]; then
+                       if [ ${#result} -gt 15 ]; then
+                               #If response is too long, truncate
+                               result="...response text too long, omitted"
+                       fi
+                       echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result\033[0K\r"
+                       echo -ne " Container $BOLD${appname}$EBOLD$GREEN is alive$EGREEN, responds to service status:$GREEN $result $EGREEN"
+                       pa_st=true
+                       break
+               else
+                       #echo " Retrying in $i seconds"
+                       echo -ne " Waiting for container ${appname} service status...retrying in $i seconds\033[0K\r"
+                       sleep $i
+               fi
+       done
+
+       if [ "$pa_st" = "false"  ]; then
+               ((RES_CONF_FAIL++))
+               echo -e $RED" Container ${appname} did not respond to service status"$ERED
+               return 0
+       fi
+
+       echo ""
+       return 0
+}
+
+
+# Function to start a container and wait until it responds on the given port and url.
+#args: <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> [<app-name> <port-number> <alive-url>]*
+__start_container() {
+
+       variableArgCount=$(($#-2))
+       if [ $# -lt 5 ] && [ [ $(($variableArgCount%3)) -ne 0 ]; then
+               ((RES_CONF_FAIL++))
+       __print_err "need 5 or more args,  <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> [<app-name> <port-number> <alive-url>]*" $@
+               exit 1
+       fi
+
+       __create_docker_network
+
+       curdir=$PWD
+       cd $SIM_GROUP
+       cd $1
+
+       if [ "$2" == "NODOCKERARGS" ]; then
+               docker-compose up -d &> /dev/null
+       else
+               docker-compose up -d $2 &> /dev/null
+       fi
+
+       shift; shift;
+       cntr=0
+       while [ $cntr -lt $variableArgCount ]; do
+               app=$1; shift;
+               port=$1; shift;
+               url=$1; shift;
+               let cntr=cntr+3
+
+               __check_container_start "$app" "$port" "$url"
+       done
+
+       cd $curdir
+       echo ""
+       return 0
+}
+
+####################
+### Consul functions
+####################
+
+# Function to load config from a file into consul for the Policy Agent
+# arg: <json-config-file>
+# (Function for test scripts)
+consul_config_app() {
+
+       echo -e $BOLD"Configuring Consul"$EBOLD
+
+       if [ $# -ne 1 ]; then
+               ((RES_CONF_FAIL++))
+       __print_err "need one arg,  <json-config-file>" $@
+               exit 1
+       fi
+
+       echo " Loading config for "$POLICY_AGENT_APP_NAME" from "$1
+
+       curl -s $LOCALHOST${CONSUL_EXTERNAL_PORT}/v1/kv/${POLICY_AGENT_APP_NAME}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$1 >/dev/null
+       if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL - json config could not be loaded to consul" $ERED
+               ((RES_CONF_FAIL++))
+               return 1
+       fi
+       body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
+
+       if [ $? -ne 0 ]; then
+               echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED
+               ((RES_CONF_FAIL++))
+               return 1
+       else
+               targetJson=$(< $1)
+               targetJson="{\"config\":"$targetJson"}"
+               echo "TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python ../common/compare_json.py "$targetJson" "$body")
+               if [ $res -ne 0 ]; then
+                       echo -e $RED" FAIL - policy json config read from consul/cbs is not equal to the intended json config...." $ERED
+                       ((RES_CONF_FAIL++))
+                       return 1
+               else
+                       echo -e $GREEN" Config loaded ok to consul"$EGREEN
+               fi
+       fi
+
+       echo ""
+
+}
+
+# Function to perpare the consul configuration according to the current simulator configuration
+# args: SDNC|NOSDNC <output-file>
+# (Function for test scripts)
+prepare_consul_config() {
+       echo -e $BOLD"Prepare Consul config"$EBOLD
+
+       echo " Writing consul config for "$POLICY_AGENT_APP_NAME" to file: "$2
+
+       if [ $# != 2 ];  then
+               ((RES_CONF_FAIL++))
+       __print_err "need two args,  SDNC|NOSDNC <output-file>" $@
+               exit 1
+       fi
+
+       if [ $1 == "SDNC" ]; then
+               echo -e " Config$BOLD including SDNC$EBOLD configuration"
+       elif [ $1 == "NOSDNC" ];  then
+               echo -e " Config$BOLD excluding SDNC$EBOLD configuration"
+       else
+               ((RES_CONF_FAIL++))
+       __print_err "need two args,  SDNC|NOSDNC <output-file>" $@
+               exit 1
+       fi
+
+       config_json="\n            {"
+       if [ $1 == "SDNC" ]; then
+               config_json=$config_json"\n   \"controller\": ["
+               config_json=$config_json"\n                     {"
+               config_json=$config_json"\n                       \"name\": \"$SDNC_APP_NAME\","
+               config_json=$config_json"\n                       \"baseUrl\": \"http://$SDNC_APP_NAME:$SDNC_INTERNAL_PORT\","
+               config_json=$config_json"\n                       \"userName\": \"$SDNC_USER\","
+               config_json=$config_json"\n                       \"password\": \"$SDNC_PWD\""
+               config_json=$config_json"\n                     }"
+               config_json=$config_json"\n   ],"
+       fi
+
+
+       config_json=$config_json"\n   \"streams_publishes\": {"
+       config_json=$config_json"\n                            \"dmaap_publisher\": {"
+       config_json=$config_json"\n                              \"type\": \"$MR_APP_NAME\","
+       config_json=$config_json"\n                              \"dmaap_info\": {"
+       config_json=$config_json"\n                                \"topic_url\": \"http://$MR_APP_NAME:$MR_INTERNAL_PORT/events/A1-POLICY-AGENT-WRITE\""
+       config_json=$config_json"\n                              }"
+       config_json=$config_json"\n                            }"
+       config_json=$config_json"\n   },"
+       config_json=$config_json"\n   \"streams_subscribes\": {"
+       config_json=$config_json"\n                             \"dmaap_subscriber\": {"
+       config_json=$config_json"\n                               \"type\": \"$MR_APP_NAME\","
+       config_json=$config_json"\n                               \"dmaap_info\": {"
+       config_json=$config_json"\n                                   \"topic_url\": \"http://$MR_APP_NAME:$MR_INTERNAL_PORT/events/A1-POLICY-AGENT-READ/users/policy-agent\""
+       config_json=$config_json"\n                                 }"
+       config_json=$config_json"\n                               }"
+       config_json=$config_json"\n   },"
+
+       config_json=$config_json"\n   \"ric\": ["
+
+       rics=$(docker ps | grep ricsim | awk '{print $NF}')
+
+       if [ $? -ne 0 ] || [ -z "$rics" ]; then
+               echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
+               ((RES_CONF_FAIL++))
+               return 1
+       fi
+
+       cntr=0
+       for ric in $rics; do
+               if [ $cntr -gt 0 ]; then
+                       config_json=$config_json"\n          ,"
+               fi
+               config_json=$config_json"\n          {"
+               config_json=$config_json"\n            \"name\": \"$ric\","
+               config_json=$config_json"\n            \"baseUrl\": \"http://$ric:$RIC_SIM_INTERNAL_PORT\","
+               if [ $1 == "SDNC" ]; then
+                       config_json=$config_json"\n            \"controller\": \"$SDNC_APP_NAME\","
+               fi
+               config_json=$config_json"\n            \"managedElementIds\": ["
+               config_json=$config_json"\n              \"me1_$ric\","
+               config_json=$config_json"\n              \"me2_$ric\""
+               config_json=$config_json"\n            ]"
+               config_json=$config_json"\n          }"
+               let cntr=cntr+1
+       done
+
+       config_json=$config_json"\n           ]"
+       config_json=$config_json"\n}"
+
+
+       printf "$config_json">$2
+
+       echo ""
+}
+
+
+# Start Consul and CBS
+# args: -
+# (Function for test scripts)
+start_consul_cbs() {
+
+       echo -e $BOLD"Starting Consul and CBS"$EBOLD
+
+       __start_container consul_cbs NODOCKERARGS  "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" \
+                                                    "$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck"
+}
+
+###########################
+### RIC Simulator functions
+###########################
+
+# Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface
+# args:  ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>
+# (Function for test scripts)
+start_ric_simulators() {
+
+       echo -e $BOLD"Starting RIC Simulators"$EBOLD
+
+       if [ $# != 3 ]; then
+               ((RES_CONF_FAIL++))
+       __print_err "need three args,  ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>" $@
+               exit 1
+       fi
+       echo " $2 simulators using basename: $1 on interface: $3"
+       #Set env var for simulator count and A1 interface vesion for the given group
+       if [ $1 == "ricsim_g1" ]; then
+               G1_COUNT=$2
+               G1_A1_VERSION=$3
+       elif [ $1 == "ricsim_g2" ]; then
+               G2_COUNT=$2
+               G2_A1_VERSION=$3
+       elif [ $1 == "ricsim_g3" ]; then
+               G3_COUNT=$2
+               G3_A1_VERSION=$3
+       else
+               ((RES_CONF_FAIL++))
+       __print_err "need three args, gricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>" $@
+               exit 1
+       fi
+
+       # Create .env file to compose project, all ric container will get this prefix
+       echo "COMPOSE_PROJECT_NAME="$RIC_SIM_PREFIX > $SIM_GROUP/ric/.env
+
+       export G1_A1_VERSION
+       export G2_A1_VERSION
+       export G3_A1_VERSION
+
+       docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT"
+       app_data=""
+       cntr=1
+       while [ $cntr -le $2 ]; do
+               app=$1"_"$cntr
+               port=0
+               app_data="$app_data $app $port /"
+               let cntr=cntr+1
+       done
+
+       __start_container ric "$docker_args" $app_data
+
+}
+
+###########################
+### Control Panel functions
+###########################
+
+# Start the Control Panel container
+# args: -
+# (Function for test scripts)
+start_control_panel() {
+
+       echo -e $BOLD"Starting Control Panel"$EBOLD
+
+       __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/"
+
+}
+
+##################
+### SDNC functions
+##################
+
+# Start the SDNC A1 Controller
+# args: -
+# (Function for test scripts)
+start_sdnc() {
+
+       echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
+
+       __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT "/apidoc/explorer"
+
+}
+
+#####################
+### MR stub functions
+#####################
+
+# Start the Message Router stub interface in the simulator group
+# args: -
+# (Function for test scripts)
+start_mr() {
+
+       echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD
+
+       __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/"
+
+}
+
+################
+### CR functions
+################
+
+# Start the Callback reciver in the simulator group
+# args: -
+# (Function for test scripts)
+start_cr() {
+
+       echo -e $BOLD"Starting Callback Receiver"$EBOLD
+
+       __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/"
+
+}
+
+###########################
+### Policy Agents functions
+###########################
+
+# Start the policy agwent
+# args: -
+# (Function for test scripts)
+start_policy_agent() {
+
+       echo -e $BOLD"Starting Policy Agent"$EBOLD
+
+       __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status"
+
+}
+
+# All calls to the agent will be directed to the agent REST interface from now on
+# args: -
+# (Function for test scripts)
+use_agent_rest() {
+       echo -e $BOLD"Using agent REST interface"$EBOLD
+       export ADAPTER=$RESTBASE
+       echo ""
+}
+
+# All calls to the agent will be directed to the agent dmaap interface from now on
+# args: -
+# (Function for test scripts)
+use_agent_dmaap() {
+       echo -e $BOLD"Using agent DMAAP interface"$EBOLD
+       export ADAPTER=$DMAAPBASE
+       echo ""
+
+}
+
+# Turn on debug level tracing in the agent
+# args: -
+# (Function for test scripts)
+set_agent_debug() {
+       echo -e $BOLD"Setting agent debug"$EBOLD
+       curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST  -H 'Content-Type: application/json' -d '{"configuredLevel":"debug"}' &> /dev/null
+       if [ $? -ne 0 ]; then
+               __print_err "could not set debug mode" $@
+               return 1
+       fi
+       return 0
+       echo ""
+}
+
+# Perform curl retries when making direct call to the agent for the specified http response codes
+# Speace separated list of http response codes
+# args: [<response-code>]*
+use_agent_retries() {
+       echo -e $BOLD"Do curl retries to the agent REST inteface for these response codes:$@"$EBOLD
+       AGENT_RETRY_CODES=$@
+       echo ""
+}
+
+#################
+### Log functions
+#################
+
+# Check the agent logs for WARNINGs and ERRORs
+# args: -
+# (Function for test scripts)
+
+check_policy_agent_logs() {
+       __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH
+}
+
+check_control_panel_logs() {
+       __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH
+}
+
+__check_container_logs() {
+       dispname=$1
+       appname=$2
+       logpath=$3
+       echo -e $BOLD"Checking $dispname container $appname log ($logpath) for WARNINGs and ERRORs"$EBOLD
+
+       #tmp=$(docker ps | grep $appname)
+       tmp=$(docker ps -q --filter name=$appname) #get the container id
+       if [ -z "$tmp" ]; then  #Only check logs for running Policy Agent apps
+               echo $dispname" is not running, no check made"
+               return
+       fi
+       foundentries="$(docker exec -it $tmp grep WARN $logpath | wc -l)"
+       if [ $? -ne  0 ];then
+               echo "  Problem to search $appname log $logpath"
+       else
+               if [ $foundentries -eq 0 ]; then
+                       echo "  No WARN entries found in $appname log $logpath"
+               else
+                       echo -e "  Found \033[1m"$foundentries"\033[0m WARN entries in $appname log $logpath"
+               fi
+       fi
+       foundentries="$(docker exec -it $tmp grep ERR $logpath | wc -l)"
+       if [ $? -ne  0 ];then
+               echo "  Problem to search $appname log $logpath"
+       else
+               if [ $foundentries -eq 0 ]; then
+                       echo "  No ERR entries found in $appname log $logpath"
+               else
+                       echo -e $RED"  Found \033[1m"$foundentries"\033[0m"$RED" ERR entries in $appname log $logpath"$ERED
+               fi
+       fi
+       echo ""
+}
+
+# Store all container logs and other logs in the log dir for the script
+# Logs are stored with a prefix in case logs should be stored several times during a test
+# args: <logfile-prefix>
+# (Function for test scripts)
+store_logs() {
+       if [ $# != 1 ]; then
+               ((RES_CONF_FAIL++))
+       __print_err "need one arg, <file-prefix>" $@
+               exit 1
+       fi
+       echo -e $BOLD"Storing all container logs, Policy Agent app log and consul config using prefix: "$1
+
+       docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1
+       docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1
+       docker logs $POLICY_AGENT_APP_NAME > $TESTLOGS/$ATC/$1_policy-agent.log 2>&1
+       docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_control-panel.log 2>&1
+       docker logs $MR_APP_NAME > $TESTLOGS/$ATC/$1_mr.log 2>&1
+       docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
+       cp .httplog_${ATC}.txt $TESTLOGS/$ATC/$1_httplog_${ATC}.txt 2>&1
+
+       docker exec -it $SDNC_APP_NAME cat /opt/opendaylight/data/log/karaf.log > $TESTLOGS/$ATC/$1_karaf.log 2>&1
+
+       rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
+       for ric in $rics; do
+               docker logs $ric > $TESTLOGS/$ATC/$1_$ric.log 2>&1
+       done
+       body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
+       echo "$body" > $TESTLOGS/$ATC/$1_consul_config.json 2>&1
+       echo ""
+}
+
+###############
+## Generic curl
+###############
+# Generic curl function, assumed all 200-codes are ok
+# args: <url>
+# returns: <returned response (without respose code)>  or "<no-response-from-server>" or "<not found, <http-code>>""
+# returns: The return code is 0 for ok and 1 for not ok
+__do_curl() {
+       echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
+       curlString="curl -skw %{http_code} $1"
+       echo " CMD: $curlString" >> $HTTPLOG
+       res=$($curlString)
+       echo " RESP: $res" >> $HTTPLOG
+       http_code="${res:${#res}-3}"
+       if [ ${#res} -eq 3 ]; then
+               echo "<no-response-from-server>"
+               return 1
+       else
+               if [ $http_code -lt 200 ] || [ $http_code -gt 299 ]; then
+                       echo "<not found, resp:${http_code}>"
+                       return 1
+               fi
+               if [ $# -eq 2 ]; then
+                       echo "${res:0:${#res}-3}" | xargs
+               else
+                       echo "${res:0:${#res}-3}"
+               fi
+
+               return 0
+       fi
+}
+
+#######################################
+### Basic helper function for test cases
+#######################################
+
+# Test a simulator container variable value towards target value using an condition operator with an optional timeout.
+# Arg: <simulator-name> <host> <variable-name> <condition-operator> <target-value>  - This test is done
+# immediately and sets pass or fail depending on the result of comparing variable and target using the operator.
+# Arg: <simulator-name> <host> <variable-name> <condition-operator> <target-value> <timeout>  - This test waits up to the timeout
+# before setting pass or fail depending on the result of comparing variable and target using the operator.
+# If the <variable-name> has the 'json:' prefix, the the variable will be used as url and the <target-value> will be compared towards the length of the json array in the response.
+# Not to be called from test script.
+
+__var_test() {
+       checkjsonarraycount=0
+
+       if [ $# -eq 6 ]; then
+               if [[ $3 == "json:"* ]]; then
+                       checkjsonarraycount=1
+               fi
+
+               #echo -e "---- ${1} sim test criteria: \033[1m ${3} \033[0m ${4} ${5} within ${6} seconds ----"
+               echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds"
+               ((RES_TEST++))
+               start=$SECONDS
+               ctr=0
+               for (( ; ; )); do
+                       if [ $checkjsonarraycount -eq 0 ]; then
+                               result="$(__do_curl $2$3)"
+                               retcode=$?
+                               result=${result//[[:blank:]]/} #Strip blanks
+                       else
+                               path=${3:5}
+                               result="$(__do_curl $2$path)"
+                               retcode=$?
+                               echo "$result" > .tmp.curl.json
+                               result=$(python ../common/count_json_elements.py ".tmp.curl.json")
+                       fi
+                       duration=$((SECONDS-start))
+                       echo -ne " Result=${result} after ${duration} seconds\033[0K\r"
+                       let ctr=ctr+1
+                       if [ $retcode -ne 0 ]; then
+                               if [ $duration -gt $6 ]; then
+                                       ((RES_FAIL++))
+                                       #echo -e "----  \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5}  not reached in ${6} seconds, result = ${result} ----"
+                                       echo -e $RED" FAIL${ERED} - ${3} ${4} ${5} not reached in ${6} seconds, result = ${result}"
+                                       return
+                               fi
+                       elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
+                               ((RES_PASS++))
+                               echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+                               echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
+                               #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds ----"
+                               return
+                       elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
+                               ((RES_PASS++))
+                               echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+                               echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
+                               #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result}  ----"
+                               return
+                       elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
+                               ((RES_PASS++))
+                               echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+                               echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
+                               #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result}  ----"
+                               return
+                       elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
+                               ((RES_PASS++))
+                               echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+                               echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
+                               #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result}  ----"
+                               return
+                       else
+                               if [ $duration -gt $6 ]; then
+                                       ((RES_FAIL++))
+                                       echo -e $RED" FAIL${ERED} - ${3} ${4} ${5} not reached in ${6} seconds, result = ${result}"
+                                       #echo -e "----  \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5}  not reached in ${6} seconds, result = ${result} ----"
+                                       return
+                               fi
+                       fi
+                       sleep 1
+               done
+       elif [ $# -eq 5 ]; then
+               if [[ $3 == "json:"* ]]; then
+                       checkjsonarraycount=1
+               fi
+
+               #echo -e "---- ${1} sim test criteria: \033[1m ${3} \033[0m ${4} ${5} ----"
+               echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5}"$EBOLD
+               ((RES_TEST++))
+               if [ $checkjsonarraycount -eq 0 ]; then
+                       result="$(__do_curl $2$3)"
+                       retcode=$?
+                       result=${result//[[:blank:]]/} #Strip blanks
+               else
+                       path=${3:5}
+                       result="$(__do_curl $2$path)"
+                       retcode=$?
+                       echo "$result" > .tmp.curl.json
+                       result=$(python ../common/count_json_elements.py ".tmp.curl.json")
+               fi
+               if [ $retcode -ne 0 ]; then
+                       ((RES_FAIL++))
+                       #echo -e "----  \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5} not reached, result = ${result} ----"
+                       echo -e $RED" FAIL ${ERED}- ${3} ${4} ${5} not reached, result = ${result}"
+               elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
+                       ((RES_PASS++))
+                       echo -e $GREEN" PASS${EGREEN} - Result=${result}"
+                       #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met"
+               elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
+                       ((RES_PASS++))
+                       echo -e $GREEN" PASS${EGREEN} - Result=${result}"
+                       #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met, result = ${result} ----"
+               elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
+                       ((RES_PASS++))
+                       echo -e $GREEN" PASS${EGREEN} - Result=${result}"
+                       #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met, result = ${result} ----"
+               elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
+                       ((RES_PASS++))
+                       echo -e $GREEN" PASS${EGREEN} - Result=${result}"
+                       #echo -e "----  \033[32m\033[1mPASS\033[0m - Test criteria met, result = ${result} ----"
+               else
+                       ((RES_FAIL++))
+                       echo -e $RED" FAIL${ERED} - ${3} ${4} ${5} not reached, result = ${result}"
+                       #echo -e "----  \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5} not reached, result = ${result} ----"
+               fi
+       else
+               echo "Wrong args to __var_test, needs five or six args: <simulator-name> <host> <variable-name> <condition-operator> <target-value> [ <timeout> ]"
+               echo "Got:" $@
+               exit 1
+       fi
+}
+
+
+### Generic test cases for varaible checking
+
+# Tests if a variable value in the CR is equal to a target value and and optional timeout.
+# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
+# equal to the target or not.
+# Arg: <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
+# before setting pass or fail depending on if the variable value becomes equal to the target
+# value or not.
+# (Function for test scripts)
+cr_equal() {
+       if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+               __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
+       else
+               ((RES_CONF_FAIL++))
+               __print_err "Wrong args to cr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
+       fi
+}
+
+# Tests if a variable value in the MR stub is equal to a target value and and optional timeout.
+# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
+# equal to the target or not.
+# Arg: <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
+# before setting pass or fail depending on if the variable value becomes equal to the target
+# value or not.
+# (Function for test scripts)
+mr_equal() {
+       if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+               __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
+       else
+               ((RES_CONF_FAIL++))
+               __print_err "Wrong args to mr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
+       fi
+}
+
+# Tests if a variable value in the MR stub is greater than a target value and and optional timeout.
+# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
+# greater than the target or not.
+# Arg: <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
+# before setting pass or fail depending on if the variable value becomes greater than the target
+# value or not.
+# (Function for test scripts)
+mr_greater() {
+       if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+               __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
+       else
+               ((RES_CONF_FAIL++))
+               __print_err "Wrong args to mr_greater, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
+       fi
+}
+
+# Read a variable value from MR sim and send to stdout. Arg: <variable-name>
+mr_read() {
+       echo "$(__do_curl $LOCALHOST$MR_EXTERNAL_PORT/counter/$1)"
+}
+
+# Print a variable value from the MR stub.
+# arg: <variable-name>
+# (Function for test scripts)
+mr_print() {
+       if [ $# != 1 ]; then
+               ((RES_CONF_FAIL++))
+       __print_err "need one arg, <mr-param>" $@
+               exit 1
+       fi
+       echo -e $BOLD"INFO(${BASH_LINENO[0]}): mrstub, $1 = $(__do_curl $LOCALHOST$MR_EXTERNAL_PORT/counter/$1)"$EBOLD
+}
+
+
diff --git a/test/common/testsuite_common.sh b/test/common/testsuite_common.sh
new file mode 100644 (file)
index 0000000..2c5e6c3
--- /dev/null
@@ -0,0 +1,119 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+
+# Script containing all functions needed for auto testing of test suites
+
+echo "Test suite started as: ${BASH_SOURCE[$i+1]} "$1 $2
+
+
+IMAGE_TAG=""
+
+paramError=1
+if [ $# -gt 0 ]; then
+       if [ $1 == "local" ] || [ $1 == "remote" ] || [ $1 == "remote-remove" ] ; then
+               paramError=0
+       fi
+fi
+if [ $# -eq 2 ]; then
+    if [ $2 == "auto-clean" ]; then
+               paramError=0
+    fi
+fi
+if [ $paramError -ne 0 ]; then
+       echo "Expected arg: local|remote|remote-remove [ auto-clean ]"
+       exit 1
+fi
+
+# Set a description string for the test suite
+if [ -z "$TS_ONELINE_DESCR" ]; then
+       TS_ONELINE_DESCR="<no-description>"
+       echo "No test suite description found, TC_ONELINE_DESCR should be set on in the test script , using "$TS_ONELINE_DESCR
+fi
+
+TSTEST_START=$SECONDS
+
+suite_setup() {
+    ATS=$(basename "${BASH_SOURCE[$i+1]}" .sh)
+
+    echo "#################################################################################################"
+    echo "###################################      Test suite: "$ATS
+    echo "###################################      Started:    "$(date)
+    echo "#################################################################################################"
+    echo "## Description: " $TS_ONELINE_DESCR
+    echo "#################################################################################################"
+    echo ""
+    echo 0 > .tmp_tcsuite_ctr
+    echo 0 > .tmp_tcsuite_pass_ctr
+    echo 0 > .tmp_tcsuite_fail_ctr
+    rm .tmp_tcsuite_pass &> /dev/null
+    touch .tmp_tcsuite_pass
+    rm .tmp_tcsuite_fail &> /dev/null
+    touch .tmp_tcsuite_fail
+}
+
+__print_err() {
+    echo ${FUNCNAME[1]} " "$1" " ${BASH_SOURCE[$i+2]} " line" ${BASH_LINENO[$i+1]}
+}
+
+run_tc() {
+       if [ $# -eq 2 ]; then
+               ./$1 $2 $IMAGE_TAG
+       elif [ $# -eq 3 ]; then
+               ./$1 $2 $3
+       else
+               echo -e "Test case \033[31m\033[1m./"$1 $2 $3 "could not be executed.\033[0m"
+       fi
+}
+
+suite_complete() {
+    TSTEST_END=$SECONDS
+    echo ""
+    echo "#################################################################################################"
+    echo "###################################      Test suite: "$ATS
+    echo "###################################      Ended:      "$(date)
+    echo "#################################################################################################"
+    echo "## Description: " $TS_ONELINE_DESCR
+    echo "## Execution time: " $((TSTEST_END-TSTEST_START)) " seconds"
+    echo "#################################################################################################"
+    echo "###################################      RESULTS"
+    echo ""
+
+    TCSUITE_CTR=$(< .tmp_tcsuite_ctr)
+    TCSUITE_PASS_CTR=$(< .tmp_tcsuite_pass_ctr)
+    TCSUITE_FAIL_CTR=$(< .tmp_tcsuite_fail_ctr)
+
+    total=$((TCSUITE_PASS_CTR+TCSUITE_FAIL_CTR))
+    if [ $TCSUITE_CTR -eq 0 ]; then
+               echo -e "\033[1mNo test cases seem to have executed. Check the script....\033[0m"
+       elif [ $total != $TCSUITE_CTR ]; then
+        echo -e "\033[1mTotal number of test cases does not match the sum of passed and failed test cases. Check the script....\033[0m"
+    fi
+    echo "Number of test cases : " $TCSUITE_CTR
+    echo -e "Number of \033[31m\033[1mFAIL\033[0m:        " $TCSUITE_FAIL_CTR
+    echo -e "Number of \033[32m\033[1mPASS\033[0m:        " $TCSUITE_PASS_CTR
+    echo ""
+    echo "PASS test cases"
+    cat .tmp_tcsuite_pass
+    echo ""
+    echo "FAIL test cases"
+    cat .tmp_tcsuite_fail
+    echo ""
+
+    echo "###################################      Test suite completed      ##############################"
+    echo "#################################################################################################"
+}
\ No newline at end of file
diff --git a/test/cr/.gitignore b/test/cr/.gitignore
new file mode 100644 (file)
index 0000000..4512d6f
--- /dev/null
@@ -0,0 +1 @@
+.tmp.json
\ No newline at end of file
diff --git a/test/cr/Dockerfile b/test/cr/Dockerfile
new file mode 100644 (file)
index 0000000..d2e69cd
--- /dev/null
@@ -0,0 +1,28 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+FROM python:3.8-slim-buster
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt requirements.txt
+
+RUN pip install -r requirements.txt
+
+COPY cr.py cr.py
+
+CMD [ "python3", "-u", "./cr.py" ]
\ No newline at end of file
diff --git a/test/cr/README.md b/test/cr/README.md
new file mode 100644 (file)
index 0000000..74205f4
--- /dev/null
@@ -0,0 +1,44 @@
+## callback receiver - a stub interface to receive callbacks ##
+
+The mrstub is intended for function tests to simulate a message router.
+The mrstub exposes the read and write urls, used by the agent, as configured in consul.
+In addition, request messages can be fed to the mrstub and the response messages can be read by polling.
+
+
+### Control interface ###
+
+The control interface can be used by any test script.
+The following REST operations are available:
+
+>Send a message to MR<br>
+This method puts a request message in the queue for the agent to pick up. The returned correlationId (auto generated by the mrstub) is used when polling for the reposone message of this particular request.<br>
+```URI and parameter, (GET): /get-event/<id>```<br><br>
+```response: message + 200 or 204```
+
+>Receive a message response for MR for the included correlation id<br>
+The method is for polling of messages, returns immediately containing the received response (if any) for the supplied correlationId.<br>
+```URI and payload, (PUT or POST): /callbacks/<id> <json array of response messages>```<br><br>
+```response: OK 200 or 500 for other errors```
+
+>Metrics - counters<br>
+There are a number of counters that can be read to monitor the message processing. Do a http GET on any of the current counters and an integer value will be returned with http response code 200.
+```/counter/received_callbacks``` - The total number of received callbacks<br>
+```/counter/fetched_callbacks``` - The total number of fetched callbacks<br>
+```/counter/current_messages``` - The current number of callback messages waiting to be fetched<br>
+
+
+### Build and start ###
+
+>Build image<br>
+```docker build -t callback-receiver .```
+
+>Start the image<br>
+```docker run -it -p 8090:8090 callback-receiver```
+
+The script ```crstub-build-start.sh``` do the above two steps in one go. This starts the callback-receiver container in stand-alone mode for basic test.<br>If the callback-receiver should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be aligned with the other components, i.e. the host named given in all callback urls).
+```docker run -it -p 8090:8090 --network nonrtric-docker-net --name callback-receiver callback-receiver```
+
+
+### Basic test ###
+
+Basic test is made with the script ```basic_test.sh``` which tests all the available urls with a subset of the possible operations. Use the script ```cr-build-start.sh``` to start the callback-receiver in a container first.
\ No newline at end of file
diff --git a/test/cr/basic_test.sh b/test/cr/basic_test.sh
new file mode 100755 (executable)
index 0000000..8be110a
--- /dev/null
@@ -0,0 +1,110 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# Automated test script for callback receiver container
+
+# callbackreciver port
+export PORT=8090
+
+# source function to do curl and check result
+. ../common/do_curl_function.sh
+
+echo "=== CR hello world ==="
+RESULT="OK"
+do_curl GET / 200
+
+
+echo "=== Get counter - callbacks ==="
+RESULT="0"
+do_curl GET /counter/received_callbacks 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="0"
+do_curl GET /counter/fetched_callbacks 200
+
+echo "=== Get counter - current events ==="
+RESULT="0"
+do_curl GET /counter/current_messages 200
+
+
+echo "=== Send a request ==="
+RESULT="*"
+#create payload
+echo "\"DATA-MSG\"" > .tmp.json
+do_curl POST '/callbacks/test' 200 .tmp.json
+
+
+echo "=== Fetch an event, wrong id==="
+RESULT="*"
+do_curl GET '/get-event/wrongid' 204
+
+
+echo "=== Get counter - callbacks ==="
+RESULT="1"
+do_curl GET /counter/received_callbacks 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="0"
+do_curl GET /counter/fetched_callbacks 200
+
+echo "=== Get counter - current events ==="
+RESULT="1"
+do_curl GET /counter/current_messages 200
+
+
+echo "=== Fetch an event ==="
+RESULT="DATA-MSG"
+do_curl GET '/get-event/test' 200
+
+echo "=== Fetch an event again ==="
+RESULT="*"
+do_curl GET '/get-event/test' 204
+
+echo "=== Get counter - callbacks ==="
+RESULT="1"
+do_curl GET /counter/received_callbacks 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="1"
+do_curl GET /counter/fetched_callbacks 200
+
+echo "=== Get counter - current events ==="
+RESULT="0"
+do_curl GET /counter/current_messages 200
+
+echo "=== CR reset ==="
+RESULT="OK"
+do_curl GET /reset 200
+
+echo "=== Get counter - callbacks ==="
+RESULT="0"
+do_curl GET /counter/received_callbacks 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="0"
+do_curl GET /counter/fetched_callbacks 200
+
+echo "=== Get counter - current events ==="
+RESULT="0"
+do_curl GET /counter/current_messages 200
+
+
+echo "********************"
+echo "*** All tests ok ***"
+echo "********************"
diff --git a/test/cr/cr-build-start.sh b/test/cr/cr-build-start.sh
new file mode 100755 (executable)
index 0000000..1954eb7
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+#Builds the callback receiver container and starts it in interactive mode
+
+docker build -t callback-receiver .
+
+docker run -it -p 8090:8090 callback-receiver
diff --git a/test/cr/cr.py b/test/cr/cr.py
new file mode 100644 (file)
index 0000000..28e3b10
--- /dev/null
@@ -0,0 +1,158 @@
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+from flask import Flask, request
+from time import sleep
+import time
+import datetime
+import json
+from flask import Flask
+from flask import Response
+import traceback
+
+app = Flask(__name__)
+
+# list of callback messages
+msg_callbacks={}
+
+# Server info
+HOST_IP = "0.0.0.0"
+HOST_PORT = 8090
+
+# Metrics vars
+cntr_msg_callbacks=0
+cntr_msg_fetched=0
+
+# Request and response constants
+CALLBACK_URL="/callbacks/<string:id>"
+APP_READ_URL="/get-event/<string:id>"
+
+MIME_TEXT="text/plain"
+MIME_JSON="application/json"
+CAUGHT_EXCEPTION="Caught exception: "
+SERVER_ERROR="Server error :"
+
+#I'm alive function
+@app.route('/',
+    methods=['GET'])
+def index():
+    return 'OK', 200
+
+### Callback interface, for control
+
+# Fetch the oldest callback message for an id
+# URI and parameter, (GET): /get-event/<id>
+# response: message + 200 or 204
+@app.route(APP_READ_URL,
+    methods=['GET'])
+def receiveresponse(id):
+    global msg_callbacks
+    global cntr_msg_fetched
+
+    try:
+        if ((id in msg_callbacks.keys()) and (len(msg_callbacks[id]) > 0)):
+            cntr_msg_fetched+=1
+            msg=str(msg_callbacks[id][0])
+            print("Fetching msg for id: "+id+", msg="+msg)
+            del msg_callbacks[id][0]
+            return msg,200
+        print("No messages for id: "+id)
+    except Exception as e:
+        print(CAUGHT_EXCEPTION+str(e))
+
+    return "",204
+
+
+# Receive a callback message
+# URI and payload, (PUT or POST): /callbacks/<id> <json array of response messages>
+# response: OK 200 or 500 for other errors
+@app.route(CALLBACK_URL,
+    methods=['PUT','POST'])
+def events_write(id):
+    global msg_callbacks
+    global cntr_msg_callbacks
+
+    try:
+        print("Received callback for id: "+id +", content-type="+request.content_type)
+        try:
+            print("data:"+request.get_data)
+            if (request.content_type == MIME_JSON):
+                msg = request.json
+                print("Payload(json): "+str(msg))
+            elif (request.content_type == MIME_TEXT):
+                msg= request.form
+                print("Payload(text): "+str(msg))
+            else:
+                msg="\"\""
+                print("Payload(content-type="+request.content_type+"). Setting data to empty, quoted, string")
+        except:
+            msg="\"\""
+            print("Payload does not contain any json or text data, setting empty string as payload")
+
+        cntr_msg_callbacks += 1
+        if (id in msg_callbacks.keys()):
+            msg_callbacks[id].append(msg)
+        else:
+            msg_callbacks[id]=[]
+            msg_callbacks[id].append(msg)
+    except Exception as e:
+        print(CAUGHT_EXCEPTION+str(e))
+        return 'OK',500
+
+    return 'OK',200
+
+
+### Functions for metrics read out ###
+
+@app.route('/counter/received_callbacks',
+    methods=['GET'])
+def requests_submitted():
+    return Response(str(cntr_msg_callbacks), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/fetched_callbacks',
+    methods=['GET'])
+def requests_fetched():
+    return Response(str(cntr_msg_fetched), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/current_messages',
+    methods=['GET'])
+def current_messages():
+    return Response(str(cntr_msg_callbacks-cntr_msg_fetched), status=200, mimetype=MIME_TEXT)
+
+
+
+### Admin ###
+
+# Reset all messsages and counters
+@app.route('/reset',
+    methods=['GET', 'POST', 'PUT'])
+def reset():
+    global msg_callbacks
+    global cntr_msg_fetched
+    global cntr_msg_callbacks
+
+    msg_callbacks={}
+    cntr_msg_fetched=0
+    cntr_msg_callbacks=0
+
+    return Response('OK', status=200, mimetype=MIME_TEXT)
+
+### Main function ###
+
+if __name__ == "__main__":
+    app.run(port=HOST_PORT, host=HOST_IP)
diff --git a/test/cr/requirements.txt b/test/cr/requirements.txt
new file mode 100644 (file)
index 0000000..1dabaa8
--- /dev/null
@@ -0,0 +1,3 @@
+Flask==1.1.1
+
+
diff --git a/test/mrstub/.gitignore b/test/mrstub/.gitignore
new file mode 100644 (file)
index 0000000..4512d6f
--- /dev/null
@@ -0,0 +1 @@
+.tmp.json
\ No newline at end of file
diff --git a/test/mrstub/Dockerfile b/test/mrstub/Dockerfile
new file mode 100644 (file)
index 0000000..f1d16b7
--- /dev/null
@@ -0,0 +1,28 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+FROM python:3.7
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt requirements.txt
+
+RUN pip install -r requirements.txt
+
+COPY mr.py mr.py
+
+CMD [ "python3", "-u", "./mr.py" ]
\ No newline at end of file
diff --git a/test/mrstub/README.md b/test/mrstub/README.md
new file mode 100644 (file)
index 0000000..6a69930
--- /dev/null
@@ -0,0 +1,47 @@
+## mrstub - stub interface to interact with the policy agent over Dmaap ##
+
+The mrstub is intended for function tests to simulate a message router.
+The mrstub exposes the read and write urls, used by the agent, as configured in consul.
+In addition, request messages can be fed to the mrstub and the response messages can be read by polling.
+
+
+### Control interface ###
+
+The control interface can be used by any test script.
+The following REST operations are available:
+
+>Send a message to MR<br>
+This method puts a request message in the queue for the agent to pick up. The returned correlationId (auto generated by the mrstub) is used when polling for the reposone message of this particular request.<br>
+```URI and parameters (GET): /send-request?operation=<GET|PUT|POST|DELETE>&url=<url>```<br><br>
+```response: <correlation-id> (http 200) or 400 for parameter error or 500 for other errors```
+
+>Receive a message response for MR for the included correlation id<br>
+The method is for polling of messages, returns immediately containing the received response (if any) for the supplied correlationId.<br>
+```URI and parameter, (GET): /receive-response?correlationId=<correlationid>```<br><br>
+```response: <json-array of 1 response> 200 or empty 204 or other errors 500```
+
+>Metrics - counters<br>
+There are a number of counters that can be read to monitor the message processing. Do a http GET on any of the current counters and an integer value will be returned with http response code 200.
+```/counter/requests_submitted``` - The total number of requests sent from the application<br>
+```/counter/requests_fetched``` - The total number of requests picked up by the agent<br>
+```/counter/responses_submitted``` - The total number of responses written by the agent<br>
+```/counter/responses_fetched``` - The total number of responses picked up by the application<br>
+```/counter/current_requests``` - The current number of requests waiting to be picked up by the agent<br>
+```/counter/current_responses``` - The current number of responses waiting to be picked up by the application<br>
+
+
+### Build and start ###
+
+>Build image<br>
+```docker build -t mrstub .```
+
+>Start the image<br>
+```docker run -it -p 3905:3905 mrstub```
+
+The script ```mrstub-build-start.sh``` do the above two steps in one go. This starts the stub container in stand-alone mode for basic test.<br>If the mrstub should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be the same as configured in consul for the read and write streams).
+```docker run -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub```
+
+
+### Basic test ###
+
+Basic test is made with the script ```basic_test.sh``` which tests all the available urls with a subset of the possible operations. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first.
\ No newline at end of file
diff --git a/test/mrstub/basic_test.sh b/test/mrstub/basic_test.sh
new file mode 100755 (executable)
index 0000000..13ea3a6
--- /dev/null
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# Automated test script for mrstub container
+
+# mr-stub port
+export PORT=3905
+
+# source function to do curl and check result
+. ../common/do_curl_function.sh
+
+echo "=== Stub hello world ==="
+RESULT="OK"
+do_curl GET / 200
+
+echo "=== Stub reset ==="
+RESULT="OK"
+do_curl GET /reset 200
+
+## Test with json response
+
+echo "=== Send a request ==="
+RESULT="*"
+#create payload
+echo "{\"data\": \"data-value\"}" > .tmp.json
+
+do_curl POST '/send-request?operation=PUT&url=/test' 200 .tmp.json
+#Save id for later
+CORRID=$body
+
+echo "=== Fetch a response, shall be empty ==="
+RESULT=""
+do_curl GET '/receive-response?correlationid='$CORRID 204
+
+echo "=== Fetch a request ==="
+RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"PUT\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{\"data\": \"data-value\"},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test\"}]"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200
+
+echo "=== Send a json response ==="
+# Create minimal accepted response message
+echo "[{\"correlationId\": \""$CORRID"\", \"message\": {\"test\":\"testresponse\"}, \"status\": \"200\"}]" > .tmp.json
+RESULT="OK"
+do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json
+
+echo "=== Fetch a response ==="
+RESULT="{\"test\": \"testresponse\"}200"
+do_curl GET '/receive-response?correlationid='$CORRID 200
+
+### Test with plain text response
+
+echo "=== Send a request ==="
+RESULT="*"
+do_curl POST '/send-request?operation=GET&url=/test2' 200
+#Save id for later
+CORRID=$body
+
+echo "=== Fetch a response, shall be empty ==="
+RESULT=""
+do_curl GET '/receive-response?correlationid='$CORRID 204
+
+echo "=== Fetch a request ==="
+RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"GET\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test2\"}]"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200
+
+echo "=== Send a json response ==="
+# Create minimal accepted response message
+echo "[{\"correlationId\": \""$CORRID"\", \"message\": \"test2-response\", \"status\": \"200\"}]" > .tmp.json
+RESULT="OK"
+do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json
+
+echo "=== Fetch a response ==="
+RESULT="test2-response200"
+do_curl GET '/receive-response?correlationid='$CORRID 200
+
+echo "********************"
+echo "*** All tests ok ***"
+echo "********************"
diff --git a/test/mrstub/mr.py b/test/mrstub/mr.py
new file mode 100644 (file)
index 0000000..45f8cfe
--- /dev/null
@@ -0,0 +1,265 @@
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+from flask import Flask, request
+from time import sleep
+import time
+import datetime
+import json
+from flask import Flask
+from flask import Response
+import traceback
+
+app = Flask(__name__)
+
+# list of messages to/from Dmaap
+msg_requests={}
+msg_responses={}
+
+# Server info
+HOST_IP = "0.0.0.0"
+HOST_PORT = 3905
+
+# Metrics vars
+cntr_msg_requests_submitted=0
+cntr_msg_requests_fetched=0
+cntr_msg_responses_submitted=0
+cntr_msg_responses_fetched=0
+
+# Request and response constants
+AGENT_WRITE_URL="/events/A1-POLICY-AGENT-WRITE"
+AGENT_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent"
+APP_WRITE_URL="/send-request"
+APP_READ_URL="/receive-response"
+MIME_TEXT="text/plain"
+MIME_JSON="application/json"
+CAUGHT_EXCEPTION="Caught exception: "
+SERVER_ERROR="Server error :"
+
+#I'm alive function
+@app.route('/',
+    methods=['GET'])
+def index():
+    return 'OK', 200
+
+
+# Helper function to create a Dmaap request message
+# args : <GET|PUT|DELETE> <correlation-id> <json-string-payload - may be None> <url>
+# response: json formatted string of a complete Dmaap message
+def create_message(operation, correlation_id, payload, url):
+    if (payload is None):
+        payload="{}"
+    time_stamp=datetime.datetime.utcnow()
+    msg = '{\"apiVersion\":\"1.0\",\"operation\":\"'+operation+'\",\"correlationId\":\"'+correlation_id+'\",\"originatorId\": \"849e6c6b420\",'
+    msg = msg + '\"payload\":'+payload+',\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"'+str(time_stamp)+'\", \"type\":\"request\",\"url\":\"'+url+'\"}'
+    return msg
+
+
+### MR-stub interface, for MR control
+
+# Send a message to MR
+# URI and parameters (GET): /send-request?operation=<GET|PUT|POST|DELETE>&url=<url>
+# response: <correlation-id> (http 200) o4 400 for parameter error or 500 for other errors
+@app.route(APP_WRITE_URL,
+    methods=['PUT','POST'])
+def sendrequest():
+    global msg_requests
+    global cntr_msg_requests_submitted
+
+    try:
+
+        oper=request.args.get('operation')
+        if (oper is None):
+            print(APP_WRITE_URL+" parameter 'operation' missing")
+            return Response('Parameter operation missing in request', status=400, mimetype=MIME_TEXT)
+
+        url=request.args.get('url')
+        if (url is None):
+            print(APP_WRITE_URL+" parameter 'url' missing")
+            return Response('Parameter url missing in request', status=400, mimetype=MIME_TEXT)
+
+        if (oper != "GET" and oper != "PUT" and oper != "POST" and oper != "DELETE"):
+            print(APP_WRITE_URL+" parameter 'operation' need to be: DEL|PUT|POST|DELETE")
+            return Response('Parameter operation does not contain DEL|PUT|POST|DELETE in request', status=400, mimetype=MIME_TEXT)
+
+        print(APP_WRITE_URL+" operation="+oper+" url="+url)
+        correlation_id=str(time.time_ns())
+        payload=None
+        if (oper == "PUT") and (request.json is not None):
+            payload=json.dumps(request.json)
+
+        msg=create_message(oper, correlation_id, payload, url)
+        print(msg)
+        print(APP_WRITE_URL+" MSG(correlationid = "+correlation_id+"): " + json.dumps(json.loads(msg), indent=2))
+        msg_requests[correlation_id]=msg
+        cntr_msg_requests_submitted += 1
+        return Response(correlation_id, status=200, mimetype=MIME_TEXT)
+    except Exception as e:
+        print(APP_WRITE_URL+"-"+CAUGHT_EXCEPTION+" "+str(e) + " "+traceback.format_exc())
+        return Response(SERVER_ERROR+" "+str(e), status=500, mimetype=MIME_TEXT)
+
+# Receive a message response for MR for the included correlation id
+# URI and parameter, (GET): /receive-response?correlationid=<correlation-id>
+# response: <json-array of 1 response> 200 or empty 204 or other errors 500
+@app.route(APP_READ_URL,
+    methods=['GET'])
+def receiveresponse():
+    global msg_responses
+    global cntr_msg_responses_fetched
+
+    try:
+        id=request.args.get('correlationid')
+        if (id is None):
+            print(APP_READ_URL+" parameter 'correclationid' missing")
+            return Response('Parameter correlationid missing in json', status=500, mimetype=MIME_TEXT)
+
+        if (id in msg_responses):
+            answer=msg_responses[id]
+            del msg_responses[id]
+            print(APP_READ_URL+" response (correlationid="+id+"): " + answer)
+            cntr_msg_responses_fetched += 1
+            return Response(answer, status=200, mimetype=MIME_JSON)
+
+        print(APP_READ_URL+" - no messages (correlationid="+id+"): ")
+        return Response('', status=204, mimetype=MIME_JSON)
+    except Exception as e:
+        print(APP_READ_URL+"-"+CAUGHT_EXCEPTION+" "+str(e) + " "+traceback.format_exc())
+        return Response(SERVER_ERROR+" "+str(e), status=500, mimetype=MIME_TEXT)
+
+### Dmaap interface ###
+
+# Read messages stream. URI according to agent configuration.
+# URI, (GET): /events/A1-POLICY-AGENT-READ/users/policy-agent
+# response: 200 <json array of request messages>, or 500 for other errors
+@app.route(AGENT_READ_URL,
+    methods=['GET'])
+def events_read():
+    global msg_requests
+    global cntr_msg_requests_fetched
+    try:
+        msgs=''
+        for item in msg_requests:
+            if (len(msgs)>1):
+                msgs=msgs+','
+            msgs=msgs+msg_requests[item]
+            cntr_msg_requests_fetched += 1
+
+        msg_requests={}
+        msgs='['+msgs+']'
+        print(AGENT_READ_URL+" MSGs: "+json.dumps(json.loads(msgs), indent=2))
+        return Response(msgs, status=200, mimetype=MIME_JSON)
+    except Exception as e:
+        print(AGENT_READ_URL+"-"+CAUGHT_EXCEPTION+" "+str(e) + " "+traceback.format_exc())
+        return Response(SERVER_ERROR+" "+str(e), status=500, mimetype=MIME_TEXT)
+
+# Write messages stream. URI according to agent configuration.
+# URI and payload, (PUT or POST): /events/A1-POLICY-AGENT-WRITE <json array of response messages>
+# response: OK 200 or 400 for missing json parameters, 500 for other errors
+@app.route(AGENT_WRITE_URL,
+    methods=['PUT','POST'])
+def events_write():
+    global msg_responses
+    global cntr_msg_responses_submitted
+
+    try:
+        answer=request.json
+        print(AGENT_WRITE_URL+ " json=" + json.dumps(answer, indent=2))
+        for item in answer:
+            id=item['correlationId']
+            if (id is None):
+                print(AGENT_WRITE_URL+" parameter 'correlatonid' missing")
+                return Response('Parameter <correlationid> missing in json', status=400, mimetype=MIME_TEXT)
+            msg=item['message']
+            if (msg is None):
+                print(AGENT_WRITE_URL+" parameter 'msgs' missing")
+                return Response('Parameter >message> missing in json', status=400, mimetype=MIME_TEXT)
+            status=item['status']
+            if (status is None):
+                print(AGENT_WRITE_URL+" parameter 'status' missing")
+                return Response('Parameter <status> missing in json', status=400, mimetype=MIME_TEXT)
+            if isinstance(msg, list) or isinstance(msg, dict):
+                msg_str=json.dumps(msg)+status[0:3]
+            else:
+                msg_str=msg+status[0:3]
+            msg_responses[id]=msg_str
+            cntr_msg_responses_submitted += 1
+            print(AGENT_WRITE_URL+ " msg+status (correlationid="+id+") :" + str(msg_str))
+    except Exception as e:
+        print(AGENT_WRITE_URL+"-"+CAUGHT_EXCEPTION+" "+str(e) + " "+traceback.format_exc())
+        return Response(SERVER_ERROR+" "+str(e), status=500, mimetype=MIME_TEXT)
+
+    return Response('OK', status=200, mimetype=MIME_TEXT)
+
+
+### Functions for metrics read out ###
+
+@app.route('/counter/requests_submitted',
+    methods=['GET'])
+def requests_submitted():
+    return Response(str(cntr_msg_requests_submitted), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/requests_fetched',
+    methods=['GET'])
+def requests_fetched():
+    return Response(str(cntr_msg_requests_fetched), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/responses_submitted',
+    methods=['GET'])
+def responses_submitted():
+    return Response(str(cntr_msg_responses_submitted), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/responses_fetched',
+    methods=['GET'])
+def responses_fetched():
+    return Response(str(cntr_msg_responses_fetched), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/current_requests',
+    methods=['GET'])
+def current_requests():
+    return Response(str(len(msg_requests)), status=200, mimetype=MIME_TEXT)
+
+@app.route('/counter/current_responses',
+    methods=['GET'])
+def current_responses():
+    return Response(str(len(msg_responses)), status=200, mimetype=MIME_TEXT)
+
+### Admin ###
+
+# Reset all messsages and counters
+@app.route('/reset',
+    methods=['GET', 'POST', 'PUT'])
+def reset():
+    global cntr_msg_requests_submitted
+    global cntr_msg_requests_fetched
+    global cntr_msg_responses_submitted
+    global cntr_msg_responses_fetched
+    global msg_requests
+    global msg_responses
+
+    cntr_msg_requests_submitted=0
+    cntr_msg_requests_fetched=0
+    cntr_msg_responses_submitted=0
+    cntr_msg_responses_fetched=0
+    msg_requests={}
+    msg_responses={}
+    return Response('OK', status=200, mimetype=MIME_TEXT)
+
+### Main function ###
+
+if __name__ == "__main__":
+    app.run(port=HOST_PORT, host=HOST_IP)
diff --git a/test/mrstub/mrstub-build-start.sh b/test/mrstub/mrstub-build-start.sh
new file mode 100755 (executable)
index 0000000..1a463dc
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+#Builds the mrstub container and starts it in interactive mode
+
+docker build -t mrstub .
+
+docker run -it -p 3905:3905 mrstub
diff --git a/test/mrstub/requirements.txt b/test/mrstub/requirements.txt
new file mode 100644 (file)
index 0000000..1dabaa8
--- /dev/null
@@ -0,0 +1,3 @@
+Flask==1.1.1
+
+
diff --git a/test/simulator-group/.gitignore b/test/simulator-group/.gitignore
new file mode 100644 (file)
index 0000000..25c8fdb
--- /dev/null
@@ -0,0 +1,2 @@
+node_modules
+package-lock.json
\ No newline at end of file
diff --git a/test/simulator-group/consul_cbs/consul/cbs_config.hcl b/test/simulator-group/consul_cbs/consul/cbs_config.hcl
new file mode 100644 (file)
index 0000000..004fb1d
--- /dev/null
@@ -0,0 +1,30 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+#server = true
+#bootstrap = true
+#client_addr = "0.0.0.0"
+
+service  {
+  # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
+  # should be passed to Policy Agent app with this value
+  Name = "config-binding-service"
+  # Host name where CBS is running
+  Address = "config-binding-service"
+  # Port number where CBS is running
+  Port = 10000
+}
\ No newline at end of file
diff --git a/test/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl b/test/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl
new file mode 100644 (file)
index 0000000..ff0bd31
--- /dev/null
@@ -0,0 +1,28 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+service {
+  # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
+  # should be passed to Policy Agent app with this value
+  # This is only to be used when contacting cbs via local host
+  # (typicall when Policy Agent is executed as an application without a container)
+  Name = "config-binding-service-localhost"
+  # Host name where CBS is running
+  Address = "localhost"
+  # Port number where CBS is running
+  Port = 10000
+}
\ No newline at end of file
diff --git a/test/simulator-group/consul_cbs/docker-compose.yml b/test/simulator-group/consul_cbs/docker-compose.yml
new file mode 100644 (file)
index 0000000..15d3de1
--- /dev/null
@@ -0,0 +1,48 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+version: '3'
+
+networks:
+  default:
+    external:
+      name: ${DOCKER_SIM_NWNAME}
+
+services:
+
+  consul-server:
+    networks:
+      - default
+    container_name: ${CONSUL_APP_NAME}
+    image: ${CONSUL_IMAGE}
+    ports:
+      - ${CONSUL_EXTERNAL_PORT}:${CONSUL_INTERNAL_PORT}
+    volumes:
+      - ./consul/:/consul/config
+
+  config-binding-service:
+    networks:
+      - default
+    container_name: ${CBS_APP_NAME}
+    image: ${CBS_IMAGE}
+    ports:
+      - ${CBS_EXTERNAL_PORT}:${CBS_INTERNAL_PORT}
+    environment:
+      - CONSUL_HOST=${CONSUL_HOST}
+    depends_on:
+      - ${CONSUL_HOST}
+
diff --git a/test/simulator-group/consul_cbs/start.sh b/test/simulator-group/consul_cbs/start.sh
new file mode 100755 (executable)
index 0000000..b0399f2
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+DOCKER_SIM_NWNAME="nonrtric-docker-net"
+echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
+docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
+
+docker-compose -f docker-compose-template.yml config > docker-compose.yml
+
+docker-compose up -d
+
+CONSUL_PORT=8500
+
+APP="policy-agent"
+JSON_FILE="config.json"
+
+curl -s -v  http://127.0.0.1:${CONSUL_PORT}/v1/kv/${APP}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$JSON_FILE
\ No newline at end of file
diff --git a/test/simulator-group/control_panel/docker-compose.yml b/test/simulator-group/control_panel/docker-compose.yml
new file mode 100644 (file)
index 0000000..4e86f3c
--- /dev/null
@@ -0,0 +1,32 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+version: '3.0'
+networks:
+  default:
+    external:
+      name: nonrtric-docker-net
+services:
+  control-panel:
+    image: ${CONTROL_PANEL_IMAGE}
+    container_name: ${CONTROL_PANEL_APP_NAME}
+    networks:
+      - default
+    ports:
+    - ${CONTROL_PANEL_EXTERNAL_PORT}:${CONTROL_PANEL_INTERNAL_PORT}
+
+
+
diff --git a/test/simulator-group/cr/docker-compose.yml b/test/simulator-group/cr/docker-compose.yml
new file mode 100644 (file)
index 0000000..77a958f
--- /dev/null
@@ -0,0 +1,30 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+version: '3.0'
+networks:
+  default:
+    external:
+      name: ${DOCKER_SIM_NWNAME}
+services:
+  callback-receiver:
+    networks:
+      - default
+    container_name: ${CR_APP_NAME}
+    image: ${CR_IMAGE}
+    ports:
+      - ${CR_EXTERNAL_PORT}:${CR_INTERNAL_PORT}
diff --git a/test/simulator-group/mr/docker-compose.yml b/test/simulator-group/mr/docker-compose.yml
new file mode 100644 (file)
index 0000000..887b216
--- /dev/null
@@ -0,0 +1,30 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+version: '3.0'
+networks:
+  default:
+    external:
+      name: ${DOCKER_SIM_NWNAME}
+services:
+  message-router:
+    networks:
+      - default
+    container_name: ${MR_APP_NAME}
+    image: ${MRSTUB_IMAGE}
+    ports:
+      - ${MR_EXTERNAL_PORT}:${MR_INTERNAL_PORT}
diff --git a/test/simulator-group/policy_agent/docker-compose.yml b/test/simulator-group/policy_agent/docker-compose.yml
new file mode 100644 (file)
index 0000000..f349249
--- /dev/null
@@ -0,0 +1,35 @@
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+version: '3.0'
+networks:
+  default:
+    external:
+      name: ${DOCKER_SIM_NWNAME}
+services:
+  policy-agent:
+    image: ${POLICY_AGENT_IMAGE}
+    container_name: ${POLICY_AGENT_APP_NAME}
+    networks:
+      - default
+    ports:
+    - ${POLICY_AGENT_EXTERNAL_PORT}:${POLICY_AGENT_INTERNAL_PORT}
+    environment:
+      - CONSUL_HOST=${CONSUL_HOST}
+      - CONSUL_PORT=${CONSUL_INTERNAL_PORT}
+      - CONFIG_BINDING_SERVICE=${CONFIG_BINDING_SERVICE}
+      - HOSTNAME=${POLICY_AGENT_APP_NAME}
+
+
diff --git a/test/simulator-group/ric/.gitignore b/test/simulator-group/ric/.gitignore
new file mode 100644 (file)
index 0000000..2eea525
--- /dev/null
@@ -0,0 +1 @@
+.env
\ No newline at end of file
diff --git a/test/simulator-group/ric/cleanConsul.py b/test/simulator-group/ric/cleanConsul.py
new file mode 100644 (file)
index 0000000..fcf3034
--- /dev/null
@@ -0,0 +1,41 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+import json
+import subprocess
+import os
+
+print(" Clean old ric configurations in Consul config file")
+
+p = os.path.abspath('..')
+consul_config = p + '/consul_cbs' + '/config.json'
+
+
+def write_json(data, filename=consul_config):
+    with open(filename, 'w') as f:
+        json.dump(data, f, indent=4)
+
+
+with open(consul_config) as json_file:
+    clean = json.load(json_file)
+    clean['ric'] = []
+
+
+write_json(clean)
+print(" Clean old ric configurations from Consul config file, done")
+
+
diff --git a/test/simulator-group/ric/docker-compose.yml b/test/simulator-group/ric/docker-compose.yml
new file mode 100644 (file)
index 0000000..17ef5aa
--- /dev/null
@@ -0,0 +1,50 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+version: '3.0'
+
+# Compose file to bring up 3 groups of ric simulator containers with variable interface and count
+
+networks:
+  default:
+    external:
+      name: ${DOCKER_SIM_NWNAME}
+services:
+  g1:
+    image: ${RIC_SIM_IMAGE}
+    networks:
+      - default
+    ports:
+      - ${RIC_SIM_INTERNAL_PORT}/tcp
+    environment:
+      - A1_VERSION=${G1_A1_VERSION}
+  g2:
+    image: ${RIC_SIM_IMAGE}
+    networks:
+      - default
+    ports:
+      - ${RIC_SIM_INTERNAL_PORT}/tcp
+    environment:
+      - A1_VERSION=${G2_A1_VERSION}
+  g3:
+    image: ${RIC_SIM_IMAGE}
+    networks:
+      - default
+    ports:
+      - ${RIC_SIM_INTERNAL_PORT}/tcp
+    environment:
+      - A1_VERSION=${G3_A1_VERSION}
\ No newline at end of file
diff --git a/test/simulator-group/ric/prepareConsul.py b/test/simulator-group/ric/prepareConsul.py
new file mode 100644 (file)
index 0000000..fcb01e9
--- /dev/null
@@ -0,0 +1,60 @@
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+import json
+import subprocess
+import os
+
+print(" Update fresh ric configuration in Consul configuration file")
+
+p = os.path.abspath('..')
+consul_config = p + '/consul_cbs' + '/config.json'
+
+
+def write_json(data, filename=consul_config):
+    with open(filename, 'w') as f:
+        json.dump(data, f, indent=4)
+
+
+def bash_command(cmd):
+    result = []
+    sp = subprocess.Popen(['/bin/bash', '-c', cmd], stdout=subprocess.PIPE)
+    for line in sp.stdout.readlines():
+        result.append(line.decode().strip())
+    return result
+
+
+command = "docker ps | grep simulator | awk '{print $NF}'"
+
+ric_list = bash_command(command)
+
+with open(consul_config) as json_file:
+    data = json.load(json_file)
+    temp = data['ric']
+    for ric in ric_list:
+        y = {"name": ric,
+             "baseUrl": "http://" + ric + ":8085/",
+             "managedElementIds": [
+                 "kista_" + ric,
+                 "stockholm_" + ric
+             ]
+             }
+        temp.append(y)
+
+
+write_json(data)
+print(" Update Consul config file with fresh ric configuration,  done")
@@ -18,12 +18,12 @@ version: '2.1'
 networks:
   default:
     driver: bridge
-    name: nonrtric-docker-net
+    name: ${DOCKER_SIM_NWNAME}
 
 services:
   db:
-    image: mysql/mysql-server:5.6
-    container_name: sdnc_db_container
+    image: ${SDNC_DB_IMAGE}
+    container_name: ${SDNC_DB_APP_NAME}
     networks:
       - default
     ports:
@@ -38,15 +38,15 @@ services:
         max-file: "5"
 
   a1-controller:
-    image: nexus3.o-ran-sc.org:10002/o-ran-sc/nonrtric-a1-controller:1.7.4
+    image: ${SDNC_A1_CONTROLLER_IMAGE}
     depends_on :
       - db
-    container_name: a1-controller-container
+    container_name: ${SDNC_APP_NAME}
     networks:
       - default
     entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"]
     ports:
-      - "8282:8181"
+      - ${SDNC_EXTERNAL_PORT}:${SDNC_INTERNAL_PORT}
     links:
       - db:dbhost
       - db:sdnctldb01
diff --git a/test/simulator-group/sim-monitor-start.sh b/test/simulator-group/sim-monitor-start.sh
new file mode 100755 (executable)
index 0000000..14316ca
--- /dev/null
@@ -0,0 +1,25 @@
+#/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+#Script to install dependencies and start the sim-monitor
+
+npm install express
+npm install json
+node sim-monitor
+
diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js
new file mode 100644 (file)
index 0000000..da71a9e
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+*/
+
+// Sim mon server - query the agent and the simulators for counters and other data
+// Presents a web page on localhost:9999/mon
+
+var LOCALHOST="http://127.0.0.1:"
+var MRSTUB_PORT="3905"
+var AGENT_PORT="8081"
+var CR_PORT="8090"
+var http = require('http');
+
+var express = require('express');
+var app = express();
+var fieldSize=32;
+
+
+
+//I am alive
+app.get("/",function(req, res){
+       res.send("ok");
+})
+
+//Get parameter valuue from other server
+function getSimCtr(url, index, cb) {
+    var data = '';
+       http.get(url, (resp) => {
+               // A chunk of data has been recieved.
+               resp.on('data', (chunk) => {
+               data += chunk;
+               });
+
+               // The whole response has been received.
+               resp.on('end', () => {
+            var code=resp.statusCode
+            if (code > 199 && code < 300) {
+                cb(data, index);
+            } else {
+                cb("not found", index);
+            }
+               });
+
+       }).on("error", (err) => {
+               console.log("Error: " + err.message);
+               cb("no response", index);
+       });
+};
+
+
+//Format a comma separated list of data to a html-safe string with fixed fieldsizes
+function formatDataRow(commaList) {
+       var str = "";
+       var tmp=commaList.split(',');
+    for(var i=0;i<tmp.length;i++) {
+        var data=tmp[i];
+        var len = fieldSize-data.length;
+        while(len>0) {
+            data = data+"&nbsp;";
+            len--;
+        }
+        str=str+data+"&nbsp;&nbsp;&nbsp;";
+     }
+       return str;
+}
+
+//Format a comma separated list of ids to a html-safe string with fixed fieldsizes
+function formatIdRow(commaList) {
+       var str = "";
+       var tmp=commaList.split(',');
+    for(var i=0;i<tmp.length;i++) {
+       tmp[i] = tmp[i].trim();
+        var data="&lt"+tmp[i]+"&gt";
+        var len = fieldSize+4-data.length;
+        while(len>0) {
+            data = data+"&nbsp;";
+            len--;
+        }
+        str=str+data+"&nbsp;&nbsp;&nbsp;";
+    }
+       return str;
+}
+
+//Format a list of ids to a html-safe string in compact format
+function formatIdRowCompact(commaList) {
+    if (commaList == undefined) {
+        commaList= "";
+    }
+       var str = "";
+       var tmp=commaList.split(',');
+    for(var i=0;i<tmp.length;i++) {
+       tmp[i] = tmp[i].trim();
+        var data="&lt"+tmp[i]+"&gt";
+        str=str+data+"&nbsp;";
+    }
+       return str;
+}
+
+//Pad a string upto a certain size using a pad string
+function padding(val, fieldSize, pad) {
+       var s=""+val;
+       for(var i=s.length;i<fieldSize;i++) {
+               s=s+pad
+       }
+       return s;
+}
+
+//Status variables, for parameters values fetched from other simulators
+var mr1="", mr2="", mr3="", mr4="", mr5="", mr6="";
+
+//Status variables for agent
+var ag1=""
+var ag2=""
+var ag3=""
+var ag4=""
+
+//Status variables for callback receiver
+var cr1=""
+var cr2=""
+var cr3=""
+
+
+//Container names and ports of the ric simulator
+var simnames=[]
+var simports=[]
+
+//Status variables for each ric simulator
+var simvar1=[]
+var simvar2=[]
+var simvar3=[]
+var simvar4=[]
+
+//Counts the number of get request for the html page
+var getCtr=0
+
+var refreshInterval=2000
+
+function fetchAllMetrics() {
+    setTimeout(() => {
+
+        console.log("Fetching all metics data")
+        if (refreshInterval < 20000) {
+            refreshInterval+=100
+        }
+        if (getCtr%3 == 0) {
+            //Extract the port numbers from the running simulators, for every 3 calls
+            const { exec } = require('child_process');
+            exec('docker ps --filter "name=ricsim" --format "{{.Names}} {{.Ports}}" | sed s/0.0.0.0:// | cut -d \'>\' -f1 | sed \'s/[[-]]*$//\'', (err, stdout, stderr) => {
+
+                var simulators = ""
+                simulators=`${stdout}`.replace(/(\r\n|\n|\r)/gm," ");
+                simulators=simulators.trim();
+                var sims=simulators.split(" ")
+                simnames=[]
+                simports=[]
+                for(i=0;i<sims.length;i=i+2) {
+                    simnames[i/2]=sims[i]
+                    simports[i/2]=sims[i+1]
+                }
+            });
+        }
+        getCtr=getCtr+1
+
+        //Get metric values from the simulators
+        for(var index=0;index<simnames.length;index++) {
+            getSimCtr(LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
+                simvar1[index] = data;
+            });
+            getSimCtr(LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
+                simvar2[index] = data;
+            });
+            getSimCtr(LOCALHOST+simports[index]+"/policytypes", index, function(data,index) {
+                data=data.replace(/\[/g,'');
+                data=data.replace(/\]/g,'');
+                data=data.replace(/ /g,'');
+                data=data.replace(/\"/g,'');
+                simvar3[index] = data;
+            });
+            getSimCtr(LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
+                simvar4[index] = data;
+            });
+        }
+
+        //MR - get metrics values from the MR stub
+        getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
+            mr1 = data;
+        });
+        getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
+            mr2 = data;
+        });
+        getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
+            mr3 = data;
+        });
+        getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
+            mr4 = data;
+        });
+        getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
+            mr5 = data;
+        });
+        getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
+            mr6 = data;
+        });
+
+        //CR - get metrics values from the callbackreceiver
+        getSimCtr(LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
+            cr1 = data;
+        });
+        getSimCtr(LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
+            cr2 = data;
+        });
+        getSimCtr(LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
+            cr3 = data;
+        });
+
+        //Agent - get metrics from the agent
+        getSimCtr(LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
+            ag1 = data;
+        });
+        getSimCtr(LOCALHOST+AGENT_PORT+"/services", 0, function(data, index) {
+            ag2="";
+            try {
+                var jd=JSON.parse(data);
+                for(var key in jd) {
+                    if (ag2.length > 1) {
+                        ag2=ag2+", "
+                    }
+                    ag2=ag2+(jd[key]["serviceName"]).trim()
+                }
+            }
+            catch (err) {
+                ag2=data
+            }
+        });
+        getSimCtr(LOCALHOST+AGENT_PORT+"/policy_types", 0, function(data, index) {
+            ag3="";
+            try {
+                var jd=JSON.parse(data);
+                for(var key in jd) {
+                    if (ag3.length > 0) {
+                        ag3=ag3+", "
+                    }
+                    ag3=ag3+jd[key].trim()
+                }
+            }
+            catch (err) {
+                ag3=""
+            }
+        });
+        getSimCtr(LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
+            ag4=""
+            try {
+                var jd=JSON.parse(data);
+                ag4=""+jd.length
+            }
+            catch (err) {
+                ag4=""
+            }
+        });
+
+
+
+        fetchAllMetrics();
+    }, refreshInterval)
+}
+
+fetchAllMetrics();
+
+setInterval(() => {
+    console.log("Setting interval "+refreshInterval+"ms")
+}, refreshInterval)
+
+app.get("/mon",function(req, res){
+
+
+    refreshInterval=2000
+
+  //Build web page
+       var htmlStr = "<!DOCTYPE html>" +
+          "<html>" +
+          "<head>" +
+            "<meta http-equiv=\"refresh\" content=\"2\">"+  //2 sec auto refresh
+            "<title>Policy Agent and simulator monitor</title>"+
+            "</head>" +
+            "<body>" +
+            "<h3>Policy agent</h3>" +
+            "<font face=\"monospace\">" +
+            "Status:..............................." + formatDataRow(ag1) + "<br>" +
+            "Services:............................." + formatIdRowCompact(ag2) + "<br>" +
+            "Types:................................" + formatIdRowCompact(ag3) + "<br>" +
+            "Number of instances:.................." + formatDataRow(ag4) + "<br>" +
+            "</font>" +
+            "<h3>MR Stub interface</h3>" +
+            "<font face=\"monospace\">"+
+            "Submitted requests:............................" + formatDataRow(mr1) + "<br>" +
+            "Fetched requests:.............................." + formatDataRow(mr2) + "<br>" +
+            "Current requests waiting:......................" + formatDataRow(mr3) + "<br>" +
+            "Submitted responses:..........................." + formatDataRow(mr4) + "<br>" +
+            "Fetched responses.............................." + formatDataRow(mr5) + "<br>" +
+            "Current responses waiting......................" + formatDataRow(mr6) + "<br>" +
+            "</font>"+
+            "<h3>Callback receiver</h3>" +
+            "<font face=\"monospace\">" +
+            "Callbacks received:..................." + formatDataRow(cr1) + "<br>" +
+            "Callbacks fetched:...................." + formatDataRow(cr2) + "<br>" +
+            "Number of waiting callback messages:.." + formatDataRow(cr3) + "<br>" +
+            "</font>" +
+            "<h3>Near-RT RIC Simulators</h3>" +
+            "<font face=\"monospace\">"
+
+            htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35,"&nbsp;")
+            htmlStr=htmlStr+padding("Types", 10,"&nbsp;")
+            htmlStr=htmlStr+padding("Instances", 10,"&nbsp;")
+            htmlStr=htmlStr+"<br>"+padding("",55,"=")+"<br>"
+
+            for(var simIndex=0;simIndex<simnames.length;simIndex++) {
+                htmlStr=htmlStr+padding(simnames[simIndex]+ " ("+simports[simIndex]+")",35,"&nbsp;");
+                htmlStr=htmlStr+padding(simvar2[simIndex],10,"&nbsp;")
+                htmlStr=htmlStr+padding(simvar1[simIndex],10,"&nbsp;")
+                htmlStr=htmlStr+"<br>";
+            }
+
+            htmlStr=htmlStr+"<br>";
+            htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35,"&nbsp;")
+            htmlStr=htmlStr+padding("Version", 20,"&nbsp;")
+            htmlStr=htmlStr+padding("Type-IDs", 10,"&nbsp;")+"<br>"
+            htmlStr=htmlStr+padding("",65,"=")+"<br>"
+            for(simIndex=0;simIndex<simnames.length;simIndex++) {
+                htmlStr=htmlStr+padding(simnames[simIndex]+ " ("+simports[simIndex]+")",35,"&nbsp;");
+                htmlStr=htmlStr+padding(simvar4[simIndex],20,"&nbsp;")
+                htmlStr=htmlStr+padding(formatIdRowCompact(simvar3[simIndex]),10,"&nbsp;")
+                htmlStr=htmlStr+"<br>";
+            }
+
+            htmlStr=htmlStr+
+           "</body>" +
+          "</html>";
+       res.send(htmlStr);
+})
+
+var httpServer = http.createServer(app);
+var httpPort=9999;
+httpServer.listen(httpPort);
+console.log("Simulator monitor listening (http) at "+httpPort);
+console.log("Open the web page on localhost:9999/mon to view the statistics page.")
\ No newline at end of file