Пример #1
0
class TestSQLDB(NodeAssignmentTests, TestCase):

    _SQLURI = os.environ.get('WIMMS_SQLURI', 'sqlite:////tmp/wimms.' + TEMP_ID)

    def setUp(self):
        self.backend = SQLNodeAssignment(self._SQLURI, create_tables=True)
        super(TestSQLDB, self).setUp()

    def tearDown(self):
        super(TestSQLDB, self).tearDown()
        if self.backend._engine.driver == 'pysqlite':
            filename = self.backend.sqluri.split('sqlite://')[-1]
            if os.path.exists(filename):
                os.remove(filename)
        else:
            self.backend._safe_execute('drop table services;')
            self.backend._safe_execute('drop table nodes;')
            self.backend._safe_execute('drop table users;')

    def test_default_node_available_capacity(self):
        node = "https://phx13"
        self.backend.add_node("sync-1.0", node, capacity=100)
        available = int(math.ceil(self.backend.capacity_release_rate * 100))
        query = "SELECT * FROM nodes WHERE node=:node"
        res = self.backend._safe_execute(query, node=node)
        row = res.fetchone()
        res.close()
        self.assertEqual(row["available"], available)
Пример #2
0
class TestSQLDB(NodeAssignmentTests, unittest.TestCase):

    _SQLURI = os.environ.get('MOZSVC_SQLURI', DEFAULT_SQLURI)

    def setUp(self):
        self.backend = SQLNodeAssignment(self._SQLURI, create_tables=True)
        super(TestSQLDB, self).setUp()

    def tearDown(self):
        super(TestSQLDB, self).tearDown()
        if self.backend._engine.driver == 'pysqlite':
            filename = self.backend.sqluri.split('sqlite://')[-1]
            if os.path.exists(filename):
                os.remove(filename)
        else:
            self.backend._safe_execute('drop table services;')
            self.backend._safe_execute('drop table nodes;')
            self.backend._safe_execute('drop table users;')

    def test_default_node_available_capacity(self):
        node = "https://phx13"
        self.backend.add_node("sync-1.0", node, capacity=100)
        available = int(math.ceil(self.backend.capacity_release_rate * 100))
        query = sqltext("SELECT * FROM nodes WHERE node=:node")
        res = self.backend._safe_execute(query, node=node)
        row = res.fetchone()
        res.close()
        self.assertEqual(row["available"], available)
Пример #3
0
class TestSQLDB(NodeAssignmentTests, TestCase):

    _SQLURI = os.environ.get('WIMMS_SQLURI', 'sqlite:////tmp/wimms.' + TEMP_ID)

    def setUp(self):
        self.backend = SQLNodeAssignment(self._SQLURI, create_tables=True)
        super(TestSQLDB, self).setUp()

    def tearDown(self):
        super(TestSQLDB, self).tearDown()
        if self.backend._engine.driver == 'pysqlite':
            filename = self.backend.sqluri.split('sqlite://')[-1]
            if os.path.exists(filename):
                os.remove(filename)
        else:
            self.backend._safe_execute('drop table services;')
            self.backend._safe_execute('drop table nodes;')
            self.backend._safe_execute('drop table users;')