RIFT OSM R1 Initial Submission
[osm/SO.git] / examples / ping_pong_ns / ping_pong_ns / test / test.sh
1 #!/bin/bash
2
3 #
4 # Copyright 2016 RIFT.IO Inc
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19
20 pong_ip='14.0.0.2'
21 pong_port=18889
22
23 ping_ip='14.0.0.3'
24
25 ping_port=18888
26
27 if [ "$1" == "pong" ];
28 then
29 if [ "$2" == "enable" ];
30 then
31 echo "enable pong"
32
33 curl -D /dev/stdout \
34 -H "Accept: application/vnd.yang.data+xml" \
35 -H "Content-Type: application/vnd.yang.data+json" \
36 -X POST \
37 -d "{\"enable\":true}" \
38 http://${pong_ip}:${pong_port}/api/v1/pong/adminstatus/state
39 fi
40 if [ "$2" == "disable" ];
41 then
42 echo "disable pong"
43
44 curl -D /dev/stdout \
45 -H "Accept: application/vnd.yang.data+xml" \
46 -H "Content-Type: application/vnd.yang.data+json" \
47 -X POST \
48 -d "{\"enable\":false}" \
49 http://${pong_ip}:${pong_port}/api/v1/pong/adminstatus/state
50 fi
51
52 if [ "$2" == "server" ];
53 then
54 echo "set server"
55
56 curl -D /dev/stdout \
57 -H "Accept: application/vnd.yang.data+xml" \
58 -H "Content-Type: application/vnd.yang.data+json" \
59 -X POST \
60 -d "{\"ip\":\"$3\", \"port\":$4}" \
61 http://${pong_ip}:${pong_port}/api/v1/pong/server
62 fi
63
64 echo ""
65 fi
66
67 if [ "$1" == "ping" ];
68 then
69 if [ "$2" == "enable" ];
70 then
71 echo "enable ping"
72
73 curl -D /dev/stdout \
74 -H "Accept: application/vnd.yang.data+xml" \
75 -H "Content-Type: application/vnd.yang.data+json" \
76 -X POST \
77 -d "{\"enable\":true}" \
78 http://${ping_ip}:${ping_port}/api/v1/ping/adminstatus/state
79 fi
80 if [ "$2" == "disable" ];
81 then
82 echo "disable ping"
83
84 curl -D /dev/stdout \
85 -H "Accept: application/vnd.yang.data+xml" \
86 -H "Content-Type: application/vnd.yang.data+json" \
87 -X POST \
88 -d "{\"enable\":false}" \
89 http://${ping_ip}:${ping_port}/api/v1/ping/adminstatus/state
90 fi
91 echo ""
92
93 if [ "$2" == "rate" ];
94 then
95 echo "disable ping"
96
97 curl -D /dev/stdout \
98 -H "Accept: application/vnd.yang.data+xml" \
99 -H "Content-Type: application/vnd.yang.data+json" \
100 -X POST \
101 -d "{\"rate\":$3}" \
102 http://${ping_ip}:${ping_port}/api/v1/ping/rate
103 fi
104 echo ""
105
106 if [ "$2" == "server" ];
107 then
108 echo "set server"
109
110 curl -D /dev/stdout \
111 -H "Accept: application/vnd.yang.data+xml" \
112 -H "Content-Type: application/vnd.yang.data+json" \
113 -X POST \
114 -d "{\"ip\":\"$3\", \"port\":$4}" \
115 http://${ping_ip}:${ping_port}/api/v1/ping/server
116 fi
117 echo ""
118
119
120 fi
121
122 if [ "$1" == "stats" ];
123 then
124 echo "ping stats:"
125 curl http://${ping_ip}:${ping_port}/api/v1/ping/stats
126 echo ""
127
128 echo "pong stats:"
129 curl http://${pong_ip}:${pong_port}/api/v1/pong/stats
130 echo ""
131 fi
132
133 if [ "$1" == "config" ];
134 then
135 echo "ping server:"
136 curl http://${ping_ip}:${ping_port}/api/v1/ping/server
137 echo ""
138 echo "ping rate:"
139 curl http://${ping_ip}:${ping_port}/api/v1/ping/rate
140 echo ""
141 echo "ping admin status:"
142 curl http://${ping_ip}:${ping_port}/api/v1/ping/adminstatus/state
143 echo ""
144 echo "pong server:"
145 curl http://${pong_ip}:${pong_port}/api/v1/pong/server
146 echo ""
147 echo "pong admin status:"
148 curl http://${pong_ip}:${pong_port}/api/v1/pong/adminstatus/state
149 echo ""
150 fi