CSIT setup in NCMP-DMI-PLUGIN Repo 87/127687/14
authormpriyank <priyank.maheshwari@est.tech>
Fri, 11 Mar 2022 11:52:24 +0000 (17:22 +0530)
committermpriyank <priyank.maheshwari@est.tech>
Wed, 16 Mar 2022 13:57:06 +0000 (19:27 +0530)
- Infrastructure code for ncmp-dmi CSITs.
- Enhanced timeout message for sdnc during setup.
- Basic CSITs for dmi health and get modules from SDNC.
- Fixed shell script permissions from 100644 to 100755.
- Fixing .gitignore as it was ignoring *.zip format and we need key0.zip
  as part of SDNC CSIT setup.

Issue-ID: CPS-930
Change-Id: I39054e3ec2c9281821ca146831ae6cc82d674924
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
21 files changed:
.gitignore
csit/README.md [new file with mode: 0644]
csit/install-robotframework.sh [new file with mode: 0755]
csit/plans/dmi/pnfsim/docker-compose.yml [new file with mode: 0644]
csit/plans/dmi/pnfsim/netconf-config/LICENSE [new file with mode: 0644]
csit/plans/dmi/pnfsim/netconf-config/stores.yang [new file with mode: 0644]
csit/plans/dmi/pnfsim/netconf-config/subscriber.py [new file with mode: 0644]
csit/plans/dmi/sdnc/certs/certs.properties [new file with mode: 0644]
csit/plans/dmi/sdnc/certs/keys0.zip [new file with mode: 0755]
csit/plans/dmi/sdnc/docker-compose.yml [new file with mode: 0644]
csit/plans/dmi/sdnc/sdnc_setup.sh [new file with mode: 0755]
csit/plans/dmi/setup.sh [new file with mode: 0755]
csit/plans/dmi/teardown.sh [new file with mode: 0755]
csit/plans/dmi/test.properties [new file with mode: 0644]
csit/plans/dmi/testplan.txt [new file with mode: 0644]
csit/prepare-csit.sh [new file with mode: 0755]
csit/pylibs.txt [new file with mode: 0644]
csit/run-csit.sh [new file with mode: 0755]
csit/run-project-csit.sh [new file with mode: 0755]
csit/tests/actuator/actuator.robot [new file with mode: 0644]
csit/tests/ncmp-dmi-passthrough/ncmp-dmi-passthrough.robot [new file with mode: 0644]

index 3ab1019..c8f6e40 100644 (file)
@@ -1,8 +1,8 @@
 *.class
 *.jar
 *.war
-*.zip
 *.log
+*.log.zip
 
 target/
 log/
