Esempio n. 1
0
class TestSQLShardedDB(TestSQLDB):

    def setUp(self):
        super(TestSQLDB, self).setUp()

        self.backend = ShardedSQLMetadata(_DBS, create_tables=True)

        # adding a node with 100 slots for sync
        self.backend._safe_execute('sync',
              """insert into nodes (`node`, `service`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                  values ("phx12", "sync", 100, 100, 0, 0, 0)""")

        self._sqlite = self.backend._dbs['sync'][0].driver == 'pysqlite'

    def tearDown(self):
        for service, (engine, __, __) in self.backend._dbs.items():

            sqlite = engine.driver == 'pysqlite'
            if sqlite:
                filename = str(engine.url).split('sqlite://')[-1]
                if os.path.exists(filename):
                    os.remove(filename)
            else:
                engine.execute('delete from nodes')
                engine.execute('delete from user_nodes')
Esempio n. 2
0
class TestSQLShardedDB(TestSQLDB):
    def setUp(self):
        super(TestSQLDB, self).setUp()

        self.backend = ShardedSQLMetadata(_DBS, create_tables=True)

        # adding a node with 100 slots for sync
        self.backend._safe_execute(
            'sync', """insert into nodes (`node`, `service`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                  values ("phx12", "sync", 100, 100, 0, 0, 0)""")

        self._sqlite = self.backend._dbs['sync'][0].driver == 'pysqlite'

    def tearDown(self):
        for service, (engine, __, __) in self.backend._dbs.items():

            sqlite = engine.driver == 'pysqlite'
            if sqlite:
                filename = str(engine.url).split('sqlite://')[-1]
                if os.path.exists(filename):
                    os.remove(filename)
            else:
                engine.execute('delete from nodes')
                engine.execute('delete from user_nodes')
Esempio n. 3
0
class TestSQLShardedDB(TestSQLDB):
    def setUp(self):
        super(TestSQLDB, self).setUp()

        self.backend = ShardedSQLMetadata(_SQLURI, create_tables=True)

        # adding a node with 100 slots for sync 1.0
        self.backend._safe_execute(
            """insert into nodes (`node`, `service`, `version`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                values ("https://phx12", "sync", "1.0", 100, 100, 0, 0, 0)""",
            service="sync",
        )

        self._sqlite = self.backend._dbs["sync"][0].driver == "pysqlite"

    def tearDown(self):
        for service, value in self.backend._dbs.items():
            engine = value[0]
            sqlite = engine.driver == "pysqlite"
            if sqlite:
                filename = str(engine.url).split("sqlite://")[-1]
                if os.path.exists(filename):
                    os.remove(filename)
            else:
                engine.execute("delete from nodes")
                engine.execute("delete from user_nodes")
Esempio n. 4
0
    def setUp(self):
        super(TestSQLDB, self).setUp()

        self.backend = ShardedSQLMetadata(_DBS, create_tables=True)

        # adding a node with 100 slots for sync
        self.backend._safe_execute(
            'sync', """insert into nodes (`node`, `service`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                  values ("phx12", "sync", 100, 100, 0, 0, 0)""")

        self._sqlite = self.backend._dbs['sync'][0].driver == 'pysqlite'
Esempio n. 5
0
    def setUp(self):
        super(TestSQLDB, self).setUp()

        self.backend = ShardedSQLMetadata(_DBS, create_tables=True)

        # adding a node with 100 slots for sync
        self.backend._safe_execute('sync',
              """insert into nodes (`node`, `service`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                  values ("phx12", "sync", 100, 100, 0, 0, 0)""")

        self._sqlite = self.backend._dbs['sync'][0].driver == 'pysqlite'
Esempio n. 6
0
    def setUp(self):
        super(TestSQLDB, self).setUp()

        self.backend = ShardedSQLMetadata(_SQLURI, create_tables=True)

        # adding a node with 100 slots for sync 1.0
        self.backend._safe_execute(
            """insert into nodes (`node`, `service`, `version`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                values ("https://phx12", "sync", "1.0", 100, 100, 0, 0, 0)""",
            service="sync",
        )

        self._sqlite = self.backend._dbs["sync"][0].driver == "pysqlite"
 def setUp(self):
     self.backend = ShardedSQLMetadata(_SQLURI, create_tables=True)
     super(TestSQLShardedDB, self).setUp()