Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
neoppod
Commits
42e85ff1
Commit
42e85ff1
authored
Aug 22, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: reuse backend to perform SQL queries in a separate connection
parent
e17bcf25
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
23 deletions
+9
-23
neo/storage/database/manager.py
neo/storage/database/manager.py
+1
-1
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+2
-2
neo/tests/functional/__init__.py
neo/tests/functional/__init__.py
+2
-7
neo/tests/functional/testStorage.py
neo/tests/functional/testStorage.py
+4
-13
No files found.
neo/storage/database/manager.py
View file @
42e85ff1
...
@@ -23,7 +23,7 @@ class CreationUndone(Exception):
...
@@ -23,7 +23,7 @@ class CreationUndone(Exception):
class
DatabaseManager
(
object
):
class
DatabaseManager
(
object
):
"""This class only describes an interface for database managers."""
"""This class only describes an interface for database managers."""
def
__init__
(
self
,
database
,
wait
):
def
__init__
(
self
,
database
,
wait
=
0
):
"""
"""
Initialize the object.
Initialize the object.
"""
"""
...
...
neo/storage/database/mysqldb.py
View file @
42e85ff1
...
@@ -52,8 +52,8 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -52,8 +52,8 @@ class MySQLDatabaseManager(DatabaseManager):
# (tested with testOudatedCellsOnDownStorage).
# (tested with testOudatedCellsOnDownStorage).
_use_partition
=
False
_use_partition
=
False
def
__init__
(
self
,
database
,
wait
):
def
__init__
(
self
,
*
args
,
**
kw
):
super
(
MySQLDatabaseManager
,
self
).
__init__
(
database
,
wait
)
super
(
MySQLDatabaseManager
,
self
).
__init__
(
*
args
,
**
kw
)
self
.
conn
=
None
self
.
conn
=
None
self
.
_config
=
{}
self
.
_config
=
{}
self
.
_connect
()
self
.
_connect
()
...
...
neo/tests/functional/__init__.py
View file @
42e85ff1
...
@@ -41,6 +41,7 @@ from .. import DB_USER, setupMySQLdb, NeoTestBase, buildUrlFromString, \
...
@@ -41,6 +41,7 @@ from .. import DB_USER, setupMySQLdb, NeoTestBase, buildUrlFromString, \
ADDRESS_TYPE
,
IP_VERSION_FORMAT_DICT
,
getTempDirectory
ADDRESS_TYPE
,
IP_VERSION_FORMAT_DICT
,
getTempDirectory
from
..cluster
import
SocketLock
from
..cluster
import
SocketLock
from
neo.client.Storage
import
Storage
from
neo.client.Storage
import
Storage
from
neo.storage.database
import
buildDatabaseManager
command_dict
=
{
command_dict
=
{
NodeTypes
.
MASTER
:
'neomaster'
,
NodeTypes
.
MASTER
:
'neomaster'
,
...
@@ -426,13 +427,7 @@ class NEOCluster(object):
...
@@ -426,13 +427,7 @@ class NEOCluster(object):
def
getSQLConnection
(
self
,
db
):
def
getSQLConnection
(
self
,
db
):
assert
db
in
self
.
db_list
assert
db
in
self
.
db_list
if
self
.
adapter
==
'MySQL'
:
return
buildDatabaseManager
(
self
.
adapter
,
(
self
.
db_template
%
db
,))
conn
=
MySQLdb
.
Connect
(
user
=
self
.
db_user
,
passwd
=
self
.
db_password
,
db
=
db
)
conn
.
autocommit
(
True
)
elif
self
.
adapter
==
'SQLite'
:
conn
=
sqlite3
.
connect
(
self
.
db_template
%
db
,
isolation_level
=
None
)
return
conn
def
getMasterProcessList
(
self
):
def
getMasterProcessList
(
self
):
return
self
.
process_dict
.
get
(
NodeTypes
.
MASTER
)
return
self
.
process_dict
.
get
(
NodeTypes
.
MASTER
)
...
...
neo/tests/functional/testStorage.py
View file @
42e85ff1
...
@@ -42,13 +42,6 @@ class StorageTests(NEOFunctionalTest):
...
@@ -42,13 +42,6 @@ class StorageTests(NEOFunctionalTest):
self
.
neo
.
stop
()
self
.
neo
.
stop
()
NEOFunctionalTest
.
_tearDown
(
self
,
success
)
NEOFunctionalTest
.
_tearDown
(
self
,
success
)
def
queryCount
(
self
,
db
,
query
):
try
:
db
.
query
(
query
)
except
AttributeError
:
return
db
.
execute
(
query
).
fetchone
()[
0
]
return
db
.
store_result
().
fetch_row
()[
0
][
0
]
def
__setup
(
self
,
storage_number
=
2
,
pending_number
=
0
,
replicas
=
1
,
def
__setup
(
self
,
storage_number
=
2
,
pending_number
=
0
,
replicas
=
1
,
partitions
=
10
,
master_count
=
2
):
partitions
=
10
,
master_count
=
2
):
# create a neo cluster
# create a neo cluster
...
@@ -81,18 +74,16 @@ class StorageTests(NEOFunctionalTest):
...
@@ -81,18 +74,16 @@ class StorageTests(NEOFunctionalTest):
db
=
self
.
neo
.
getSQLConnection
(
db_name
)
db
=
self
.
neo
.
getSQLConnection
(
db_name
)
# wait for the sql transaction to be commited
# wait for the sql transaction to be commited
def
callback
(
last_try
):
def
callback
(
last_try
):
object_number
=
self
.
queryCount
(
db
,
'select count(*) from obj'
)
# One revision per object and two for the root, before and after
(
object_number
,),
=
db
.
query
(
'select count(*) from obj'
)
return
object_number
==
OBJECT_NUMBER
+
2
,
object_number
return
object_number
==
OBJECT_NUMBER
+
2
,
object_number
self
.
neo
.
expectCondition
(
callback
)
self
.
neo
.
expectCondition
(
callback
)
# no more temporarily objects
# no more temporarily objects
t_objects
=
self
.
queryCount
(
db
,
'select count(*) from tobj'
)
(
t_objects
,),
=
db
.
query
(
'select count(*) from tobj'
)
self
.
assertEqual
(
t_objects
,
0
)
self
.
assertEqual
(
t_objects
,
0
)
# One revision per object and two for the root, before and after
revisions
=
self
.
queryCount
(
db
,
'select count(*) from obj'
)
self
.
assertEqual
(
revisions
,
OBJECT_NUMBER
+
2
)
# One object more for the root
# One object more for the root
query
=
'select count(*) from (select * from obj group by oid) as t'
query
=
'select count(*) from (select * from obj group by oid) as t'
objects
=
self
.
queryCount
(
db
,
query
)
(
objects
,),
=
db
.
query
(
query
)
self
.
assertEqual
(
objects
,
OBJECT_NUMBER
+
1
)
self
.
assertEqual
(
objects
,
OBJECT_NUMBER
+
1
)
# Check object content
# Check object content
db
,
conn
=
self
.
neo
.
getZODBConnection
()
db
,
conn
=
self
.
neo
.
getZODBConnection
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment