Esempio n. 1
0
    def testAllocationMemLimit(self):
        """
        Test MEM allocation limit
        :return:
        """
        # config
        E_CPU = 1.0
        MAX_CU = 500
        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 = UpbSimpleCloudDcRM(max_cu=MAX_CU, max_mu=MAX_MU)
        reg.register("test_dc", rm)

        # test over provisioning exeption
        exception = False
        try:
            c6 = createDummyContainerObject("c6", flavor="xlarge")
            c7 = createDummyContainerObject("c7", flavor="xlarge")
            c8 = createDummyContainerObject("c8", flavor="xlarge")
            rm.allocate(c6)  # calculate allocation
            rm.allocate(c7)  # calculate allocation
            rm.allocate(c8)  # calculate allocation
        except NotEnoughResourcesAvailable as e:
            self.assertIn("Not enough memory", e.message)
            exception = True
        self.assertTrue(exception)
    def testAllocationMemLimit(self):
        """
        Test MEM allocation limit
        :return:
        """
        # config
        E_CPU = 1.0
        MAX_CU = 500
        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 = UpbSimpleCloudDcRM(max_cu=MAX_CU, max_mu=MAX_MU)
        reg.register("test_dc", rm)

        # test over provisioning exeption
        exception = False
        try:
            c6 = createDummyContainerObject("c6", flavor="xlarge")
            c7 = createDummyContainerObject("c7", flavor="xlarge")
            c8 = createDummyContainerObject("c8", flavor="xlarge")
            rm.allocate(c6)  # calculate allocation
            rm.allocate(c7)  # calculate allocation
            rm.allocate(c8)  # calculate allocation
        except NotEnoughResourcesAvailable as e:
            self.assertIn("Not enough memory", str(e))
            exception = True
        self.assertTrue(exception)
