| hadik3r | 237d3f5 | 2016-06-27 17:57:49 +0200 | [diff] [blame] | 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 | |
| hadik3r | 237d3f5 | 2016-06-27 17:57:49 +0200 | [diff] [blame] | 10 | class testRestApi( SimpleTestTopology ): |
| 11 | """ |
| 12 | Tests to check the REST API endpoints of the emulator. |
| 13 | """ |
| 14 | |
| 15 | def testRestApi(self): |
| 16 | |
| 17 | # create network |
| 18 | self.createNet(nswitches=0, ndatacenter=2, nhosts=2, ndockers=0) |
| 19 | # setup links |
| 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]) |
| 23 | # start api |
| 24 | self.startApi() |
| 25 | # start Mininet network |
| 26 | self.startNet() |
| 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) |
| stevenvanrossem | 73efd19 | 2016-06-29 01:44:07 +0200 | [diff] [blame^] | 39 | |
| 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) |
| 46 | |
| hadik3r | 237d3f5 | 2016-06-27 17:57:49 +0200 | [diff] [blame] | 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) |
| 62 | self.stopNet() |
| 63 | |
| 64 | |
| 65 | if __name__ == '__main__': |
| 66 | unittest.main() |