Merge "Step version for release"
diff --git a/.gitignore b/.gitignore
index f459dca..6136fcb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@
.sts4-cache
.project
.settings
-.pydevproject
\ No newline at end of file
+.pydevproject
+infer-out/
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index f49a4e1..96589bf 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -198,4 +198,4 @@
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.
\ No newline at end of file
+ limitations under the License.
diff --git a/docker-compose/README.md b/docker-compose/README.md
new file mode 100644
index 0000000..7573398
--- /dev/null
+++ b/docker-compose/README.md
@@ -0,0 +1,54 @@
+# O-RAN-SC docker-compose files
+
+The docker-compose.yml file will create an entire nonrtric system with one command:
+docker-compose up
+
+Two docker-compose files are provided in this folder:
+
+nosdnc/docker-compose.yml
+This file is to create nonrtric system without sdnc a1-controller
+
+sdnc/docker-compose.yml
+This file is to create nonrtric system with sdnc a1-controller
+
+Howto:
+cd nosdnc/
+docker-compose up
+
+or
+
+cd sdnc/
+docker-compose up
+
+The scripts in data/ will generate some dummy data in the running system.
+It will create:
+one policy type in a1-sim-OSC
+one service in policy agent
+one policy in a1-sim-OSC
+one policy in a1-sim-STD
+
+Run command:
+cd data/
+./fill_data.sh [policy-agent-port] [a1-sim-OSC-port] [a1-sim-STD-port] [http/https]
+
+Open link:
+http://localhost:[control-panel-port]/
+
+All the generated data is shown on the web page
+
+## License
+
+Copyright (C) 2020 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.
+
+For more information about license please see the [LICENSE](LICENSE.txt) file for details.
diff --git a/docker-compose/data/fill_data.sh b/docker-compose/data/fill_data.sh
new file mode 100755
index 0000000..7b8f665
--- /dev/null
+++ b/docker-compose/data/fill_data.sh
@@ -0,0 +1,97 @@
+#!/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=================================================
+#
+
+# The scripts in data/ will generate some dummy data in the running system.
+# It will create:
+# one policy type in a1-sim-OSC
+# one service in policy agent
+# one policy in a1-sim-OSC
+# one policy in a1-sim-STD
+
+# Run command:
+# ./fill_data.sh [policy-agent port] [a1-sim-OSC port] [a1-sim-STD port] [http/https]
+
+policy_agent_port=${1:-8081}
+a1_sim_OSC_port=${2:-30001}
+a1_sim_STD_port=${3:-30003}
+httpx=${4:-"http"}
+
+echo "using policy_agent port: "$policy_agent_port
+echo "using a1-sim-OSC port: "$a1_sim_OSC_port
+echo "using a1-sim-STD port: "$a1_sim_STD_port
+echo "using protocol: "$httpx
+echo -e "\n"
+
+echo "policy agent status:"
+curl -skw " %{http_code}" $httpx://localhost:$policy_agent_port/status
+echo -e "\n"
+
+echo "ric1 version:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/interface
+echo -e "\n"
+
+echo "ric2 version:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/interface
+echo -e "\n"
+
+echo "create policy type 1 to ric1:"
+curl -X PUT -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/policytype?id=1 -H Content-Type:application/json --data-binary @testdata/OSC/policy_type.json
+echo -e "\n"
+
+for i in {1..12}; do
+ echo "policy types from policy agent:"
+ curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/policy_types"
+ res=$($curlString)
+ echo "$res"
+ expect="[\"\",\"1\"]200"
+ if [ "$res" == "$expect" ]; then
+ echo -e "\n"
+ break;
+ else
+ sleep $i
+ fi
+done
+
+echo "create service 1 to policy agent:"
+curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/service" --data-binary @testdata/service.json
+echo -e "\n"
+
+echo "create policy 2000 to ric1 with type1 and service1 via policy agent:"
+curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/policy?id=2000&ric=ric1&service=service1&type=1" --data-binary @testdata/policy.json
+echo -e "\n"
+
+echo "policy numbers from ric1:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/num_instances
+echo -e "\n"
+
+echo "create policy 2100 to ric2 with service1 via policy agent, no type:"
+curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/policy?id=2100&ric=ric2&service=service1" --data-binary @testdata/policy.json
+echo -e "\n"
+
+echo "policy numbers from ric2:"
+curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/num_instances
+echo -e "\n"
+
+echo "policy id 2000 from policy agent:"
+curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2000
+echo -e "\n"
+
+echo "policy id 2100 from policy agent:"
+curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2100
+echo -e "\n"
\ No newline at end of file
diff --git a/docker-compose/data/testdata/OSC/policy_type.json b/docker-compose/data/testdata/OSC/policy_type.json
new file mode 100644
index 0000000..537d86f
--- /dev/null
+++ b/docker-compose/data/testdata/OSC/policy_type.json
@@ -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/docker-compose/data/testdata/policy.json b/docker-compose/data/testdata/policy.json
new file mode 100644
index 0000000..119ba8b
--- /dev/null
+++ b/docker-compose/data/testdata/policy.json
@@ -0,0 +1,9 @@
+{
+ "scope": {
+ "ueId": "ue3100",
+ "qosId": "qos3100"
+ },
+ "qosObjective": {
+ "priorityLevel": 3100
+ }
+}
diff --git a/docker-compose/data/testdata/service.json b/docker-compose/data/testdata/service.json
new file mode 100644
index 0000000..1b973fc
--- /dev/null
+++ b/docker-compose/data/testdata/service.json
@@ -0,0 +1 @@
+{"callbackUrl": "http://callback-receiver:8090/callbacks/1","keepAliveIntervalSeconds": "3600","serviceName": "service1"}
diff --git a/docker-compose/nosdnc/config/application.yaml b/docker-compose/nosdnc/config/application.yaml
new file mode 100755
index 0000000..c0ddfb5
--- /dev/null
+++ b/docker-compose/nosdnc/config/application.yaml
@@ -0,0 +1,37 @@
+spring:
+ profiles:
+ active: prod
+ main:
+ allow-bean-definition-overriding: true
+ aop:
+ auto: false
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "loggers,logfile,health,info,metrics,threaddump,heapdump"
+
+logging:
+ level:
+ ROOT: ERROR
+ org.springframework: ERROR
+ org.springframework.data: ERROR
+ org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR
+ org.oransc.policyagent: INFO
+ file: /var/log/policy-agent/application.log
+server:
+ port : 8433
+ http-port: 8081
+ ssl:
+ key-store-type: JKS
+ key-store-password: policy_agent
+ key-store: classpath:keystore.jks
+ key-password: policy_agent
+ key-alias: policy_agent
+app:
+ filepath: /opt/app/policy-agent/config/application_configuration.json
+ webclient:
+ trust-store-used: false
+ trust-store-password: policy_agent
+ trust-store: classpath:keystore.jks
+
diff --git a/docker-compose/nosdnc/config/application_configuration.json b/docker-compose/nosdnc/config/application_configuration.json
new file mode 100644
index 0000000..3a10acd
--- /dev/null
+++ b/docker-compose/nosdnc/config/application_configuration.json
@@ -0,0 +1,23 @@
+{
+ "config": {
+ "//description": "Application configuration",
+ "ric": [
+ {
+ "name": "ric1",
+ "baseUrl": "http://a1-sim-OSC:8085/",
+ "managedElementIds": [
+ "kista_1",
+ "kista_2"
+ ]
+ },
+ {
+ "name":"ric2",
+ "baseUrl":"http://a1-sim-STD:8085/",
+ "managedElementIds": [
+ "kista_1",
+ "kista_2"
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/docker-compose/nosdnc/docker-compose.yml b/docker-compose/nosdnc/docker-compose.yml
new file mode 100644
index 0000000..8c58e34
--- /dev/null
+++ b/docker-compose/nosdnc/docker-compose.yml
@@ -0,0 +1,64 @@
+# 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'
+services:
+ policy-agent:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:1.0.0
+ container_name: policy-agent
+ networks:
+ default:
+ aliases:
+ - policy-agent-container
+ ports:
+ - 8081:8081
+ - 8433:8433
+ volumes:
+ - ./config:/opt/app/policy-agent/config:ro
+
+ a1-sim-OSC:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+ container_name: a1-sim-OSC
+ networks:
+ - default
+ ports:
+ - 30001:8085
+ - 30002:8185
+ environment:
+ - A1_VERSION=OSC_2.1.0
+ - REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
+
+ a1-sim-STD:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+ container_name: a1-sim-STD
+ networks:
+ - default
+ ports:
+ - 30003:8085
+ - 30004:8185
+ environment:
+ - A1_VERSION=STD_1.1.3
+ - REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
+
+ policy-control-panel:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:1.0.0
+ container_name: policy-control-panel
+ networks:
+ - default
+ ports:
+ - 8080:8080
+ - 8082:8082
diff --git a/docker-compose/sdnc/config/application.yaml b/docker-compose/sdnc/config/application.yaml
new file mode 100755
index 0000000..c0ddfb5
--- /dev/null
+++ b/docker-compose/sdnc/config/application.yaml
@@ -0,0 +1,37 @@
+spring:
+ profiles:
+ active: prod
+ main:
+ allow-bean-definition-overriding: true
+ aop:
+ auto: false
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "loggers,logfile,health,info,metrics,threaddump,heapdump"
+
+logging:
+ level:
+ ROOT: ERROR
+ org.springframework: ERROR
+ org.springframework.data: ERROR
+ org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR
+ org.oransc.policyagent: INFO
+ file: /var/log/policy-agent/application.log
+server:
+ port : 8433
+ http-port: 8081
+ ssl:
+ key-store-type: JKS
+ key-store-password: policy_agent
+ key-store: classpath:keystore.jks
+ key-password: policy_agent
+ key-alias: policy_agent
+app:
+ filepath: /opt/app/policy-agent/config/application_configuration.json
+ webclient:
+ trust-store-used: false
+ trust-store-password: policy_agent
+ trust-store: classpath:keystore.jks
+
diff --git a/docker-compose/sdnc/config/application_configuration.json b/docker-compose/sdnc/config/application_configuration.json
new file mode 100644
index 0000000..31ec633
--- /dev/null
+++ b/docker-compose/sdnc/config/application_configuration.json
@@ -0,0 +1,33 @@
+{
+ "config": {
+ "//description": "Application configuration",
+ "controller": [
+ {
+ "name": "a1-controller",
+ "baseUrl": "http://a1-controller:8181",
+ "userName": "admin",
+ "password": "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
+ }
+ ],
+ "ric": [
+ {
+ "name": "ric1",
+ "baseUrl": "http://a1-sim-OSC:8085/",
+ "controller": "a1-controller",
+ "managedElementIds": [
+ "kista_1",
+ "kista_2"
+ ]
+ },
+ {
+ "name":"ric2",
+ "baseUrl":"http://a1-sim-STD:8085/",
+ "controller": "a1-controller",
+ "managedElementIds":[
+ "kista_1",
+ "kista_2"
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/docker-compose/sdnc/docker-compose.yml b/docker-compose/sdnc/docker-compose.yml
new file mode 100644
index 0000000..edbe0bc
--- /dev/null
+++ b/docker-compose/sdnc/docker-compose.yml
@@ -0,0 +1,104 @@
+# 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'
+services:
+ policy-agent:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:1.0.0
+ container_name: policy-agent
+ networks:
+ default:
+ aliases:
+ - policy-agent-container
+ ports:
+ - 8081:8081
+ - 8433:8433
+ volumes:
+ - ./config:/opt/app/policy-agent/config:ro
+
+ a1-sim-OSC:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+ container_name: a1-sim-OSC
+ networks:
+ - default
+ ports:
+ - 30001:8085
+ - 30002:8185
+ environment:
+ - A1_VERSION=OSC_2.1.0
+ - REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
+
+ a1-sim-STD:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:1.0.1
+ container_name: a1-sim-STD
+ networks:
+ - default
+ ports:
+ - 30003:8085
+ - 30004:8185
+ environment:
+ - A1_VERSION=STD_1.1.3
+ - REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
+
+ policy-control-panel:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:1.0.0
+ container_name: policy-control-panel
+ networks:
+ - default
+ ports:
+ - 8080:8080
+ - 8082:8082
+
+ db:
+ image: mysql/mysql-server:5.6
+ container_name: sdnc-db
+ networks:
+ - default
+ ports:
+ - "3306"
+ environment:
+ - MYSQL_ROOT_PASSWORD=openECOMP1.0
+ - MYSQL_ROOT_HOST=%
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "30m"
+ max-file: "5"
+
+ a1-controller:
+ image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1-controller:1.7.5
+ depends_on :
+ - db
+ container_name: a1-controller
+ networks:
+ - default
+ entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"]
+ ports:
+ - 8282:8181
+ - 8443:8443
+ links:
+ - db:dbhost
+ - db:sdnctldb01
+ - db:sdnctldb02
+ environment:
+ - MYSQL_ROOT_PASSWORD=openECOMP1.0
+ - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "30m"
+ max-file: "5"
diff --git a/policy-agent/Dockerfile b/policy-agent/Dockerfile
index da9fd44..15f0502 100644
--- a/policy-agent/Dockerfile
+++ b/policy-agent/Dockerfile
@@ -27,7 +27,8 @@
EXPOSE 8081 8433
-ADD /config/* /opt/app/policy-agent/config/
+ADD /config/application.yaml /opt/app/policy-agent/config/application.yaml
+ADD /config/application_configuration.json /opt/app/policy-agent/data/application_configuration.json_example
ADD target/${JAR} /opt/app/policy-agent/policy-agent.jar
diff --git a/policy-agent/config/application.yaml b/policy-agent/config/application.yaml
index c0ddfb5..aac4393 100644
--- a/policy-agent/config/application.yaml
+++ b/policy-agent/config/application.yaml
@@ -29,7 +29,7 @@
key-password: policy_agent
key-alias: policy_agent
app:
- filepath: /opt/app/policy-agent/config/application_configuration.json
+ filepath: /opt/app/policy-agent/data/application_configuration.json
webclient:
trust-store-used: false
trust-store-password: policy_agent
diff --git a/policy-agent/config/application_configuration.json_example b/policy-agent/config/application_configuration.json
similarity index 100%
rename from policy-agent/config/application_configuration.json_example
rename to policy-agent/config/application_configuration.json
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
index 4ba58c7..b292c51 100644
--- a/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
+++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
@@ -196,7 +196,7 @@
logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(),
exception.getResponseBodyAsString());
} else {
- logger.debug("{} HTTP error: {}", traceTag, t.getMessage());
+ logger.debug("{} HTTP error", traceTag, t);
}
}
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
index 49d7702..832bbe9 100644
--- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
+++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
@@ -269,6 +269,7 @@
RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
", RIC name: " + current.ric().name() + //
", new name: " + policy.ric().name(), HttpStatus.CONFLICT);
+ logger.debug("Request rejected, {}", e);
return Mono.error(e);
}
return Mono.just("OK");
@@ -276,6 +277,7 @@
private Mono<Object> checkSupportedType(Ric ric, PolicyType type) {
if (!ric.isSupportingType(type.name())) {
+ logger.debug("Request rejected, type not supported, RIC: {}", ric);
RejectionException e = new RejectionException(
"Type: " + type.name() + " not supported by RIC: " + ric.name(), HttpStatus.NOT_FOUND);
return Mono.error(e);
@@ -287,6 +289,7 @@
if (ric.getState() == Ric.RicState.AVAILABLE) {
return Mono.just("OK");
} else {
+ logger.debug("Request rejected RIC not IDLE, ric: {}", ric);
RejectionException e = new RejectionException(
"Ric is not operational, RIC name: " + ric.name() + ", state: " + ric.getState(), HttpStatus.LOCKED);
return Mono.error(e);
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
index 3d5da62..19d1564 100644
--- a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
+++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
@@ -35,6 +35,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.reactive.function.client.WebClientException;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Mono;
@@ -73,15 +74,15 @@
.flatMap(
response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, response.getStatusCode()));
} catch (Exception e) {
- logger.warn("Received unparsable message from DMAAP: {}", msg);
- return Mono.error(e); // Cannot make any response
+ String errorMsg = "Received unparsable message from DMAAP: \"" + msg + "\", reason: " + e.getMessage();
+ return Mono.error(new ServiceException(errorMsg)); // Cannot make any response
}
}
private Mono<ResponseEntity<String>> handleAgentCallError(Throwable t, String originalMessage,
DmaapRequestMessage dmaapRequestMessage) {
logger.debug("Agent call failed: {}", t.getMessage());
- HttpStatus status = HttpStatus.NOT_FOUND;
+ HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
String errorMessage = t.getMessage();
if (t instanceof WebClientResponseException) {
WebClientResponseException exception = (WebClientResponseException) t;
@@ -90,7 +91,8 @@
} else if (t instanceof ServiceException) {
status = HttpStatus.BAD_REQUEST;
errorMessage = prepareBadOperationErrorMessage(t, originalMessage);
-
+ } else if (!(t instanceof WebClientException)) {
+ logger.warn("Unexpected exception ", t);
}
return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) //
.flatMap(notUsed -> Mono.empty());
@@ -119,7 +121,6 @@
} else {
return Mono.error(new ServiceException("Not implemented operation: " + operation));
}
-
}
private String payload(DmaapRequestMessage message) {
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/repository/Lock.java b/policy-agent/src/main/java/org/oransc/policyagent/repository/Lock.java
index ed94492..716148f 100644
--- a/policy-agent/src/main/java/org/oransc/policyagent/repository/Lock.java
+++ b/policy-agent/src/main/java/org/oransc/policyagent/repository/Lock.java
@@ -44,6 +44,115 @@
private final List<LockRequest> lockRequestQueue = new LinkedList<>();
private static AsynchCallbackExecutor callbackProcessor = new AsynchCallbackExecutor();
+ public enum LockType {
+ EXCLUSIVE, SHARED
+ }
+
+ /** The caller thread will be blocked util the lock is granted. */
+ public synchronized void lockBlocking(LockType locktype) {
+ while (!tryLock(locktype)) {
+ this.waitForUnlock();
+ }
+ }
+
+ /** Reactive version. The Lock will be emitted when the lock is granted */
+ public synchronized Mono<Lock> lock(LockType lockType) {
+ if (tryLock(lockType)) {
+ return Mono.just(this);
+ } else {
+ return Mono.create(monoSink -> addToQueue(monoSink, lockType));
+ }
+ }
+
+ public Mono<Lock> unlock() {
+ return Mono.create(monoSink -> {
+ unlockBlocking();
+ monoSink.success(this);
+ });
+ }
+
+ public synchronized void unlockBlocking() {
+ if (lockCounter <= 0) {
+ lockCounter = -1; // Might as well stop, to make it easier to find the problem
+ logger.error("Number of unlocks must match the number of locks");
+ }
+ this.lockCounter--;
+ if (lockCounter == 0) {
+ isExclusive = false;
+ }
+ this.notifyAll();
+ this.processQueuedEntries();
+ }
+
+ @Override
+ public synchronized String toString() {
+ return "Lock cnt: " + this.lockCounter + " exclusive: " + this.isExclusive + " queued: "
+ + this.lockRequestQueue.size();
+ }
+
+ /** returns the current number of granted locks */
+ public synchronized int getLockCounter() {
+ return this.lockCounter;
+ }
+
+ private void processQueuedEntries() {
+ List<LockRequest> granted = new ArrayList<>();
+ for (Iterator<LockRequest> i = lockRequestQueue.iterator(); i.hasNext();) {
+ LockRequest request = i.next();
+ if (tryLock(request.lockType)) {
+ i.remove();
+ granted.add(request);
+ }
+ }
+ callbackProcessor.addAll(granted);
+ }
+
+ private synchronized void addToQueue(MonoSink<Lock> callback, LockType lockType) {
+ lockRequestQueue.add(new LockRequest(callback, lockType, this));
+ processQueuedEntries();
+ }
+
+ @SuppressWarnings("java:S2274") // Always invoke wait() and await() methods inside a loop
+ private synchronized void waitForUnlock() {
+ try {
+ this.wait();
+ } catch (InterruptedException e) {
+ logger.warn("waitForUnlock interrupted", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ private boolean tryLock(LockType lockType) {
+ if (this.isExclusive) {
+ return false;
+ }
+ if (lockType == LockType.EXCLUSIVE && lockCounter > 0) {
+ return false;
+ }
+ lockCounter++;
+ this.isExclusive = lockType == LockType.EXCLUSIVE;
+ return true;
+ }
+
+ /**
+ * Represents a queued lock request
+ */
+ private static class LockRequest {
+ final MonoSink<Lock> callback;
+ final LockType lockType;
+ final Lock lock;
+
+ LockRequest(MonoSink<Lock> callback, LockType lockType, Lock lock) {
+ this.callback = callback;
+ this.lockType = lockType;
+ this.lock = lock;
+ }
+ }
+
+ /**
+ * A separate thread that calls a MonoSink to continue. This is done after a
+ * queued lock is granted.
+ */
private static class AsynchCallbackExecutor implements Runnable {
private List<LockRequest> lockRequestQueue = new LinkedList<>();
@@ -85,110 +194,4 @@
}
}
}
-
- public enum LockType {
- EXCLUSIVE, SHARED
- }
-
- /** The caller thread will be blocked util the lock is granted. */
- public synchronized void lockBlocking(LockType locktype) {
- while (!tryLock(locktype)) {
- this.waitForUnlock();
- }
- }
-
- /** Reactive version. The Lock will be emitted when the lock is granted */
- public synchronized Mono<Lock> lock(LockType lockType) {
- if (tryLock(lockType)) {
- return Mono.just(this);
- } else {
- return Mono.create(monoSink -> addToQueue(monoSink, lockType));
- }
- }
-
- public Mono<Lock> unlock() {
- return Mono.create(monoSink -> {
- unlockBlocking();
- monoSink.success(this);
- });
- }
-
- public void unlockBlocking() {
- synchronized (this) {
- if (lockCounter <= 0) {
- lockCounter = -1; // Might as well stop, to make it easier to find the problem
- logger.error("Number of unlocks must match the number of locks");
- }
- this.lockCounter--;
- if (lockCounter == 0) {
- isExclusive = false;
- }
- this.notifyAll();
- }
- this.processQueuedEntries();
- }
-
- @Override
- public String toString() {
- return "Lock cnt: " + this.lockCounter + " exclusive: " + this.isExclusive + " queued: "
- + this.lockRequestQueue.size();
- }
-
- /** returns the current number of granted locks */
- public synchronized int getLockCounter() {
- return this.lockCounter;
- }
-
- private void processQueuedEntries() {
- List<LockRequest> granted = new ArrayList<>();
- synchronized (this) {
- for (Iterator<LockRequest> i = lockRequestQueue.iterator(); i.hasNext();) {
- LockRequest request = i.next();
- if (tryLock(request.lockType)) {
- i.remove();
- granted.add(request);
- }
- }
- }
- callbackProcessor.addAll(granted);
- }
-
- private static class LockRequest {
- final MonoSink<Lock> callback;
- final LockType lockType;
- final Lock lock;
-
- LockRequest(MonoSink<Lock> callback, LockType lockType, Lock lock) {
- this.callback = callback;
- this.lockType = lockType;
- this.lock = lock;
- }
- }
-
- private synchronized void addToQueue(MonoSink<Lock> callback, LockType lockType) {
- lockRequestQueue.add(new LockRequest(callback, lockType, this));
- }
-
- @SuppressWarnings("java:S2274") // Always invoke wait() and await() methods inside a loop
- private synchronized void waitForUnlock() {
- try {
- this.wait();
- } catch (InterruptedException e) {
- logger.warn("waitForUnlock interrupted", e);
- Thread.currentThread().interrupt();
- }
- }
-
- private boolean tryLock(LockType lockType) {
- if (this.isExclusive) {
- return false;
- }
- if (lockType == LockType.EXCLUSIVE && lockCounter > 0) {
- return false;
- }
- lockCounter++;
- this.isExclusive = lockType == LockType.EXCLUSIVE;
- return true;
- }
-
}
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java b/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
index cffd1c4..a8cab60 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
@@ -332,7 +332,7 @@
url = "/policies";
String rsp = restClient().get(url).block();
- assertThat(rsp.contains(policyInstanceId)).isTrue();
+ assertThat(rsp.contains(policyInstanceId)).as("Response contains policy instance ID.").isTrue();
url = "/policy?id=" + policyInstanceId;
rsp = restClient().get(url).block();
@@ -400,10 +400,10 @@
String rsp = restClient().get("/policies").block();
List<PolicyInfo> info = parseList(rsp, PolicyInfo.class);
- assertThat(info).size().isEqualTo(1);
+ assertThat(info.size()).isEqualTo(1);
PolicyInfo policyInfo = info.get(0);
- assertThat(policyInfo.id.equals("id1")).isTrue();
- assertThat(policyInfo.type.equals("")).isTrue();
+ assertThat(policyInfo.id).isEqualTo("id1");
+ assertThat(policyInfo.type).isEqualTo("");
}
@Test
@@ -581,8 +581,9 @@
@Test
void testPutAndGetService() throws Exception {
// PUT
- putService("name", 0, HttpStatus.CREATED);
- putService("name", 0, HttpStatus.OK);
+ String serviceName = "name";
+ putService(serviceName, 0, HttpStatus.CREATED);
+ putService(serviceName, 0, HttpStatus.OK);
// GET one service
String url = "/services?name=name";
@@ -591,12 +592,12 @@
assertThat(info.size()).isEqualTo(1);
ServiceStatus status = info.iterator().next();
assertThat(status.keepAliveIntervalSeconds).isEqualTo(0);
- assertThat(status.serviceName).isEqualTo("name");
+ assertThat(status.serviceName).isEqualTo(serviceName);
// GET (all)
url = "/services";
rsp = restClient().get(url).block();
- assertThat(rsp.contains("name")).isTrue();
+ assertThat(rsp.contains(serviceName)).as("Response contains service name").isTrue();
logger.info(rsp);
// Keep alive
@@ -610,17 +611,17 @@
restClient().delete(url).block();
assertThat(services.size()).isEqualTo(0);
- // Keep alive, no registerred service
+ // Keep alive, no registered service
testErrorCode(restClient().put("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
// PUT servive with bad payload
testErrorCode(restClient().put("/service", "crap"), HttpStatus.BAD_REQUEST);
testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST);
- testErrorCode(restClient().put("/service", createServiceJson("name", -123)), HttpStatus.BAD_REQUEST);
- testErrorCode(restClient().put("/service", createServiceJson("name", 0, "missing.portandprotocol.com")),
+ testErrorCode(restClient().put("/service", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST);
+ testErrorCode(restClient().put("/service", createServiceJson(serviceName, 0, "missing.portandprotocol.com")),
HttpStatus.BAD_REQUEST);
- // GET non existing servive
+ // GET non existing service
testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND);
}
@@ -648,7 +649,7 @@
String url = "/policy_status?id=id";
String rsp = restClient().get(url).block();
- assertThat(rsp.equals("OK")).isTrue();
+ assertThat(rsp).isEqualTo("OK");
// GET non existing policy status
url = "/policy_status?id=XXX";
@@ -657,7 +658,7 @@
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
- Policy p = ImmutablePolicy.builder() //
+ Policy policy = ImmutablePolicy.builder() //
.id(id) //
.json(jsonString()) //
.ownerServiceName(service) //
@@ -666,8 +667,8 @@
.lastModified("lastModified") //
.isTransient(false) //
.build();
- policies.put(p);
- return p;
+ policies.put(policy);
+ return policy;
}
private Policy addPolicy(String id, String typeName, String service) throws ServiceException {
@@ -716,11 +717,11 @@
addPolicyType("type2", "ric");
for (int i = 0; i < 10; ++i) {
- Thread t =
+ Thread thread =
new Thread(new ConcurrencyTestRunnable(baseUrl(), supervision, a1ClientFactory, rics, policyTypes),
"TestThread_" + i);
- t.start();
- threads.add(t);
+ thread.start();
+ threads.add(thread);
}
for (Thread t : threads) {
t.join();
@@ -755,11 +756,11 @@
.verify();
}
- private boolean checkWebClientError(Throwable t, HttpStatus expStatus, String responseContains) {
- assertTrue(t instanceof WebClientResponseException);
- WebClientResponseException e = (WebClientResponseException) t;
- assertThat(e.getStatusCode()).isEqualTo(expStatus);
- assertThat(e.getResponseBodyAsString()).contains(responseContains);
+ private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains) {
+ assertTrue(throwable instanceof WebClientResponseException);
+ WebClientResponseException responseException = (WebClientResponseException) throwable;
+ assertThat(responseException.getStatusCode()).isEqualTo(expStatus);
+ assertThat(responseException.getResponseBodyAsString()).contains(responseContains);
return true;
}
@@ -809,8 +810,8 @@
List<T> result = new ArrayList<>();
JsonArray jsonArr = JsonParser.parseString(jsonString).getAsJsonArray();
for (JsonElement jsonElement : jsonArr) {
- T o = gson.fromJson(jsonElement.toString(), clazz);
- result.add(o);
+ T json = gson.fromJson(jsonElement.toString(), clazz);
+ result.add(json);
}
return result;
}
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java b/policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java
index 7930e5c..6b53aa1 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java
@@ -47,7 +47,7 @@
// 'proceed(Object[])' is never called
verify(proceedingJoinPoint, never()).proceed(null);
- assertThat(logAppender.list.toString().contains("Execution time of")).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage()).startsWith("Execution time of");
}
@Test
@@ -60,7 +60,7 @@
sampleAspect.entryLog(proceedingJoinPoint);
- assertThat(logAppender.list.toString().contains("Entering method: " + signature)).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage()).isEqualTo("Entering method: " + signature);
}
@Test
@@ -73,6 +73,6 @@
sampleAspect.exitLog(proceedingJoinPoint);
- assertThat(logAppender.list.toString().contains("Exiting method: " + signature)).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage()).isEqualTo("Exiting method: " + signature);
}
}
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
index d63974e..8a2f044 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
@@ -121,8 +121,8 @@
List<String> policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block();
- assertEquals(1, policyTypeIds.size(), "");
- assertEquals(POLICY_TYPE_1_ID, policyTypeIds.get(0), "");
+ assertEquals(1, policyTypeIds.size());
+ assertEquals(POLICY_TYPE_1_ID, policyTypeIds.get(0));
String expUrl = RIC_1_URL + "/a1-p/policytypes";
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
@@ -137,7 +137,7 @@
void getTypeSchema_STD() {
String policyType = clientUnderTest.getPolicyTypeSchema("").block();
- assertEquals("{}", policyType, "");
+ assertEquals("{}", policyType);
}
@Test
@@ -164,9 +164,9 @@
String inputString = "[1, \"1\" ]";
List<String> result = SdncJsonHelper.parseJsonArrayOfString(inputString).collectList().block();
- assertEquals(2, result.size(), "");
- assertEquals("1", result.get(0), "");
- assertEquals("1", result.get(1), "");
+ assertEquals(2, result.size());
+ assertEquals("1", result.get(0));
+ assertEquals("1", result.get(1));
}
@Test
@@ -177,7 +177,7 @@
List<String> returned = clientUnderTest.getPolicyIdentities().block();
- assertEquals(2, returned.size(), "");
+ assertEquals(2, returned.size());
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(policiesUrl()) //
@@ -200,7 +200,7 @@
List<String> returned = clientUnderTest.getPolicyIdentities().block();
- assertEquals(2, returned.size(), "");
+ assertEquals(2, returned.size());
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(RIC_1_URL + "/a1-p/policytypes/type1/policies") //
@@ -218,7 +218,7 @@
.putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
.block();
- assertEquals("OK", returned, "");
+ assertEquals("OK", returned);
final String expUrl = policiesUrl() + "/" + POLICY_1_ID;
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
@@ -267,7 +267,7 @@
.deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
.block();
- assertEquals("OK", returned, "");
+ assertEquals("OK", returned);
final String expUrl = policiesUrl() + "/" + POLICY_1_ID;
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerTest.java b/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerTest.java
index 5c11830..6e78656 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerTest.java
@@ -145,9 +145,8 @@
messageConsumerUnderTest.start().join();
- assertThat(logAppender.list.toString()
- .contains("Cannot fetch because of Error respons " + responseCode + " " + responseMessage + " from DMaaP."))
- .isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage()).isEqualTo(
+ "Cannot fetch because of Error respons " + responseCode + " " + responseMessage + " from DMaaP.");
verify(messageConsumerUnderTest).sleep(DmaapMessageConsumer.TIME_BETWEEN_DMAAP_RETRIES);
}
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageHandlerTest.java b/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageHandlerTest.java
index f1ae7fb..3cbe28b 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageHandlerTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageHandlerTest.java
@@ -20,6 +20,7 @@
package org.oransc.policyagent.dmaap;
+import static ch.qos.logback.classic.Level.WARN;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -32,7 +33,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
-import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
@@ -129,12 +129,15 @@
@Test
void unparseableMessage_thenWarning() {
- final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(DmaapMessageHandler.class);
+ final ListAppender<ILoggingEvent> logAppender =
+ LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN);
- testedObject.handleDmaapMsg("bad message");
+ String msg = "bad message";
+ testedObject.handleDmaapMsg(msg);
- assertThat(logAppender.list.get(0).getLevel()).isEqualTo(Level.WARN);
- assertThat(logAppender.list.toString().contains("handleDmaapMsg failure ")).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage()).startsWith(
+ "handleDmaapMsg failure org.oransc.policyagent.exceptions.ServiceException: Received unparsable "
+ + "message from DMAAP: \"" + msg + "\", reason: ");
}
@Test
@@ -237,7 +240,9 @@
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(dmaapClient).send(captor.capture());
String actualMessage = captor.getValue();
- assertThat(actualMessage.contains(HttpStatus.BAD_REQUEST.toString())).isTrue();
+ assertThat(actualMessage.contains(HttpStatus.BAD_REQUEST.toString()))
+ .as("Message \"%s\" sent to DMaaP contains %s", actualMessage, HttpStatus.BAD_REQUEST) //
+ .isTrue();
verify(dmaapClient).sendBatchWithResponse();
verifyNoMoreInteractions(dmaapClient);
@@ -255,7 +260,9 @@
verify(dmaapClient).send(captor.capture());
String actualMessage = captor.getValue();
assertThat(actualMessage
- .contains(HttpStatus.BAD_REQUEST + "\",\"message\":\"Not implemented operation: " + badOperation)).isTrue();
+ .contains(HttpStatus.BAD_REQUEST + "\",\"message\":\"Not implemented operation: " + badOperation)) //
+ .as("Message \"%s\" sent to DMaaP contains %s", actualMessage, HttpStatus.BAD_REQUEST) //
+ .isTrue();
verify(dmaapClient).sendBatchWithResponse();
verifyNoMoreInteractions(dmaapClient);
@@ -266,11 +273,12 @@
String message = dmaapInputMessage(Operation.PUT).toString();
message = message.replace(",\"payload\":{\"name\":\"name\",\"schema\":\"schema\"}", "");
- final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(DmaapMessageHandler.class);
+ final ListAppender<ILoggingEvent> logAppender =
+ LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN);
testedObject.handleDmaapMsg(message);
- assertThat(logAppender.list.get(0).getLevel()).isEqualTo(Level.WARN);
- assertThat(logAppender.list.toString().contains("Expected payload in message from DMAAP: ")).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage())
+ .startsWith("Expected payload in message from DMAAP: ");
}
}
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java
index 5d8c74c..efabba3 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java
@@ -20,9 +20,9 @@
package org.oransc.policyagent.tasks;
+import static ch.qos.logback.classic.Level.WARN;
import static org.assertj.core.api.Assertions.assertThat;
-import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
@@ -90,14 +90,14 @@
.appName(HOSTNAME_VALUE) //
.build();
- final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(EnvironmentProcessor.class);
+ final ListAppender<ILoggingEvent> logAppender =
+ LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN);
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
.expectNext(expectedEnvProperties).expectComplete();
- assertThat(logAppender.list.get(0).getLevel()).isEqualTo(Level.WARN);
- assertThat(logAppender.list.toString()
- .contains("$CONSUL_PORT variable will be set to default port " + defaultConsulPort)).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage())
+ .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort);
}
@Test
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java
index c7b913b..2b1d2a7 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java
@@ -23,6 +23,7 @@
import static ch.qos.logback.classic.Level.ERROR;
import static ch.qos.logback.classic.Level.WARN;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -138,21 +139,22 @@
refreshTaskUnderTest.start();
- assertThat(logAppender.list.toString().contains("Configuration refresh terminated")).isTrue();
+ assertThat(logAppender.list.get(0).getFormattedMessage()).isEqualTo("Configuration refresh terminated");
}
@Test
void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() {
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
- doReturn(Flux.error(new Exception("Error"))).when(refreshTaskUnderTest).createRefreshTask();
+ String errorMessage = "Error";
+ doReturn(Flux.error(new Exception(errorMessage))).when(refreshTaskUnderTest).createRefreshTask();
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
refreshTaskUnderTest.start();
ILoggingEvent event = logAppender.list.get(0);
- assertThat(event.getLevel()).isEqualTo(ERROR);
- assertThat(event.toString().contains("Configuration refresh terminated due to exception")).isTrue();
+ assertThat(event.getFormattedMessage())
+ .isEqualTo("Configuration refresh terminated due to exception java.lang.Exception: " + errorMessage);
}
@Test
@@ -163,7 +165,7 @@
refreshTaskUnderTest.start();
refreshTaskUnderTest.stop();
- assertThat(refreshTaskUnderTest.getRefreshTask().isDisposed()).isTrue();
+ assertThat(refreshTaskUnderTest.getRefreshTask().isDisposed()).as("Refresh task is disposed").isTrue();
}
@Test
@@ -215,7 +217,9 @@
verify(refreshTaskUnderTest).loadConfigurationFromFile();
assertThat(appConfig.getRicConfigs().size()).isEqualTo(0);
- assertThat(logAppender.list.toString().contains("Local configuration file not loaded: fileName, ")).isTrue();
+ await().until(() -> logAppender.list.size() > 0);
+ assertThat(logAppender.list.get(0).getFormattedMessage())
+ .startsWith("Local configuration file not loaded: fileName, ");
}
@Test
@@ -238,9 +242,9 @@
.thenCancel() //
.verify();
- assertThat(
- logAppender.list.toString().contains("Could not refresh application configuration. java.io.IOException"))
- .isTrue();
+ await().until(() -> logAppender.list.size() > 0);
+ assertThat(logAppender.list.get(0).getFormattedMessage())
+ .isEqualTo("Could not refresh application configuration. java.io.IOException");
}
@Test
@@ -316,8 +320,9 @@
.thenCancel() //
.verify();
- assertThat(logAppender.list.toString()
- .contains("Could not parse configuration org.oransc.policyagent.exceptions.ServiceException: ")).isTrue();
+ await().until(() -> logAppender.list.size() > 0);
+ assertThat(logAppender.list.get(0).getFormattedMessage())
+ .startsWith("Could not parse configuration org.oransc.policyagent.exceptions.ServiceException: ");
}
private RicConfig getRicConfig(String name) {
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java
index 224803d..8674d0a 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java
@@ -308,7 +308,8 @@
ILoggingEvent loggingEvent = logAppender.list.get(0);
assertThat(loggingEvent.getLevel()).isEqualTo(WARN);
- verifyCorrectLogMessage(0, logAppender, "Service notification failed for service: " + SERVICE_1_NAME);
+ verifyCorrectLogMessage(0, logAppender,
+ "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage);
}
private void setUpCreationOfA1Client() {
@@ -333,6 +334,6 @@
private void verifyCorrectLogMessage(int messageIndex, ListAppender<ILoggingEvent> logAppender,
String expectedMessage) {
ILoggingEvent loggingEvent = logAppender.list.get(messageIndex);
- assertThat(loggingEvent.toString().contains(expectedMessage)).isTrue();
+ assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedMessage);
}
}
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java
index 495b2a5..f1f4931 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java
@@ -136,7 +136,7 @@
assertThat(loggingEvent.getLevel()).isEqualTo(WARN);
String expectedLogMessage =
"Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage;
- assertThat(loggingEvent.toString().contains(expectedLogMessage)).isTrue();
+ assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedLogMessage);
}
@Test
diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/restadapter/RestAdapterImpl.java b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/restadapter/RestAdapterImpl.java
index d317e56..928b65f 100644
--- a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/restadapter/RestAdapterImpl.java
+++ b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/restadapter/RestAdapterImpl.java
@@ -34,7 +34,7 @@
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.conn.ssl.TrustAllStrategy;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
@@ -87,7 +87,7 @@
SSLContexts.custom()
.loadKeyMaterial(ResourceUtils.getFile(properties.getProperty("key-store")),
keystorePassword.toCharArray(), keystorePassword.toCharArray())
- .loadTrustMaterial(null, new TrustSelfSignedStrategy())
+ .loadTrustMaterial(null, new TrustAllStrategy())
.build(),
NoopHostnameVerifier.INSTANCE);
HttpClient client = HttpClients.custom().setSSLSocketFactory(scsf).build();
diff --git a/test/auto-test/.gitignore b/test/auto-test/.gitignore
index fe93abe..89e22de 100644
--- a/test/auto-test/.gitignore
+++ b/test/auto-test/.gitignore
@@ -12,3 +12,5 @@
.output.*
.sdnc*
.timer*
+.pid*
+.result*
diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh
index 306683b..877a209 100755
--- a/test/auto-test/FTC1.sh
+++ b/test/auto-test/FTC1.sh
@@ -20,6 +20,9 @@
TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
@@ -166,11 +169,11 @@
echo "########### A1 Policy Management ###########"
echo "############################################"
- api_put_policy 201 "serv1" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
- api_put_policy 200 "serv1" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
+ api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
+ api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
- api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
- api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+ api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
+ api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
api_delete_policy 204 5000
diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh
index ae4dc43..771ee55 100755
--- a/test/auto-test/FTC10.sh
+++ b/test/auto-test/FTC10.sh
@@ -19,6 +19,9 @@
TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
@@ -69,28 +72,28 @@
api_put_service 201 "service1" 3600 "$CR_PATH/1"
-api_put_policy 201 "service1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1
+api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
sim_equal ricsim_g1_1 num_instances 1
use_agent_dmaap
-api_put_policy 201 "service1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1
+api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
sim_equal ricsim_g1_1 num_instances 2
use_agent_rest_http
-api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1
+api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
sim_equal ricsim_g2_1 num_instances 1
use_agent_dmaap
-api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1
+api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
sim_equal ricsim_g2_1 num_instances 2
@@ -98,16 +101,16 @@
#Update policies
use_agent_rest_http
-api_put_service 200 "service1" 3600 "$CR_PATH/callbacks/1"
+api_put_service 200 "service1" 3600 "$CR_PATH/1"
-api_put_policy 200 "service1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1
+api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
sim_equal ricsim_g1_1 num_instances 2
use_agent_dmaap
-api_put_policy 200 "service1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1
+api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
sim_equal ricsim_g1_1 num_instances 2
@@ -115,14 +118,14 @@
use_agent_rest_http
-api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1
+api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
sim_equal ricsim_g2_1 num_instances 2
use_agent_dmaap
-api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1
+api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
sim_equal ricsim_g2_1 num_instances 2
diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh
index da5962f..8ee7e37 100755
--- a/test/auto-test/FTC100.sh
+++ b/test/auto-test/FTC100.sh
@@ -20,6 +20,9 @@
TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/without SDNC A1 Controller"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
@@ -286,15 +289,21 @@
deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
#Kept until decison
- #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
+ #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
#Allow 201 for now
- api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
+ api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
- api_put_policy 201 "service10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
- api_put_policy 200 "service10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
+ api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
+ api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
- api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
- api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+ api_put_policy 200 "service10" ricsim_g1_1 1 5000 true testdata/OSC/pi1_template.json
+ api_put_policy 200 "service10" ricsim_g1_1 1 5000 false testdata/OSC/pi1_template.json
+
+ api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
+ api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
+
+ api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true testdata/STD/pi1_template.json
+ api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false testdata/STD/pi1_template.json
VAL='NOT IN EFFECT'
api_get_policy_status 200 5000 OSC "$VAL" "false"
diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh
index b4fc885..1efce99 100755
--- a/test/auto-test/FTC110.sh
+++ b/test/auto-test/FTC110.sh
@@ -20,6 +20,9 @@
TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDMC SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
@@ -139,6 +142,46 @@
api_put_services_keepalive 404 "service3"
api_put_services_keepalive 404 "service4"
+# Policy delete after timeout
+api_put_service 201 "service10" 600 "$CR_PATH/service10"
+
+sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+api_equal json:rics 1 60
+
+api_equal json:policy_schemas 1 120
+
+api_equal json:policy_types 1
+
+api_equal json:policies 0
+
+api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
+
+api_equal json:policies 1
+
+sim_equal ricsim_g1_1 num_instances 1
+
+api_put_policy 201 "service10" ricsim_g1_1 1 5001 true testdata/OSC/pi1_template.json
+
+api_equal json:policies 2
+
+sim_equal ricsim_g1_1 num_instances 2
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+#Wait for recreate of non transient policy
+api_equal json:policies 1 180
+
+sim_equal ricsim_g1_1 num_instances 1
+
+api_put_service 200 "service10" 10 "$CR_PATH/service10"
+
+#Wait for service expiry
+api_equal json:policies 0 120
+
+sim_equal ricsim_g1_1 num_instances 0
+
+
api_get_service_ids 200
deviation "TR18 Agents sends callback with empty body"
diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh
index e1388c4..9320302 100755
--- a/test/auto-test/FTC150.sh
+++ b/test/auto-test/FTC150.sh
@@ -20,6 +20,9 @@
TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API using http/https (no agent)"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="PA CP SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/controller_api_functions.sh
. ../common/ricsimulator_api_functions.sh
diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh
index e3181bd..9320606 100755
--- a/test/auto-test/FTC300.sh
+++ b/test/auto-test/FTC300.sh
@@ -19,6 +19,9 @@
TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
@@ -102,15 +105,15 @@
api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator
- api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1"
+ api_put_service 201 "serv1" 3600 "$CR_PATH/1"
START_ID=2000
NUM_POLICIES=10000
if [[ $interface == *"BATCH"* ]]; then
- api_put_policy_batch 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES
+ api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES
else
- api_put_policy 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES
+ api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES
fi
sim_equal ricsim_g1_1 num_instances 10000
@@ -124,9 +127,9 @@
START_ID=$(($START_ID+$NUM_POLICIES))
if [[ $interface == *"BATCH"* ]]; then
- api_put_policy_batch 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES
+ api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES
else
- api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES
+ api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES
fi
sim_equal ricsim_g2_1 num_instances 10000
@@ -158,16 +161,17 @@
api_equal json:policies 19995
+ check_policy_agent_logs
+
+ store_logs "${__httpx}__${interface}"
+
done
done
-check_policy_agent_logs
-
#### TEST COMPLETE ####
-store_logs END
print_result
diff --git a/test/auto-test/FTC301.sh b/test/auto-test/FTC301.sh
deleted file mode 100755
index 5d182bf..0000000
--- a/test/auto-test/FTC301.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/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=================================================
-#
-
-TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST+SNDC"
-
-. ../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_sdnc
-
-start_consul_cbs
-
-prepare_consul_config SDNC ".consul_config.json"
-consul_config_app ".consul_config.json"
-
-start_control_panel
-
-
-start_policy_agent
-
-use_agent_rest_http
-
-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
-
-auto_clean_containers
\ No newline at end of file
diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh
index b7611cb..18d6816 100755
--- a/test/auto-test/FTC310.sh
+++ b/test/auto-test/FTC310.sh
@@ -20,6 +20,9 @@
TC_ONELINE_DESCR="Resync of RIC via changes in the consul config"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh
new file mode 100755
index 0000000..0fe253f
--- /dev/null
+++ b/test/auto-test/FTC350.sh
@@ -0,0 +1,330 @@
+#!/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=================================================
+#
+
+TC_ONELINE_DESCR="Change supported policy types and reconfigure rics"
+
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
+. ../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"
+
+NUM_RICS=10
+NUM_RICS_2=$(($NUM_RICS-2))
+
+# Tested variants of REST/SDNC config
+TESTED_VARIANTS="REST REST+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 simulators and prepare two configs
+
+ start_ric_simulators ricsim_g1 $NUM_RICS_2 OSC_2.1.0
+
+ start_cr
+
+ start_mr
+
+ start_consul_cbs
+
+ if [[ $interface = *"SDNC"* ]]; then
+ start_sdnc
+ prepare_consul_config SDNC ".consul_config_2.json"
+ else
+ prepare_consul_config NOSDNC ".consul_config_2.json"
+ fi
+
+ consul_config_app ".consul_config_2.json"
+
+
+ # Create 2nd config and save for later
+ start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
+
+ if [[ $interface = *"SDNC"* ]]; then
+ start_sdnc
+ prepare_consul_config SDNC ".consul_config_all.json"
+ else
+ prepare_consul_config NOSDNC ".consul_config_all.json"
+ fi
+
+ start_policy_agent
+
+ set_agent_debug
+
+ api_get_status 200
+
+ for ((i=1; i<=${NUM_RICS}; i++))
+ do
+ sim_print ricsim_g1_$i interface
+ done
+
+ # All sims running but 2 are not configured in consul
+ api_equal json:rics 8 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:NOTYPE:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:NOTYPE:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:NOTYPE:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:NOTYPE:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:NOTYPE:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:NOTYPE:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:NOTYPE:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:NOTYPE:???? "
+
+
+ sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+ sim_put_policy_type 201 ricsim_g1_2 1 testdata/OSC/sim_1.json
+ sim_put_policy_type 201 ricsim_g1_3 1 testdata/OSC/sim_1.json
+ sim_put_policy_type 201 ricsim_g1_4 1 testdata/OSC/sim_1.json
+ sim_put_policy_type 201 ricsim_g1_5 1 testdata/OSC/sim_1.json
+
+ sim_put_policy_type 201 ricsim_g1_2 2 testdata/OSC/sim_2.json
+ sim_put_policy_type 201 ricsim_g1_3 2 testdata/OSC/sim_2.json
+ sim_put_policy_type 201 ricsim_g1_4 2 testdata/OSC/sim_2.json
+ sim_put_policy_type 201 ricsim_g1_5 2 testdata/OSC/sim_2.json
+ sim_put_policy_type 201 ricsim_g1_6 2 testdata/OSC/sim_2.json
+
+ sim_put_policy_type 201 ricsim_g1_3 3 testdata/OSC/sim_3.json
+ sim_put_policy_type 201 ricsim_g1_4 3 testdata/OSC/sim_3.json
+ sim_put_policy_type 201 ricsim_g1_5 3 testdata/OSC/sim_3.json
+ sim_put_policy_type 201 ricsim_g1_6 3 testdata/OSC/sim_3.json
+ sim_put_policy_type 201 ricsim_g1_7 3 testdata/OSC/sim_3.json
+
+ sim_put_policy_type 201 ricsim_g1_4 4 testdata/OSC/sim_4.json
+ sim_put_policy_type 201 ricsim_g1_5 4 testdata/OSC/sim_4.json
+ sim_put_policy_type 201 ricsim_g1_6 4 testdata/OSC/sim_4.json
+ sim_put_policy_type 201 ricsim_g1_7 4 testdata/OSC/sim_4.json
+ sim_put_policy_type 201 ricsim_g1_8 4 testdata/OSC/sim_4.json
+
+ sim_put_policy_type 201 ricsim_g1_5 5 testdata/OSC/sim_5.json
+ sim_put_policy_type 201 ricsim_g1_6 5 testdata/OSC/sim_5.json
+ sim_put_policy_type 201 ricsim_g1_7 5 testdata/OSC/sim_5.json
+ sim_put_policy_type 201 ricsim_g1_8 5 testdata/OSC/sim_5.json
+ sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json
+
+ api_equal json:policy_types 5 120
+
+ echo "Check the number of types in the agent for each ric"
+ api_equal json:policy_types?ric=ricsim_g1_1 1 120
+ api_equal json:policy_types?ric=ricsim_g1_2 2 120
+ api_equal json:policy_types?ric=ricsim_g1_3 3 120
+ api_equal json:policy_types?ric=ricsim_g1_4 4 120
+ api_equal json:policy_types?ric=ricsim_g1_5 5 120
+ api_equal json:policy_types?ric=ricsim_g1_6 4 120
+ api_equal json:policy_types?ric=ricsim_g1_7 3 120
+ api_equal json:policy_types?ric=ricsim_g1_8 2 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? "
+
+
+ #Load config with all rics
+ consul_config_app ".consul_config_all.json"
+
+ api_equal json:rics 10 120
+
+ echo "Check the number of types in the agent for each ric"
+ api_equal json:policy_types?ric=ricsim_g1_1 1 120
+ api_equal json:policy_types?ric=ricsim_g1_2 2 120
+ api_equal json:policy_types?ric=ricsim_g1_3 3 120
+ api_equal json:policy_types?ric=ricsim_g1_4 4 120
+ api_equal json:policy_types?ric=ricsim_g1_5 5 120
+ api_equal json:policy_types?ric=ricsim_g1_6 4 120
+ api_equal json:policy_types?ric=ricsim_g1_7 3 120
+ api_equal json:policy_types?ric=ricsim_g1_8 2 120
+ api_equal json:policy_types?ric=ricsim_g1_9 1 120
+ api_equal json:policy_types?ric=ricsim_g1_10 0 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \
+ ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
+ ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
+
+
+ #No policy type in sim #10
+
+ api_equal json:policy_types 5
+
+ api_put_service 201 "serv1" 3600 "$CR_PATH/serv1"
+
+ api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT testdata/OSC/pi5_template.json 1
+
+ api_equal json:policy_ids 1
+
+ sim_equal ricsim_g1_9 num_instances 1
+
+
+ # Load config with reduced number of rics
+ consul_config_app ".consul_config_2.json"
+
+ api_equal json:rics 8 120
+
+ echo "Check the number of types in the agent for each ric"
+ api_equal json:policy_types?ric=ricsim_g1_1 1 120
+ api_equal json:policy_types?ric=ricsim_g1_2 2 120
+ api_equal json:policy_types?ric=ricsim_g1_3 3 120
+ api_equal json:policy_types?ric=ricsim_g1_4 4 120
+ api_equal json:policy_types?ric=ricsim_g1_5 5 120
+ api_equal json:policy_types?ric=ricsim_g1_6 4 120
+ api_equal json:policy_types?ric=ricsim_g1_7 3 120
+ api_equal json:policy_types?ric=ricsim_g1_8 2 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? "
+
+ sleep 120
+
+ api_equal json:policy_ids 0
+
+ api_get_policy_types 404 ricsim_g1_9
+
+ sim_equal ricsim_g1_9 num_instances 1
+
+ api_delete_policy 404 2000
+
+ # Load config with all rics
+ consul_config_app ".consul_config_all.json"
+
+ api_equal json:rics 10 120
+
+ echo "Check the number of types in the agent for each ric"
+ api_equal json:policy_types?ric=ricsim_g1_1 1 120
+ api_equal json:policy_types?ric=ricsim_g1_2 2 120
+ api_equal json:policy_types?ric=ricsim_g1_3 3 120
+ api_equal json:policy_types?ric=ricsim_g1_4 4 120
+ api_equal json:policy_types?ric=ricsim_g1_5 5 120
+ api_equal json:policy_types?ric=ricsim_g1_6 4 120
+ api_equal json:policy_types?ric=ricsim_g1_7 3 120
+ api_equal json:policy_types?ric=ricsim_g1_8 2 120
+ api_equal json:policy_types?ric=ricsim_g1_9 1 120
+ api_equal json:policy_types?ric=ricsim_g1_10 0 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \
+ ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
+ ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
+
+ sleep 120
+
+ api_equal json:policy_ids 0
+
+ sim_equal ricsim_g1_9 num_instances 0
+
+
+ sim_delete_policy_type 204 ricsim_g1_4 4
+ sim_delete_policy_type 204 ricsim_g1_5 4
+ sim_delete_policy_type 204 ricsim_g1_6 4
+ sim_delete_policy_type 204 ricsim_g1_7 4
+
+ sleep 120
+
+ api_equal json:policy_types?ric=ricsim_g1_1 1 120
+ api_equal json:policy_types?ric=ricsim_g1_2 2 120
+ api_equal json:policy_types?ric=ricsim_g1_3 3 120
+ api_equal json:policy_types?ric=ricsim_g1_4 3 120
+ api_equal json:policy_types?ric=ricsim_g1_5 4 120
+ api_equal json:policy_types?ric=ricsim_g1_6 3 120
+ api_equal json:policy_types?ric=ricsim_g1_7 2 120
+ api_equal json:policy_types?ric=ricsim_g1_8 2 120
+ api_equal json:policy_types?ric=ricsim_g1_9 1 120
+ api_equal json:policy_types?ric=ricsim_g1_10 0 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,5:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,5:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,5:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \
+ ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
+ ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
+
+ sim_delete_policy_type 204 ricsim_g1_8 4
+
+ api_equal json:policy_types?ric=ricsim_g1_8 1 120
+
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
+ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
+ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
+ ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3:???? \
+ ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,5:???? \
+ ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,5:???? \
+ ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,5:???? \
+ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:5:???? \
+ ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
+ ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
+
+
+
+ check_policy_agent_logs
+ store_logs ${interface}
+done
+
+
+
+
+
+#### TEST COMPLETE ####
+
+
+print_result
+
+auto_clean_containers
\ No newline at end of file
diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh
index d948e37..6bab06b 100755
--- a/test/auto-test/FTC800.sh
+++ b/test/auto-test/FTC800.sh
@@ -19,6 +19,9 @@
TC_ONELINE_DESCR="Create 10000 policies in sequence using http/https and Agent REST/DMAAP with/without SDNC controller"
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
@@ -133,10 +136,10 @@
api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulators
- api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1"
+ api_put_service 201 "serv1" 3600 "$CR_PATH/1"
start_timer "Create polices in OSC via agent REST and $interface using "$__httpx
- api_put_policy 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES
+ api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES
print_timer "Create polices in OSC via agent REST and $interface using "$__httpx
sim_equal ricsim_g1_1 num_instances $NUM_POLICIES
@@ -144,7 +147,7 @@
START_ID=$(($START_ID+$NUM_POLICIES))
start_timer "Create polices in STD via agent REST and $interface using "$__httpx
- api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES
+ api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES
print_timer "Create polices in STD via agent REST and $interface using "$__httpx
sim_equal ricsim_g2_1 num_instances $NUM_POLICIES
@@ -154,7 +157,7 @@
START_ID=$(($START_ID+$NUM_POLICIES))
start_timer "Create polices in OSC via agent DMAAP, one by one, and $interface using "$__httpx
- api_put_policy 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES
+ api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES
print_timer "Create polices in OSC via agent DMAAP, one by one, and $interface using "$__httpx
sim_equal ricsim_g1_1 num_instances $((2*$NUM_POLICIES))
@@ -162,7 +165,7 @@
START_ID=$(($START_ID+$NUM_POLICIES))
start_timer "Create polices in STD via agent DMAAP, one by one, and $interface using "$__httpx
- api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES
+ api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES
print_timer "Create polices in STD via agent DMAAP, one by one, and $interface using "$__httpx
sim_equal ricsim_g2_1 num_instances $((2*$NUM_POLICIES))
@@ -170,7 +173,7 @@
START_ID=$(($START_ID+$NUM_POLICIES))
start_timer "Create polices in OSC via agent DMAAP in batch and $interface using "$__httpx
- api_put_policy_batch 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES
+ api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES
print_timer "Create polices in OSC via agent DMAAP in batch and $interface using "$__httpx
sim_equal ricsim_g1_1 num_instances $((3*$NUM_POLICIES))
@@ -178,7 +181,7 @@
START_ID=$(($START_ID+$NUM_POLICIES))
start_timer "Create polices in STD via agent DMAAP in batch and $interface using "$__httpx
- api_put_policy_batch 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES
+ api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES
print_timer "Create polices in STD via agent DMAAP in batch and $interface using "$__httpx
sim_equal ricsim_g2_1 num_instances $((3*$NUM_POLICIES))
diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh
index 2631a16..2dae7e7 100755
--- a/test/auto-test/FTC810.sh
+++ b/test/auto-test/FTC810.sh
@@ -17,7 +17,10 @@
# ============LICENSE_END=================================================
#
-TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h. Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http"
+TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http or https"
+
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -34,8 +37,23 @@
# Number of policy instances per RIC
NUM_INSTANCES=5
+DAYS=3
+
clean_containers
+# use http or https for all apis
+HTTPX=https
+
+if [ $HTTPX == "http" ]; then
+ use_agent_rest_http
+ use_sdnc_http
+ use_simulator_http
+else
+ use_agent_rest_https
+ use_sdnc_https
+ use_simulator_https
+fi
+
start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
@@ -55,7 +73,6 @@
start_policy_agent
-use_agent_rest_http
api_get_status 200
@@ -101,10 +118,10 @@
echo "Register a service"
api_put_service 201 "serv1" 0 "$CR_PATH/1"
-TEST_DURATION=$((24*3600))
+TEST_DURATION=$((24*3600*$DAYS))
TEST_START=$SECONDS
-AGENT_INTERFACES="REST DMAAP DMAAP-BATCH"
+AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
MR_MESSAGES=0
@@ -122,8 +139,12 @@
echo "## Testing using agent interface: $interface ##"
echo "############################################"
- if [ $interface == "REST" ]; then
- use_agent_rest_http
+ if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
+ if [ $HTTPX == "http" ]; then
+ use_agent_rest_http
+ else
+ use_agent_rest_https
+ fi
else
use_agent_dmaap
fi
@@ -131,14 +152,17 @@
echo "Create $NUM_INSTANCES instances in each OSC RIC"
INSTANCE_ID=200000
INSTANCES=0
+ if [ $interface == "REST_PARALLEL" ]; then
+ api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3
+ fi
for ((i=1; i<=$NUM_RICS; i++))
do
if [ $interface == "DMAAP-BATCH" ]; then
- api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
- else
- api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
+ api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
+ elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
+ api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
fi
- if [ $interface != "REST" ]; then
+ if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
fi
sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
@@ -149,14 +173,17 @@
api_equal json:policy_ids $INSTANCES
echo "Create $NUM_INSTANCES instances in each STD RIC"
+ if [ $interface == "REST_PARALLEL" ]; then
+ api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3
+ fi
for ((i=1; i<=$NUM_RICS; i++))
do
if [ $interface == "DMAAP-BATCH" ]; then
- api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
- else
- api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
+ api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
+ elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
+ api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
fi
- if [ $interface != "REST" ]; then
+ if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
fi
sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
@@ -170,14 +197,17 @@
echo "Delete all instances in each OSC RIC"
INSTANCE_ID=200000
+ if [ $interface == "REST_PARALLEL" ]; then
+ api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
+ fi
for ((i=1; i<=$NUM_RICS; i++))
do
if [ $interface == "DMAAP-BATCH" ]; then
api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
- else
+ elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
fi
- if [ $interface != "REST" ]; then
+ if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
fi
INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
@@ -189,14 +219,17 @@
echo "Delete all instances in each STD RIC"
+ if [ $interface == "REST_PARALLEL" ]; then
+ api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
+ fi
for ((i=1; i<=$NUM_RICS; i++))
do
if [ $interface == "DMAAP-BATCH" ]; then
api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
- else
+ elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
fi
- if [ $interface != "REST" ]; then
+ if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
fi
INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh
new file mode 100755
index 0000000..f45246d
--- /dev/null
+++ b/test/auto-test/FTC850.sh
@@ -0,0 +1,170 @@
+#!/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=================================================
+#
+
+TC_ONELINE_DESCR="Create/delete policies in parallel over a number of ric using a number of child process"
+
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC_ONAP"
+
+. ../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"
+
+# Tested variants of REST/DMAAP/SDNC config
+TESTED_VARIANTS="REST REST+SDNC"
+
+#Test agent and simulator protocol versions (others are http only)
+TESTED_PROTOCOLS="HTTP HTTPS"
+
+NUM_RICS=20
+NUM_POLICIES_PER_RIC=500
+
+for __httpx in $TESTED_PROTOCOLS ; do
+ for interface in $TESTED_VARIANTS ; do
+
+ echo "#####################################################################"
+ echo "#####################################################################"
+ echo "### Testing agent: "$interface" and "$__httpx
+ echo "#####################################################################"
+ echo "#####################################################################"
+
+
+ # Clean container and start all needed containers #
+ clean_containers
+
+ if [ $__httpx == "HTTPS" ]; then
+ echo "Using secure ports towards simulators and sdnc"
+ use_simulator_https
+ use_sdnc_https
+ else
+ echo "Using non-secure ports towards simulators and sdnc"
+ use_simulator_http
+ use_sdnc_http
+ fi
+
+ start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
+
+ start_consul_cbs
+
+ if [[ $interface = *"SDNC"* ]]; then
+ start_sdnc
+ prepare_consul_config SDNC ".consul_config.json"
+ else
+ prepare_consul_config NOSDNC ".consul_config.json"
+ fi
+
+ consul_config_app ".consul_config.json"
+
+ start_mr # Not used, but removes error messages from the agent log
+
+ start_policy_agent
+
+ set_agent_debug
+
+ if [ $__httpx == "HTTPS" ]; then
+ echo "Using secure ports towards the agent"
+ use_agent_rest_https
+ else
+ echo "Using non-secure ports towards the agent"
+ use_agent_rest_http
+ fi
+
+ api_get_status 200
+
+ for ((i=1; i<=$NUM_RICS; i++))
+ do
+ sim_print ricsim_g1_$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
+
+
+ api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator
+
+ api_put_service 201 "serv1" 600 "$CR_PATH/1"
+
+ 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
+
+ START_ID=2000
+
+ start_timer "Create $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx
+
+ api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES_PER_RIC 7
+
+ print_timer "Create $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx
+
+ INSTANCES=$(($NUM_RICS*$NUM_POLICIES_PER_RIC))
+ api_equal json:policies $INSTANCES
+
+ for ((i=1; i<=$NUM_RICS; i++))
+ do
+ sim_equal ricsim_g1_$i num_instances $NUM_POLICIES_PER_RIC
+ done
+
+ start_timer "Delete $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx
+
+ api_delete_policy_parallel 204 $NUM_RICS $START_ID $NUM_POLICIES_PER_RIC 7
+
+ print_timer "Delete $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx
+
+ api_equal json:policies 0
+
+ for ((i=1; i<=$NUM_RICS; i++))
+ do
+ sim_equal ricsim_g1_$i num_instances 0
+ done
+
+ for ((i=1; i<=$NUM_RICS; i++))
+ do
+ if [ $interface == "REST+SDNC" ]; then
+ sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
+ else
+ sim_contains_str ricsim_g1_$i remote_hosts "policy-agent"
+ fi
+ done
+
+ check_policy_agent_logs
+
+ store_logs "${__httpx}__${interface}"
+
+ done
+
+done
+
+
+#### TEST COMPLETE ####
+
+print_result
+
+auto_clean_containers
\ No newline at end of file
diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh
index 13a9af0..5a71916 100755
--- a/test/auto-test/FTC900.sh
+++ b/test/auto-test/FTC900.sh
@@ -17,7 +17,10 @@
# ============LICENSE_END=================================================
#
-TC_ONELINE_DESCR="Testing of the health check app"
+TC_ONELINE_DESCR="Testing of the Control Panel and the Health Check app - populating with types and instances"
+
+#App names to exclude checking pulling images for, space separated list
+EXCLUDED_IMAGES="SDNC SDNC_ONAP"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -32,80 +35,98 @@
clean_containers
-start_ric_simulators ricsim_g1 6 OSC_2.1.0
+OSC_NUM_RICS=6
+STD_NUM_RICS=5
-start_ric_simulators ricsim_g2 5 STD_1.1.3
+start_ric_simulators ricsim_g1 $OSC_NUM_RICS OSC_2.1.0
+start_ric_simulators ricsim_g2 $STD_NUM_RICS STD_1.1.3
+start_mr #Just to prevent errors in the agent log...
+
+start_control_panel
start_consul_cbs
prepare_consul_config NOSDNC ".consul_config.json"
consul_config_app ".consul_config.json"
-
start_policy_agent
-
use_agent_rest_http
api_get_status 200
-sim_print ricsim_g1_1 interface
-sim_print ricsim_g1_2 interface
-sim_print ricsim_g1_3 interface
-sim_print ricsim_g1_4 interface
-sim_print ricsim_g1_5 interface
-sim_print ricsim_g1_6 interface
+# Print the A1 version for OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ sim_print ricsim_g1_$i interface
+done
-sim_print ricsim_g2_1 interface
-sim_print ricsim_g2_2 interface
-sim_print ricsim_g2_3 interface
-sim_print ricsim_g2_4 interface
-sim_print ricsim_g2_5 interface
-sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
-sim_put_policy_type 201 ricsim_g1_2 1 testdata/OSC/sim_1.json
-sim_put_policy_type 201 ricsim_g1_3 1 testdata/OSC/sim_1.json
-sim_put_policy_type 201 ricsim_g1_4 1 testdata/OSC/sim_1.json
-sim_put_policy_type 201 ricsim_g1_5 1 testdata/OSC/sim_1.json
-sim_put_policy_type 201 ricsim_g1_6 1 testdata/OSC/sim_1.json
+# Print the A1 version for STD
+for ((i=1; i<=$STD_NUM_RICS; i++))
+do
+ sim_print ricsim_g2_$i interface
+done
-api_equal json:policy_types 2 120
-sleep_wait 30 "Give the agent some extra time...."
+# Load the polictypes in osc
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ sim_put_policy_type 201 ricsim_g1_$i 2 testdata/OSC/sim_hw.json
+ sim_put_policy_type 201 ricsim_g1_$i 20008 testdata/OSC/sim_tsa.json
+done
+
+
+#Check the number of schemas and the individual schemas in OSC
+api_equal json:policy_types 3 120
+
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ api_equal json:policy_types?ric=ricsim_g1_$i 2 120
+done
+
+# Check the schemas in OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ api_get_policy_schema 200 2 testdata/OSC/hw-agent-modified.json
+ api_get_policy_schema 200 20008 testdata/OSC/tsa-agent-modified.json
+done
+
# Create policies
use_agent_rest_http
-api_put_service 201 "rapp1" 3600 "$CR_PATH/1"
+api_put_service 201 "rapp1" 0 "$CR_PATH/1"
-api_put_policy 201 "rapp1" ricsim_g1_1 1 2010 testdata/OSC/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g1_2 1 2020 testdata/OSC/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g1_3 1 2030 testdata/OSC/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g1_4 1 2040 testdata/OSC/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g1_5 1 2050 testdata/OSC/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g1_6 1 2060 testdata/OSC/pi1_template.json 1
+# Create policies in OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ api_put_policy 201 "rapp1" ricsim_g1_$i 2 $((2000+$i)) NOTRANSIENT testdata/OSC/pihw_template.json 1
+ api_put_policy 201 "rapp1" ricsim_g1_$i 20008 $((2050+$i*10)) NOTRANSIENT testdata/OSC/pitsa_template.json 1
+done
-sim_equal ricsim_g1_1 num_instances 1
-sim_equal ricsim_g1_2 num_instances 1
-sim_equal ricsim_g1_3 num_instances 1
-sim_equal ricsim_g1_4 num_instances 1
-sim_equal ricsim_g1_5 num_instances 1
-sim_equal ricsim_g1_6 num_instances 1
-api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 2110 testdata/STD/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g2_2 NOTYPE 2120 testdata/STD/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g2_3 NOTYPE 2130 testdata/STD/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g2_4 NOTYPE 2140 testdata/STD/pi1_template.json 1
-api_put_policy 201 "rapp1" ricsim_g2_5 NOTYPE 2150 testdata/STD/pi1_template.json 1
+# Check the number of policies in OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ sim_equal ricsim_g1_$i num_instances 2
+done
-sim_equal ricsim_g2_1 num_instances 1
-sim_equal ricsim_g2_2 num_instances 1
-sim_equal ricsim_g2_3 num_instances 1
-sim_equal ricsim_g2_4 num_instances 1
-sim_equal ricsim_g2_5 num_instances 1
+# Create policies in STD
+for ((i=1; i<=$STD_NUM_RICS; i++))
+do
+ api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $((2100+$i)) NOTRANSIENT testdata/STD/pi1_template.json 1
+done
+
+
+# Check the number of policies in STD
+for ((i=1; i<=$STD_NUM_RICS; i++))
+do
+ sim_equal ricsim_g2_$i num_instances 1
+done
check_policy_agent_logs
diff --git a/test/auto-test/Suite-all.sh b/test/auto-test/Suite-all.sh
new file mode 100755
index 0000000..342596d
--- /dev/null
+++ b/test/auto-test/Suite-all.sh
@@ -0,0 +1,48 @@
+#!/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=================================================
+#
+
+TS_ONELINE_DESCR="Test suite - all test cases except the stab test(s)"
+
+. ../common/testsuite_common.sh
+
+suite_setup
+
+############# TEST CASES #################
+ARG1=$1
+
+./FTC1.sh $1
+
+if [ $ARG1 == "remote-remove" ]; then
+ #Prevent image removal for every test case
+ ARG1="remote"
+fi
+
+./FTC10.sh $1
+./FTC100.sh $1
+./FTC110.sh $1
+./FTC150.sh $1
+./FTC300.sh $1
+./FTC310.sh $1
+./FTC350.sh $1
+./FTC800.sh $1
+./FTC850.sh $1
+
+##########################################
+
+suite_complete
\ No newline at end of file
diff --git a/test/auto-test/Suite-interfaces.sh b/test/auto-test/Suite-interfaces.sh
index 1723555..7a21646 100755
--- a/test/auto-test/Suite-interfaces.sh
+++ b/test/auto-test/Suite-interfaces.sh
@@ -25,9 +25,17 @@
############# TEST CASES #################
-./FTC100.sh $1
-./FTC110.sh $1
-./FTC150.sh $1
+ARG1=$1
+
+./FTC100.sh $ARG1
+
+if [ $ARG1 == "remote-remove" ]; then
+ #Prevent image removal for every test case
+ ARG1="remote"
+fi
+
+./FTC110.sh $ARG1
+./FTC150.sh $ARG1
##########################################
diff --git a/test/auto-test/testdata/OSC/3-agent-modified.json b/test/auto-test/testdata/OSC/3-agent-modified.json
new file mode 100644
index 0000000..303b36b
--- /dev/null
+++ b/test/auto-test/testdata/OSC/3-agent-modified.json
@@ -0,0 +1,36 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "3",
+ "description": "Type 3 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "groupId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+ }
diff --git a/test/auto-test/testdata/OSC/3.json b/test/auto-test/testdata/OSC/3.json
new file mode 100644
index 0000000..ab0204d
--- /dev/null
+++ b/test/auto-test/testdata/OSC/3.json
@@ -0,0 +1,36 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type3_1.0.0",
+ "description": "Type 3 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "groupId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+}
diff --git a/test/auto-test/testdata/OSC/4-agent-modified.json b/test/auto-test/testdata/OSC/4-agent-modified.json
new file mode 100644
index 0000000..868ceea
--- /dev/null
+++ b/test/auto-test/testdata/OSC/4-agent-modified.json
@@ -0,0 +1,36 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "4",
+ "description": "Type 4 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "cellId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "cellId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+ }
diff --git a/test/auto-test/testdata/OSC/4.json b/test/auto-test/testdata/OSC/4.json
new file mode 100644
index 0000000..c5e785c
--- /dev/null
+++ b/test/auto-test/testdata/OSC/4.json
@@ -0,0 +1,36 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type4_1.0.0",
+ "description": "Type 4 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "cellId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "cellId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+}
diff --git a/test/auto-test/testdata/OSC/5-agent-modified.json b/test/auto-test/testdata/OSC/5-agent-modified.json
new file mode 100644
index 0000000..b5fd5bc
--- /dev/null
+++ b/test/auto-test/testdata/OSC/5-agent-modified.json
@@ -0,0 +1,40 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "5",
+ "description": "Type 5 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "sliceId": {
+ "type": "string"
+ },
+ "cellId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "sliceId",
+ "cellId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+ }
diff --git a/test/auto-test/testdata/OSC/5.json b/test/auto-test/testdata/OSC/5.json
new file mode 100644
index 0000000..dee440a
--- /dev/null
+++ b/test/auto-test/testdata/OSC/5.json
@@ -0,0 +1,40 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type5_1.0.0",
+ "description": "Type 5 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "sliceId": {
+ "type": "string"
+ },
+ "cellId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "sliceId",
+ "cellId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+}
diff --git a/test/auto-test/testdata/OSC/hw-agent-modified.json b/test/auto-test/testdata/OSC/hw-agent-modified.json
new file mode 100644
index 0000000..c48736e
--- /dev/null
+++ b/test/auto-test/testdata/OSC/hw-agent-modified.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "2",
+ "description": "HW policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/hw.json b/test/auto-test/testdata/OSC/hw.json
new file mode 100644
index 0000000..684f80d
--- /dev/null
+++ b/test/auto-test/testdata/OSC/hw.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "HW Policy",
+ "description": "HW policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/pi3_template.json b/test/auto-test/testdata/OSC/pi3_template.json
new file mode 100644
index 0000000..a916fad
--- /dev/null
+++ b/test/auto-test/testdata/OSC/pi3_template.json
@@ -0,0 +1,8 @@
+{
+ "scope": {
+ "groupId": "groupXXX"
+ },
+ "qosObjective": {
+ "priorityLevel": XXX
+ }
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/pi4_template.json b/test/auto-test/testdata/OSC/pi4_template.json
new file mode 100644
index 0000000..0673dec
--- /dev/null
+++ b/test/auto-test/testdata/OSC/pi4_template.json
@@ -0,0 +1,8 @@
+{
+ "scope": {
+ "cellId": "cellXXX"
+ },
+ "qosObjective": {
+ "priorityLevel": XXX
+ }
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/pi5_template.json b/test/auto-test/testdata/OSC/pi5_template.json
new file mode 100644
index 0000000..e362c9e
--- /dev/null
+++ b/test/auto-test/testdata/OSC/pi5_template.json
@@ -0,0 +1,9 @@
+{
+ "scope": {
+ "sliceId": "sliceXXX",
+ "cellId": "cellXXX"
+ },
+ "qosObjective": {
+ "priorityLevel": XXX
+ }
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/pihw_template.json b/test/auto-test/testdata/OSC/pihw_template.json
new file mode 100644
index 0000000..7574995
--- /dev/null
+++ b/test/auto-test/testdata/OSC/pihw_template.json
@@ -0,0 +1,3 @@
+{
+ "threshold": XXX
+}
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/pitsa_template.json b/test/auto-test/testdata/OSC/pitsa_template.json
new file mode 100644
index 0000000..7574995
--- /dev/null
+++ b/test/auto-test/testdata/OSC/pitsa_template.json
@@ -0,0 +1,3 @@
+{
+ "threshold": XXX
+}
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/sim_3.json b/test/auto-test/testdata/OSC/sim_3.json
new file mode 100644
index 0000000..1b97047
--- /dev/null
+++ b/test/auto-test/testdata/OSC/sim_3.json
@@ -0,0 +1,41 @@
+{
+ "name": "pt3",
+ "description": "pt3 policy type",
+ "policy_type_id": 3,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type3_1.0.0",
+ "description": "Type 3 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "groupId"
+ ]
+ },
+ "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_4.json b/test/auto-test/testdata/OSC/sim_4.json
new file mode 100644
index 0000000..ac1fa2b
--- /dev/null
+++ b/test/auto-test/testdata/OSC/sim_4.json
@@ -0,0 +1,41 @@
+{
+ "name": "pt4",
+ "description": "pt4 policy type",
+ "policy_type_id": 4,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type4_1.0.0",
+ "description": "Type 4 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "cellId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "cellId"
+ ]
+ },
+ "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_5.json b/test/auto-test/testdata/OSC/sim_5.json
new file mode 100644
index 0000000..4d8f3c9
--- /dev/null
+++ b/test/auto-test/testdata/OSC/sim_5.json
@@ -0,0 +1,45 @@
+{
+ "name": "pt5",
+ "description": "pt5 policy type",
+ "policy_type_id": 5,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type5_1.0.0",
+ "description": "Type 5 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "sliceId": {
+ "type": "string"
+ },
+ "cellId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "sliceId",
+ "cellId"
+ ]
+ },
+ "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_hw.json b/test/auto-test/testdata/OSC/sim_hw.json
new file mode 100644
index 0000000..65085c5
--- /dev/null
+++ b/test/auto-test/testdata/OSC/sim_hw.json
@@ -0,0 +1,18 @@
+{
+ "name": "hwpolicy",
+ "description": "Hellow World policy type",
+ "policy_type_id": 2,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "HW Policy",
+ "description": "HW policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/sim_tsa.json b/test/auto-test/testdata/OSC/sim_tsa.json
new file mode 100644
index 0000000..4520cfa
--- /dev/null
+++ b/test/auto-test/testdata/OSC/sim_tsa.json
@@ -0,0 +1,18 @@
+{
+ "name": "tsapolicy",
+ "description": "tsa parameters",
+ "policy_type_id": 20008,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "TS Policy",
+ "description": "TS policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
+}
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/tsa-agent-modified.json b/test/auto-test/testdata/OSC/tsa-agent-modified.json
new file mode 100644
index 0000000..7d48ff9
--- /dev/null
+++ b/test/auto-test/testdata/OSC/tsa-agent-modified.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "20008",
+ "description": "TS policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
\ No newline at end of file
diff --git a/test/auto-test/testdata/OSC/tsa.json b/test/auto-test/testdata/OSC/tsa.json
new file mode 100644
index 0000000..b1d443b
--- /dev/null
+++ b/test/auto-test/testdata/OSC/tsa.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "TS Policy",
+ "description": "TS policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
\ No newline at end of file
diff --git a/test/common/README.md b/test/common/README.md
index dd1ddf3..62ee842 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -1,35 +1,347 @@
-## Description for common test scripts
+## Introduction ##
+This dir contains most scripts needed for the auto-test environment. There are scripts with functions to adapt to the apis of the components of the Non-RT RIC; Policy Agent, A1 Controller and Ric (A1) simulator.
+Some of the scripts can also be used for other kinds of tests, for example basic tests.
+
+## Overview for common test scripts and files ##
`test_env.sh` \
-Common env variables for test in the auto-test dir.
-Used by the auto test cases/suites but could be used for other test script as well.
+Common env variables for test in the auto-test dir. All configuration of port numbers, image names and version etc shall be made in this file.
+Used by the auto test scripts/suites but could be used for other test script as well.
`testcase_common.sh` \
-Common functions for auto test cases in the auto-test dir.
-A subset of the functions could be used in other test scripts as well.
+Common functions for auto test cases in the auto-test dir. This script is the foundation of test auto environment which sets up images and enviroment variables needed by this script as well as the script adapting to the APIs.
+The included functions are described in detail further below.
-###Descriptions of functions in testcase_common.sh
+`testsuite_common.sh` \
+Common functions for running two or more auto test scripts as a suite.
-`clean_containers` \
-Stop and remove all containers including Policy Agent apps and simulators
+`agent_api_functions.sh` \
+Contains functions for adapting towards the Policy Agent API, also via dmaap (using a message-router stub interface)
-`start_simulators` \
-Start all simulators in the simulator group
+`controller_api_functions.sh` \
+Contains functions for adaping towards the A1-controller API.
-`consul_config_app ` \
-Configure consul with json file with app config for a Policy Agent instance using the Policy Agent
-instance id and the json file.
+`ricsimulator_api_functions.sh` \
+Contains functions for adapting towards the RIC (A1) simulator admin API.
-`start_policy_agent` \
-Start the Policy Agent application.
+`compare_json.py` \
+A python script to compare two json obects for equality. Note that the comparsion always sort json-arrays before comparing (that is, it does not care about the order of items within the array). In addition, the target json object may specify individual parameter values where equality is 'dont care'.
-`check_policy_agent_logs`
-Check the Policy Agent application log for WARN and ERR messages and print the count.
-`store_logs`
-Store all Policy Agent app and simulators log to the test case log dir. All logs get a prefix to
-separate logs stored at different steps in the test script.
-If logs need to be stored in several locations, use different prefix to easily identify the location
-when the logs where taken.
+`count_json_elements.py` \
+A python script returning the number of items in a json array.
+
+`create_policies_process.py` \
+A python script to create a batch of policies. The script is intended to run in a number of processes to create policies in parallel.
+
+`create_rics_json.py` \
+A python script to create a json file from a formatted string of ric info. Helper for the test enviroment.
+
+`delete_policies_process.py` \
+A python script to delete a batch of policies. The script is intended to run in a number of processes to delete policies in parallel.
+
+`extract_sdnc_reply.py` \
+A python script to extract the information from an sdnc (A1 Controller) reply json. Helper for the test environment.
+
+`do_curl_function.sh`
+A script for executing a curl call with a specific url and optional payload. It also compare the response with an expected result in terms of response code and optional returned payload. Intended to be used by test script (for example basic test scripts of other components)
+
+
+
+### Descriptions of functions in testcase_common.sh ###
+
+#### Script args ####
+The script can be started with these arguments
+
+| arg list |
+|--|
+| `local|remote|remote-remove [auto-clean] [--stop-at-error] [--use-local-image <app-nam> [<app-name>]*]` |
+
+| parameter | description |
+|-|-|
+| `local` | only locally built images (in local docker respository) will be used for the Non-RT RIC components. CBS, Consul, DB will still use remote nexus images |
+| `remote` | only remote images from nexus will be used. Images pulled if not present in local docker repository |
+| `remote-remove` | same as remote but all images are removed first so that fresh images are pulled when running |
+| `auto-clean` | all containers will be automatically stopped and removed when the test case is complete. Requires the function 'auto_clean_containers' to be included last in the applicable auto-test script |
+| `--stop-at-error` | intended for debugging and make the script stop at first 'FAIL' and save all logs with a prefix 'STOP_AT_ERROR' |
+| `--use-local-image` | Only applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC for Policy Agent, Control Panel, A1-controller and the Ric simulator |
+
+#### Function: print_result ####
+Print a test report of an auto-test script.
+| arg list |
+|--|
+| None |
+
+#### Function: start_timer ####
+Start a timer for time measurement. Only one timer can be running.
+| arg list |
+|--|
+| None - but any args will be printed (It is good practice to use same args for this function as for the `print_timer`) |
+
+#### Function: print_timer ####
+Print the value of the timer (in seconds) previously started by 'start_timer'. (Note that timer is still running after this function). The result of the timer as well as the args to the function will also be printed in the test report.
+| arg list |
+|--|
+| `<timer-message-to-print>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<timer-message-to-print>` | Any text message to be printed along with the timer result.(It is good practice to use same args for this function as for the `start_timer`) |
+
+#### Function: print_and_reset_timer ####
+Print the value of the timer (in seconds) previously started by 'start_timer'. Also reset the timer to 0. The result of the timer as well as the args to the function will also be printed in the test report.
+| arg list |
+|--|
+| `<timer-message-to-print>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<timer-message-to-print>` | Any text message to be printed along with the timer result.(It is good practice to use same args for this function as for the `start_timer`) |
+
+#### Function: deviation ####
+Mark a test as a deviation from the requirements. The list of deviations will be printed in the test report.
+| arg list |
+|--|
+| `<deviation-message-to-print>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<deviation-message-to-print>` | Any text message describing the deviation. The text will also be printed in the test report. The intention is to mark known deviations, compared to required functionality |
+
+#### Function: clean_containers ####
+Stop and remove all containers. Containers not part of the test are not affected.
+| arg list |
+|--|
+| None |
+
+#### Function: auto_clean_containers ####
+Stop and remove all containers. Containers not part of the test are not affected. This function has effect only if the test script is started with arg `auto-clean`. This intention is to use this function as the last step in an auto-test script.
+| arg list |
+|--|
+| None |
+
+#### Function: sleep_wait ####
+Make the script sleep for a number of seconds.
+| arg list |
+|--|
+| `<sleep-time-in-sec> [<any-text-in-quotes-to-be-printed>]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<sleep-time-in-sec> ` | Number of seconds to sleep |
+| `<any-text-in-quotes-to-be-printed>` | Optional. The text will be printed, if present |
+
+
+
+#### Function: consul_config_app ####
+Function to load a json config from a file into consul for the Policy Agent
+
+| arg list |
+|--|
+| `<json-config-file>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<json-config-file>` | The path to the json file to be loaded to Consul/CBS |
+
+#### Function: prepare_consul_config ####
+Function to prepare a Consul config based on the previously configured (and started simulators). Note that all simulator must be running and the test script has to configure if http or https shall be used for the components (this is done by the functions 'use_simulator_http', 'use_simulator_https', 'use_sdnc_http', 'use_sdnc_https', 'use_mr_http', 'use_mr_https')
+| arg list |
+|--|
+| `<deviation-message-to-print>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `SDNC|SDNC_ONAP|NOSDNC` | Configure based on a1-controller (SNDC), a1-adapter (SDNC_ONAP) or without a controller/adapter (NOSDNC) |
+| `<output-file>` | The path to the json output file containing the prepared config. This file is used in 'consul_config_app' |
+
+#### Function: start_consul_cbs ####
+Start the Consul and CBS containers
+| arg list |
+|--|
+| None |
+
+#### Function: use_simulator_http ####
+Use http for all API calls (A1) toward the simulator. This is the default. Admin API calls to the simulator are not affected. Note that this function shall be called before preparing the config for Consul.
+| arg list |
+|--|
+| None |
+
+#### Function: use_simulator_https ####
+Use https for all API calls (A1) toward the simulator. Admin API calls to the simulator are not affected. Note that this function shall be called before preparing the config for Consul.
+| arg list |
+|--|
+| None |
+
+#### Function: start_ric_simulators ####
+Start a group of simulator where a group may contain 1 more simulators.
+| arg list |
+|--|
+| `ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `ricsim_g1|ricsim_g2|ricsim_g3` | Base name of the simulator. Each instance will have an postfix instance id added, starting on '1'. For examplle 'ricsim_g1_1', 'ricsim_g1_2' etc |
+|`<count>`| And integer, 1 or greater. Specifies the number of simulators to start|
+|`<interface-id>`| Shall be the interface id of the simulator. See the repo 'a1-interface' for the available ids. |
+
+#### Function: start_control_panel ####
+Start the Control Panel container
+| arg list |
+|--|
+| None |
+
+#### Function: start_sdnc ####
+Start the SDNC A1 Controller container and its database container
+| arg list |
+|--|
+| None |
+
+#### Function: use_sdnc_http ####
+Use http for all API calls towards the SDNC A1 Controller. This is the default. Note that this function shall be called before preparing the config for Consul.
+| arg list |
+|--|
+| None |
+
+#### Function: use_sdnc_http ####
+Use https for all API calls towards the SDNC A1 Controller. Note that this function shall be called before preparing the config for Consul.
+| arg list |
+|--|
+| None |
+
+#### Function: start_sdnc_onap ####
+Start the SDNC A1 Adapter container and its database container
+| arg list |
+|--|
+| None |
+
+#### Function: config_sdnc_onap ####
+Configure the SDNC A1 adapter - Not implemented
+| arg list |
+|--|
+| None |
+
+#### Function: start_mr ####
+Start the Message Router stub interface container
+| arg list |
+|--|
+| None |
+
+#### Function: use_mr_http ####
+Use http for all Dmaap calls to the MR. This is the default. The admin API is not affected. Note that this function shall be called before preparing the config for Consul.
+| arg list |
+|--|
+| None |
+
+#### Function: use_mr_https ####
+Use https for all Dmaap call to the MR. The admin API is not affected. Note that this function shall be called before preparing the config for Consul.
+| arg list |
+|--|
+| None |
+
+#### Function: start_cr ####
+Start the Callback Receiver container
+| arg list |
+|--|
+| None |
+
+#### Function: start_policy_agent ####
+Start the Policy Agent container. If the test script is configured to use a stand alone Policy Agent (for example other container or stand alone app) the script will prompt for starting the stand alone Policy Agent.
+| arg list |
+|--|
+| None |
+
+#### Function: use_agent_stand_alone ####
+Configure to run the Policy Agent as a stand alone container or app. See also 'start_policy_agent'
+| arg list |
+|--|
+| None |
+
+#### Function: use_agent_rest_http ####
+Use http for all API calls to the Policy Agent. This is the default.
+| arg list |
+|--|
+| None |
+
+#### Function: use_agent_rest_https ####
+Use https for all API calls to the Policy Agent.
+| arg list |
+|--|
+| None |
+
+#### Function: use_agent_dmaap ####
+Send and recieve all API calls to the Policy Agent over Dmaap via the MR.
+| arg list |
+|--|
+| None |
+
+#### Function: set_agent_debug ####
+Configure the Policy Agent log on debug level. The Policy Agent must be running.
+| arg list |
+|--|
+| None |
+
+#### Function: set_agent_trace ####
+Configure the Policy Agent log on trace level. The Policy Agent must be running.
+| arg list |
+|--|
+| None |
+
+#### Function: use_agent_retries ####
+Configure the Policy Agent to make upto 5 retries if an API calls return any of the specified http return codes.
+| arg list |
+|--|
+| `[<response-code>]*` |
+
+| parameter | description |
+| --------- | ----------- |
+| `[<response-code>]*` | A space separated list of http response codes, may be empty to reset to 'no codes'. |
+
+#### Function: check_policy_agent_logs ####
+Check the Policy Agent log for any warnings and errors and print the count of each.
+| arg list |
+|--|
+| None |
+
+#### Function: check_control_panel_logs ####
+Check the Control Panel log for any warnings and errors and print the count of each.
+| arg list |
+|--|
+| None |
+
+#### Function: store_logs ####
+Take a snap-shot of all logs for all running containers and stores them in `./logs/<ATC-id>`. All logs will get the specified prefix in the file name. In general, one of the last steps in an auto-test script shall be to call this function. If logs shall be taken several times during a test script, different prefixes shall be used each time.
+| arg list |
+|--|
+| `<logfile-prefix>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<logfile-prefix>` | Log file prefix |
+
+
+#### Function: cr_equal ####
+TBD
+
+#### Function: mr_equal ####
+TBD
+
+#### Function: mr_greater ####
+TBD
+
+#### Function: mr_read ####
+TBD
+
+#### Function: mr_print ####
+TBD
+
+### Descriptions of functions in testsuite_common.sh ###
+TBD
+### Descriptions of functions in agent_api_function.sh ###
+TBD
+### Descriptions of functions in ricsimulator_api_functions.sh ###
+TBD
+### Descriptions of functions in controller_api_functions.sh ###
+TBD
## License
diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh
index 08c8f96..b2d6a24 100644
--- a/test/common/agent_api_functions.sh
+++ b/test/common/agent_api_functions.sh
@@ -280,6 +280,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -316,6 +317,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -346,6 +348,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -360,6 +363,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -370,15 +374,15 @@
}
# API Test function: PUT /policy
-# args: <response-code> <service-name> <ric-id> <policytype-id> <policy-id> <template-file> [<count>]
+# args: <response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <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>]" $@
+ if [ $# -lt 7 ] || [ $# -gt 8 ]; then
+ __print_err "<response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <template-file> [<count>]" $@
return 1
fi
@@ -386,33 +390,35 @@
count=0
max=1
- if [ $# -eq 7 ]; then
- max=$7
+ if [ $# -eq 8 ]; then
+ max=$8
fi
pid=$5
- file=$6
+ file=$7
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"
+ if [ $4 != "NOTYPE" ]; then
+ query=$query"&type=$4"
+ fi
+
+ if [ $6 != NOTRANSIENT ]; then
+ query=$query"&transient=$6"
fi
file=".p.json"
- sed 's/XXX/'${pid}'/g' $6 > $file
+ sed 's/XXX/'${pid}'/g' $7 > $file
res="$(__do_curl_to_agent PUT $query $file)"
status=${res:${#res}-3}
echo -ne " Creating "$count"("$max")${SAMELINE}"
-
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++))
+ __check_stop_at_error
return 1
fi
@@ -428,15 +434,15 @@
}
# API Test function: PUT /policy to run in batch
-# args: <response-code> <service-name> <ric-id> <policytype-id> <policy-id> <template-file> [<count>]
+# args: <response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <template-file> [<count>]
# (Function for test scripts)
api_put_policy_batch() {
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>]" $@
+ if [ $# -lt 7 ] || [ $# -gt 8 ]; then
+ __print_err "<response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <template-file> [<count>]" $@
return 1
fi
@@ -444,24 +450,26 @@
count=0
max=1
- if [ $# -eq 7 ]; then
- max=$7
+ if [ $# -eq 8 ]; then
+ max=$8
fi
pid=$5
- file=$6
+ file=$7
ARR=""
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"
+ if [ $4 != "NOTYPE" ]; then
+ query=$query"&type=$4"
+ fi
+
+ if [ $6 != NOTRANSIENT ]; then
+ query=$query"&transient=$6"
fi
file=".p.json"
- sed 's/XXX/'${pid}'/g' $6 > $file
+ sed 's/XXX/'${pid}'/g' $7 > $file
res="$(__do_curl_to_agent PUT_BATCH $query $file)"
status=${res:${#res}-3}
echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
@@ -471,6 +479,7 @@
echo " Requested(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status 200 (in request), got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
cid=${res:0:${#res}-3}
@@ -493,6 +502,7 @@
echo " Created(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -507,6 +517,90 @@
return 0
}
+# API Test function: PUT /policy to run in i parallel for a number of rics
+# args: <response-code> <service-name> <ric-id-base> <number-of-rics> <policytype-id> <policy-start-id> <transient> <template-file> <count-per-ric> <number-of-threads>
+# (Function for test scripts)
+api_put_policy_parallel() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -ne 10 ]; then
+ __print_err " <response-code> <service-name> <ric-id-base> <number-of-rics> <policytype-id> <policy-start-id> <transient> <template-file> <count-per-ric> <number-of-threads>" $@
+ return 1
+ fi
+ resp_code=$1; shift;
+ serv=$1; shift
+ ric_base=$1; shift;
+ num_rics=$1; shift;
+ type=$1; shift;
+ start_id=$1; shift;
+ transient=$1; shift;
+ template=$1; shift;
+ count=$1; shift;
+ pids=$1; shift;
+
+ if [ $ADAPTER != $RESTBASE ] && [ $ADAPTER != $RESTBASE_SECURE ]; then
+ echo " Info - api_put_policy_parallel uses only the agent REST interface - create over dmaap in parallel is not supported"
+ echo " Info - will execute over agent REST"
+ fi
+
+ if [ $serv == "NOSERVICE" ]; then
+ serv=""
+ fi
+ query="/policy?service=$serv"
+
+ if [ $type != "NOTYPE" ]; then
+ query=$query"&type=$type"
+ fi
+
+ if [ $transient != NOTRANSIENT ]; then
+ query=$query"&transient=$transient"
+ fi
+
+ urlbase=${ADAPTER}${query}
+
+ for ((i=1; i<=$pids; i++))
+ do
+ echo "" > ".pid${i}.res.txt"
+ echo $resp_code $urlbase $ric_base $num_rics $start_id $template $count $pids $i > ".pid${i}.txt"
+ echo $i
+ done | xargs -n 1 -I{} -P $pids bash -c '{
+ arg=$(echo {})
+ echo " Parallel process $arg started"
+ tmp=$(< ".pid${arg}.txt")
+ python3 ../common/create_policies_process.py $tmp > .pid${arg}.res.txt
+ }'
+ msg=""
+ for ((i=1; i<=$pids; i++))
+ do
+ file=".pid${i}.res.txt"
+ tmp=$(< $file)
+ if [ -z "$tmp" ]; then
+ echo " Process $i : unknown result (result file empty"
+ msg="failed"
+ else
+ res=${tmp:0:1}
+ if [ $res == "0" ]; then
+ echo " Process $i : OK"
+ else
+ echo " Process $i : failed - "${tmp:1}
+ msg="failed"
+ fi
+ fi
+ done
+ if [ -z $msg ]; then
+ echo " $(($count*$num_rics)) policies created/updated"
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+ fi
+
+ echo -e $RED" FAIL. One of more processes failed to execute" $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+}
# API Test function: DELETE /policy
# args: <response-code> <policy-id> [count]
@@ -540,6 +634,7 @@
echo " Deleted "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
let pid=$pid+1
@@ -586,6 +681,7 @@
echo " Requested(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status 200 (in request), got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
cid=${res:0:${#res}-3}
@@ -609,6 +705,7 @@
echo " Deleted(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -621,6 +718,75 @@
return 0
}
+# API Test function: DELETE /policy to run in i parallel for a number of rics
+# args: <response-code> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>
+# (Function for test scripts)
+api_delete_policy_parallel() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -ne 5 ]; then
+ __print_err " <response-code> <ric-id-base> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>" $@
+ return 1
+ fi
+ resp_code=$1; shift;
+ num_rics=$1; shift;
+ start_id=$1; shift;
+ count=$1; shift;
+ pids=$1; shift;
+
+ if [ $ADAPTER != $RESTBASE ] && [ $ADAPTER != $RESTBASE_SECURE ]; then
+ echo " Info - api_delete_policy_parallel uses only the agent REST interface - create over dmaap in parallel is not supported"
+ echo " Info - will execute over agent REST"
+ fi
+
+ query="/policy"
+
+ urlbase=${ADAPTER}${query}
+
+ for ((i=1; i<=$pids; i++))
+ do
+ echo "" > ".pid${i}.del.res.txt"
+ echo $resp_code $urlbase $num_rics $start_id $count $pids $i > ".pid${i}.del.txt"
+ echo $i
+ done | xargs -n 1 -I{} -P $pids bash -c '{
+ arg=$(echo {})
+ echo " Parallel process $arg started"
+ tmp=$(< ".pid${arg}.del.txt")
+ python3 ../common/delete_policies_process.py $tmp > .pid${arg}.del.res.txt
+ }'
+ msg=""
+ for ((i=1; i<=$pids; i++))
+ do
+ file=".pid${i}.del.res.txt"
+ tmp=$(< $file)
+ if [ -z "$tmp" ]; then
+ echo " Process $i : unknown result (result file empty"
+ msg="failed"
+ else
+ res=${tmp:0:1}
+ if [ $res == "0" ]; then
+ echo " Process $i : OK"
+ else
+ echo " Process $i : failed - "${tmp:1}
+ msg="failed"
+ fi
+ fi
+ done
+ if [ -z $msg ]; then
+ echo " $(($count*$num_rics)) deleted"
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+ fi
+
+ echo -e $RED" FAIL. One of more processes failed to execute" $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+}
+
# 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)
@@ -662,6 +828,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -685,6 +852,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -714,6 +882,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -728,6 +897,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -761,6 +931,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -786,6 +957,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -834,6 +1006,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -844,6 +1017,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -879,6 +1053,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -903,6 +1078,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -934,6 +1110,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -966,6 +1143,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -974,6 +1152,7 @@
if [ "$body" != "$3" ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -1009,6 +1188,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1018,6 +1198,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, could not create target ric info json"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1027,6 +1208,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -1063,6 +1245,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1110,6 +1293,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1136,6 +1320,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -1165,6 +1350,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1184,6 +1370,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1212,6 +1399,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -1240,6 +1428,7 @@
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh
index 37d1b40..daab47c 100644
--- a/test/common/controller_api_functions.sh
+++ b/test/common/controller_api_functions.sh
@@ -41,9 +41,9 @@
body=$(echo "$3" | sed 's/"/\\"/g')
json='{"input":{"near-rt-ric-url":"'$2'","body":"'"$body"'"}}'
fi
- echo "$json" > .sndc.payload.json
+ echo "$json" > .sdnc.payload.json
echo " FILE: $json" >> $HTTPLOG
- curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sndc.payload.json"
+ curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sdnc.payload.json"
echo " CMD: "$curlString >> $HTTPLOG
res=$($curlString)
retcode=$?
@@ -98,12 +98,14 @@
if [ $? -ne 0 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
body=${res:0:${#res}-3}
@@ -128,6 +130,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -163,12 +166,14 @@
if [ $? -ne 0 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
body=${res:0:${#res}-3}
@@ -184,6 +189,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
@@ -222,12 +228,14 @@
if [ $? -ne 0 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -268,12 +276,14 @@
if [ $? -ne 0 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -325,12 +335,14 @@
if [ $? -ne 0 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
if [ $status -ne $1 ]; then
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
@@ -343,6 +355,7 @@
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
+ __check_stop_at_error
return 1
fi
fi
diff --git a/test/common/create_policies_process.py b/test/common/create_policies_process.py
new file mode 100644
index 0000000..19a77ba
--- /dev/null
+++ b/test/common/create_policies_process.py
@@ -0,0 +1,79 @@
+# ============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 script create/update policies spread over a number rics
+# Intended for parallel processing
+# Returns a string with result, either "0" for ok, or "1<fault description>"
+
+import os
+import json
+import sys
+import requests
+import traceback
+
+# disable warning about unverified https requests
+from requests.packages import urllib3
+
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+
+#arg responsecode baseurl ric_base num_rics startid templatepath count pids pid_id
+try:
+ if len(sys.argv) != 10:
+ print("1Expected 9 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl ric_base num_rics startid templatepath count pids pid_id")
+ sys.exit()
+
+ responsecode=int(sys.argv[1])
+ baseurl=sys.argv[2]
+ ric_base=sys.argv[3]
+ num_rics=int(sys.argv[4])
+ start=int(sys.argv[5])
+ templatepath=sys.argv[6]
+ count=int(sys.argv[7])
+ pids=int(sys.argv[8])
+ pid_id=int(sys.argv[9])
+
+ with open(templatepath, 'r') as file:
+ template = file.read()
+
+ start=start
+ stop=count*num_rics+start
+
+ for i in range(start,stop):
+ if (i%pids == (pid_id-1)):
+ payload=template.replace("XXX",str(i))
+ ric_id=(i%num_rics)+1
+ ric=ric_base+str(ric_id)
+ url=baseurl+"&id="+str(i)+"&ric="+str(ric)
+ try:
+ headers = {'Content-type': 'application/json'}
+ resp=requests.put(url, json.dumps(json.loads(payload)), headers=headers, verify=False, timeout=90)
+ except Exception as e1:
+ print("1Put failed for id:"+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
+ sys.exit()
+ if (resp.status_code == None):
+ print("1Put failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: None")
+ sys.exit()
+ if (resp.status_code != responsecode):
+ print("1Put failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code))
+ sys.exit()
+
+ print("0")
+ sys.exit()
+
+except Exception as e:
+ print("1"+str(e))
+sys.exit()
\ No newline at end of file
diff --git a/test/common/delete_policies_process.py b/test/common/delete_policies_process.py
new file mode 100644
index 0000000..fe87919
--- /dev/null
+++ b/test/common/delete_policies_process.py
@@ -0,0 +1,69 @@
+# ============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 script delete policies spread over a number rics
+# Intended for parallel processing
+# Returns a string with result, either "0" for ok, or "1<fault description>"
+
+import os
+import json
+import sys
+import requests
+import traceback
+
+# disable warning about unverified https requests
+from requests.packages import urllib3
+
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+
+#arg responsecode baseurl num_rics startid count pids pid_id
+
+try:
+ if len(sys.argv) != 8:
+ print("1Expected 7 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl num_rics startid count pids pid_id")
+ sys.exit()
+
+ responsecode=int(sys.argv[1])
+ baseurl=sys.argv[2]
+ num_rics=int(sys.argv[3])
+ start=int(sys.argv[4])
+ count=int(sys.argv[5])
+ pids=int(sys.argv[6])
+ pid_id=int(sys.argv[7])
+
+ stop=count*num_rics+start
+ for i in range(start,stop):
+ if (i%pids == (pid_id-1)):
+ url=str(baseurl+"?id="+str(i))
+ try:
+ resp=requests.delete(url, verify=False, timeout=90)
+ except Exception as e1:
+ print("1Delete failed for id:"+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
+ sys.exit()
+ if (resp.status_code == None):
+ print("1Delete failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: None")
+ sys.exit()
+ if (resp.status_code != responsecode):
+ print("1Delete failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code))
+ sys.exit()
+
+ print("0")
+ sys.exit()
+
+except Exception as e:
+ print("1"+str(e))
+sys.exit()
\ No newline at end of file
diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh
index c30af1a..f003559 100644
--- a/test/common/ricsimulator_api_functions.sh
+++ b/test/common/ricsimulator_api_functions.sh
@@ -214,7 +214,7 @@
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/delay"
+ curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/forcedelay"
if [ $# -eq 3 ]; then
curlString=$curlString"?delay="$3
fi
diff --git a/test/common/test_env.sh b/test/common/test_env.sh
index 24a9561..afe81c9 100755
--- a/test/common/test_env.sh
+++ b/test/common/test_env.sh
@@ -41,10 +41,10 @@
# 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_LOCAL_IMAGE_TAG="1.7.5-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_A1_CONTROLLER_REMOTE_IMAGE_TAG="1.7.5"
#SDNC DB remote image and tag
diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh
index 57344fb..4d89d0c 100755
--- a/test/common/testcase_common.sh
+++ b/test/common/testcase_common.sh
@@ -43,6 +43,12 @@
exit 1
fi
+tmp=$(which docker-compose)
+if [ $? -ne 0 ] || [ -z tmp ]; then
+ echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED
+ exit 1
+fi
+
# Just resetting any previous echo formatting...
echo -ne $EBOLD
@@ -85,6 +91,12 @@
# Var to hold 'auto' in case containers shall be stopped when test case ends
AUTO_CLEAN=""
+# Var to hold the app names to use local image for when running 'remote' or 'remote-remove'
+USE_LOCAL_IMAGES=""
+
+# Use this var (STOP_AT_ERROR=1 in the test script) for debugging/trouble shooting to take all logs and exit at first FAIL test case
+STOP_AT_ERROR=0
+
# Set a description string for the test case
if [ -z "$TC_ONELINE_DESCR" ]; then
TC_ONELINE_DESCR="<no-description>"
@@ -112,6 +124,11 @@
HTTPLOG=$PWD"/.httplog_"$ATC".txt"
echo "" > $HTTPLOG
+#Create result file (containing '1' for error) for this test case
+#Will be replaced with a file containing '0' if script is ok
+
+echo "1" > "$PWD/.result$ATC.txt"
+
# Create a log dir for the test case
mkdir -p $TESTLOGS/$ATC
@@ -151,6 +168,48 @@
echo "-------------------------------------------------------------------------------------------------"
echo "----------------------------------- Test case setup -----------------------------------"
+START_ARG=$1
+paramerror=0
+if [ $# -lt 1 ]; then
+ paramerror=1
+fi
+if [ $paramerror -eq 0 ]; then
+ if [ "$1" != "remote" ] && [ "$1" != "remote-remove" ] && [ "$1" != "local" ]; then
+ paramerror=1
+ else
+ shift;
+ fi
+fi
+if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "auto-clean" ]; then
+ AUTO_CLEAN="auto"
+ shift;
+ fi
+fi
+if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--stop-at-error" ]; then
+ STOP_AT_ERROR=1
+ shift;
+ fi
+fi
+if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-local-image" ]; then
+ USE_LOCAL_IMAGES=${@:2}
+ while [ $# -gt 0 ]; do
+ shift;
+ done
+ fi
+fi
+
+if [ $paramerror -eq 0 ] && [ $# -gt 0 ]; then
+ paramerror=1
+fi
+
+if [ $paramerror -eq 1 ]; then
+ echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--use-local-image <app-nam> [<app-name>]*]"$ERED
+ exit 1
+fi
+
echo -e $BOLD"Checking configured image setting for this test case"$EBOLD
#Temp var to check for image variable name errors
@@ -195,62 +254,100 @@
#echo " Configured image for ${1} (script start arg=${2}): "$image":"$tag
}
+
+#Check if app local image shall override remote image
+__check_image_local_override() {
+ for im in $USE_LOCAL_IMAGES; do
+ if [ "$1" == "$im" ]; then
+ return 1
+ fi
+ done
+ return 0
+}
+
+#Check if app uses image excluded from this test run
+__check_excluded_image() {
+ for im in $EXCLUDED_IMAGES; do
+ if [ "$1" == "$im" ]; then
+ return 1
+ fi
+ done
+ return 0
+}
+
# 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
+
+if [ $START_ARG == "local" ]; then
#Local agent image
- __check_image_var " Policy Agent" $1 "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
+ __check_image_var " Policy Agent" $START_ARG "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"
+ __check_image_var " Control Panel" $START_ARG "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"
+ __check_image_var " SDNC A1 Controller" $START_ARG "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"
+ __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
-elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
+elif [ $START_ARG == "remote" ] || [ $START_ARG == "remote-remove" ]; then
- #Remote agent image
- __check_image_var " Policy Agent" $1 "POLICY_AGENT_IMAGE" "POLICY_AGENT_REMOTE_IMAGE" "POLICY_AGENT_REMOTE_IMAGE_TAG"
+ __check_image_local_override 'PA'
+ if [ $? -eq 0 ]; then
+ #Remote agent image
+ __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_REMOTE_IMAGE" "POLICY_AGENT_REMOTE_IMAGE_TAG"
+ else
+ #Local agent image
+ __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
+ fi
- #Remote Control Panel image
- __check_image_var " Control Panel" $1 "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE_TAG"
+ __check_image_local_override 'CP'
+ if [ $? -eq 0 ]; then
+ #Remote Control Panel image
+ __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE_TAG"
+ else
+ #Local Control Panel image
+ __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG"
+ fi
- #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"
+ __check_image_local_override 'SDNC'
+ if [ $? -eq 0 ]; then
+ #Remote SDNC image
+ __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG"
+ else
+ #Local SNDC image
+ __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG"
+ fi
- #Remote ric sim image
- __check_image_var " RIC Simulator" $1 "RIC_SIM_IMAGE" "RIC_SIM_REMOTE_IMAGE" "RIC_SIM_REMOTE_IMAGE_TAG"
+ __check_image_local_override 'RICSIM'
+ if [ $? -eq 0 ]; then
+ #Remote ric sim image
+ __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_REMOTE_IMAGE" "RIC_SIM_REMOTE_IMAGE_TAG"
+ else
+ #Local ric sim image
+ __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
+ fi
else
- echo "Expected arg: local|remote|remote-remove [auto-clean]"
+ #Should never get here....
+ echo "Unknow args: "$@
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"
-__check_image_var " SDNC ONAP A1 Adapter" $1 "SDNC_ONAP_A1_ADAPTER_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG"
-__check_image_var " SDNC ONAP DB" $1 "SDNC_ONAP_DB_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE_TAG"
+__check_image_var " Message Router" $START_ARG "MRSTUB_IMAGE" "MRSTUB_LOCAL_IMAGE" "MRSTUB_LOCAL_IMAGE_TAG"
+__check_image_var " Callback Receiver" $START_ARG "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_IMAGE_TAG"
+__check_image_var " Consul" $START_ARG "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG"
+__check_image_var " CBS" $START_ARG "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG"
+__check_image_var " SDNC DB" $START_ARG "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG"
+__check_excluded_image 'SDNC_ONAP'
+if [ $? -eq 0 ]; then
+ __check_image_var " SDNC ONAP A1 Adapter" $START_ARG "SDNC_ONAP_A1_ADAPTER_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG"
+ __check_image_var " SDNC ONAP DB" $START_ARG "SDNC_ONAP_DB_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE_TAG"
+fi
#Errors in image setting - exit
if [ $IMAGE_ERR -ne 0 ]; then
@@ -258,7 +355,7 @@
fi
#Print a tables of the image settings
-echo -e $BOLD"Images configured for start arg: "$1 $EBOLD
+echo -e $BOLD"Images configured for start arg: "$START $EBOLD
column -t -s $'\t' $image_list_file
echo ""
@@ -369,19 +466,48 @@
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
+START_ARG_MOD=$START_ARG
+__check_image_local_override 'PA'
+if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+fi
+app="Policy Agent"; __check_and_pull_image $START_ARG_MOD "$app" $POLICY_AGENT_APP_NAME $POLICY_AGENT_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
+START_ARG_MOD=$START_ARG
+__check_image_local_override 'CP'
+if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+fi
+app="Non-RT RIC Control Panel"; __check_and_pull_image $START_ARG_MOD "$app" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_IMAGE
-echo -e $YELLOW"SDNC ONAP image is skipped"$EYELLOW
-#app="SDNC ONAP A1 Adapter"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE
-#app="SDNC ONAP DB"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE
+START_ARG_MOD=$START_ARG
+__check_image_local_override 'RICSIM'
+if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+fi
+app="Near-RT RIC Simulator"; __check_and_pull_image $START_ARG_MOD "$app" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE $RIC_SIM_IMAGE
+app="Consul"; __check_and_pull_image $START_ARG "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
+app="CBS"; __check_and_pull_image $START_ARG "$app" $CBS_APP_NAME $CBS_IMAGE
+__check_excluded_image 'SDNC'
+if [ $? -eq 0 ]; then
+ START_ARG_MOD=$START_ARG
+ __check_image_local_override 'SDNC'
+ if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+ fi
+ app="SDNC A1 Controller"; __check_and_pull_image $START_ARG_MOD "$app" $SDNC_APP_NAME $SDNC_A1_CONTROLLER_IMAGE
+ app="SDNC DB"; __check_and_pull_image $START_ARG "$app" $SDNC_APP_NAME $SDNC_DB_IMAGE
+else
+ echo -e $YELLOW" Excluding SDNC image and related DB image from image check/pull"$EYELLOW
+fi
+__check_excluded_image 'SDNC_ONAP'
+if [ $? -eq 0 ]; then
+ app="SDNC ONAP A1 Adapter"; __check_and_pull_image $START_ARG "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE
+ app="SDNC ONAP DB"; __check_and_pull_image $START_ARG "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE
+else
+ echo -e $YELLOW" Excluding ONAP SDNC image and related DB image from image check/pull"$EYELLOW
+fi
# 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
@@ -391,6 +517,7 @@
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 -e $RED"Or local image, overriding remote image, does not exist"$ERED
echo "#################################################################################################"
echo ""
exit 1
@@ -436,15 +563,21 @@
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
-echo -e " SDNC ONAP A1 Adapter\t$(docker images --format $format_string $SDNC_ONAP_A1_ADAPTER_IMAGE)" >> $docker_tmp_file
-echo -e " SDNC ONAP DB\t$(docker images --format $format_string $SDNC_ONAP_DB_IMAGE)" >> $docker_tmp_file
+__check_excluded_image 'SDNC'
+if [ $? -eq 0 ]; then
+ echo -e " SDNC A1 Controller\t$(docker images --format $format_string $SDNC_A1_CONTROLLER_IMAGE)" >> $docker_tmp_file
+ echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >> $docker_tmp_file
+fi
+__check_excluded_image 'SDNC_ONAP'
+if [ $? -eq 0 ]; then
+ echo -e " SDNC ONAP A1 Adapter\t$(docker images --format $format_string $SDNC_ONAP_A1_ADAPTER_IMAGE)" >> $docker_tmp_file
+ echo -e " SDNC ONAP DB\t$(docker images --format $format_string $SDNC_ONAP_DB_IMAGE)" >> $docker_tmp_file
+fi
column -t -s $'\t' $docker_tmp_file
@@ -474,6 +607,17 @@
echo ""
+ if [ $RES_DEVIATION -gt 0 ]; then
+ echo "Test case deviations"
+ echo "===================================="
+ cat $DEVIATION_FILE
+ fi
+ echo ""
+ echo "Timer measurement in the test script"
+ echo "===================================="
+ column -t -s $'\t' $TIMER_MEASUREMENTS
+ 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"
@@ -510,6 +654,8 @@
if [ -f .tmp_tcsuite_pass ]; then
echo " - "$ATC " -- "$TC_ONELINE_DESCR" Execution time: "$duration" seconds" >> .tmp_tcsuite_pass
fi
+ #Create file with OK exit code
+ echo "0" > "$PWD/.result$ATC.txt"
else
echo -e "One or more tests with status \033[31m\033[1mFAIL\033[0m "
echo -e "\033[31m\033[1m ___ _ ___ _ \033[0m"
@@ -528,17 +674,6 @@
fi
fi
- if [ $RES_DEVIATION -gt 0 ]; then
- echo "Test case deviations"
- echo "===================================="
- cat $DEVIATION_FILE
- fi
- echo ""
- echo "Timer measurement in the test script"
- echo "===================================="
- column -t -s $'\t' $TIMER_MEASUREMENTS
- echo ""
-
echo "++++ Number of tests: "$RES_TEST
echo "++++ Number of passed tests: "$RES_PASS
echo "++++ Number of failed tests: "$RES_FAIL
@@ -624,6 +759,16 @@
echo ""
}
+# Stop at first FAIL test case and take all logs - only for debugging/trouble shooting
+__check_stop_at_error() {
+ if [ $STOP_AT_ERROR -eq 1 ]; then
+ echo -e $RED"Test script configured to stop at first FAIL, taking all logs and stops"$ERED
+ store_logs "STOP_AT_ERROR"
+ exit 1
+ fi
+ return 0
+}
+
# Stop and remove all containers
# args: -
# (Function for test scripts)
@@ -659,11 +804,31 @@
echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}${SAMELINE}"
docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null
echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}${SAMELINE}"
- docker rm $(docker ps -qa --filter name=${CONTR}) &> /dev/null
+ docker rm --force $(docker ps -qa --filter name=${CONTR}) &> /dev/null
echo -e " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}"
done
echo ""
+
+ echo -e $BOLD" Removing docker network"$EBOLD
+ TMP=$(docker network ls -q --filter name=$DOCKER_SIM_NWNAME)
+ if [ "$TMP" == $DOCKER_SIM_NWNAME ]; then
+ docker network rm $DOCKER_SIM_NWNAME
+ if [ $? -ne 0 ]; then
+ echo -e $RED" Cannot remove docker network. Manually remove or disconnect containers from $DOCKER_SIM_NWNAME"$ERED
+ exit 1
+ fi
+ fi
+
+ echo -e $BOLD" Removing all unused docker neworks"$EBOLD
+ docker network prune --force #&> /dev/null
+
+ echo -e $BOLD" Removing all unused docker volumes"$EBOLD
+ docker volume prune --force #&> /dev/null
+
+ echo -e $BOLD" Removing all dangling/untagged docker images"$EBOLD
+ docker rmi --force $(docker images -q -f dangling=true) &> /dev/null
+ 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
@@ -678,7 +843,7 @@
}
# 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]
+# args: <sleep-time-in-sec> [any-text-in-quotes-to-be-printed]
# (Function for test scripts)
sleep_wait() {
@@ -794,7 +959,8 @@
pa_st=false
echo -ne " Waiting for container ${appname} service status...${SAMELINE}"
- for i in {1..20}; do
+ TSTART=$SECONDS
+ for i in {1..50}; do
if [ $4 == "https" ]; then
result="$(__do_curl "-k https://localhost:"${localport}${url})"
else
@@ -806,13 +972,15 @@
result="...response text too long, omitted"
fi
echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result${SAMELINE}"
- echo -ne " Container $BOLD${appname}$EBOLD$GREEN is alive$EGREEN, responds to service status:$GREEN $result $EGREEN"
+ echo -ne " Container $BOLD${appname}$EBOLD$GREEN is alive$EGREEN, responds to service status:$GREEN $result $EGREEN after $(($SECONDS-$TSTART)) seconds"
pa_st=true
break
else
- #echo " Retrying in $i seconds"
- echo -ne " Waiting for container ${appname} service status...retrying in $i seconds${SAMELINE}"
- sleep $i
+ TS_TMP=$SECONDS
+ while [ $(($TS_TMP+$i)) -gt $SECONDS ]; do
+ echo -ne " Waiting for container ${appname} service status...retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}"
+ sleep 1
+ done
fi
done
@@ -1163,6 +1331,13 @@
echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
+ __check_excluded_image 'SDNC'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The image for SDNC and the related DB has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"SDNC will not be started"$ERED
+ exit
+ fi
+
__start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT $SDNC_ALIVE_URL "http"
}
@@ -1194,6 +1369,13 @@
echo -e $BOLD"Starting SDNC ONAP A1 Adapter"$EBOLD
+ __check_excluded_image 'SDNC_ONAP'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The image for SDNC ONAP and the related DB has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"SDNC ONAP will not be started"$ERED
+ exit
+ fi
+
__start_container sdnc_onap NODOCKERARGS $SDNC_ONAP_APP_NAME $SDNC_ONAP_EXTERNAL_PORT $SDNC_ONAP_ALIVE_URL "http"
}
@@ -1353,6 +1535,20 @@
return 0
}
+# Turn on trace level tracing in the agent
+# args: -
+# (Function for test scripts)
+set_agent_trace() {
+ echo -e $BOLD"Setting agent trace"$EBOLD
+ curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H 'Content-Type: application/json' -d '{"configuredLevel":"trace"}' &> /dev/null
+ if [ $? -ne 0 ]; then
+ __print_err "could not set trace mode" $@
+ return 1
+ fi
+ echo ""
+ return 0
+}
+
# 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>]*
@@ -1426,6 +1622,7 @@
fi
echo -e $BOLD"Storing all container logs, Policy Agent app log and consul config using prefix: "$1$EBOLD
+ docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&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
@@ -1499,7 +1696,6 @@
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"$EBOLD
((RES_TEST++))
start=$SECONDS
@@ -1522,39 +1718,35 @@
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}"
+ __check_stop_at_error
return
fi
elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
((RES_PASS++))
echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
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${SAMELINE}"
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${SAMELINE}"
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${SAMELINE}"
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} ----"
+ __check_stop_at_error
return
fi
fi
@@ -1565,7 +1757,6 @@
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
@@ -1581,28 +1772,24 @@
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}"
+ __check_stop_at_error
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} ----"
+ __check_stop_at_error
fi
else
echo "Wrong args to __var_test, needs five or six args: <simulator-name> <host> <variable-name> <condition-operator> <target-value> [ <timeout> ]"
diff --git a/test/simulator-group/ric/docker-compose.yml b/test/simulator-group/ric/docker-compose.yml
index 701a7f5..70ec587 100644
--- a/test/simulator-group/ric/docker-compose.yml
+++ b/test/simulator-group/ric/docker-compose.yml
@@ -34,6 +34,7 @@
environment:
- A1_VERSION=${G1_A1_VERSION}
- REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
volumes:
- ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
g2:
@@ -46,6 +47,7 @@
environment:
- A1_VERSION=${G2_A1_VERSION}
- REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
volumes:
- ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
g3:
@@ -58,5 +60,6 @@
environment:
- A1_VERSION=${G3_A1_VERSION}
- REMOTE_HOSTS_LOGGING=1
+ - ALLOW_HTTP=true
volumes:
- ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
\ No newline at end of file
diff --git a/test/simulator-group/sdnc/docker-compose.yml b/test/simulator-group/sdnc/docker-compose.yml
index 2c8a29a..31b4e2b 100644
--- a/test/simulator-group/sdnc/docker-compose.yml
+++ b/test/simulator-group/sdnc/docker-compose.yml
@@ -55,12 +55,9 @@
environment:
- MYSQL_ROOT_PASSWORD=openECOMP1.0
- SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
- dns:
- - ${DNS_IP_ADDR-10.0.100.1}
logging:
driver: "json-file"
options:
max-size: "30m"
max-file: "5"
- extra_hosts:
- aaf.osaaf.org: 10.12.6.214
+
diff --git a/test/simulator-group/sdnc_onap/docker-compose.yml b/test/simulator-group/sdnc_onap/docker-compose.yml
index d4d757e..7aab1da 100644
--- a/test/simulator-group/sdnc_onap/docker-compose.yml
+++ b/test/simulator-group/sdnc_onap/docker-compose.yml
@@ -55,12 +55,9 @@
environment:
- MYSQL_ROOT_PASSWORD=openECOMP1.0
- SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
- dns:
- - ${DNS_IP_ADDR-10.0.100.1}
logging:
driver: "json-file"
options:
max-size: "30m"
max-file: "5"
- extra_hosts:
- aaf.osaaf.org: 10.12.6.214
+
diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js
index 76739f3..d56ad7f 100644
--- a/test/simulator-group/sim-monitor.js
+++ b/test/simulator-group/sim-monitor.js
@@ -21,20 +21,16 @@
// Presents a web page on localhost:9999/mon
var LOCALHOST="http://127.0.0.1:"
-var LOCALHOSTSECURE="https://127.0.0.1:"
-//This var may switch between LOCALHOST and LOCALHOSTSECURE
-var SIM_LOCALHOST=LOCALHOST
var MRSTUB_PORT="3905"
var AGENT_PORT="8081"
var CR_PORT="8090"
var http = require('http');
-var https = require('https');
var express = require('express');
var app = express();
var fieldSize=32;
-
+var flagstore={}
//I am alive
app.get("/",function(req, res){
@@ -42,15 +38,12 @@
})
//Get parameter valuue from other server
-function getSimCtr(httpx, url, index, cb) {
+function getSimCtr(url, index, cb) {
var data = '';
- var http_type=http
- if (httpx=="https") {
- http_type=https
- }
- console.log("URL: "+ url + " - " + httpx)
+
+ console.log("URL: "+ url + " - ")
try {
- http_type.get(url, (resp) => {
+ http.get(url, (resp) => {
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
@@ -133,6 +126,34 @@
return s;
}
+//Function to check if the previous call has returned, if so return true, if not return false
+//For preventing multiple calls to slow containers.
+function checkFunctionFlag(flag) {
+ if (flagstore.hasOwnProperty(flag)) {
+ if (flagstore[flag] == 0) {
+ flagstore[flag]=1
+ return true
+ } else if (flagstore[flag] > 10) {
+ //Reset flag after ten attempts
+ console.log("Force release flag "+flag)
+ flagstore[flag]=1
+ return true
+ } else {
+ //Previous call not returned
+ console.log("Flag not available "+flag)
+ flagstore[flag]=flagstore[flag]+1
+ return false
+ }
+ } else {
+ flagstore[flag]=1
+ return true
+ }
+}
+//Clear flag for parameter
+function clearFlag(flag) {
+ flagstore[flag]=0
+}
+
//Status variables, for parameters values fetched from other simulators
var mr1="", mr2="", mr3="", mr4="", mr5="", mr6="";
@@ -164,11 +185,6 @@
var refreshInterval=4000
-//Ignore self signed cert
-process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
-
-var sim_http_type="http"
-
function fetchAllMetrics() {
setTimeout(() => {
@@ -197,124 +213,156 @@
//Get metric values from the simulators
for(var index=0;index<simnames.length;index++) {
- try {
- if (index == 0) {
- // Check is simulator are running on http or https - no response assumes http
- getSimCtr("https",LOCALHOSTSECURE+simports[index]+"/", index, function(data, index) {
- if (data=="OK") {
- console.log("Found https simulator - assuming all simulators using https" )
- sim_http_type="https"
- SIM_LOCALHOST=LOCALHOSTSECURE
- } else {
- console.log("No https simulator found - assuming all simulators using http" )
- sim_http_type="http"
- SIM_LOCALHOST=LOCALHOST
- }
- });
- }
- } catch(err) {
- console.log("No https simulator found - assuming all simulators using http" )
- sim_http_type="http"
- SIM_LOCALHOST=LOCALHOST
+ if (checkFunctionFlag("simvar1_"+index)) {
+ getSimCtr(LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
+ simvar1[index] = data;
+ clearFlag("simvar1_"+index)
+ });
}
- getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
- simvar1[index] = data;
- });
- getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
- simvar2[index] = data;
- });
- getSimCtr(sim_http_type, SIM_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(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
- simvar4[index] = data;
- });
- getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/remote_hosts", index, function(data,index) {
- simvar5[index] = data;
- });
+ if (checkFunctionFlag("simvar2_"+index)) {
+ getSimCtr(LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
+ simvar2[index] = data;
+ clearFlag("simvar2_"+index)
+ });
+ }
+ if (checkFunctionFlag("simvar3_"+index)) {
+ 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;
+ clearFlag("simvar3_"+index)
+ });
+ }
+ if (checkFunctionFlag("simvar4_"+index)) {
+ getSimCtr(LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
+ simvar4[index] = data;
+ clearFlag("simvar4_"+index)
+ });
+ }
+ if (checkFunctionFlag("simvar5_"+index)) {
+ getSimCtr(LOCALHOST+simports[index]+"/counter/remote_hosts", index, function(data,index) {
+ simvar5[index] = data;
+ clearFlag("simvar5_"+index)
+ });
+ }
}
//MR - get metrics values from the MR stub
- getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
- mr1 = data;
- });
- getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
- mr2 = data;
- });
- getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
- mr3 = data;
- });
- getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
- mr4 = data;
- });
- getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
- mr5 = data;
- });
- getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
- mr6 = data;
- });
+ if (checkFunctionFlag("mr1")) {
+ getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
+ mr1 = data;
+ clearFlag("mr1")
+ });
+ }
+ if (checkFunctionFlag("mr2")) {
+ getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
+ mr2 = data;
+ clearFlag("mr2")
+ });
+ }
+ if (checkFunctionFlag("mr3")) {
+ getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
+ mr3 = data;
+ clearFlag("mr3")
+ });
+ }
+ if (checkFunctionFlag("mr4")) {
+ getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
+ mr4 = data;
+ clearFlag("mr4")
+ });
+ }
+ if (checkFunctionFlag("mr5")) {
+ getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
+ mr5 = data;
+ clearFlag("mr5")
+ });
+ }
+ if (checkFunctionFlag("mr6")) {
+ getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
+ mr6 = data;
+ clearFlag("mr6")
+ });
+ }
//CR - get metrics values from the callbackreceiver
- getSimCtr("http", LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
- cr1 = data;
- });
- getSimCtr("http", LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
- cr2 = data;
- });
- getSimCtr("http", LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
- cr3 = data;
- });
-
- //Agent - get metrics from the agent
- getSimCtr("http", LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
- ag1 = data;
- });
- getSimCtr("http", 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+", "
+ if (checkFunctionFlag("cr1")) {
+ getSimCtr(LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
+ cr1 = data;
+ clearFlag("cr1")
+ });
+ }
+ if (checkFunctionFlag("cr2")) {
+ getSimCtr(LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
+ cr2 = data;
+ clearFlag("cr2")
+ });
+ }
+ if (checkFunctionFlag("cr3")) {
+ getSimCtr(LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
+ cr3 = data;
+ clearFlag("cr3")
+ });
+ }
+ //Agent - more get metrics from the agent
+ if (checkFunctionFlag("ag1")) {
+ getSimCtr(LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
+ ag1 = data;
+ clearFlag("ag1")
+ });
+ }
+ if (checkFunctionFlag("ag2")) {
+ 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()
}
- ag2=ag2+(jd[key]["serviceName"]).trim()
}
- }
- catch (err) {
- ag2=data
- }
- });
- getSimCtr("http", 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+", "
+ catch (err) {
+ ag2=data
+ }
+ clearFlag("ag2")
+ });
+ }
+ if (checkFunctionFlag("ag3")) {
+ 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()
}
- ag3=ag3+jd[key].trim()
}
- }
- catch (err) {
- ag3=""
- }
- });
- getSimCtr("http", LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
- ag4=""
- try {
- var jd=JSON.parse(data);
- ag4=""+jd.length
- }
- catch (err) {
+ catch (err) {
+ ag3=""
+ }
+ clearFlag("ag3")
+ });
+ }
+ if (checkFunctionFlag("ag4")) {
+ getSimCtr(LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
ag4=""
- }
- });
-
+ try {
+ var jd=JSON.parse(data);
+ ag4=""+jd.length
+ }
+ catch (err) {
+ ag4=""
+ }
+ clearFlag("ag4")
+ });
+ }
fetchAllMetrics();