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
c66c97bc
Commit
c66c97bc
authored
Jan 17, 2017
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: fix ImporterTests.test
It was failing when some .py files were not compiled.
parent
f9ff4249
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
neo/tests/threaded/testImporter.py
neo/tests/threaded/testImporter.py
+23
-12
No files found.
neo/tests/threaded/testImporter.py
View file @
c66c97bc
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
collections
import
deque
from
cPickle
import
Pickler
,
Unpickler
from
cPickle
import
Pickler
,
Unpickler
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
from
itertools
import
islice
,
izip_longest
from
itertools
import
islice
,
izip_longest
...
@@ -129,19 +128,28 @@ class ImporterTests(NEOThreadedTest):
...
@@ -129,19 +128,28 @@ class ImporterTests(NEOThreadedTest):
self
.
assertDictEqual
(
state
,
load
())
self
.
assertDictEqual
(
state
,
load
())
def
test
(
self
):
def
test
(
self
):
# XXX: Using NEO source files as test data was a bad idea because
# the test breaks easily in case of massive changes in the code,
# or if there are many untracked files.
importer
=
[]
importer
=
[]
fs_dir
=
os
.
path
.
join
(
getTempDirectory
(),
self
.
id
())
fs_dir
=
os
.
path
.
join
(
getTempDirectory
(),
self
.
id
())
shutil
.
rmtree
(
fs_dir
,
1
)
# for --loop
shutil
.
rmtree
(
fs_dir
,
1
)
# for --loop
os
.
mkdir
(
fs_dir
)
os
.
mkdir
(
fs_dir
)
src_root
,
=
neo
.
__path__
src_root
,
=
neo
.
__path__
fs_list
=
"root"
,
"client"
,
"master"
,
"tests"
fs_list
=
"root"
,
"client"
,
"master"
,
"tests"
def
not_pyc
(
name
):
return
not
name
.
endswith
(
".pyc"
)
# We use 'hash' to skip roughly half of files.
# They'll be added after the migration has started.
def
root_filter
(
name
):
def
root_filter
(
name
):
if
not
name
.
endswith
(
".pyc"
):
if
not
_pyc
(
name
):
i
=
name
.
find
(
os
.
sep
)
i
=
name
.
find
(
os
.
sep
)
return
i
<
0
or
name
[:
i
]
not
in
fs_list
return
(
i
<
0
or
name
[:
i
]
not
in
fs_list
)
and
(
'.'
not
in
name
or
hash
(
name
)
&
1
)
def
sub_filter
(
name
):
def
sub_filter
(
name
):
return
lambda
n
:
n
[
-
4
:]
!=
'.pyc'
and
\
return
lambda
n
:
not_pyc
(
n
)
and
(
n
.
split
(
os
.
sep
,
1
)[
0
]
in
(
name
,
"scripts"
)
hash
(
n
)
&
1
if
'.'
in
n
else
os
.
sep
in
n
or
n
in
(
name
,
"scripts"
))
conn_list
=
[]
conn_list
=
[]
iter_list
=
[]
iter_list
=
[]
# Setup several FileStorage databases.
# Setup several FileStorage databases.
...
@@ -193,7 +201,7 @@ class ImporterTests(NEOThreadedTest):
...
@@ -193,7 +201,7 @@ class ImporterTests(NEOThreadedTest):
cluster
.
start
()
cluster
.
start
()
t
,
c
=
cluster
.
getTransaction
()
t
,
c
=
cluster
.
getTransaction
()
r
=
c
.
root
()[
"neo"
]
r
=
c
.
root
()[
"neo"
]
# Test retrieving of an object from ZODB when next serial in NEO.
# Test retrieving of an object from ZODB when next serial i
s i
n NEO.
r
.
_p_changed
=
1
r
.
_p_changed
=
1
t
.
commit
()
t
.
commit
()
t
.
begin
()
t
.
begin
()
...
@@ -204,20 +212,23 @@ class ImporterTests(NEOThreadedTest):
...
@@ -204,20 +212,23 @@ class ImporterTests(NEOThreadedTest):
self
.
assertRaisesRegexp
(
NotImplementedError
,
" getObjectHistory$"
,
self
.
assertRaisesRegexp
(
NotImplementedError
,
" getObjectHistory$"
,
c
.
db
().
history
,
r
.
_p_oid
)
c
.
db
().
history
,
r
.
_p_oid
)
i
=
r
.
walk
()
i
=
r
.
walk
()
next
(
islice
(
i
,
9
,
None
))
next
(
islice
(
i
,
4
,
None
))
logging
.
info
(
"start migration"
)
logging
.
info
(
"start migration"
)
dm
.
doOperation
(
cluster
.
storage
)
dm
.
doOperation
(
cluster
.
storage
)
deque
(
i
,
maxlen
=
0
)
# Adjust if needed. Must remain > 0.
last_import
=
None
assert
14
==
sum
(
1
for
i
in
i
)
for
i
,
r
in
enumerate
(
r
.
treeFromFs
(
src_root
,
10
)):
last_import
=
-
1
for
i
,
r
in
enumerate
(
r
.
treeFromFs
(
src_root
,
6
,
not_pyc
)):
t
.
commit
()
t
.
commit
()
if
cluster
.
storage
.
dm
.
_import
:
if
cluster
.
storage
.
dm
.
_import
:
last_import
=
i
last_import
=
i
self
.
tic
()
self
.
tic
()
self
.
assertTrue
(
last_import
and
not
cluster
.
storage
.
dm
.
_import
)
# Same as above. We want last_import smaller enough compared to i
assert
i
/
3
<
last_import
<
i
-
3
,
(
last_import
,
i
)
self
.
assertFalse
(
cluster
.
storage
.
dm
.
_import
)
i
=
len
(
src_root
)
+
1
i
=
len
(
src_root
)
+
1
self
.
assertEqual
(
sorted
(
r
.
walk
()),
sorted
(
self
.
assertEqual
(
sorted
(
r
.
walk
()),
sorted
(
(
x
[
i
:]
or
'.'
,
sorted
(
y
),
sorted
(
z
))
(
x
[
i
:]
or
'.'
,
sorted
(
y
),
sorted
(
filter
(
not_pyc
,
z
)
))
for
x
,
y
,
z
in
os
.
walk
(
src_root
)))
for
x
,
y
,
z
in
os
.
walk
(
src_root
)))
t
.
commit
()
t
.
commit
()
...
...
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