diff options
author | JosephKeenan <joseph.keenan@est.tech> | 2021-10-01 10:40:47 +0100 |
---|---|---|
committer | Rahul Tyagi <rahul.tyagi@est.tech> | 2021-10-18 09:40:45 +0000 |
commit | cc52af1d1166e549abda10510cfebe1a2acb049a (patch) | |
tree | 116bff7333f16861304cfa370ae2363b786adcf5 /csit | |
parent | 162a596f111037a1442be8de411fc7779e021052 (diff) |
CPS-615 - CSIT for model sync & passthrough
This commit contains
-Registration and sync test cases
-Passthrough read and write test case
Issue-ID: CPS-615
Change-Id: I1ad70dbc8c0af96bd5cf69476acdad42cf3c179d
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
(cherry picked from commit d181b0e51b6385105362c9b59239ab581cace45e)
Diffstat (limited to 'csit')
-rw-r--r-- | csit/data/bookstoreAddEntry.json | 19 | ||||
-rw-r--r-- | csit/data/cmHandleRegistration.json | 5 | ||||
-rw-r--r-- | csit/data/postModuleRequestBody.json | 11 | ||||
-rwxr-xr-x | csit/plans/cps/pnfsim/docker-compose.yml | 28 | ||||
-rwxr-xr-x | csit/plans/cps/pnfsim/netconf-config/LICENSE | 13 | ||||
-rw-r--r-- | csit/plans/cps/pnfsim/netconf-config/stores.yang | 63 | ||||
-rwxr-xr-x | csit/plans/cps/pnfsim/netconf-config/subscriber.py | 131 | ||||
-rw-r--r-- | csit/plans/cps/sdnc/certs/certs.properties | 2 | ||||
-rw-r--r-- | csit/plans/cps/sdnc/certs/keys0.zip | bin | 0 -> 5057 bytes | |||
-rw-r--r-- | csit/plans/cps/sdnc/docker-compose.yml | 64 | ||||
-rw-r--r-- | csit/plans/cps/sdnc/sdnc_setup.sh | 49 | ||||
-rwxr-xr-x | csit/plans/cps/setup.sh (renamed from csit/plans/default/setup.sh) | 71 | ||||
-rwxr-xr-x | csit/plans/cps/teardown.sh (renamed from csit/plans/default/teardown.sh) | 13 | ||||
-rw-r--r-- | csit/plans/cps/testplan.txt | 24 | ||||
-rw-r--r-- | csit/plans/default/testplan.txt | 6 | ||||
-rw-r--r-- | csit/tests/cps-model-sync/cps-model-sync.robot | 58 | ||||
-rw-r--r-- | csit/tests/ncmp-passthrough/ncmp-passthrough.robot | 65 |
17 files changed, 604 insertions, 18 deletions
diff --git a/csit/data/bookstoreAddEntry.json b/csit/data/bookstoreAddEntry.json new file mode 100644 index 0000000000..86e9a5b3d6 --- /dev/null +++ b/csit/data/bookstoreAddEntry.json @@ -0,0 +1,19 @@ +{ + "stores:categories": [ + { + "stores:code": "ISBN200123", + "stores:name": "library", + "stores:books": [ + { + "stores:title": "A good book", + "stores:lang": "English", + "stores:authors": [ + "Joe & Rahul" + ], + "stores:pub_year": "2001", + "stores:price": "1000" + } + ] + } + ] +}
\ No newline at end of file diff --git a/csit/data/cmHandleRegistration.json b/csit/data/cmHandleRegistration.json new file mode 100644 index 0000000000..0133148fda --- /dev/null +++ b/csit/data/cmHandleRegistration.json @@ -0,0 +1,5 @@ +{ + "cmHandles": [ + "PNFDemo" + ] +}
\ No newline at end of file diff --git a/csit/data/postModuleRequestBody.json b/csit/data/postModuleRequestBody.json new file mode 100644 index 0000000000..e12af9d916 --- /dev/null +++ b/csit/data/postModuleRequestBody.json @@ -0,0 +1,11 @@ +{ + "operation": "read", + "data": { + "modules": [ + { + "name": "nc-notifications", + "revision": "2008-07-14" + } + ] + } +}
\ No newline at end of file diff --git a/csit/plans/cps/pnfsim/docker-compose.yml b/csit/plans/cps/pnfsim/docker-compose.yml new file mode 100755 index 0000000000..568f98f415 --- /dev/null +++ b/csit/plans/cps/pnfsim/docker-compose.yml @@ -0,0 +1,28 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +version: '3' + +services: + netconf-pnp-simulator: + image: nexus3.onap.org:10001/onap/integration/simulators/netconf-pnp-simulator:2.8.6 + container_name: netconf-simulator + restart: always + ports: + - "831:830" + - "6512:6513" + volumes: + - ./netconf-config:/config/modules/stores diff --git a/csit/plans/cps/pnfsim/netconf-config/LICENSE b/csit/plans/cps/pnfsim/netconf-config/LICENSE new file mode 100755 index 0000000000..3bc5b026c6 --- /dev/null +++ b/csit/plans/cps/pnfsim/netconf-config/LICENSE @@ -0,0 +1,13 @@ +Copyright (C) 2021 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. diff --git a/csit/plans/cps/pnfsim/netconf-config/stores.yang b/csit/plans/cps/pnfsim/netconf-config/stores.yang new file mode 100644 index 0000000000..b24ac0e1ac --- /dev/null +++ b/csit/plans/cps/pnfsim/netconf-config/stores.yang @@ -0,0 +1,63 @@ +module stores {
+
+ yang-version 1.1;
+
+ namespace "org:onap:ccsdk:sample";
+
+ prefix book-store;
+
+ import ietf-yang-types { prefix yang; }
+ import ietf-inet-types { prefix inet; }
+
+ revision "2020-09-15" {
+ description
+ "Sample Model";
+ }
+
+ typedef year {
+ type uint16 {
+ range "1000..9999";
+ }
+ }
+
+ container bookstore {
+
+ leaf bookstore-name {
+ type string;
+ }
+
+ list categories {
+
+ key "code";
+
+ leaf code {
+ type string;
+ }
+
+ leaf name {
+ type string;
+ }
+
+ list books {
+ key title;
+
+ leaf title {
+ type string;
+ }
+ leaf lang {
+ type string;
+ }
+ leaf-list authors {
+ type string;
+ }
+ leaf pub_year {
+ type year;
+ }
+ leaf price {
+ type uint64;
+ }
+ }
+ }
+ }
+}
+
diff --git a/csit/plans/cps/pnfsim/netconf-config/subscriber.py b/csit/plans/cps/pnfsim/netconf-config/subscriber.py new file mode 100755 index 0000000000..5147c93458 --- /dev/null +++ b/csit/plans/cps/pnfsim/netconf-config/subscriber.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 + +__author__ = "Mislav Novakovic <mislav.novakovic@sartura.hr>" +__copyright__ = "Copyright 2018, Deutsche Telekom AG" +__license__ = "Apache 2.0" + +# ============LICENSE_START======================================================= +# Copyright (C) 2018 Deutsche Telekom AG +# Modifications Copyright (C) 2021 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +import sysrepo as sr +import sys + + +# Helper function for printing changes given operation, old and new value. +def print_change(op, old_val, new_val): + if op == sr.SR_OP_CREATED: + print(f"CREATED: {new_val.to_string()}") + elif op == sr.SR_OP_DELETED: + print(f"DELETED: {old_val.to_string()}") + elif op == sr.SR_OP_MODIFIED: + print(f"MODIFIED: {old_val.to_string()} to {new_val.to_string()}") + elif op == sr.SR_OP_MOVED: + print(f"MOVED: {new_val.xpath()} after {old_val.xpath()}") + + +# Helper function for printing events. +def ev_to_str(ev): + if ev == sr.SR_EV_VERIFY: + return "verify" + elif ev == sr.SR_EV_APPLY: + return "apply" + elif ev == sr.SR_EV_ABORT: + return "abort" + else: + return "unknown" + + +# Function to print current configuration state. +# It does so by loading all the items of a session and printing them out. +def print_current_config(session, module_name): + select_xpath = f"/{module_name}:*//*" + + values = session.get_items(select_xpath) + + if values is not None: + print("========== BEGIN CONFIG ==========") + for i in range(values.val_cnt()): + print(values.val(i).to_string(), end='') + print("=========== END CONFIG ===========") + + +# Function to be called for subscribed client of given session whenever configuration changes. +def module_change_cb(sess, module_name, event, private_ctx): + try: + print("========== Notification " + ev_to_str(event) + " =============================================") + if event == sr.SR_EV_APPLY: + print_current_config(sess, module_name) + + print("========== CHANGES: =============================================") + + change_path = f"/{module_name}:*" + + it = sess.get_changes_iter(change_path) + + while True: + change = sess.get_change_next(it) + if change is None: + break + print_change(change.oper(), change.old_val(), change.new_val()) + + print("========== END OF CHANGES =======================================") + except Exception as e: + print(e) + + return sr.SR_ERR_OK + + +def main(): + # Notable difference between c implementation is using exception mechanism for open handling unexpected events. + # Here it is useful because `Connection`, `Session` and `Subscribe` could throw an exception. + try: + module_name = "ietf-interfaces" + if len(sys.argv) > 1: + module_name = sys.argv[1] + else: + print("\nYou can pass the module name to be subscribed as the first argument") + + print(f"Application will watch for changes in {module_name}") + + # connect to sysrepo + conn = sr.Connection(module_name) + + # start session + sess = sr.Session(conn) + + # subscribe for changes in running config */ + subscribe = sr.Subscribe(sess) + + subscribe.module_change_subscribe(module_name, module_change_cb) + + try: + print_current_config(sess, module_name) + except Exception as e: + print(e) + + print("========== STARTUP CONFIG APPLIED AS RUNNING ==========") + + sr.global_loop() + + print("Application exit requested, exiting.") + + except Exception as e: + print(e) + + +if __name__ == '__main__': + main() diff --git a/csit/plans/cps/sdnc/certs/certs.properties b/csit/plans/cps/sdnc/certs/certs.properties new file mode 100644 index 0000000000..f8f3fa72b6 --- /dev/null +++ b/csit/plans/cps/sdnc/certs/certs.properties @@ -0,0 +1,2 @@ +keys0.zip +***** diff --git a/csit/plans/cps/sdnc/certs/keys0.zip b/csit/plans/cps/sdnc/certs/keys0.zip Binary files differnew file mode 100644 index 0000000000..48b4d90a10 --- /dev/null +++ b/csit/plans/cps/sdnc/certs/keys0.zip diff --git a/csit/plans/cps/sdnc/docker-compose.yml b/csit/plans/cps/sdnc/docker-compose.yml new file mode 100644 index 0000000000..1b7fe1f48f --- /dev/null +++ b/csit/plans/cps/sdnc/docker-compose.yml @@ -0,0 +1,64 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +version: '3' + +services: + mariadb: + image: mariadb:10.1.11 + ports: + - "3306:3306" + container_name: mariadb + environment: + - MYSQL_ROOT_PASSWORD=password + hostname: + mariadb.so.testlab.onap.org + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + sdnc: + image: onap/sdnc-image:1.8.1 + container_name: sdnc + volumes: + - /etc/localtime:/etc/localtime:ro + - $SDNC_CERT_PATH:/opt/opendaylight/current/certs + entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"] + ports: + - "8282:8181" + hostname: + sdnc + depends_on: + - mariadb + environment: + - MYSQL_ROOT_PASSWORD=password + - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties + - MYSQL_PASSWD=password + - ODL_CERT_DIR=/opt/opendaylight/current/certs + - ODL_ADMIN_USERNAME=admin + - ODL_ADMIN_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U + dns: + - ${DNS_IP_ADDR-10.0.100.1} + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + extra_hosts: + - sdnctldb02:${LOCAL_IP} + - sdnctldb01:${LOCAL_IP} + - dbhost:${LOCAL_IP}
\ No newline at end of file diff --git a/csit/plans/cps/sdnc/sdnc_setup.sh b/csit/plans/cps/sdnc/sdnc_setup.sh new file mode 100644 index 0000000000..18d21b3889 --- /dev/null +++ b/csit/plans/cps/sdnc/sdnc_setup.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# @author Rahul Tyagi (rahul.tyagi@est.tech) +# setup sdnc + +export SDNC_CERT_PATH=$WORKSPACE/plans/cps/sdnc/certs + +#start SDNC containers with docker compose and configuration from docker-compose.yml +docker-compose -f $WORKSPACE/plans/cps/sdnc/docker-compose.yml up -d + +# WAIT 10 minutes maximum and test every 30 seconds if SDNC is up using HealthCheck API +TIME_OUT=600 +INTERVAL=30 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); + echo $response + + if [ "$response" == "200" ]; then + echo SDNC started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) +done + +if [ "$TIME" -ge "$TIME_OUT" ]; then + echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... +fi
\ No newline at end of file diff --git a/csit/plans/default/setup.sh b/csit/plans/cps/setup.sh index e8074ddc0f..2fc0ec4877 100755 --- a/csit/plans/default/setup.sh +++ b/csit/plans/cps/setup.sh @@ -18,6 +18,7 @@ # Modifications copyright (c) 2020-2021 Samsung Electronics Co., Ltd. # Modifications Copyright (C) 2021 Pantheon.tech # Modifications Copyright (C) 2021 Bell Canada. +# Modifications Copyright (C) 2021 Nordix Foundation. # # Branched from ccsdk/distribution to this repository Feb 23, 2021 # @@ -28,7 +29,11 @@ cp $WORKSPACE/../docker-compose/*.yml $WORKSPACE/archives/docker-compose cd $WORKSPACE/archives/docker-compose # Set env variables for docker compose -export DB_HOST=dbpostgresql +export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') +export DMI_SERVICE_URL=http://$LOCAL_IP:8783 +export DB_HOST=$LOCAL_IP +export SDNC_HOST=$LOCAL_IP +export CPS_CORE_HOST=$LOCAL_IP export DB_USERNAME=cps export DB_PASSWORD=cps # Use latest image version @@ -39,7 +44,62 @@ curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compos chmod +x docker-compose # start CPS and PostgreSQL containers with docker compose +docker network create test_network ./docker-compose up -d + +###################### setup sdnc ############################ +source $WORKSPACE/plans/cps/sdnc/sdnc_setup.sh + +###################### setup pnfsim ########################## +docker-compose -f $WORKSPACE/plans/cps/pnfsim/docker-compose.yml up -d + +# Allow time for netconf-pnp-simulator & SDNC to come up fully +sleep 30s + +SDNC_TIME_OUT=250 +SDNC_INTERVAL=10 +SDNC_TIME=0 + +while [ "$SDNC_TIME" -le "$SDNC_TIME_OUT" ]; do + + # Mount netconf node + + curl --location --request PUT 'http://'"$LOCAL_IP"':8282/restconf/config/network-topology:network-topology/topology/topology-netconf/node/PNFDemo' \ + --header 'Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "node": [ + { + "node-id": "PNFDemo", + "netconf-node-topology:protocol": { + "name": "TLS" + }, + "netconf-node-topology:host": '"$LOCAL_IP"', + "netconf-node-topology:key-based": { + "username": "netconf", + "key-id": "ODL_private_key_0" + }, + "netconf-node-topology:port": 6512, + "netconf-node-topology:tcp-only": false, + "netconf-node-topology:max-connection-attempts": 5 + } + ] + }' + + # Verify node has been mounted + + RESPONSE=$( curl --location --request GET 'http://'"$LOCAL_IP"':8282/restconf/config/network-topology:network-topology/topology/topology-netconf' --header 'Authorization: basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==') + + if [[ "$RESPONSE" == *"PNFDemo"* ]]; then + echo "Node mounted in $SDNC_TIME" + break; + fi + + sleep $SDNC_INTERVAL + SDNC_TIME=$((SDNC_TIME + SDNC_INTERVAL)) + +done + # Validate CPS service initialization completed via periodic log checking for line like below: # org.onap.cps.Application ... Started Application in X.XXX seconds @@ -65,12 +125,5 @@ if [ "$TIME" -gt "$TIME_OUT" ]; then exit 1; fi -# The CPS host according to docker-compose.yml -CPS_HOST="localhost" -CPS_PORT="8883" - -MANAGEMENT_PORT="8887" - # Pass variables required for Robot test suites in ROBOT_VARIABLES -ROBOT_VARIABLES="-v CPS_HOST:$CPS_HOST -v CPS_PORT:$CPS_PORT -v MANAGEMENT_PORT:$MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data" - +ROBOT_VARIABLES="-v CPS_HOST:$LOCAL_IP -v CPS_PORT:8883 -v DMI_HOST:$LOCAL_IP -v DMI_PORT:8783 -v MANAGEMENT_PORT:8887 -v DATADIR:$WORKSPACE/data"
\ No newline at end of file diff --git a/csit/plans/default/teardown.sh b/csit/plans/cps/teardown.sh index f9368f9dff..3ef50d4146 100755 --- a/csit/plans/default/teardown.sh +++ b/csit/plans/cps/teardown.sh @@ -17,9 +17,16 @@ # Modifications copyright (c) 2017 AT&T Intellectual Property # Modifications copyright (c) 2020 Samsung Electronics Co., Ltd. # Modifications Copyright (C) 2021 Pantheon.tech -# +# Modifications Copyright (C) 2021 Nordix Foundation # Branched from ccsdk/distribution to this repository Feb 23, 2021 # -cd $WORKSPACE/archives/docker-compose -./docker-compose down -v +echo 'Stopping, Removing all running containers...' +docker stop $(docker ps -aq) && docker rm $(docker ps -aq) + +echo 'Removing Volumes...' +echo y | docker volume prune + +echo 'Removing Networks...' +echo y | docker network prune + diff --git a/csit/plans/cps/testplan.txt b/csit/plans/cps/testplan.txt new file mode 100644 index 0000000000..8069bb72e7 --- /dev/null +++ b/csit/plans/cps/testplan.txt @@ -0,0 +1,24 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +# Test suites are relative paths under csit/tests/. +# Place the suites in run order. +actuator +cps-model-sync +ncmp-passthrough +cps-admin +cps-data + diff --git a/csit/plans/default/testplan.txt b/csit/plans/default/testplan.txt deleted file mode 100644 index e4e875988a..0000000000 --- a/csit/plans/default/testplan.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Test suites are relative paths under csit/tests/. -# Place the suites in run order. -actuator -cps-admin -cps-data - diff --git a/csit/tests/cps-model-sync/cps-model-sync.robot b/csit/tests/cps-model-sync/cps-model-sync.robot new file mode 100644 index 0000000000..340577e2ce --- /dev/null +++ b/csit/tests/cps-model-sync/cps-model-sync.robot @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +*** Settings *** +Documentation NCMP-DMI - Model Sync + +Library Collections +Library OperatingSystem +Library RequestsLibrary +Library BuiltIn + +Suite Setup Create Session DMI_URL http://${DMI_HOST}:${DMI_PORT} + +*** Variables *** + +${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= +${basePath} /dmi + + +*** Test Cases *** +Register node & sync models + ${uri}= Set Variable ${basePath}/v1/inventory/cmHandles + ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} + ${jsonData}= Get Binary File ${DATADIR}${/}cmHandleRegistration.json + ${response}= POST On Session DMI_URL ${uri} headers=${headers} data=${jsonData} + Should Be Equal As Strings ${response.status_code} 201 + +Verify Sync + ${uri}= Set Variable ${basePath}/v1/ch/PNFDemo/modules + ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} + ${jsonData}= Get Binary File ${DATADIR}${/}postModuleRequestBody.json + ${response}= POST On Session DMI_URL ${uri} headers=${headers} data=${jsonData} + ${responseJson}= Set Variable ${response.json()} + ${moduleCount}= Get length ${responseJson['schemas']} + Should Be Equal As Strings ${response.status_code} 200 + FOR ${item} IN @{responseJson['schemas']} + IF "${item}.get('moduleName')" == "stores" + Should Be Equal As Strings "${item}.get('revision')" 2020-09-15 + Should Be Equal As Strings "${item}.get('namespace')" org:onap:ccsdk:sample + END + END diff --git a/csit/tests/ncmp-passthrough/ncmp-passthrough.robot b/csit/tests/ncmp-passthrough/ncmp-passthrough.robot new file mode 100644 index 0000000000..3b68c335f5 --- /dev/null +++ b/csit/tests/ncmp-passthrough/ncmp-passthrough.robot @@ -0,0 +1,65 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +*** Settings *** +Documentation NCMP + +Library Collections +Library OperatingSystem +Library RequestsLibrary +Library BuiltIn + +Suite Setup Create Session CPS_URL http://${CPS_HOST}:${CPS_PORT} + +*** Variables *** + +${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= +${ncmpBasePath} /ncmp +${netconf} NETCONF + +*** Test Cases *** + +Get for Passthough Operational (CF, RO) with fields + ${uri}= Set Variable ${ncmpBasePath}/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-operational?resourceIdentifier=ietf-netconf-monitoring:netconf-state&options=(fields=schemas/schema/location) + ${headers}= Create Dictionary Authorization=${auth} + ${response}= Get On Session CPS_URL ${uri} headers=${headers} expected_status=200 + ${responseJson}= Set Variable ${response.json()} + ${schemaCount}= Get length ${responseJson['ietf-netconf-monitoring:netconf-state']['schemas']} + Should Be True ${schemaCount} >0 + Should Contain ${responseJson['ietf-netconf-monitoring:netconf-state']['schemas']['schema'][0]['location']} ${netconf} + +Write to bookstore using passthrough-running + ${uri}= Set Variable ${ncmpBasePath}/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore + ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} + ${jsonData}= Get Binary File ${DATADIR}${/}bookstoreAddEntry.json + ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData} + Should Be Equal As Strings ${response.status_code} 201 + +Verify write to bookstore using passthrough-running + ${uri}= Set Variable ${ncmpBasePath}/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore + ${headers}= Create Dictionary Authorization=${auth} + ${response}= Get On Session CPS_URL ${uri} headers=${headers} + ${responseJson}= Set Variable ${response.json()} + Should Be Equal As Strings ${response.status_code} 200 + FOR ${item} IN @{responseJson['stores:bookstore']['categories']} + IF "${item['code']}" == "ISBN200123" + Should Be Equal As Strings "${item['books']}[0][title]" "A good book" + END + END |