def test_resource_graph(self):
        bank = bank_plugin.Bank(_InMemoryBankPlugin())
        bank_lease = _InMemoryLeasePlugin()
        checkpoints_section = bank_plugin.BankSection(bank, "/checkpoints")
        indices_section = bank_plugin.BankSection(bank, "/indices")
        owner_id = bank.get_owner_id()
        plan = fake_protection_plan()
        cp = checkpoint.Checkpoint.create_in_section(
            checkpoints_section=checkpoints_section,
            indices_section=indices_section,
            bank_lease=bank_lease,
            owner_id=owner_id,
            plan=plan)

        resource_graph = graph.build_graph([A, B, C, D],
                                           resource_map.__getitem__)
        cp.resource_graph = resource_graph
        cp.commit()
        checkpoint_data = cp._md_cache
        self.assertEqual(
            checkpoint_data,
            bank._plugin.get_object(
                "/checkpoints/%s/%s" %
                (checkpoint_data["id"], checkpoint._INDEX_FILE_NAME)))
        self.assertEqual(len(resource_graph), len(cp.resource_graph))
        for start_node in resource_graph:
            self.assertIn(start_node, cp.resource_graph)
Esempio n. 2
0
    def test_resource_graph(self):
        bank = bank_plugin.Bank(_InMemoryBankPlugin())
        bank_lease = _InMemoryLeasePlugin()
        checkpoints_section = bank_plugin.BankSection(bank, "/checkpoints")
        indices_section = bank_plugin.BankSection(bank, "/indices")
        owner_id = bank.get_owner_id()
        plan = fake_protection_plan()
        cp = checkpoint.Checkpoint.create_in_section(
            checkpoints_section=checkpoints_section,
            indices_section=indices_section,
            bank_lease=bank_lease,
            owner_id=owner_id,
            plan=plan)

        resource_graph = graph.build_graph([A, B, C, D],
                                           resource_map.__getitem__)
        cp.resource_graph = resource_graph
        cp.commit()
        checkpoint_data = cp._md_cache
        self.assertEqual(
            checkpoint_data,
            bank._plugin.get_object(
                "/checkpoints/%s/%s" % (checkpoint_data["id"],
                                        checkpoint._INDEX_FILE_NAME)
            )
        )
        self.assertEqual(len(resource_graph), len(cp.resource_graph))
        for start_node in resource_graph:
            self.assertIn(start_node, cp.resource_graph)
 def test_create_in_section(self):
     bank = bank_plugin.Bank(_InMemoryBankPlugin())
     bank_lease = _InMemoryLeasePlugin()
     checkpoints_section = bank_plugin.BankSection(bank, "/checkpoints")
     indices_section = bank_plugin.BankSection(bank, "/indices")
     owner_id = bank.get_owner_id()
     plan = fake_protection_plan()
     cp = checkpoint.Checkpoint.create_in_section(
         checkpoints_section=checkpoints_section,
         indices_section=indices_section,
         bank_lease=bank_lease,
         owner_id=owner_id,
         plan=plan)
     checkpoint_data = cp._md_cache
     self.assertEqual(
         checkpoint_data,
         bank._plugin.get_object(
             "/checkpoints/%s/%s" %
             (checkpoint_data['id'], checkpoint._INDEX_FILE_NAME)))
     self.assertEqual(owner_id, cp.owner_id)
     self.assertEqual("protecting", cp.status)
Esempio n. 4
0
 def test_create_in_section(self):
     bank = bank_plugin.Bank(_InMemoryBankPlugin())
     bank_lease = _InMemoryLeasePlugin()
     checkpoints_section = bank_plugin.BankSection(bank, "/checkpoints")
     indices_section = bank_plugin.BankSection(bank, "/indices")
     owner_id = bank.get_owner_id()
     plan = fake_protection_plan()
     cp = checkpoint.Checkpoint.create_in_section(
         checkpoints_section=checkpoints_section,
         indices_section=indices_section,
         bank_lease=bank_lease,
         owner_id=owner_id,
         plan=plan)
     checkpoint_data = cp._md_cache
     self.assertEqual(
         checkpoint_data,
         bank._plugin.get_object(
             "/checkpoints/%s/%s" % (checkpoint_data['id'],
                                     checkpoint._INDEX_FILE_NAME)
         )
     )
     self.assertEqual(owner_id, cp.owner_id)
     self.assertEqual("protecting", cp.status)
 def _create_test_collection(self):
     return CheckpointCollection(Bank(_InMemoryBankPlugin()),
                                 _InMemoryLeasePlugin())