示例#1
0
    def test_full_sync_removes_pending_rows(self):
        self._mock_canary_missing()
        db.create_pending_row(self.db_session, odl_const.ODL_NETWORK, "uuid",
                              odl_const.ODL_CREATE, {'foo': 'bar'})
        full_sync.full_sync(self.db_session)

        rows = self._assert_canary_created()
        self._assert_no_journal_rows(rows)
示例#2
0
    def _test_full_sync_resources(self, expected_journal):
        self._mock_canary_missing()

        full_sync.full_sync(self.db_session)

        rows = self._assert_canary_created()
        rows = self._filter_out_canary(rows)
        self.assertItemsEqual(expected_journal.keys(),
                              [row['object_type'] for row in rows])
        for row in rows:
            self.assertEqual(expected_journal[row['object_type']],
                             row['object_uuid'])
示例#3
0
    def _test_full_sync_resources(self, expected_journal):
        self._mock_canary_missing()
        directory.add_plugin(constants.CORE, mock.Mock())
        full_sync.full_sync(self.db_context)

        rows = self._assert_canary_created()
        rows = self._filter_out_canary(rows)
        self.assertItemsEqual(expected_journal.keys(),
                              [row['object_type'] for row in rows])
        for row in rows:
            self.assertEqual(expected_journal[row['object_type']],
                             row['object_uuid'])
    def _test_full_sync_resources(self, expected_journal):
        self._mock_canary_missing()
        directory.add_plugin(constants.CORE, mock.Mock())
        full_sync.full_sync(self.db_context)

        rows = self._assert_canary_created()
        rows = self._filter_out_canary(rows)
        self.assertItemsEqual(expected_journal.keys(),
                              [row['object_type'] for row in rows])
        for row in rows:
            self.assertEqual(expected_journal[row['object_type']],
                             row['object_uuid'])
示例#5
0
    def test_full_sync_resources(self):
        self._mock_canary_missing()
        resources = self._mock_plugin_resources()

        full_sync.full_sync(self.db_session)

        rows = self._assert_canary_created()
        rows = self._filter_out_canary(rows)
        self.assertItemsEqual(resources.keys(),
                              [row['object_type'] for row in rows])
        for row in rows:
            self.assertEqual(resources[row['object_type']], row['object_uuid'])
示例#6
0
    def _test_no_full_sync_when_canary_in_journal(self, state):
        self._mock_canary_missing()
        self._mock_l2_resources()
        db.create_pending_row(self.db_session, odl_const.ODL_NETWORK,
                              full_sync._CANARY_NETWORK_ID,
                              odl_const.ODL_CREATE, {})
        row = db.get_all_db_rows(self.db_session)[0]
        db.update_db_row_state(self.db_session, row, state)

        full_sync.full_sync(self.db_session)

        rows = db.get_all_db_rows(self.db_session)
        self.assertEqual([], self._filter_out_canary(rows))
    def _test_no_full_sync_when_canary_in_journal(self, state):
        self._mock_canary_missing()
        self._mock_l2_resources()
        db.create_pending_row(self.db_context, odl_const.ODL_NETWORK,
                              full_sync._CANARY_NETWORK_ID,
                              odl_const.ODL_CREATE, {})
        row = db.get_all_db_rows(self.db_context)[0]
        db.update_db_row_state(self.db_context, row, state)

        full_sync.full_sync(self.db_context)

        rows = db.get_all_db_rows(self.db_context)
        self.assertEqual([], self._filter_out_canary(rows))
示例#8
0
    def test_sync_resource_order(
            self, record_mock, _sync_resources_mock, _full_sync_needed_mock,
            delete_pending_rows_mock):
        all_resources = self._get_all_resources()
        full_sync.FULL_SYNC_RESOURCES = {resource_type: mock.Mock()
                                         for resource_type, _ in all_resources}
        _full_sync_needed_mock._full_sync_needed.return_value = True
        context = mock.MagicMock()
        full_sync.full_sync(context)

        _sync_resources_mock.assert_has_calls(
            [mock.call(mock.ANY, object_type, mock.ANY)
                for object_type, _ in all_resources])
示例#9
0
    def _test_no_full_sync_when_canary_in_journal(self, state):
        self._mock_canary_missing()
        self._mock_plugin_resources()
        db.create_pending_row(self.db_session, odl_const.ODL_NETWORK,
                              full_sync._CANARY_NETWORK_ID,
                              odl_const.ODL_CREATE, {})
        row = db.get_all_db_rows(self.db_session)[0]
        db.update_db_row_state(self.db_session, row, state)

        full_sync.full_sync(self.db_session)

        rows = db.get_all_db_rows(self.db_session)
        self._assert_no_journal_rows(rows)
