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
0afd029d
Commit
0afd029d
authored
Feb 16, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
18b3a2f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
11 deletions
+83
-11
t/neo/storage/fs1/index_test.go
t/neo/storage/fs1/index_test.go
+59
-10
t/neo/storage/fs1/indexcmp
t/neo/storage/fs1/indexcmp
+23
-0
t/neo/storage/fs1/testdata_expect.go
t/neo/storage/fs1/testdata_expect.go
+1
-1
No files found.
t/neo/storage/fs1/index_test.go
View file @
0afd029d
...
...
@@ -7,6 +7,7 @@ package fs1
import
(
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"sort"
...
...
@@ -173,17 +174,13 @@ func checkIndexEqual(t *testing.T, subject string, topPos1, topPos2 int64, fsi1,
}
func
TestIndexSaveLoad
(
t
*
testing
.
T
)
{
workdir
,
err
:=
ioutil
.
TempDir
(
""
,
"t-index"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
RemoveAll
(
workdir
)
workdir
:=
xworkdir
(
t
)
topPos
:=
int64
(
786
)
fsi
:=
fsIndexNew
()
setIndex
(
fsi
,
indexTest1
[
:
])
err
=
fsi
.
SaveFile
(
topPos
,
workdir
+
"/1.fs.index"
)
err
:
=
fsi
.
SaveFile
(
topPos
,
workdir
+
"/1.fs.index"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -213,13 +210,65 @@ func TestIndexLoadFromPy(t *testing.T) {
checkIndexEqual
(
t
,
"index load"
,
topPosPy
,
_1fs_indexTopPos
,
fsiPy
,
fsiExpect
)
}
var
havePyZODB
=
false
func
init
()
{
// test zodb/py can read index data as saved by us
func
TestIndexSaveToPy
(
t
*
testing
.
T
)
{
needZODBPy
(
t
)
workdir
:=
xworkdir
(
t
)
fsi
:=
fsIndexNew
()
setIndex
(
fsi
,
_1fs_indexEntryv
[
:
])
err
:=
fsi
.
SaveFile
(
_1fs_indexTopPos
,
workdir
+
"/1.fs.index"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// now ask python part to compare testdata and save-by-us index
cmd
:=
exec
.
Command
(
"./indexcmp"
,
"testdata/1.fs.index"
,
workdir
+
"/1.fs.index"
)
cmd
.
Stdout
=
os
.
Stdout
cmd
.
Stderr
=
os
.
Stderr
err
=
cmd
.
Run
()
if
err
!=
nil
{
t
.
Fatalf
(
"zodb/py read/compare index: %v"
,
err
)
}
}
var
haveZODBPy
=
false
var
workRoot
string
func
TestMain
(
m
*
testing
.
M
)
{
// check whether we have zodb/py
cmd
:=
exec
.
Command
(
"python2"
,
"-c"
,
"import ZODB"
)
err
:=
cmd
.
Run
()
if
err
==
nil
{
havePyZODB
=
true
haveZODBPy
=
true
}
// setup work root for all tests
workRoot
,
err
=
ioutil
.
TempDir
(
""
,
"t-index"
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
exit
:=
m
.
Run
()
os
.
RemoveAll
(
workRoot
)
os
.
Exit
(
exit
)
}
func
needZODBPy
(
t
*
testing
.
T
)
{
if
haveZODBPy
{
return
}
t
.
Skipf
(
"zodb/py is not available"
)
}
//println("havePyZODB:", havePyZODB)
// create temp dir inside workRoot
func
xworkdir
(
t
*
testing
.
T
)
string
{
work
,
err
:=
ioutil
.
TempDir
(
workRoot
,
""
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
work
}
t/neo/storage/fs1/indexcmp
0 → 100755
View file @
0afd029d
#!/usr/bin/env python2
"""compare two index files"""
from
ZODB.fsIndex
import
fsIndex
import
sys
def
main
():
path1
,
path2
=
sys
.
argv
[
1
:]
d1
=
fsIndex
.
load
(
path1
)
d2
=
fsIndex
.
load
(
path2
)
topPos1
,
fsi1
=
d1
[
"pos"
],
d1
[
"index"
]
topPos2
,
fsi2
=
d2
[
"pos"
],
d2
[
"index"
]
#print topPos1, topPos2
#print fsi1.items()
#print fsi2.items()
equal
=
(
topPos1
==
topPos2
and
fsi1
.
items
()
==
fsi2
.
items
())
sys
.
exit
(
int
(
not
equal
))
if
__name__
==
'__main__'
:
main
()
t/neo/storage/fs1/testdata_expect.go
View file @
0afd029d
...
...
@@ -8,6 +8,6 @@ var _1fs_indexEntryv = [...]indexEntry{
{
3
,
8691
},
{
4
,
8543
},
{
5
,
7359
},
{
6
,
8839
},
{
9
,
8839
},
{
7
,
7507
},
}
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