Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
cc72e972
Commit
cc72e972
authored
Feb 26, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: new NEO_DB_SOCKET environment variable to chose the MySQL server to use
parent
9bd524ab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
13 deletions
+16
-13
neo/scripts/runner.py
neo/scripts/runner.py
+1
-0
neo/tests/__init__.py
neo/tests/__init__.py
+4
-2
neo/tests/functional/__init__.py
neo/tests/functional/__init__.py
+4
-3
neo/tests/storage/testStorageMySQL.py
neo/tests/storage/testStorageMySQL.py
+5
-6
neo/tests/threaded/__init__.py
neo/tests/threaded/__init__.py
+2
-2
No files found.
neo/scripts/runner.py
View file @
cc72e972
...
...
@@ -215,6 +215,7 @@ Environment Variables:
MySQL otherwise.
MySQL specific:
NEO_DB_SOCKET default: libmysqlclient.so default
NEO_DB_PREFIX default: %(DB_PREFIX)s
NEO_DB_ADMIN default: %(DB_ADMIN)s
NEO_DB_PASSWD default: %(DB_PASSWD)s
...
...
neo/tests/__init__.py
View file @
cc72e972
...
...
@@ -60,6 +60,7 @@ DB_PREFIX = os.getenv('NEO_DB_PREFIX', 'test_neo')
DB_ADMIN
=
os
.
getenv
(
'NEO_DB_ADMIN'
,
'root'
)
DB_PASSWD
=
os
.
getenv
(
'NEO_DB_PASSWD'
,
''
)
DB_USER
=
os
.
getenv
(
'NEO_DB_USER'
,
'test'
)
DB_SOCKET
=
os
.
getenv
(
'NEO_DB_SOCKET'
,
''
)
IP_VERSION_FORMAT_DICT
=
{
socket
.
AF_INET
:
'127.0.0.1'
,
...
...
@@ -127,7 +128,8 @@ def getTempDirectory():
def
setupMySQLdb
(
db_list
,
user
=
DB_USER
,
password
=
''
,
clear_databases
=
True
):
from
MySQLdb.constants.ER
import
BAD_DB_ERROR
conn
=
MySQLdb
.
Connect
(
user
=
DB_ADMIN
,
passwd
=
DB_PASSWD
)
kw
=
{
'unix_socket'
:
os
.
path
.
expanduser
(
DB_SOCKET
)}
if
DB_SOCKET
else
{}
conn
=
MySQLdb
.
connect
(
user
=
DB_ADMIN
,
passwd
=
DB_PASSWD
,
**
kw
)
cursor
=
conn
.
cursor
()
for
database
in
db_list
:
try
:
...
...
@@ -230,7 +232,7 @@ class NeoUnitTestBase(NeoTestBase):
10010
+
i
)
for
i
in
xrange
(
master_number
)]
adapter
=
os
.
getenv
(
'NEO_TESTS_ADAPTER'
,
'MySQL'
)
if
adapter
==
'MySQL'
:
db
=
'%s@%s%s
'
%
(
DB_USER
,
prefix
,
index
)
db
=
'%s@%s%s
%s'
%
(
DB_USER
,
prefix
,
index
,
DB_SOCKET
)
elif
adapter
==
'SQLite'
:
db
=
os
.
path
.
join
(
getTempDirectory
(),
'test_neo%s.sqlite'
%
index
)
else
:
...
...
neo/tests/functional/__init__.py
View file @
cc72e972
...
...
@@ -37,8 +37,8 @@ from neo.lib import logging
from
neo.lib.protocol
import
ClusterStates
,
NodeTypes
,
CellStates
,
NodeStates
,
\
UUID_NAMESPACES
from
neo.lib.util
import
dump
from
..
import
cluster
,
DB_USER
,
setupMySQLdb
,
NeoTestBase
,
buildUrlFromString
,
\
ADDRESS_TYPE
,
IP_VERSION_FORMAT_DICT
,
getTempDirectory
,
SSL
from
..
import
ADDRESS_TYPE
,
DB_SOCKET
,
DB_USER
,
IP_VERSION_FORMAT_DICT
,
SSL
,
\
buildUrlFromString
,
cluster
,
getTempDirectory
,
NeoTestBase
,
setupMySQLdb
from
neo.client.Storage
import
Storage
from
neo.storage.database
import
buildDatabaseManager
...
...
@@ -244,7 +244,8 @@ class NEOCluster(object):
if
adapter
==
'MySQL'
:
self
.
db_user
=
db_user
self
.
db_password
=
db_password
self
.
db_template
=
(
'%s:%s@%%s'
%
(
db_user
,
db_password
)).
__mod__
self
.
db_template
=
(
'%s:%s@%%s%s'
%
(
db_user
,
db_password
,
DB_SOCKET
)).
__mod__
elif
adapter
==
'SQLite'
:
self
.
db_template
=
(
lambda
t
:
lambda
db
:
':memory:'
if
db
is
None
else
db
if
os
.
sep
in
db
else
t
%
db
...
...
neo/tests/storage/testStorageMySQL.py
View file @
cc72e972
...
...
@@ -19,23 +19,22 @@ import MySQLdb
from
mock
import
Mock
from
neo.lib.exception
import
DatabaseFailure
from
neo.lib.util
import
p64
from
..
import
DB_PREFIX
,
DB_SOCKET
,
DB_USER
from
.testStorageDBTests
import
StorageDBTests
from
neo.storage.database.mysqldb
import
MySQLDatabaseManager
NEO_SQL_DATABASE
=
'test_mysqldb0'
NEO_SQL_USER
=
'test'
class
StorageMySQLdbTests
(
StorageDBTests
):
engine
=
None
def
getDB
(
self
,
reset
=
0
):
self
.
prepareDatabase
(
number
=
1
,
prefix
=
NEO_SQL_DATABASE
[:
-
1
]
)
self
.
prepareDatabase
(
number
=
1
,
prefix
=
DB_PREFIX
)
# db manager
database
=
'%s@%s
'
%
(
NEO_SQL_USER
,
NEO_SQL_DATABASE
)
database
=
'%s@%s
0%s'
%
(
DB_USER
,
DB_PREFIX
,
DB_SOCKET
)
db
=
MySQLDatabaseManager
(
database
,
self
.
engine
)
self
.
assertEqual
(
db
.
db
,
NEO_SQL_DATABASE
)
self
.
assertEqual
(
db
.
user
,
NEO_SQL
_USER
)
self
.
assertEqual
(
db
.
db
,
DB_PREFIX
+
'0'
)
self
.
assertEqual
(
db
.
user
,
DB
_USER
)
db
.
setup
(
reset
)
return
db
...
...
neo/tests/threaded/__init__.py
View file @
cc72e972
...
...
@@ -38,7 +38,7 @@ from neo.lib.locking import SimpleQueue
from
neo.lib.protocol
import
ClusterStates
,
NodeStates
,
NodeTypes
from
neo.lib.util
import
cached_property
,
parseMasterList
,
p64
from
..
import
NeoTestBase
,
Patch
,
getTempDirectory
,
setupMySQLdb
,
\
ADDRESS_TYPE
,
IP_VERSION_FORMAT_DICT
,
DB_PREFIX
,
DB_USER
ADDRESS_TYPE
,
IP_VERSION_FORMAT_DICT
,
DB_PREFIX
,
DB_
SOCKET
,
DB_
USER
BIND
=
IP_VERSION_FORMAT_DICT
[
ADDRESS_TYPE
],
0
LOCAL_IP
=
socket
.
inet_pton
(
ADDRESS_TYPE
,
IP_VERSION_FORMAT_DICT
[
ADDRESS_TYPE
])
...
...
@@ -592,7 +592,7 @@ class NEOCluster(object):
for
_
in
xrange
(
storage_count
)]
if
adapter
==
'MySQL'
:
setupMySQLdb
(
db_list
,
db_user
,
db_password
,
clear_databases
)
db
=
'%s:%s@%%s
'
%
(
db_user
,
db_password
)
db
=
'%s:%s@%%s
%s'
%
(
db_user
,
db_password
,
DB_SOCKET
)
elif
adapter
==
'SQLite'
:
db
=
os
.
path
.
join
(
getTempDirectory
(),
'%s.sqlite'
)
else
:
...
...
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