示例#10
0
    def test_sync_resource_order(self, record_mock, _sync_resources_mock,
                                 _full_sync_needed_mock,
                                 delete_pending_rows_mock):

        full_sync.ALL_RESOURCES = self._get_all_resources()
        _full_sync_needed_mock._full_sync_needed.return_value = True
        context = mock.MagicMock()
        full_sync.full_sync(context)

        _sync_resources_mock.assert_has_calls([
            mock.call(mock.ANY, mock.ANY, object_type, collection_name)
            for (object_type, collection_name) in
            [(odl_const.ODL_SG, odl_const.ODL_SGS
              ), (odl_const.ODL_SG_RULE, odl_const.ODL_SG_RULES
                  ), (odl_const.ODL_NETWORK, odl_const.ODL_NETWORKS
                      ), (odl_const.ODL_SUBNET, odl_const.ODL_SUBNETS),
             (odl_const.ODL_ROUTER,
              odl_const.ODL_ROUTERS), (odl_const.ODL_PORT,
                                       odl_const.ODL_PORTS),
             (odl_const.ODL_FLOATINGIP, odl_const.ODL_FLOATINGIPS
              ), (odl_const.ODL_LOADBALANCER, odl_const.ODL_LOADBALANCERS
                  ), (odl_const.ODL_LISTENER, odl_const.ODL_LISTENERS
                      ), (odl_const.ODL_POOL, odl_const.ODL_POOLS
                          ), (odl_const.ODL_MEMBER, odl_const.ODL_MEMBERS),
             (odl_const.ODL_HEALTHMONITOR, odl_const.ODL_HEALTHMONITORS
              ), (odl_const.ODL_QOS_POLICY, odl_const.ODL_QOS_POLICIES
                  ), (odl_const.ODL_TRUNK, odl_const.ODL_TRUNKS
                      ), (odl_const.ODL_BGPVPN, odl_const.ODL_BGPVPNS),
             (odl_const.ODL_BGPVPN_NETWORK_ASSOCIATION,
              odl_const.ODL_BGPVPN_NETWORK_ASSOCIATIONS),
             (odl_const.ODL_BGPVPN_ROUTER_ASSOCIATION,
              odl_const.ODL_BGPVPN_ROUTER_ASSOCIATIONS),
             (odl_const.ODL_SFC_FLOW_CLASSIFIER,
              odl_const.NETWORKING_SFC_FLOW_CLASSIFIERS),
             (odl_const.ODL_SFC_PORT_PAIR,
              odl_const.NETWORKING_SFC_PORT_PAIRS),
             (odl_const.ODL_SFC_PORT_PAIR_GROUP,
              odl_const.NETWORKING_SFC_PORT_PAIR_GROUPS),
             (odl_const.ODL_SFC_PORT_CHAIN,
              odl_const.NETWORKING_SFC_PORT_CHAINS
              ), (odl_const.ODL_L2GATEWAY, odl_const.ODL_L2GATEWAYS),
             (odl_const.ODL_L2GATEWAY_CONNECTION,
              odl_const.ODL_L2GATEWAY_CONNECTIONS)]
        ])
示例#11
0
    def test_sync_resource_order(self, record_mock, _sync_resources_mock,
                                 _full_sync_needed_mock,
                                 delete_pending_rows_mock):
        _full_sync_needed_mock._full_sync_needed.return_value = True
        session = mock.MagicMock()
        full_sync.full_sync(session)

        _sync_resources_mock.assert_has_calls([
            mock.call(session, mock.ANY, mock.ANY, object_type,
                      collection_name)
            for (object_type, collection_name) in [(
                odl_const.ODL_SG, odl_const.ODL_SGS
            ), (odl_const.ODL_SG_RULE, odl_const.ODL_SG_RULES
                ), (odl_const.ODL_NETWORK, odl_const.ODL_NETWORKS
                    ), (odl_const.ODL_SUBNET, odl_const.ODL_SUBNETS
                        ), (odl_const.ODL_ROUTER, odl_const.ODL_ROUTERS
                            ), (odl_const.ODL_PORT, odl_const.ODL_PORTS),
                                                   (odl_const.ODL_FLOATINGIP,
                                                    odl_const.ODL_FLOATINGIPS)]
        ])
示例#12
0
 def test_no_full_sync_when_canary_exists(self):
     full_sync.full_sync(self.db_session)
     self.assertEqual([], db.get_all_db_rows(self.db_session))
示例#13
0
 def test_no_full_sync_when_canary_exists(self):
     full_sync.full_sync(self.db_context)
     self.assertEqual([], db.get_all_db_rows(self.db_context))
示例#14
0
    def test_full_sync_no_resources(self):
        self._mock_canary_missing()
        full_sync.full_sync(self.db_session)

        rows = self._assert_canary_created()
        self._assert_no_journal_rows(rows)