示例#1
0
    def test_compatible_updates(self):
        proxy = self.node.get_proxy('/')
        tx1 = proxy.open_transaction()
        tx2 = proxy.open_transaction()
        tx3 = proxy.open_transaction()
        tx4 = proxy.open_transaction()
        tx5 = proxy.open_transaction()
        tx1.update('/health', HealthStatus(state=HealthStatus.OVERLOADED))
        self.make_change(tx2, '/adapters/1', 'version', '42')
        self.make_change(tx3, '/adapters/2', 'config.log_level', 2)
        self.make_change(tx4, '/adapters/1', 'version', '42')
        self.make_change(tx5, '/adapters/1', 'version', '422')
        tx1.commit()
        tx2.commit()
        tx3.commit()
        tx4.commit()
        self.assertRaises(MergeConflictException, tx5.commit)

        # verify outcome
        self.assertEqual(self.node.get('/health').state, 1)
        self.assertEqual(self.node.get('/', deep=1).adapters[1].version, '42')
        self.assertEqual(self.log_levels(), {
            '0': 3,
            '1': 3,
            '2': 2,
            '3': 3,
            '4': 3
        })
示例#2
0
    def test_passive_ownership(self):

        # grab a proxy for a given node
        proxy = self.node.get_proxy('/health')

        # able to read the value directly using this proxy
        self.assertEqual(proxy.get(), HealthStatus(state=HealthStatus.DYING))

        # able to update value directly using this proxy, but the whole tree
        # updates
        proxy.update('/', HealthStatus(state=HealthStatus.HEALTHY))
        self.assertEqual(proxy.get().state, HealthStatus.HEALTHY)
        self.assertNotEqual(self.node.latest.hash, self.hash_orig)

        # access constraints are still enforced
        self.assertRaises(
            ValueError, proxy.update,
            '/', HealthStatus(state=HealthStatus.OVERLOADED), strict=1)
示例#3
0
 def setUp(self):
     gc.collect()
     _rev_cache.clear()
     self.health = HealthStatus(state=HealthStatus.DYING)
     self.base_shallow = VolthaInstance(instance_id='1')
     self.base_deep = copy(self.base_shallow)
     self.base_deep.health.state = HealthStatus.DYING  # = self.health
     for i in xrange(5):
         self.base_deep.adapters.add().MergeFrom(
             Adapter(id=str(i), config=AdapterConfig(log_level=3)))
     self.node = ConfigRoot(self.base_deep)
     self.hash_orig = self.node.latest.hash
示例#4
0
    def test_deep_update_non_container(self):

        self.node.update('/health', HealthStatus(state=HealthStatus.HEALTHY))

        # root hash is now different
        hash_new = self.node.latest.hash
        self.assertNotEqual(self.hash_orig, hash_new)

        # original tree is still intact
        orig = self.node.get(hash=self.hash_orig, deep=1)
        self.assertEqual(orig, self.base_deep)
        self.assertEqual(orig.health.state, HealthStatus.DYING)

        # but the latest contains the change
        new = self.node.get(deep=1)
        self.assertNotEqual(new, orig)
        self.assertEqual(new.health.state, HealthStatus.HEALTHY)
示例#5
0
 def pump_some_data(self, node):
     seed(0)
     node.update('/',
                 VolthaInstance(instance_id='1', version='42', log_level=1))
     node.update('/health', HealthStatus(state=HealthStatus.OVERLOADED))
     for i in xrange(n_adapters):
         node.add(
             '/adapters',
             Adapter(id=str(i),
                     vendor='cord',
                     version=str(randint(1, 10)),
                     config=AdapterConfig(log_level=0)))
     for i in xrange(n_logical_nodes):
         node.add(
             '/logical_devices',
             LogicalDevice(id=str(i),
                           datapath_id=randint(1, 100000),
                           desc=ofp_desc(mfr_desc='foo',
                                         hw_desc='bar',
                                         sw_desc='zoo')))