3 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Modifications copyright (c) 2017 AT&T Intellectual Property
18 # Modifications copyright (c) 2020-2021 Samsung Electronics Co., Ltd.
19 # Modifications Copyright (C) 2021 Pantheon.tech
20 # Modifications Copyright (C) 2021 Bell Canada.
21 # Modifications Copyright (C) 2021 Nordix Foundation.
23 # Branched from ccsdk/distribution to this repository Feb 23, 2021
26 # Copy docker-compose.yml and application.yml to archives
27 mkdir -p $WORKSPACE/archives/docker-compose
28 cp $WORKSPACE/../docker-compose/*.yml $WORKSPACE/archives/docker-compose
29 cd $WORKSPACE/archives/docker-compose
31 # Set env variables for docker compose
32 export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
33 export DMI_SERVICE_URL=http://$LOCAL_IP:8783
34 export DB_HOST=$LOCAL_IP
35 export SDNC_HOST=$LOCAL_IP
36 export CPS_CORE_HOST=$LOCAL_IP
37 export DB_USERNAME=cps
38 export DB_PASSWORD=cps
39 # Use latest image version
42 # download docker-compose of a required version (1.25.0 supports configuration of version 3.7)
43 curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
44 chmod +x docker-compose
46 # start CPS and PostgreSQL containers with docker compose
47 docker network create test_network
48 ./docker-compose up -d
50 ###################### setup sdnc ############################
51 source $WORKSPACE/plans/cps/sdnc/sdnc_setup.sh
53 ###################### setup pnfsim ##########################
54 docker-compose -f $WORKSPACE/plans/cps/pnfsim/docker-compose.yml up -d
56 # Allow time for netconf-pnp-simulator & SDNC to come up fully
63 while [ "$SDNC_TIME" -le "$SDNC_TIME_OUT" ]; do
67 curl --location --request PUT 'http://'"$LOCAL_IP"':8282/restconf/config/network-topology:network-topology/topology/topology-netconf/node/PNFDemo' \
68 --header 'Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==' \
69 --header 'Content-Type: application/json' \
74 "netconf-node-topology:protocol": {
77 "netconf-node-topology:host": '"$LOCAL_IP"',
78 "netconf-node-topology:key-based": {
79 "username": "netconf",
80 "key-id": "ODL_private_key_0"
82 "netconf-node-topology:port": 6512,
83 "netconf-node-topology:tcp-only": false,
84 "netconf-node-topology:max-connection-attempts": 5
89 # Verify node has been mounted
91 RESPONSE=$( curl --location --request GET 'http://'"$LOCAL_IP"':8282/restconf/config/network-topology:network-topology/topology/topology-netconf' --header 'Authorization: basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==')
93 if [[ "$RESPONSE" == *"PNFDemo"* ]]; then
94 echo "Node mounted in $SDNC_TIME"
99 SDNC_TIME=$((SDNC_TIME + SDNC_INTERVAL))
103 # Validate CPS service initialization completed via periodic log checking for line like below:
104 # org.onap.cps.Application ... Started Application in X.XXX seconds
110 while [ "$TIME" -le "$TIME_OUT" ]; do
111 LOG_FOUND=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.Application" | egrep -c "Started Application in" )
113 if [ "$LOG_FOUND" -gt 0 ]; then
114 echo "CPS Service started"
118 echo "Sleep $INTERVAL seconds before next check for CPS initialization (waiting $TIME seconds; timeout is $TIME_OUT seconds)"
120 TIME=$((TIME + INTERVAL))
123 if [ "$TIME" -gt "$TIME_OUT" ]; then
124 echo "TIME OUT: CPS Service wasn't able to start in $TIME_OUT seconds, setup failed."
128 # Pass variables required for Robot test suites in ROBOT_VARIABLES
129 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"