blob: 4d10051cefc92bef937b63eaad423e3c324ce1bc [file] [log] [blame]
Mahesh Jethanandanice6f4ef2021-06-15 16:01:18 -07001#!/bin/bash
2
3cd client/tests
4# cleanup any previous (unsuccessful) runs.
5docker-compose down
6
7# bringup simulators
8docker-compose up -d
9
10cd ../
11# cleanup any previous (unsuccessful) runs.
12docker-compose down
13# Bringup sdnr
14docker-compose up -d
15
16# wait until sdnr up & running
17for i in {1..60}; do
18 res=$(curl -o /dev/null -sw %{http_code} http://localhost:8181/odlux/index.html)
19 echo "$res"
20 expect="200"
21 if [ "$res" == "$expect" ]; then
22 echo -e "SDNR is up and running\n"
23 break;
24 else
25 sleep $i
26 fi
27done
28
29# check RU
30nc -z localhost 18300
31if [ $? == 0 ]; then
32 echo -e "RU is up.\n"
33else
34 echo -e "RU failed to connect.\n"
35 exit 1
36fi
37
38# check DU status
39nc -z localhost 18310
40if [ $? == 0 ]; then
41 echo -e "DU is up.\n"
42else
43 echo -e "DU failed to connect.\n"
44 exit 1
45fi
46
47# Adding delay to avoid curl failures
48sleep 30
49
50HOST_IP=$(hostname -I | awk '{print $1}')
51USER_PWD=admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
52
53# Add DU
54echo "Adding DU simulator"
55res=$(curl -o /dev/null -sw %{http_code} -u $USER_PWD -X POST "http://localhost:8181/rests/operations/netconf-node-topology:create-device" -H "accept: */*" -H "Content-Type: application/json" -d '{"input":{"pass-through":{},"login-password":{"username":"netconf","password":"netconf!"},"host":"'"$HOST_IP"'","port":"18310","node-id":"du_sim"}}')
56
57if [ "$res" == "204" ]; then
58 echo -e "Successfully added device DU \n"
59else
60 echo -e "Failed to add DU.\n"
61 exit 1
62fi
63sleep 2
64
65# check DU connection
66echo -e "Checking DU simulator \n"
67res=$(curl -o /dev/null -sw '%{http_code}' -u $USER_PWD -X GET "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=du_sim/netconf-node-topology:available-capabilities?content=nonconfig" -H "accept: application/xml")
68if [ $res == 200 ]; then
69 echo -e "DU simulator is alive.\n"
70else
71 echo -e "DU simulator is not responding.\n"
72 exit 1
73fi
74
75# Add RU
76echo ""
77echo "Adding RU Simulator\n"
78res=$(curl -o /dev/null -sw %{http_code} -u $USER_PWD -X POST "http://localhost:8181/rests/operations/netconf-node-topology:create-device" -H "accept: */*" -H "Content-Type: application/json" -d '{"input":{"pass-through":{},"login-password":{"username":"netconf","password":"netconf!"},"host":"'"$HOST_IP"'","port":"18300","node-id":"ru_sim"}}')
79
80if [ "$res" == "204" ]; then
81 echo -e "Successfully added device RU \n"
82else
83 echo -e "Failed to add RU.\n"
84 exit 1
85fi
86sleep 2
87
88# check RU connection
89echo -e "Checking RU simulator connection"
90res=$(curl -o /dev/null -sw '%{http_code}' -u $USER_PWD -X GET "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=ru_sim/netconf-node-topology:available-capabilities?content=nonconfig" -H "accept: application/xml")
91if [ $res == 200 ]; then
92 echo -e "RU simulator is alive.\n"
93else
94 echo -e "RU simulator is not responding.\n"
95 exit 1
96fi
97
98echo -e "\nRU cofig before update"
99res=$(curl -o /dev/null -sw '%{http_code}' -u $USER_PWD -X GET "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=ru_sim/yang-ext:mount/o-ran-delay-management:delay-management/adaptive-delay-configuration/transport-delay" -H "accept: application/xml")
100if [ $res == 200 ]; then
101 echo -e "RU config check before update succeeded.\n"
102else
103 echo -e "RU config check before update failed.\n"
104 exit 1
105fi
106
107echo -e "\nUpdating RU config"
108res=$(curl -o /dev/null -sw %{http_code} -u $USER_PWD -X PUT "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=ru_sim/yang-ext:mount/o-ran-delay-management:delay-management/adaptive-delay-configuration/transport-delay" -H "accept: */*" -H "Content-Type: application/json" -d '{"transport-delay":{"t12-min":1000,"t12-max":66666,"t34-min":2000,"t34-max":55555}}')
109if [ "$res" == "204" ]; then
110 echo -e "Successfully updated RU config.\n"
111else
112 echo -e "Failed to update RU config.\n"
113 exit 1
114fi
115
116echo -e "\nRU config afer update."
117res=$(curl -o /dev/null -sw '%{http_code}' -u $USER_PWD -X GET "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=ru_sim/yang-ext:mount/o-ran-delay-management:delay-management/adaptive-delay-configuration/transport-delay" -H "accept: application/xml")
118if [ $res == 200 ]; then
119 echo -e "RU config after update succeeded.\n"
120else
121 echo -e "RU config after update failed.\n"
122 exit 1
123fi
124
125# get DU config
126echo -e "\nDU config before update."
127res=$(curl -o /dev/null -sw '%{http_code}' -u $USER_PWD -X GET "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=du_sim/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=O-RU-1" -H "accept: application/xml")
128if [ $res == 200 ]; then
129 echo -e "DU config before update succeeded.\n"
130else
131 echo -e "DU config before update failed.\n"
132 exit 1
133fi
134
135# Update DU config
136echo -e "Updating DU config"
137res=$(curl -o /dev/null -sw %{http_code} -u $USER_PWD -X PUT "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=du_sim/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=O-RU-1" -H "accept: */*" -H "Content-Type: application/json" -d "{"du-to-ru-connection":[{"name":"O-RU-1","administrative-state":"UNLOCKED"}]}")
138if [ "$res" == "204" ]; then
139 echo -e "Successfully updated DU config.\n"
140else
141 echo -e "Failed to update DU config.\n"
142 exit 1
143fi
144
145# Validate DU config after update
146echo -e "DU cofig afer update"
147res=$(curl -o /dev/null -sw '%{http_code}' -u $USER_PWD -X GET "http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=du_sim/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=O-RU-1" -H "accept: application/xml")
148if [ $res == 200 ]; then
149 echo -e "DU config after update succeeded.\n"
150else
151 echo -e "DU config after update failed.\n"
152 exit 1
153fi
154
155# Bring down the sdnr
156docker-compose down
157
158# bring down the simulators
159cd tests/
160docker-compose down
161echo -e "\nTests completed"
162exit 0