2 Test suite to automatically test emulator REST API endpoints.
7 from emuvim
.test
.api_base
import SimpleTestTopology
10 class testRestApi( SimpleTestTopology
):
12 Tests to check the REST API endpoints of the emulator.
15 def testRestApi(self
):
18 self
.createNet(nswitches
=0, ndatacenter
=2, nhosts
=2, ndockers
=0)
20 self
.net
.addLink(self
.dc
[0], self
.h
[0])
21 self
.net
.addLink(self
.h
[1], self
.dc
[1])
22 self
.net
.addLink(self
.dc
[0], self
.dc
[1])
25 # start Mininet network
27 print('compute start datacenter0, vnf1 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
28 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
29 subprocess
.call("son-emu-cli compute start -d datacenter0 -n vnf1", shell
=True)
30 print('compute start datacenter0, vnf2 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
31 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
32 subprocess
.call("son-emu-cli compute start -d datacenter0 -n vnf2", shell
=True)
33 print('compute start datacenter1, vnf3 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
34 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
35 subprocess
.call("son-emu-cli compute start -d datacenter1 -n vnf3", shell
=True)
36 print('compute list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
37 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
38 subprocess
.call("son-emu-cli compute list", shell
=True)
40 print('network add vnf1 vnf2->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
41 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
42 subprocess
.call("son-emu-cli network add -src vnf1 -dst vnf2 -b -c 10", shell
=True)
43 print('network remove vnf1 vnf2->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
44 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
45 subprocess
.call("son-emu-cli network remove -src vnf1 -dst vnf2 -b", shell
=True)
47 print('compute stop datacenter0, vnf2 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
48 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
49 subprocess
.call("son-emu-cli compute stop -d datacenter0 -n vnf2", shell
=True)
50 print('compute list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
51 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
52 subprocess
.call("son-emu-cli compute list", shell
=True)
53 print('compute status datacenter0, vnf1 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
54 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
55 subprocess
.call("son-emu-cli compute status -d datacenter0 -n vnf1", shell
=True)
56 print('datacenter list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
57 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
58 subprocess
.call("son-emu-cli datacenter list", shell
=True)
59 print('datacenter status datacenter0 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
60 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
61 subprocess
.call("son-emu-cli datacenter status -d datacenter0", shell
=True)
65 if __name__
== '__main__':