Esempio n. 3
0
    def testAllocationComputations(self):
        """
        Test the allocation procedures and correct calculations.
        :return:
        """
        # config
        E_CPU = 1.0
        MAX_CU = 100
        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 = UpbSimpleCloudDcRM(max_cu=MAX_CU, max_mu=MAX_MU)
        reg.register("test_dc", rm)

        c1 = createDummyContainerObject("c1", flavor="tiny")
        rm.allocate(c1)  # calculate allocation
        # validate compute result
        self.assertEqual(float(
            c1.resources['cpu_quota']) / c1.resources['cpu_period'], E_CPU / MAX_CU * 0.5)
        # validate memory result
        self.assertEqual(
            float(c1.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 32)

        c2 = createDummyContainerObject("c2", flavor="small")
        rm.allocate(c2)  # calculate allocation
        # validate compute result
        self.assertEqual(float(
            c2.resources['cpu_quota']) / c2.resources['cpu_period'], E_CPU / MAX_CU * 1)
        # validate memory result
        self.assertEqual(
            float(c2.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 128)

        c3 = createDummyContainerObject("c3", flavor="medium")
        rm.allocate(c3)  # calculate allocation
        # validate compute result
        self.assertEqual(float(
            c3.resources['cpu_quota']) / c3.resources['cpu_period'], E_CPU / MAX_CU * 4)
        # validate memory result
        self.assertEqual(
            float(c3.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 256)

        c4 = createDummyContainerObject("c4", flavor="large")
        rm.allocate(c4)  # calculate allocation
        # validate compute result
        self.assertEqual(float(
            c4.resources['cpu_quota']) / c4.resources['cpu_period'], E_CPU / MAX_CU * 8)
        # validate memory result
        self.assertEqual(
            float(c4.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 512)

        c5 = createDummyContainerObject("c5", flavor="xlarge")
        rm.allocate(c5)  # calculate allocation
        # validate compute result
        self.assertEqual(float(
            c5.resources['cpu_quota']) / c5.resources['cpu_period'], E_CPU / MAX_CU * 16)
        # validate memory result
        self.assertEqual(
            float(c5.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 1024)
Esempio n. 4
0
    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 = UpbOverprovisioningCloudDcRM(max_cu=MAX_CU, max_mu=MAX_MU)
        reg.register("test_dc", rm)

        c1 = createDummyContainerObject("c1", flavor="small")
        rm.allocate(c1)  # calculate allocation
        self.assertAlmostEqual(float(
            c1.resources['cpu_quota']) / c1.resources['cpu_period'], E_CPU / MAX_CU * 1.0, places=5)
        self.assertAlmostEqual(
            float(c1.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 1.0)

        c2 = createDummyContainerObject("c2", flavor="small")
        rm.allocate(c2)  # calculate allocation
        self.assertAlmostEqual(float(
            c2.resources['cpu_quota']) / c2.resources['cpu_period'], E_CPU / MAX_CU * 1.0, places=5)
        self.assertAlmostEqual(
            float(c2.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 1.0)

        c3 = createDummyContainerObject("c3", flavor="small")
        rm.allocate(c3)  # calculate allocation
        self.assertAlmostEqual(float(
            c3.resources['cpu_quota']) / c3.resources['cpu_period'], E_CPU / MAX_CU * 1.0, places=5)
        self.assertAlmostEqual(
            float(c3.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 1.0)

        # from this container onwards, we should go to over provisioning mode:
        c4 = createDummyContainerObject("c4", flavor="small")
        rm.allocate(c4)  # calculate allocation
        self.assertAlmostEqual(float(
            c4.resources['cpu_quota']) / c4.resources['cpu_period'], E_CPU / MAX_CU * (float(3) / 4), places=5)
        self.assertAlmostEqual(float(
            c4.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 128, places=5)
        self.assertAlmostEqual(rm.cpu_op_factor, 0.75)

        c5 = createDummyContainerObject("c5", flavor="small")
        rm.allocate(c5)  # calculate allocation
        self.assertAlmostEqual(float(
            c5.resources['cpu_quota']) / c5.resources['cpu_period'], E_CPU / MAX_CU * (float(3) / 5), places=5)
        self.assertAlmostEqual(
            float(c5.resources['mem_limit'] / 1024 / 1024), float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 0.6)
 def testFree(self):
     """
     Test the free procedure.
     :return:
     """
     # create dummy resource model environment
     reg = ResourceModelRegistrar(dc_emulation_max_cpu=1.0,
                                  dc_emulation_max_mem=512)
     rm = UpbSimpleCloudDcRM(max_cu=100, max_mu=100)
     reg.register("test_dc", rm)
     c1 = createDummyContainerObject("c6", flavor="tiny")
     rm.allocate(c1)  # calculate allocation
     self.assertTrue(rm.dc_alloc_cu == 0.5)
     rm.free(c1)
     self.assertTrue(rm.dc_alloc_cu == 0)
Esempio n. 6
0
 def testFree(self):
     """
     Test the free procedure.
     :return:
     """
     # create dummy resource model environment
     reg = ResourceModelRegistrar(
         dc_emulation_max_cpu=1.0, dc_emulation_max_mem=512)
     rm = UpbSimpleCloudDcRM(max_cu=100, max_mu=100)
     reg.register("test_dc", rm)
     c1 = createDummyContainerObject("c6", flavor="tiny")
     rm.allocate(c1)  # calculate allocation
     self.assertTrue(rm.dc_alloc_cu == 0.5)
     rm.free(c1)
     self.assertTrue(rm.dc_alloc_cu == 0)
Esempio n. 7
0
    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)
    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)
    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 = UpbOverprovisioningCloudDcRM(max_cu=MAX_CU, max_mu=MAX_MU)
        reg.register("test_dc", rm)

        c1 = createDummyContainerObject("c1", flavor="small")
        rm.allocate(c1)  # calculate allocation
        self.assertAlmostEqual(float(c1.resources['cpu_quota']) /
                               c1.resources['cpu_period'],
                               E_CPU / MAX_CU * 1.0,
                               places=5)
        self.assertAlmostEqual(float(c1.resources['mem_limit'] / 1024 / 1024),
                               float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 1.0)

        c2 = createDummyContainerObject("c2", flavor="small")
        rm.allocate(c2)  # calculate allocation
        self.assertAlmostEqual(float(c2.resources['cpu_quota']) /
                               c2.resources['cpu_period'],
                               E_CPU / MAX_CU * 1.0,
                               places=5)
        self.assertAlmostEqual(float(c2.resources['mem_limit'] / 1024 / 1024),
                               float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 1.0)

        c3 = createDummyContainerObject("c3", flavor="small")
        rm.allocate(c3)  # calculate allocation
        self.assertAlmostEqual(float(c3.resources['cpu_quota']) /
                               c3.resources['cpu_period'],
                               E_CPU / MAX_CU * 1.0,
                               places=5)
        self.assertAlmostEqual(float(c3.resources['mem_limit'] / 1024 / 1024),
                               float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 1.0)

        # from this container onwards, we should go to over provisioning mode:
        c4 = createDummyContainerObject("c4", flavor="small")
        rm.allocate(c4)  # calculate allocation
        self.assertAlmostEqual(float(c4.resources['cpu_quota']) /
                               c4.resources['cpu_period'],
                               E_CPU / MAX_CU * (float(3) / 4),
                               places=5)
        self.assertAlmostEqual(float(c4.resources['mem_limit'] / 1024 / 1024),
                               float(E_MEM) / MAX_MU * 128,
                               places=5)
        self.assertAlmostEqual(rm.cpu_op_factor, 0.75)

        c5 = createDummyContainerObject("c5", flavor="small")
        rm.allocate(c5)  # calculate allocation
        self.assertAlmostEqual(float(c5.resources['cpu_quota']) /
                               c5.resources['cpu_period'],
                               E_CPU / MAX_CU * (float(3) / 5),
                               places=5)
        self.assertAlmostEqual(float(c5.resources['mem_limit'] / 1024 / 1024),
                               float(E_MEM) / MAX_MU * 128)
        self.assertAlmostEqual(rm.cpu_op_factor, 0.6)
    def testAllocationComputations(self):
        """
        Test the allocation procedures and correct calculations.
        :return:
        """
        # config
        E_CPU = 1.0
        MAX_CU = 100
        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 = UpbSimpleCloudDcRM(max_cu=MAX_CU, max_mu=MAX_MU)
        reg.register("test_dc", rm)

        c1 = createDummyContainerObject("c1", flavor="tiny")
        rm.allocate(c1)  # calculate allocation
        # validate compute result
        self.assertEqual(
            float(c1.resources['cpu_quota']) / c1.resources['cpu_period'],
            E_CPU / MAX_CU * 0.5)
        # validate memory result
        self.assertEqual(float(c1.resources['mem_limit'] / 1024 / 1024),
                         float(E_MEM) / MAX_MU * 32)

        c2 = createDummyContainerObject("c2", flavor="small")
        rm.allocate(c2)  # calculate allocation
        # validate compute result
        self.assertEqual(
            float(c2.resources['cpu_quota']) / c2.resources['cpu_period'],
            E_CPU / MAX_CU * 1)
        # validate memory result
        self.assertEqual(float(c2.resources['mem_limit'] / 1024 / 1024),
                         float(E_MEM) / MAX_MU * 128)

        c3 = createDummyContainerObject("c3", flavor="medium")
        rm.allocate(c3)  # calculate allocation
        # validate compute result
        self.assertEqual(
            float(c3.resources['cpu_quota']) / c3.resources['cpu_period'],
            E_CPU / MAX_CU * 4)
        # validate memory result
        self.assertEqual(float(c3.resources['mem_limit'] / 1024 / 1024),
                         float(E_MEM) / MAX_MU * 256)

        c4 = createDummyContainerObject("c4", flavor="large")
        rm.allocate(c4)  # calculate allocation
        # validate compute result
        self.assertEqual(
            float(c4.resources['cpu_quota']) / c4.resources['cpu_period'],
            E_CPU / MAX_CU * 8)
        # validate memory result
        self.assertEqual(float(c4.resources['mem_limit'] / 1024 / 1024),
                         float(E_MEM) / MAX_MU * 512)

        c5 = createDummyContainerObject("c5", flavor="xlarge")
        rm.allocate(c5)  # calculate allocation
        # validate compute result
        self.assertEqual(
            float(c5.resources['cpu_quota']) / c5.resources['cpu_period'],
            E_CPU / MAX_CU * 16)
        # validate memory result
        self.assertEqual(float(c5.resources['mem_limit'] / 1024 / 1024),
                         float(E_MEM) / MAX_MU * 1024)