diff --git a/csit/README.md b/csit/README.md
new file mode 100644 (file)
index 0000000..f6a7081
--- /dev/null
@@ -0,0 +1,70 @@
+<!--
+  ============LICENSE_START=======================================================
+   Copyright (C) 2022 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=========================================================
+-->
+
+## Continuous System and Integration Testing (CSIT) for NCMP-DMI-PLUGIN
+
+The directory structure:
+
+- **plans/** contains testing plans, each sub-folder represents a separate test plan, contains processed subsequently:
+    _startup.sh_ (serves docker containers startup), _testplan.txt_ (lists test-suits), _teardown.sh_ (serves docker containers stopping and images removal)
+- **scripts/** contains shell scripts used on tests executions
+- **tests/** contains test suits which are processed by folder name (relative to _tests_ folder) taken from _testplan.txt_
+
+Test suits are executed using Robots framework.
+
+### Running on local environment
+
+Prerequisites:
+- docker
+- python + pip
+- virtualenv
+
+```bash
+sudo apt install python3 python3-pip virtualenv
+```
+
+Add an alias in the ```.bashrc``` file for pip3 to be pip at the end of the file. </br>
+This file will be present on the home directory of the Ubuntu system.
+```bash
+alias pip=pip3
+```
+
+Now load the ```.bashrc``` file.
+```bash
+. .bashrc
+```
+
+The Robot framework and required python packages will be installed on first execution.
+
+Navigate to ncmp-dmi-plugin project directory
+```bash
+cd ~/<your_git_repo>/ncmp-dmi-plugin
+```
+
+Build a docker image (see also [docker-compose readme](../docker-compose/README.md) ) from your ncmp-dmi-plugin directory:
+
+```bash
+mvn clean install -Dmaven.test.skip=true -Ddocker.repository.push=
+```
+
+Execute test from current ncmp-dmi-plugin folder:
+```bash
+./csit/run-project-csit.sh
+```
\ No newline at end of file
diff --git a/csit/install-robotframework.sh b/csit/install-robotframework.sh
new file mode 100755 (executable)
index 0000000..dada622
--- /dev/null
@@ -0,0 +1,16 @@
+ROBOT_VENV=$(mktemp -d --suffix=robot_venv)
+echo "ROBOT_VENV=${ROBOT_VENV}" >> "${WORKSPACE}/env.properties"
+
+echo "Python version is: $(python3 --version)"
+
+python3 -m venv "${ROBOT_VENV}"
+source "${ROBOT_VENV}/bin/activate"
+
+set -exu
+
+# Make sure pip3 itself us up-to-date.
+python3 -m pip install --upgrade pip
+
+echo "Installing Python Requirements"
+python3 -m pip install -r ${WORKSPACE}/pylibs.txt
+python3 -m pip freeze
diff --git a/csit/plans/dmi/pnfsim/docker-compose.yml b/csit/plans/dmi/pnfsim/docker-compose.yml
new file mode 100644 (file)
index 0000000..de9b271
--- /dev/null
@@ -0,0 +1,28 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2022 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/dmi/pnfsim/netconf-config/LICENSE b/csit/plans/dmi/pnfsim/netconf-config/LICENSE
new file mode 100644 (file)
index 0000000..2ae313c
--- /dev/null
@@ -0,0 +1,13 @@
+Copyright (C) 2022 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/dmi/pnfsim/netconf-config/stores.yang b/csit/plans/dmi/pnfsim/netconf-config/stores.yang
new file mode 100644 (file)
index 0000000..59051f2
--- /dev/null
@@ -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/dmi/pnfsim/netconf-config/subscriber.py b/csit/plans/dmi/pnfsim/netconf-config/subscriber.py
new file mode 100644 (file)
index 0000000..5147c93
--- /dev/null
@@ -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/dmi/sdnc/certs/certs.properties b/csit/plans/dmi/sdnc/certs/certs.properties
new file mode 100644 (file)
index 0000000..f8f3fa7
--- /dev/null
@@ -0,0 +1,2 @@
+keys0.zip
+*****
diff --git a/csit/plans/dmi/sdnc/certs/keys0.zip b/csit/plans/dmi/sdnc/certs/keys0.zip
new file mode 100755 (executable)
index 0000000..48b4d90
Binary files /dev/null and b/csit/plans/dmi/sdnc/certs/keys0.zip differ
diff --git a/csit/plans/dmi/sdnc/docker-compose.yml b/csit/plans/dmi/sdnc/docker-compose.yml
new file mode 100644 (file)
index 0000000..c604b7c
--- /dev/null
@@ -0,0 +1,73 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2022 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.5
+    ports:
+      - "3306:3306"
+    environment:
+      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password}
+      - MYSQL_ROOT_HOST=%
+      - MYSQL_USER=${MYSQL_USER:-sdnc}
+      - MYSQL_PASSWORD=${MYSQL_PASSWORD:-password}
+      - MYSQL_DATABASE=${MYSQL_DATABASE:-sdncdb}
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "30m"
+        max-file: "5"
+
+  sdnc:
+    image: onap/sdnc-image:${VERSION:-2.2.3}
+    container_name: sdnc
+    depends_on :
+      - mariadb
+    entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"]
+    ports:
+      - "8282:8181"
+    hostname:
+      sdnc
+    links:
+      - mariadb:dbhost
+      - mariadb:sdnctldb01
+      - mariadb:sdnctldb02
+    environment:
+      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password}
+      - MYSQL_USER=${MYSQL_USER:-sdnc}
+      - MYSQL_PASSWORD=${MYSQL_PASSWORD:-password}
+      - MYSQL_DATABASE=${MYSQL_DATABASE:-sdncdb}
+      - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
+      - SDNC_BIN=/opt/onap/sdnc/bin
+      - ODL_CERT_DIR=/opt/opendaylight/certs
+      - ODL_ADMIN_USERNAME=${ODL_USER:-admin}
+      - ODL_ADMIN_PASSWORD=${ODL_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
+      - SDNC_DB_INIT=true
+      - SQL_CRYPTKEY=${SQL_CRYPTKEY:-fakECryptKey}
+
+    volumes:
+      - ./certs/certs.properties:/opt/opendaylight/certs/certs.properties
+      - ./certs/keys0.zip:/opt/opendaylight/certs/keys0.zip
+
+    dns:
+      - ${DNS_IP_ADDR-10.0.100.1}
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "30m"
+        max-file: "5"
\ No newline at end of file
diff --git a/csit/plans/dmi/sdnc/sdnc_setup.sh b/csit/plans/dmi/sdnc/sdnc_setup.sh
new file mode 100755 (executable)
index 0000000..b93c9d3
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# ============LICENSE_START=======================================================
+#   Copyright (C) 2022 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=========================================================
+
+export SDNC_CERT_PATH=$WORKSPACE/plans/dmi/sdnc/certs
+
+#start SDNC containers with docker compose and configuration from docker-compose.yml
+docker-compose -f $WORKSPACE/plans/dmi/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://$SDNC_HOST:$SDNC_PORT/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: SDNC not started in $TIME_OUT seconds... Could cause problems for testing activities...
+fi
\ No newline at end of file
diff --git a/csit/plans/dmi/setup.sh b/csit/plans/dmi/setup.sh
new file mode 100755 (executable)
index 0000000..9a6d27b
--- /dev/null
@@ -0,0 +1,141 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 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=========================================================
+#
+# Branched from ccsdk/distribution to this repository Feb 23, 2021
+#
+
+check_health()
+{
+  TIME_OUT=120
+  INTERVAL=5
+  TICKER=0
+
+  while [ "$TICKER" -le "$TIME_OUT" ]; do
+
+    RESPONSE=$(curl --location --request GET 'http://'$1'/manage/health/readiness')
+
+    if [[ "$RESPONSE" == *"UP"* ]]; then
+      echo "$2 started in $TICKER"
+      break;
+    fi
+
+    sleep $INTERVAL
+    TICKER=$((TICKER + INTERVAL))
+
+  done
+
+  if [ "$TICKER" -ge "$TIME_OUT" ]; then
+    echo TIME OUT: $2 session not started in $TIME_OUT seconds... Could cause problems for testing activities...
+  fi
+}
+
+###################### setup env ############################
+# Set env variables for docker compose
+export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
+
+source $WORKSPACE/plans/dmi/test.properties
+export $(cut -d= -f1 $WORKSPACE/plans/dmi/test.properties)
+
+###################### setup ncmp-dmi-plugin ############################
+mkdir -p $WORKSPACE/archives/ncmp-dmi-plugin
+cp $WORKSPACE/../docker-compose/*.yml $WORKSPACE/archives/ncmp-dmi-plugin
+cd $WORKSPACE/archives/ncmp-dmi-plugin
+
+# download docker-compose of a required version (1.25.0 supports configuration of version 3.7)
+curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
+chmod +x docker-compose
+
+# start CPS and PostgreSQL containers with docker compose
+./docker-compose up -d
+
+####################### setup cps-ncmp ############################
+
+cd $WORKSPACE/archives
+git clone "https://gerrit.onap.org/r/cps"
+mkdir -p $WORKSPACE/archives/dc-cps-ncmp
+cat $WORKSPACE/archives/cps/docker-compose/docker-compose.yml
+cp $WORKSPACE/archives/cps/docker-compose/*.yml $WORKSPACE/archives/dc-cps-ncmp
+cd $WORKSPACE/archives/dc-cps-ncmp
+# copy docker-compose (downloaded already for cps)
+cp $WORKSPACE/archives/ncmp-dmi-plugin/docker-compose .
+chmod +x docker-compose
+./docker-compose up -d
+
+###################### setup sdnc #######################################
+source $WORKSPACE/plans/dmi/sdnc/sdnc_setup.sh
+
+###################### setup pnfsim #####################################
+docker-compose -f $WORKSPACE/plans/dmi/pnfsim/docker-compose.yml up -d
+
+# Allow time for netconf-pnp-simulator & SDNC to come up fully
+sleep 30s
+
+###################### mount pnf-sim as PNFDemo ##########################
+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://'$SDNC_HOST:$SDNC_PORT'/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://'$SDNC_HOST:$SDNC_PORT'/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
+
+####################### verify ncmp-cps health ##########################
+#
+check_health $CPS_CORE_HOST:$CPS_CORE_MANAGEMENT_PORT 'cps-ncmp'
+
+###################### verify dmi health ##########################
+
+check_health $DMI_HOST:$DMI_MANAGEMENT_PORT 'dmi-plugin'
+
+###################### ROBOT Configurations ##########################
+# Pass variables required for Robot test suites in ROBOT_VARIABLES
+ROBOT_VARIABLES="-v CPS_CORE_HOST:$CPS_CORE_HOST -v CPS_CORE_PORT:$CPS_CORE_PORT -v DMI_HOST:$LOCAL_IP -v DMI_PORT:$DMI_PORT -v DMI_MANAGEMENT_PORT:$DMI_MANAGEMENT_PORT -v CPS_CORE_MANAGEMENT_PORT:$CPS_CORE_MANAGEMENT_PORT -v SDNC_HOST:$SDNC_HOST -v SDNC_PORT:$SDNC_PORT -v DATADIR:$WORKSPACE/data --exitonfailure"
\ No newline at end of file
diff --git a/csit/plans/dmi/teardown.sh b/csit/plans/dmi/teardown.sh
new file mode 100755 (executable)
index 0000000..5d8dfb1
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 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=========================================================
+#
+# Branched from ccsdk/distribution to this repository Feb 23, 2021
+#
+echo '================================== docker info =========================='
+docker ps -a
+
+echo '================================== CPS-NCMP Logs ========================'
+docker logs cps-and-ncmp
+
+echo '================================== DMI Logs ============================='
+docker logs ncmp-dmi-plugin
+
+echo '================================== SDNC Logs ============================'
+docker logs sdnc
+
+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/dmi/test.properties b/csit/plans/dmi/test.properties
new file mode 100644 (file)
index 0000000..88c3815
--- /dev/null
@@ -0,0 +1,25 @@
+DB_HOST=$LOCAL_IP
+DB_USERNAME=cps
+DB_PASSWORD=cps
+
+SDNC_HOST=$LOCAL_IP
+SDNC_PORT=8282
+SDNC_USERNAME=admin
+SDNC_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+
+CPS_CORE_HOST=$LOCAL_IP
+CPS_CORE_PORT=8883
+CPS_CORE_MANAGEMENT_PORT=8887
+CPS_CORE_USERNAME=cpsuser
+CPS_CORE_PASSWORD=cpsr0cks!
+
+DMI_HOST=$LOCAL_IP
+DMI_PORT=8783
+DMI_USERNAME=cpsuser
+DMI_PASSWORD=cpsr0cks!
+DMI_MANAGEMENT_PORT=8787
+DMI_SERVICE_URL=http://$LOCAL_IP:$DMI_PORT
+
+DOCKER_REPO=nexus3.onap.org:10003
+
+CPS_VERSION=latest
\ No newline at end of file
diff --git a/csit/plans/dmi/testplan.txt b/csit/plans/dmi/testplan.txt
new file mode 100644 (file)
index 0000000..37005e8
--- /dev/null
@@ -0,0 +1,20 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2022 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
+ncmp-dmi-passthrough
\ No newline at end of file
diff --git a/csit/prepare-csit.sh b/csit/prepare-csit.sh
new file mode 100755 (executable)
index 0000000..e295b03
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash -x
+#
+# Copyright (C) 2022 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=========================================================
+#
+# This script installs common libraries required by CSIT tests
+#
+# Branched from ccsdk/distribution to this repository Feb 23, 2021
+#
+
+if [ -z "$WORKSPACE" ]; then
+    export WORKSPACE=`git rev-parse --show-toplevel`
+fi
+
+TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
+
+# Assume that if ROBOT_VENV is set and virtualenv with system site packages can be activated,
+# ci-management/jjb/integration/include-raw-integration-install-robotframework.sh has already
+# been executed
+
+if [ -f ${WORKSPACE}/env.properties ]; then
+    source ${WORKSPACE}/env.properties
+fi
+if [ -f ${ROBOT_VENV}/bin/activate ]; then
+    source ${ROBOT_VENV}/bin/activate
+else
+    rm -rf /tmp/ci-management
+    rm -f ${WORKSPACE}/env.properties
+    cd /tmp
+    source ${WORKSPACE}/install-robotframework.sh
+fi
+
+# install eteutils
+mkdir -p ${ROBOT_VENV}/src/onap
+rm -rf ${ROBOT_VENV}/src/onap/testsuite
+python3 -m pip install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.5.1.*' --pre
+
+pip freeze
+
diff --git a/csit/pylibs.txt b/csit/pylibs.txt
new file mode 100644 (file)
index 0000000..d6250db
--- /dev/null
@@ -0,0 +1,27 @@
+docker-py
+ipaddr
+netaddr
+netifaces
+pyhocon
+requests
+robotframework-httplibrary
+robotframework-requests
+robotframework-selenium2library
+robotframework-extendedselenium2library
+robotframework-sshlibrary
+scapy
+# Module jsonpath is needed by current AAA idmlite suite.
+jsonpath-rw
+# Modules for longevity framework robot library
+elasticsearch
+elasticsearch-dsl
+# Module for pyangbind used by lispflowmapping project
+pyangbind
+# Module for iso8601 datetime format
+isodate
+# Module for TemplatedRequests.robot library
+jmespath
+# Module for backup-restore support library
+jsonpatch
+# odltools for extra debugging
+odltools
diff --git a/csit/run-csit.sh b/csit/run-csit.sh
new file mode 100755 (executable)
index 0000000..b5d7e0d
--- /dev/null
@@ -0,0 +1,197 @@
+#!/bin/bash -x
+#
+# Copyright (C) 2022 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=========================================================
+#
+# $1 project/functionality
+# $2 robot options
+#
+# Branched from ccsdk/distribution to this repository Feb 23, 2021
+
+#
+# functions
+#
+
+function on_exit(){
+    rc=$?
+    if [[ ${WORKSPACE} ]]; then
+        if [[ ${WORKDIR} ]]; then
+            rsync -av "$WORKDIR/" "$WORKSPACE/archives/$TESTPLAN"
+        fi
+        # Record list of active docker containers
+        docker ps --format "{{.Image}}" > "$WORKSPACE/archives/$TESTPLAN/_docker-images.log"
+
+        # show memory consumption after all docker instances initialized
+        docker_stats | tee "$WORKSPACE/archives/$TESTPLAN/_sysinfo-2-after-robot.txt"
+    fi
+    # Run teardown script plan if it exists
+    cd "${TESTPLANDIR}"
+    TEARDOWN="${TESTPLANDIR}/teardown.sh"
+    if [ -f "${TEARDOWN}" ]; then
+        echo "Running teardown script ${TEARDOWN}"
+        source_safely "${TEARDOWN}"
+    fi
+    # TODO: do something with the output
+     exit $rc
+}
+# ensure that teardown and other finalizing steps are always executed
+trap on_exit EXIT
+
+function docker_stats(){
+    #General memory details
+    echo "> top -bn1 | head -3"
+    top -bn1 | head -3
+    echo
+
+    echo "> free -h"
+    free -h
+    echo
+
+    #Memory details per Docker
+    echo "> docker ps"
+    docker ps
+    echo
+
+    echo "> docker stats --no-stream"
+    docker stats --no-stream
+    echo
+}
+
+# save current set options
+function save_set() {
+    RUN_CSIT_SAVE_SET="$-"
+    RUN_CSIT_SHELLOPTS="$SHELLOPTS"
+}
+
+# load the saved set options
+function load_set() {
+    _setopts="$-"
+
+    # bash shellopts
+    for i in $(echo "$SHELLOPTS" | tr ':' ' ') ; do
+        set +o ${i}
+    done
+    for i in $(echo "$RUN_CSIT_SHELLOPTS" | tr ':' ' ') ; do
+        set -o ${i}
+    done
+
+    # other options
+    for i in $(echo "$_setopts" | sed 's/./& /g') ; do
+        set +${i}
+    done
+    set -${RUN_CSIT_SAVE_SET}
+}
+
+# set options for quick bailout when error
+function harden_set() {
+    set -xeo pipefail
+    set +u # enabled it would probably fail too many often
+}
+
+# relax set options so the sourced file will not fail
+# the responsibility is shifted to the sourced file...
+function relax_set() {
+    set +e
+    set +o pipefail
+}
+
+# wrapper for sourcing a file
+function source_safely() {
+    [ -z "$1" ] && return 1
+    relax_set
+    . "$1"
+    load_set
+}
+
+#
+# main
+#
+
+# set and save options for quick failure
+harden_set && save_set
+
+if [ $# -eq 0 ]
+then
+    echo
+    echo "Usage: $0 plans/<project>/<functionality> [<robot-options>]"
+    echo
+    echo "    <project>, <functionality>, <robot-options>:  "
+    echo "        The same values as for the '{project}-csit-{functionality}' JJB job template."
+    echo
+    exit 1
+fi
+
+if [ -z "$WORKSPACE" ]; then
+    export WORKSPACE=$(git rev-parse --show-toplevel)
+fi
+
+if [ -f "${WORKSPACE}/${1}/testplan.txt" ]; then
+    export TESTPLAN="${1}"
+else
+    echo "testplan not found: ${WORKSPACE}/${TESTPLAN}/testplan.txt"
+    exit 2
+fi
+
+export TESTOPTIONS="${2}"
+
+rm -rf "$WORKSPACE/archives/$TESTPLAN"
+mkdir -p "$WORKSPACE/archives/$TESTPLAN"
+
+TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
+
+# Run installation of prerequired libraries
+source_safely "${WORKSPACE}/prepare-csit.sh"
+
+# Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
+source_safely "${ROBOT_VENV}/bin/activate"
+
+WORKDIR=$(mktemp -d --suffix=-robot-workdir)
+cd "${WORKDIR}"
+
+# Add csit scripts to PATH
+export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin"
+export SCRIPTS="${WORKSPACE}/scripts"
+export ROBOT_VARIABLES=
+
+# Sign in to nexus3 docker repo
+docker login -u docker -p docker nexus3.onap.org:10001
+
+# Run setup script plan if it exists
+cd "${TESTPLANDIR}"
+SETUP="${TESTPLANDIR}/setup.sh"
+if [ -f "${SETUP}" ]; then
+    echo "Running setup script ${SETUP}"
+    source_safely "${SETUP}"
+fi
+
+# show memory consumption after all docker instances initialized
+docker_stats | tee "$WORKSPACE/archives/$TESTPLAN/_sysinfo-1-after-setup.txt"
+
+# Run test plan
+cd "$WORKDIR"
+echo "Reading the testplan:"
+cat "${TESTPLANDIR}/testplan.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${WORKSPACE}/tests/|" > testplan.txt
+cat testplan.txt
+SUITES=$( xargs -a testplan.txt )
+
+echo ROBOT_VARIABLES="${ROBOT_VARIABLES}"
+echo "Starting Robot test suites ${SUITES} ..."
+relax_set
+python3 -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
+RESULT=$?
+load_set
+echo "RESULT: $RESULT"
+# Note that the final steps are done in on_exit function after this exit!
+exit $RESULT
diff --git a/csit/run-project-csit.sh b/csit/run-project-csit.sh
new file mode 100755 (executable)
index 0000000..3cbc278
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash -x
+#
+# Copyright (C) 2022 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=========================================================
+#
+# Branched from ccsdk/distribution to this repository Feb 23, 2021
+# $1 test options (passed on to run-csit.sh as such)
+
+export TESTOPTIONS=${1}
+export WORKSPACE=$(git rev-parse --show-toplevel)/csit
+
+rm -rf ${WORKSPACE}/archives
+mkdir -p ${WORKSPACE}/archives
+cd ${WORKSPACE}
+
+# Execute all test-suites defined under plans subdirectory
+for dir in plans/*/
+do
+    dir=${dir%*/}  # remove the trailing /
+   ./run-csit.sh ${dir} ${TESTOPTIONS}
+done
diff --git a/csit/tests/actuator/actuator.robot b/csit/tests/actuator/actuator.robot
new file mode 100644 (file)
index 0000000..dcb4f3e
--- /dev/null
@@ -0,0 +1,33 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2022 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         DMI - Actuator endpoints
+
+Library               Collections
+Library               RequestsLibrary
+
+Suite Setup           Create Session    MANAGEMENT_URL    http://${DMI_HOST}:${DMI_MANAGEMENT_PORT}/manage
+
+*** Test Cases ***
+Test DMI Enhanced Healthcheck
+    [Documentation]     Runs DMI Health Check. It will check for overall status update of DMI component like, Database and diskspace status along with liveliness and readiness check
+    ${response}=      GET On Session    MANAGEMENT_URL     health    expected_status=200
+    ${resp_body}=      Convert to string     ${response.text}
+    Should Contain      ${resp_body}     UP
+    Should Not Contain      ${resp_body}     DOWN
diff --git a/csit/tests/ncmp-dmi-passthrough/ncmp-dmi-passthrough.robot b/csit/tests/ncmp-dmi-passthrough/ncmp-dmi-passthrough.robot
new file mode 100644 (file)
index 0000000..0878084
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2022 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      DMI_URL    http://${DMI_HOST}:${DMI_PORT}
+
+*** Variables ***
+
+${auth}                 Basic Y3BzdXNlcjpjcHNyMGNrcyE=
+${dmiBasePath}          /dmi
+
+*** Test Cases ***
+
+Get all modules for given cm-handle
+    ${uri}=              Set Variable       ${dmiBasePath}/v1/ch/PNFDemo/modules
+    ${headers}=          Create Dictionary  Content-Type=application/json   Authorization=${auth}
+    ${response}=         POST On Session    DMI_URL   ${uri}   headers=${headers}   data={}   expected_status=200
\ No newline at end of file