Esempio n. 1
0
    def test_get_table_metadata_full(self):
        self.mox.StubOutWithMock(queuer.db, 'shard_connection')
        conn = self.mox.CreateMockAnything()
        queuer.db.shard_connection('src', read=True).AndReturn(self.context(conn))
        self.mox.StubOutWithMock(queuer.db, 'cursor')
        cur = self.mox.CreateMockAnything()
        conn.get_current_timestamp().AndReturn(1)
        self.tt.update()
        self.mox.StubOutWithMock(queuer.QueueChunksWorker, 'get_column_metadata')
        queuer.QueueChunksWorker.get_column_metadata(conn)
        db.cursor(conn).AndReturn(self.context(cur))
        cur.execute(mox.IgnoreArg(), mox.IgnoreArg())
        cur.fetchone().AndReturn((1, 2, 3))

        self.mox.ReplayAll()
        self.config.migration_type = orm.MigrationType.FULL
        worker = queuer.QueueChunksWorker(self.config, self.redis)
        worker.get_table_metadata()
Esempio n. 2
0
    def test_get_table_metadata_delta(self):
        self.config.delta_start = 12345
        self.mox.StubOutWithMock(queuer.db, 'shard_connection')
        conn = self.mox.CreateMockAnything()
        queuer.db.shard_connection('src', read=True).AndReturn(self.context(conn))
        self.mox.StubOutWithMock(queuer.db, 'cursor')
        cur = self.mox.CreateMockAnything()
        conn.get_current_timestamp().AndReturn(1)
        self.tt.update()
        self.mox.StubOutWithMock(queuer.QueueChunksWorker, 'get_column_metadata')
        queuer.QueueChunksWorker.get_column_metadata(conn)
        conn.from_unixtime_value(12345).AndReturn('2042T')

        db.cursor(conn).AndReturn(self.context(cur))
        cur.execute(mox.IgnoreArg(), mox.IgnoreArg())
        cur.fetchone().AndReturn((1, 2, 3))

        self.mox.ReplayAll()
        self.config.migration_type = orm.MigrationType.DELTA
        worker = queuer.QueueChunksWorker(self.config, self.redis)
        worker.column_map = {'a': {}, 'b': {}, 'c': {}}
        worker.get_table_metadata()