Пример #1
0
 def ensure_isl_props(self, tx, isl, props):
     isl_record = isl_utils.fetch(tx, isl)
     neo4j_connect.pull(isl_record)
     for name in props:
         self.assertEqual(
             props[name], isl_record[name],
             "Invalid ISL's {!r} value ({!r})".format(name, isl_record))
Пример #2
0
    def test_time_update_on_isl_discovery(self):
        sw_alpha = make_datapath_id(1)
        sw_beta = make_datapath_id(2)
        isl_alpha_beta = model.InterSwitchLink(
            model.NetworkEndpoint(sw_alpha, 2),
            model.NetworkEndpoint(sw_beta, 2), None)

        self.assertTrue(make_switch_add(sw_alpha))
        self.assertTrue(make_switch_add(sw_beta))

        update_point_a = model.TimeProperty.now(milliseconds_precission=True)

        message = share.command(share.payload_isl_info(isl_alpha_beta))
        message['timestamp'] = update_point_a.as_java_timestamp()
        self.assertTrue(messageclasses.MessageItem(**message).handle())

        recovered = model.TimeProperty.new_from_java_timestamp(
            message['timestamp'])
        self.assertEquals(update_point_a.value, recovered.value)

        with neo4j_connect.begin() as tx:
            isl = isl_utils.fetch(tx, isl_alpha_beta)
            neo4j_connect.pull(isl)

            db_ctime = model.TimeProperty.new_from_db(isl['time_create'])
            self.assertEqual(update_point_a.value, db_ctime.value)

            db_mtime = model.TimeProperty.new_from_db(isl['time_modify'])
            self.assertEqual(update_point_a.value, db_mtime.value)

        # one more update
        update_point_b = model.TimeProperty.now(milliseconds_precission=True)
        self.assertNotEqual(update_point_a.value, update_point_b.value)

        message['timestamp'] = update_point_b.as_java_timestamp()
        self.assertTrue(messageclasses.MessageItem(**message).handle())
        with neo4j_connect.begin() as tx:
            isl = isl_utils.fetch(tx, isl_alpha_beta)
            neo4j_connect.pull(isl)

            db_ctime = model.TimeProperty.new_from_db(isl['time_create'])
            self.assertEqual(update_point_a.value, db_ctime.value)

            db_mtime = model.TimeProperty.new_from_db(isl['time_modify'])
            self.assertEqual(update_point_b.value, db_mtime.value)
Пример #3
0
    def test_drop(self):
        lookup_mask = model.LinkProps(self.endpoint_alpha, self.endpoint_beta)

        with self.open_neo4j_session() as tx:
            isl_db = isl_utils.fetch(
                tx,
                model.InterSwitchLink(self.endpoint_alpha, self.endpoint_beta))
            tx.graph.pull(isl_db)
            self.assertEqual('alpha-beta', isl_db['name'])

        self._drop(lookup_mask)

        self._ensure_missing(lookup_mask)
        self._ensure_exists(
            model.LinkProps(self.endpoint_alpha, self.endpoint_gamma),
            model.LinkProps(self.endpoint_beta, self.endpoint_gamma))

        with self.open_neo4j_session() as tx:
            isl_db = isl_utils.fetch(
                tx,
                model.InterSwitchLink(self.endpoint_alpha, self.endpoint_beta))
            tx.graph.pull(isl_db)
            self.assertNotIn('name', isl_db)
Пример #4
0
    def test_put_and_propagate(self):
        unique_value = str(uuid.uuid4())
        link_props = model.LinkProps(self.endpoint_alpha,
                                     self.endpoint_beta,
                                     props={'test': unique_value})
        self._put(link_props)

        with self.open_neo4j_session() as tx:
            persistent = link_props_utils.read(tx, link_props)
            self.assertEqual(link_props, persistent)

            isl_db = isl_utils.fetch(
                tx, model.InterSwitchLink.new_from_link_props(link_props))
            tx.graph.pull(isl_db)
            self.assertEqual(unique_value, isl_db['test'])
Пример #5
0
    def test_isl_without_life_cycle_fields(self):
        sw_alpha = share.make_datapath_id(1)
        sw_beta = share.make_datapath_id(2)
        isl_alpha_beta = model.InterSwitchLink(
                model.IslPathNode(sw_alpha, 2),
                model.IslPathNode(sw_beta, 2), None)

        self.assertTrue(make_switch_add(sw_alpha))
        self.assertTrue(make_switch_add(sw_beta))

        self.assertTrue(share.feed_isl_discovery(isl_alpha_beta))

        with neo4j_connect.begin() as tx:
            neo4j_connect.pull(isl_utils.fetch(tx, isl_alpha_beta))
            isl_utils.set_props(
                    tx, isl_alpha_beta,
                    {'time_create': None, 'time_modify': None})

        self.assertTrue(share.feed_isl_discovery(isl_alpha_beta))