Пример #1
0
    def test_get_by_filter(self):
        db_acc = self.fake_accelerator
        db_pf = self.fake_physical_function
        db_vf = self.fake_virtual_function
        acc = objects.Accelerator(context=self.context, **db_acc)
        acc.create(self.context)
        acc_get = objects.Accelerator.get(self.context, acc.uuid)
        pf = objects.PhysicalFunction(context=self.context, **db_pf)

        pf.accelerator_id = acc_get.id
        pf.create(self.context)
        pf_get = objects.PhysicalFunction.get(self.context, pf.uuid)
        vf = objects.VirtualFunction(context=self.context, **db_vf)
        vf.accelerator_id = pf_get.accelerator_id
        vf.create(self.context)
        vf_get = objects.VirtualFunction.get(self.context, vf.uuid)
        pf_get.add_vf(vf_get)
        pf_get.save(self.context)

        query = {"vendor": pf_get['vendor']}
        vf_get_list = objects.VirtualFunction.get_by_filter(
            self.context, query)

        self.assertEqual(len(vf_get_list), 1)
        self.assertEqual(vf_get_list[0].uuid, vf.uuid)
        self.assertEqual(objects.VirtualFunction, type(vf_get_list[0]))
        self.assertEqual(1, 1)
Пример #2
0
    def test_get(self):
        db_vf = self.fake_virtual_function
        db_acc = self.fake_accelerator

        acc = objects.Accelerator(context=self.context, **db_acc)
        acc.create(self.context)
        acc_get = objects.Accelerator.get(self.context, acc.uuid)
        vf = objects.VirtualFunction(context=self.context, **db_vf)
        vf.accelerator_id = acc_get.id
        vf.create(self.context)
        vf_get = objects.VirtualFunction.get(self.context, vf.uuid)
        self.assertEqual(vf_get.uuid, vf.uuid)
Пример #3
0
    def test_destroy(self):
        db_vf = self.fake_virtual_function
        db_acc = self.fake_accelerator

        acc = objects.Accelerator(context=self.context, **db_acc)
        acc.create(self.context)
        acc_get = objects.Accelerator.get(self.context, acc.uuid)
        vf = objects.VirtualFunction(context=self.context, **db_vf)
        vf.accelerator_id = acc_get.id
        vf.create(self.context)
        vf_get = objects.VirtualFunction.get(self.context, vf.uuid)
        self.assertEqual(db_vf['uuid'], vf_get.uuid)
        vf_get.destroy(self.context)
        self.assertRaises(exception.DeployableNotFound,
                          objects.VirtualFunction.get, self.context,
                          vf_get['uuid'])
Пример #4
0
    def test_add_vf(self):
        db_pf = self.fake_physical_function
        db_vf = self.fake_virtual_function
        db_acc = self.fake_accelerator
        acc = objects.Accelerator(context=self.context, **db_acc)
        acc.create(self.context)
        acc_get = objects.Accelerator.get(self.context, acc.uuid)
        pf = objects.PhysicalFunction(context=self.context, **db_pf)
        pf.accelerator_id = acc_get.id
        pf.create(self.context)
        pf_get = objects.PhysicalFunction.get(self.context, pf.uuid)

        vf = objects.VirtualFunction(context=self.context, **db_vf)
        vf.accelerator_id = pf_get.accelerator_id
        vf.create(self.context)
        vf_get = objects.VirtualFunction.get(self.context, vf.uuid)

        pf_get.add_vf(vf_get)

        pf_get.save(self.context)
        pf_get_2 = objects.PhysicalFunction.get(self.context, pf.uuid)

        self.assertEqual(db_vf['uuid'], pf_get_2.virtual_function_list[0].uuid)