Merge pull request #122 from hadik3r/master
[osm/vim-emu.git] / src / emuvim / test / unittests / test_restapi.py
1 """
2 Test suite to automatically test emulator REST API endpoints.
3 """
4
5 import time
6 import unittest
7 from emuvim.test.api_base import SimpleTestTopology
8 import subprocess
9
10
11 class testRestApi( SimpleTestTopology ):
12 """
13 Tests to check the REST API endpoints of the emulator.
14 """
15
16 def testRestApi(self):
17
18 # create network
19 self.createNet(nswitches=0, ndatacenter=2, nhosts=2, ndockers=0)
20 # setup links
21 self.net.addLink(self.dc[0], self.h[0])
22 self.net.addLink(self.h[1], self.dc[1])
23 self.net.addLink(self.dc[0], self.dc[1])
24 # start api
25 self.startApi()
26 # start Mininet network
27 self.startNet()
28 print('compute start datacenter0, vnf1 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
29 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
30 subprocess.call("son-emu-cli compute start -d datacenter0 -n vnf1", shell=True)
31 print('compute start datacenter0, vnf2 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
32 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
33 subprocess.call("son-emu-cli compute start -d datacenter0 -n vnf2", shell=True)
34 print('compute start datacenter1, vnf3 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
35 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
36 subprocess.call("son-emu-cli compute start -d datacenter1 -n vnf3", shell=True)
37 print('compute list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
38 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
39 subprocess.call("son-emu-cli compute list", shell=True)
40 print('compute stop datacenter0, vnf2 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
41 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
42 subprocess.call("son-emu-cli compute stop -d datacenter0 -n vnf2", shell=True)
43 print('compute list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
44 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
45 subprocess.call("son-emu-cli compute list", shell=True)
46 print('compute status datacenter0, vnf1 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
47 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
48 subprocess.call("son-emu-cli compute status -d datacenter0 -n vnf1", shell=True)
49 print('datacenter list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
50 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
51 subprocess.call("son-emu-cli datacenter list", shell=True)
52 print('datacenter status datacenter0 ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
53 print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
54 subprocess.call("son-emu-cli datacenter status -d datacenter0", shell=True)
55 self.stopNet()
56
57
58 if __name__ == '__main__':
59 unittest.main()