Commit a979165a authored by Julien Muchembled's avatar Julien Muchembled

stress: fix SQLite support and make it usable even if MySQLdb is not installed

parent b0a6b8ac
...@@ -26,7 +26,6 @@ import sys ...@@ -26,7 +26,6 @@ import sys
import tempfile import tempfile
import unittest import unittest
import weakref import weakref
import MySQLdb
import transaction import transaction
from contextlib import contextmanager from contextlib import contextmanager
...@@ -141,6 +140,7 @@ def getTempDirectory(): ...@@ -141,6 +140,7 @@ def getTempDirectory():
def setupMySQLdb(db_list, clear_databases=True): def setupMySQLdb(db_list, clear_databases=True):
if mysql_pool: if mysql_pool:
return mysql_pool.setup(db_list, clear_databases) return mysql_pool.setup(db_list, clear_databases)
import MySQLdb
from MySQLdb.constants.ER import BAD_DB_ERROR from MySQLdb.constants.ER import BAD_DB_ERROR
user = DB_USER user = DB_USER
password = '' password = ''
...@@ -178,6 +178,7 @@ class MySQLPool(object): ...@@ -178,6 +178,7 @@ class MySQLPool(object):
self.kill(*self._mysqld_dict) self.kill(*self._mysqld_dict)
def setup(self, db_list, clear_databases): def setup(self, db_list, clear_databases):
import MySQLdb
start_list = set(db_list).difference(self._mysqld_dict) start_list = set(db_list).difference(self._mysqld_dict)
if start_list: if start_list:
start_list = sorted(start_list) start_list = sorted(start_list)
......
...@@ -22,7 +22,6 @@ import ZODB ...@@ -22,7 +22,6 @@ import ZODB
import socket import socket
import signal import signal
import random import random
import MySQLdb
import sqlite3 import sqlite3
import unittest import unittest
import tempfile import tempfile
......
...@@ -650,11 +650,14 @@ def main(): ...@@ -650,11 +650,14 @@ def main():
parser.error( parser.error(
'--datadir: meaningless when using an existing MySQL server') '--datadir: meaningless when using an existing MySQL server')
kw = {'wait': -1}
if args.engine:
kw['engine'] = args.engine
kw = dict(db_list=db_list, name='stress', kw = dict(db_list=db_list, name='stress',
partitions=args.partitions, replicas=args.replicas, partitions=args.partitions, replicas=args.replicas,
adapter=args.adapter, address_type=args.address_type, adapter=args.adapter, address_type=args.address_type,
temp_dir=args.logdir or args.datadir or getTempDirectory(), temp_dir=args.logdir or args.datadir or getTempDirectory(),
storage_kw={'engine': args.engine, 'wait': -1}) storage_kw=kw)
if args.command == 'run': if args.command == 'run':
NFQueue.delay = args.delay NFQueue.delay = args.delay
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment