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
Xavier Thompson
neoppod
Commits
e2dacd6a
Commit
e2dacd6a
authored
May 24, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: new testStorageUpgrade
parent
477e0e44
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
2 deletions
+85
-2
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+22
-0
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+21
-0
neo/tests/__init__.py
neo/tests/__init__.py
+2
-0
neo/tests/threaded/__init__.py
neo/tests/threaded/__init__.py
+2
-2
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+38
-0
No files found.
neo/storage/database/mysqldb.py
View file @
e2dacd6a
...
@@ -944,3 +944,25 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -944,3 +944,25 @@ class MySQLDatabaseManager(DatabaseManager):
sha1
(
','
.
join
(
str
(
x
[
1
])
for
x
in
r
)).
digest
(),
sha1
(
','
.
join
(
str
(
x
[
1
])
for
x
in
r
)).
digest
(),
p64
(
r
[
-
1
][
1
]))
p64
(
r
[
-
1
][
1
]))
return
0
,
ZERO_HASH
,
ZERO_TID
,
ZERO_HASH
,
ZERO_OID
return
0
,
ZERO_HASH
,
ZERO_TID
,
ZERO_HASH
,
ZERO_OID
def
_cmdline
(
self
):
for
x
in
(
'u'
,
self
.
user
),
(
'p'
,
self
.
passwd
),
(
'S'
,
self
.
socket
):
if
x
[
1
]:
yield
'-%s%s'
%
x
yield
self
.
db
def
dump
(
self
):
import
subprocess
cmd
=
[
'mysqldump'
,
'--compact'
,
'--hex-blob'
]
cmd
+=
self
.
_cmdline
()
return
subprocess
.
check_output
(
cmd
)
def
restore
(
self
,
sql
):
import
subprocess
cmd
=
[
'mysql'
]
cmd
+=
self
.
_cmdline
()
p
=
subprocess
.
Popen
(
cmd
,
stdin
=
subprocess
.
PIPE
)
p
.
communicate
(
sql
)
retcode
=
p
.
wait
()
if
retcode
:
raise
subprocess
.
CalledProcessError
(
retcode
,
cmd
)
neo/storage/database/sqlite.py
View file @
e2dacd6a
...
@@ -694,3 +694,24 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -694,3 +694,24 @@ class SQLiteDatabaseManager(DatabaseManager):
sha1
(
','
.
join
(
str
(
x
[
1
])
for
x
in
r
)).
digest
(),
sha1
(
','
.
join
(
str
(
x
[
1
])
for
x
in
r
)).
digest
(),
p64
(
r
[
-
1
][
1
]))
p64
(
r
[
-
1
][
1
]))
return
0
,
ZERO_HASH
,
ZERO_TID
,
ZERO_HASH
,
ZERO_OID
return
0
,
ZERO_HASH
,
ZERO_TID
,
ZERO_HASH
,
ZERO_OID
def
dump
(
self
):
main
=
[]
data
=
[]
for
line
in
self
.
conn
.
iterdump
():
if
line
.
startswith
(
'INSERT '
):
assert
line
.
endswith
(
';'
),
line
data
.
append
(
line
)
continue
if
line
.
startswith
(
'CREATE TABLE '
):
# ALTER TABLE adds quotes.
create
,
table
,
name
,
tail
=
line
.
split
(
' '
,
3
)
line
=
' '
.
join
((
create
,
table
,
name
.
strip
(
'"'
),
tail
))
main
.
append
(
line
)
assert
line
==
'COMMIT;'
,
line
data
.
sort
()
main
[
-
1
:
-
1
]
=
data
return
'
\
n
'
.
join
(
main
)
+
'
\
n
'
def
restore
(
self
,
sql
):
self
.
conn
.
executescript
(
sql
)
neo/tests/__init__.py
View file @
e2dacd6a
...
@@ -170,6 +170,8 @@ def ImporterConfigParser(adapter, zodb, **kw):
...
@@ -170,6 +170,8 @@ def ImporterConfigParser(adapter, zodb, **kw):
class
NeoTestBase
(
unittest
.
TestCase
):
class
NeoTestBase
(
unittest
.
TestCase
):
maxDiff
=
None
def
setUp
(
self
):
def
setUp
(
self
):
logging
.
name
=
self
.
setupLog
()
logging
.
name
=
self
.
setupLog
()
unittest
.
TestCase
.
setUp
(
self
)
unittest
.
TestCase
.
setUp
(
self
)
...
...
neo/tests/threaded/__init__.py
View file @
e2dacd6a
...
@@ -652,8 +652,8 @@ class NEOCluster(object):
...
@@ -652,8 +652,8 @@ class NEOCluster(object):
adapter
=
os
.
getenv
(
'NEO_TESTS_ADAPTER'
,
'SQLite'
),
adapter
=
os
.
getenv
(
'NEO_TESTS_ADAPTER'
,
'SQLite'
),
storage_count
=
None
,
db_list
=
None
,
clear_databases
=
True
,
storage_count
=
None
,
db_list
=
None
,
clear_databases
=
True
,
db_user
=
DB_USER
,
db_password
=
''
,
compress
=
True
,
db_user
=
DB_USER
,
db_password
=
''
,
compress
=
True
,
importer
=
None
,
autostart
=
None
,
dedup
=
False
):
importer
=
None
,
autostart
=
None
,
dedup
=
False
,
name
=
None
):
self
.
name
=
'neo_%s'
%
self
.
_allocate
(
'name'
,
self
.
name
=
name
or
'neo_%s'
%
self
.
_allocate
(
'name'
,
lambda
:
random
.
randint
(
0
,
100
))
lambda
:
random
.
randint
(
0
,
100
))
self
.
compress
=
compress
self
.
compress
=
compress
self
.
num_partitions
=
partitions
self
.
num_partitions
=
partitions
...
...
neo/tests/threaded/test.py
View file @
e2dacd6a
...
@@ -2361,6 +2361,44 @@ class Test(NEOThreadedTest):
...
@@ -2361,6 +2361,44 @@ class Test(NEOThreadedTest):
self
.
assertEqual
(
expected
,
self
.
assertEqual
(
expected
,
(
dm
.
getLastTID
(
u64
(
MAX_TID
)),
dm
.
getLastIDs
()))
(
dm
.
getLastTID
(
u64
(
MAX_TID
)),
dm
.
getLastIDs
()))
def
testStorageUpgrade
(
self
):
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
self
.
_testMethodName
+
'-%s'
,
's%s.sql'
)
dump_dict
=
{}
def
switch
(
s
):
dm
=
s
.
dm
dm
.
commit
()
dump_dict
[
s
.
uuid
]
=
dm
.
dump
()
dm
.
erase
()
with
open
(
path
%
(
s
.
getAdapter
(),
s
.
uuid
))
as
f
:
dm
.
restore
(
f
.
read
())
with
NEOCluster
(
storage_count
=
3
,
partitions
=
3
,
replicas
=
1
,
name
=
self
.
_testMethodName
)
as
cluster
:
s1
,
s2
,
s3
=
cluster
.
storage_list
cluster
.
start
(
storage_list
=
(
s1
,))
for
s
in
s2
,
s3
:
s
.
start
()
self
.
tic
()
cluster
.
neoctl
.
enableStorageList
([
s
.
uuid
])
cluster
.
neoctl
.
tweakPartitionTable
()
self
.
tic
()
nid_list
=
[
s
.
uuid
for
s
in
cluster
.
storage_list
]
switch
(
s3
)
s3
.
stop
()
storage
=
cluster
.
getZODBStorage
()
txn
=
transaction
.
Transaction
()
storage
.
tpc_begin
(
txn
,
p64
(
85
**
9
))
# partition 1
storage
.
store
(
p64
(
0
),
None
,
'foo'
,
''
,
txn
)
storage
.
tpc_vote
(
txn
)
storage
.
tpc_finish
(
txn
)
self
.
tic
()
switch
(
s1
)
switch
(
s2
)
cluster
.
stop
()
for
i
,
s
in
zip
(
nid_list
,
cluster
.
storage_list
):
self
.
assertMultiLineEqual
(
s
.
dm
.
dump
(),
dump_dict
[
i
])
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
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