From 8687cb7cc800f3766e9d173add63b81266d1d40c Mon Sep 17 00:00:00 2001 From: peusterm Date: Thu, 28 Apr 2016 20:32:36 +0200 Subject: [PATCH] Added a dummy resource model that logs allocations but does no limitations. Used as reference for the emulator paper's evaluation --- .../dcemulator/resourcemodel/upb/simple.py | 13 +++++++++ src/emuvim/test/test_resourcemodel.py | 29 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/emuvim/dcemulator/resourcemodel/upb/simple.py b/src/emuvim/dcemulator/resourcemodel/upb/simple.py index d7a0897..beb3fbe 100644 --- a/src/emuvim/dcemulator/resourcemodel/upb/simple.py +++ b/src/emuvim/dcemulator/resourcemodel/upb/simple.py @@ -289,3 +289,16 @@ class UpbOverprovisioningCloudDcRM(UpbSimpleCloudDcRM): # calculate return float(e_cpu) / sum([rm.dc_max_cu for rm in list(self.registrar.resource_models)]) * self.cpu_op_factor + +class UpbDummyRM(UpbSimpleCloudDcRM): + """ + No limits. But log allocations. + """ + def __init__(self, *args, **kvargs): + super(UpbDummyRM, self).__init__(*args, **kvargs) + self.raise_no_cpu_resources_left = False + + def _apply_limits(self): + # do nothing here + pass + diff --git a/src/emuvim/test/test_resourcemodel.py b/src/emuvim/test/test_resourcemodel.py index 3976536..1817a25 100644 --- a/src/emuvim/test/test_resourcemodel.py +++ b/src/emuvim/test/test_resourcemodel.py @@ -2,7 +2,7 @@ import time import os from emuvim.test.base import SimpleTestTopology from emuvim.dcemulator.resourcemodel import BaseResourceModel, ResourceFlavor, NotEnoughResourcesAvailable, ResourceModelRegistrar -from emuvim.dcemulator.resourcemodel.upb.simple import UpbSimpleCloudDcRM, UpbOverprovisioningCloudDcRM +from emuvim.dcemulator.resourcemodel.upb.simple import UpbSimpleCloudDcRM, UpbOverprovisioningCloudDcRM, UpbDummyRM @@ -309,4 +309,31 @@ class testUpbOverprovisioningCloudDcRM(SimpleTestTopology): self.assertAlmostEqual(rm.cpu_op_factor, 0.6) +class testUpbDummyRM(SimpleTestTopology): + """ + Test the UpbDummyRM resource model. + """ + + def testAllocationComputations(self): + """ + Test the allocation procedures and correct calculations. + :return: + """ + # config + E_CPU = 1.0 + MAX_CU = 3 + E_MEM = 512 + MAX_MU = 2048 + # create dummy resource model environment + reg = ResourceModelRegistrar(dc_emulation_max_cpu=E_CPU, dc_emulation_max_mem=E_MEM) + rm = UpbDummyRM(max_cu=MAX_CU, max_mu=MAX_MU) + reg.register("test_dc", rm) + + c1 = createDummyContainerObject("c1", flavor="small") + rm.allocate(c1) # calculate allocation + self.assertEqual(len(rm._allocated_compute_instances), 1) + + c2 = createDummyContainerObject("c2", flavor="small") + rm.allocate(c2) # calculate allocation + self.assertEqual(len(rm._allocated_compute_instances), 2) -- 2.25.1