X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Femuvim%2Ftest%2Ftest_emulator.py;h=243f0501fd084293533c64ba4a37b071791214f4;hb=5877ea26273aed77b51263efb19fc13b70087c25;hp=905b1c6014da70bc33413627da2accd326d3e27c;hpb=57551f0497178f51b4cb67b3e21a949cdda8505d;p=osm%2Fvim-emu.git diff --git a/src/emuvim/test/test_emulator.py b/src/emuvim/test/test_emulator.py index 905b1c6..243f050 100755 --- a/src/emuvim/test/test_emulator.py +++ b/src/emuvim/test/test_emulator.py @@ -6,6 +6,7 @@ Python API. Does not test API endpoints. This is done in separated test suites. """ +import time import unittest from emuvim.dcemulator.node import EmulatorCompute from emuvim.test.base import SimpleTestTopology @@ -31,14 +32,15 @@ class testEmulatorTopology( SimpleTestTopology ): # start Mininet network self.startNet() # check number of running nodes - assert(len(self.getDockernetContainers()) == 0) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 1) + self.assertTrue(len(self.getContainernetContainers()) == 0) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 1) # check connectivity by using ping - assert(self.net.ping([self.h[0], self.h[1]]) <= 0.0) + self.assertTrue(self.net.ping([self.h[0], self.h[1]]) <= 0.0) # stop Mininet network self.stopNet() + #@unittest.skip("disabled to test if CI fails because this is the first test.") def testMultipleDatacenterDirect(self): """ Create a two data centers and interconnect them. @@ -52,11 +54,11 @@ class testEmulatorTopology( SimpleTestTopology ): # start Mininet network self.startNet() # check number of running nodes - assert(len(self.getDockernetContainers()) == 0) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 2) + self.assertTrue(len(self.getContainernetContainers()) == 0) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 2) # check connectivity by using ping - assert(self.net.ping([self.h[0], self.h[1]]) <= 0.0) + self.assertTrue(self.net.ping([self.h[0], self.h[1]]) <= 0.0) # stop Mininet network self.stopNet() @@ -77,11 +79,11 @@ class testEmulatorTopology( SimpleTestTopology ): # start Mininet network self.startNet() # check number of running nodes - assert(len(self.getDockernetContainers()) == 0) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 5) + self.assertTrue(len(self.getContainernetContainers()) == 0) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 5) # check connectivity by using ping - assert(self.net.ping([self.h[0], self.h[1]]) <= 0.0) + self.assertTrue(self.net.ping([self.h[0], self.h[1]]) <= 0.0) # stop Mininet network self.stopNet() @@ -108,15 +110,15 @@ class testEmulatorCompute( SimpleTestTopology ): # add compute resources vnf1 = self.dc[0].startCompute("vnf1") # check number of running nodes - assert(len(self.getDockernetContainers()) == 1) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 1) + self.assertTrue(len(self.getContainernetContainers()) == 1) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 1) # check compute list result - assert(len(self.dc[0].listCompute()) == 1) - assert(isinstance(self.dc[0].listCompute()[0], EmulatorCompute)) - assert(self.dc[0].listCompute()[0].name == "vnf1") + self.assertTrue(len(self.dc[0].listCompute()) == 1) + self.assertTrue(isinstance(self.dc[0].listCompute()[0], EmulatorCompute)) + self.assertTrue(self.dc[0].listCompute()[0].name == "vnf1") # check connectivity by using ping - assert(self.net.ping([self.h[0], vnf1]) <= 0.0) + self.assertTrue(self.net.ping([self.h[0], vnf1]) <= 0.0) # stop Mininet network self.stopNet() @@ -134,21 +136,21 @@ class testEmulatorCompute( SimpleTestTopology ): # add compute resources vnf1 = self.dc[0].startCompute("vnf1") # check number of running nodes - assert(len(self.getDockernetContainers()) == 1) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 1) + self.assertTrue(len(self.getContainernetContainers()) == 1) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 1) # check compute list result - assert(len(self.dc[0].listCompute()) == 1) + self.assertTrue(len(self.dc[0].listCompute()) == 1) # check connectivity by using ping - assert(self.net.ping([self.h[0], vnf1]) <= 0.0) + self.assertTrue(self.net.ping([self.h[0], vnf1]) <= 0.0) # remove compute resources self.dc[0].stopCompute("vnf1") # check number of running nodes - assert(len(self.getDockernetContainers()) == 0) - assert(len(self.net.hosts) == 1) - assert(len(self.net.switches) == 1) + self.assertTrue(len(self.getContainernetContainers()) == 0) + self.assertTrue(len(self.net.hosts) == 1) + self.assertTrue(len(self.net.switches) == 1) # check compute list result - assert(len(self.dc[0].listCompute()) == 0) + self.assertTrue(len(self.dc[0].listCompute()) == 0) # stop Mininet network self.stopNet() @@ -166,19 +168,19 @@ class testEmulatorCompute( SimpleTestTopology ): # add compute resources vnf1 = self.dc[0].startCompute("vnf1") # check number of running nodes - assert(len(self.getDockernetContainers()) == 1) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 1) + self.assertTrue(len(self.getContainernetContainers()) == 1) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 1) # check compute list result - assert(len(self.dc[0].listCompute()) == 1) - assert(isinstance(self.dc[0].listCompute()[0], EmulatorCompute)) - assert(self.dc[0].listCompute()[0].name == "vnf1") + self.assertTrue(len(self.dc[0].listCompute()) == 1) + self.assertTrue(isinstance(self.dc[0].listCompute()[0], EmulatorCompute)) + self.assertTrue(self.dc[0].listCompute()[0].name == "vnf1") # check connectivity by using ping - assert(self.net.ping([self.h[0], vnf1]) <= 0.0) + self.assertTrue(self.net.ping([self.h[0], vnf1]) <= 0.0) # check get status s = self.dc[0].containers.get("vnf1").getStatus() - assert(s["name"] == "vnf1") - assert(s["state"]["Running"]) + self.assertTrue(s["name"] == "vnf1") + self.assertTrue(s["state"]["Running"]) # stop Mininet network self.stopNet() @@ -200,14 +202,14 @@ class testEmulatorCompute( SimpleTestTopology ): vnf1 = self.dc[0].startCompute("vnf1") vnf2 = self.dc[1].startCompute("vnf2") # check number of running nodes - assert(len(self.getDockernetContainers()) == 2) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 5) + self.assertTrue(len(self.getContainernetContainers()) == 2) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 5) # check compute list result - assert(len(self.dc[0].listCompute()) == 1) - assert(len(self.dc[1].listCompute()) == 1) + self.assertTrue(len(self.dc[0].listCompute()) == 1) + self.assertTrue(len(self.dc[1].listCompute()) == 1) # check connectivity by using ping - assert(self.net.ping([vnf1, vnf2]) <= 0.0) + self.assertTrue(self.net.ping([vnf1, vnf2]) <= 0.0) # stop Mininet network self.stopNet() @@ -229,38 +231,38 @@ class testEmulatorCompute( SimpleTestTopology ): vnf1 = self.dc[0].startCompute("vnf1") vnf2 = self.dc[1].startCompute("vnf2") # check number of running nodes - assert(len(self.getDockernetContainers()) == 2) - assert(len(self.net.hosts) == 2) - assert(len(self.net.switches) == 5) + self.assertTrue(len(self.getContainernetContainers()) == 2) + self.assertTrue(len(self.net.hosts) == 2) + self.assertTrue(len(self.net.switches) == 5) # check compute list result - assert(len(self.dc[0].listCompute()) == 1) - assert(len(self.dc[1].listCompute()) == 1) + self.assertTrue(len(self.dc[0].listCompute()) == 1) + self.assertTrue(len(self.dc[1].listCompute()) == 1) # check connectivity by using ping - assert(self.net.ping([vnf1, vnf2]) <= 0.0) + self.assertTrue(self.net.ping([vnf1, vnf2]) <= 0.0) # remove compute resources self.dc[0].stopCompute("vnf1") # check number of running nodes - assert(len(self.getDockernetContainers()) == 1) - assert(len(self.net.hosts) == 1) - assert(len(self.net.switches) == 5) + self.assertTrue(len(self.getContainernetContainers()) == 1) + self.assertTrue(len(self.net.hosts) == 1) + self.assertTrue(len(self.net.switches) == 5) # check compute list result - assert(len(self.dc[0].listCompute()) == 0) - assert(len(self.dc[1].listCompute()) == 1) + self.assertTrue(len(self.dc[0].listCompute()) == 0) + self.assertTrue(len(self.dc[1].listCompute()) == 1) # add compute resources vnf3 = self.dc[0].startCompute("vnf3") vnf4 = self.dc[0].startCompute("vnf4") # check compute list result - assert(len(self.dc[0].listCompute()) == 2) - assert(len(self.dc[1].listCompute()) == 1) - assert(self.net.ping([vnf3, vnf2]) <= 0.0) - assert(self.net.ping([vnf4, vnf2]) <= 0.0) + self.assertTrue(len(self.dc[0].listCompute()) == 2) + self.assertTrue(len(self.dc[1].listCompute()) == 1) + self.assertTrue(self.net.ping([vnf3, vnf2]) <= 0.0) + self.assertTrue(self.net.ping([vnf4, vnf2]) <= 0.0) # remove compute resources self.dc[0].stopCompute("vnf3") self.dc[0].stopCompute("vnf4") self.dc[1].stopCompute("vnf2") # check compute list result - assert(len(self.dc[0].listCompute()) == 0) - assert(len(self.dc[1].listCompute()) == 0) + self.assertTrue(len(self.dc[0].listCompute()) == 0) + self.assertTrue(len(self.dc[1].listCompute()) == 0) # stop Mininet network self.stopNet()