mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
a. Test Discovery is only found in python 2.7+. unittest2 makes it backwards compatible for python 2.4-2.6
b. Adding traceback from pymysql to debug problems in connecting with database (cherry picked from commit 81218d718af0ec101f7ba424c62bb6e0b5642744)
This commit is contained in:
parent
5ae45e4baf
commit
81366d35c1
@ -1,4 +1,8 @@
|
|||||||
import unittest
|
try:
|
||||||
|
import unittest2 as unittest
|
||||||
|
except ImportError:
|
||||||
|
import unittest
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -37,4 +41,4 @@ class TestCaseExecuteEngine(object):
|
|||||||
|
|
||||||
unittest.TextTestRunner(stream=self.testResultLogFile, verbosity=2).run(suite)
|
unittest.TextTestRunner(stream=self.testResultLogFile, verbosity=2).run(suite)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import pymysql
|
|||||||
import cloudstackException
|
import cloudstackException
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
class dbConnection(object):
|
class dbConnection(object):
|
||||||
def __init__(self, host="localhost", port=3306, user='cloud', passwd='cloud', db='cloud'):
|
def __init__(self, host="localhost", port=3306, user='cloud', passwd='cloud', db='cloud'):
|
||||||
self.host = host
|
self.host = host
|
||||||
@ -13,6 +14,7 @@ class dbConnection(object):
|
|||||||
try:
|
try:
|
||||||
self.db = pymysql.Connect(host=host, port=port, user=user, passwd=passwd, db=db)
|
self.db = pymysql.Connect(host=host, port=port, user=user, passwd=passwd, db=db)
|
||||||
except:
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
raise cloudstackException.InvalidParameterException(sys.exc_info())
|
raise cloudstackException.InvalidParameterException(sys.exc_info())
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
@ -73,4 +75,4 @@ if __name__ == "__main__":
|
|||||||
for i in range(10):
|
for i in range(10):
|
||||||
result = db.execute("select job_status, created, last_updated from async_job where id=%d"%i)
|
result = db.execute("select job_status, created, last_updated from async_job where id=%d"%i)
|
||||||
print result
|
print result
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user