Relase notest updated for G-release
[smo/o1.git] / run_tests.sh
1 #!/bin/bash
2
3 cd client/tests
4 # cleanup any previous (unsuccessful) runs.
5 docker-compose down
6
7 # bringup simulators
8 docker-compose up -d
9
10 cd ../
11 # cleanup any previous (unsuccessful) runs.
12 docker-compose down
13 # Bringup sdnr
14 docker-compose up -d
15
16 # wait until sdnr up & running
17 for 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
27 done
28
29 # check RU 
30 nc -z localhost 18300
31 if [ $? == 0 ]; then
32     echo -e "RU is up.\n"
33 else
34     echo -e "RU failed to connect.\n"
35     exit 1
36 fi
37
38 # check DU status
39 nc -z localhost 18310
40 if [ $? == 0 ]; then
41     echo -e "DU is up.\n"
42 else
43     echo -e "DU failed to connect.\n"
44     exit 1
45 fi
46
47 # Adding delay to avoid curl failures
48 sleep 30
49
50 HOST_IP=$(hostname -I | awk '{print $1}')
51 USER_PWD=admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
52
53 # Add DU
54 echo "Adding DU simulator"
55 res=$(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
57 if [ "$res" == "204" ]; then
58     echo -e "Successfully added device DU \n"
59 else
60     echo -e "Failed to add DU.\n"
61     exit 1
62 fi
63 sleep 2
64
65 # check DU connection
66 echo -e "Checking DU simulator \n"
67 res=$(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")
68 if [ $res == 200 ]; then
69     echo -e "DU simulator is alive.\n"
70 else
71     echo -e "DU simulator is not responding.\n"
72     exit 1
73 fi
74
75 # Add RU
76 echo ""
77 echo "Adding RU Simulator\n"
78 res=$(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
80 if [ "$res" == "204" ]; then
81     echo -e "Successfully added device RU \n"
82 else
83     echo -e "Failed to add RU.\n"
84     exit 1
85 fi
86 sleep 2
87
88 # check RU connection
89 echo -e "Checking RU simulator connection"
90 res=$(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")
91 if [ $res == 200 ]; then
92     echo -e "RU simulator is alive.\n"
93 else
94     echo -e "RU simulator is not responding.\n"
95     exit 1
96 fi
97
98 echo -e "\nRU cofig before update"
99 res=$(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")
100 if [ $res == 200 ]; then
101     echo -e "RU config check before update succeeded.\n"
102 else
103     echo -e "RU config check before update failed.\n"
104     exit 1
105 fi
106
107 echo -e "\nUpdating RU config"
108 res=$(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}}')
109 if [ "$res" == "204" ]; then
110     echo -e "Successfully updated RU config.\n"
111 else
112     echo -e "Failed to update RU config.\n"
113     exit 1
114 fi
115
116 echo -e "\nRU config afer update."
117 res=$(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")
118 if [ $res == 200 ]; then
119     echo -e "RU config after update succeeded.\n"
120 else
121     echo -e "RU config after update failed.\n"
122     exit 1
123 fi
124
125 # get DU config
126 echo -e "\nDU config before update."
127 res=$(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")
128 if [ $res == 200 ]; then
129     echo -e "DU config before update succeeded.\n"
130 else
131     echo -e "DU config before update failed.\n"
132     exit 1
133 fi
134
135 # Update DU config
136 echo -e "Updating DU config"
137 res=$(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"}]}")
138 if [ "$res" == "204" ]; then
139     echo -e "Successfully updated DU config.\n"
140 else
141     echo -e "Failed to update DU config.\n"
142     exit 1
143 fi
144
145 # Validate DU config after update
146 echo -e "DU cofig afer update"
147 res=$(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")
148 if [ $res == 200 ]; then
149     echo -e "DU config after update succeeded.\n"
150 else
151     echo -e "DU config after update failed.\n"
152     exit 1
153 fi
154
155 # Bring down the sdnr
156 docker-compose down
157
158 # bring down the simulators
159 cd tests/
160 docker-compose down
161 echo -e "\nTests completed"
162 exit 0