From: peusterm Date: Sun, 13 Mar 2016 11:54:11 +0000 (+0100) Subject: added first tests for resource model api X-Git-Tag: v3.1~163^2~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=5c6475c4aa9c587ccb7ab8de03ce27037c74aaaf;p=osm%2Fvim-emu.git added first tests for resource model api --- diff --git a/src/emuvim/test/test_resourcemodel_api.py b/src/emuvim/test/test_resourcemodel_api.py new file mode 100644 index 0000000..2ec31a0 --- /dev/null +++ b/src/emuvim/test/test_resourcemodel_api.py @@ -0,0 +1,35 @@ +from emuvim.test.base import SimpleTestTopology +from emuvim.dcemulator.resourcemodel import BaseResourceModel + + +class testResourceModel(SimpleTestTopology): + + def testBaseResourceModelApi(self): + pass + # TODO test add flavor etc. + # TODO test aaloc / free + + def testAddRmToDc(self): + # create network + self.createNet(nswitches=0, ndatacenter=1, nhosts=2, ndockers=0) + # setup links + self.net.addLink(self.dc[0], self.h[0]) + self.net.addLink(self.h[1], self.dc[0]) + # add resource model + r = BaseResourceModel() + self.dc[0].assignResourceModel(r) + # 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) + # check resource model and resource model registrar + assert(self.dc[0]._resource_model is not None) + assert(self.net.rm_registrar.num_models == 1) + # TODO test if alloc was called on start + # TODO if free was called on stop + # check connectivity by using ping + assert(self.net.ping([self.h[0], self.h[1]]) <= 0.0) + # stop Mininet network + self.stopNet()