コード例 #1
0
class MigrationStoreTest(TestWithMongo):

    def setUp(self):
        self.store = MigrationStore(self.conn,  self.__class__.__name__)

    def test_create_and_read_migration(self):
        mig = Migration()
        mig.ID = "3_my_migration"
        mig.applied_timestamp = time.time()
        self.store.store_executed_migration(mig)

        last = self.store.read_last_migrated()
        self.assertEqual(last, mig)

        mig2 = Migration()
        mig2.ID = "2_my_migration"
        mig2.applied_timestamp = time.time()
        time.sleep(0.05)
        self.store.store_executed_migration(mig2)

        # Its last yet
        last = self.store.read_last_migrated()
        self.assertEqual(last, mig2)

        mig3 = Migration()
        mig3.ID = "4_my_migration"
        mig3.applied_timestamp = time.time()
        time.sleep(0.05)
        self.store.store_executed_migration(mig3)

        last = self.store.read_last_migrated()
        self.assertEqual(last, mig3)

        applied = self.store.applied_migrations()

        self.assertEqual(len(applied), 3)
        self.assertEqual(set(applied), set([mig, mig2, mig3]))
コード例 #2
0
def launch():
    # Default MongoClient params are:
    # w=1  perform a write acknowledgement only in primary
    # j=False the driver does not add j to the getlasterror command
    # fsync=False the server does not add Sync to disk. to the getlasterror command
    mongo_connection = MongoClient(BII_MONGO_URI, max_pool_size=BII_MAX_MONGO_POOL_SIZE)
    migration_store = MigrationStore(mongo_connection)
    server_store = MongoServerStore(mongo_connection)
    biiout = OutputStream()
    manager = MigrationManager(migration_store, SERVER_MIGRATIONS, biiout)

    # Pass in kwargs all variables migrations can need
    n1 = time.time()
    manager.migrate(server_store=server_store)
    n2 = time.time()
    biiout.info('All took %s seconds' % str(n2 - n1))

    # DO NOT REMOVE THIS PRINT NOR REPLACE WITH LOGGER, ITS A CONSOLE SCRIPT
    # INVOKED IN DEPLOYMENT PROCESS AND ITS NECESSARY IT PRINTS TO OUTPUT
    print biiout
コード例 #3
0
 def setUp(self):
     self.store = MigrationStore(self.conn,  self.__class__.__name__)