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
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
Stefane Fermigier
neo
Commits
4c621541
Commit
4c621541
authored
Nov 09, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X fs1: test for empty-file case
parent
98fa98ce
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
25 deletions
+46
-25
go/zodb/storage/fs1/fs1tools/dump_test.go
go/zodb/storage/fs1/fs1tools/dump_test.go
+19
-8
go/zodb/storage/fs1/fs1tools/testdata/empty.fsdump.ok
go/zodb/storage/fs1/fs1tools/testdata/empty.fsdump.ok
+0
-0
go/zodb/storage/fs1/fs1tools/testdata/empty.fsdumpv.ok
go/zodb/storage/fs1/fs1tools/testdata/empty.fsdumpv.ok
+2
-0
go/zodb/storage/fs1/fs1tools/testdata/empty.fstail.ok
go/zodb/storage/fs1/fs1tools/testdata/empty.fstail.ok
+0
-0
go/zodb/storage/fs1/testdata/empty.fs
go/zodb/storage/fs1/testdata/empty.fs
+1
-0
go/zodb/zodbtools/dump_test.go
go/zodb/zodbtools/dump_test.go
+24
-17
go/zodb/zodbtools/testdata/empty.zdump.pyok
go/zodb/zodbtools/testdata/empty.zdump.pyok
+0
-0
No files found.
go/zodb/storage/fs1/fs1tools/dump_test.go
View file @
4c621541
...
...
@@ -23,6 +23,12 @@ package fs1tools
//go:generate sh -c "python2 -c 'from ZODB.FileStorage import fsdump; fsdump.main()' ../testdata/1.fs >testdata/1.fsdump.ok"
//go:generate sh -c "python2 -c 'from ZODB.FileStorage.fsdump import Dumper; import sys; d = Dumper(sys.argv[1]); d.dump()' ../testdata/1.fs >testdata/1.fsdumpv.ok"
// fstail.py crashes on empty.fs . The output should be empty file so generate it with just echo.
////go:generate sh -c "python2 -m ZODB.scripts.fstail -n 1000000 ../testdata/empty.fs >testdata/empty.fstail.ok"
//go:generate sh -c "echo -n >testdata/empty.fstail.ok"
//go:generate sh -c "python2 -c 'from ZODB.FileStorage import fsdump; fsdump.main()' ../testdata/empty.fs >testdata/empty.fsdump.ok"
//go:generate sh -c "python2 -c 'from ZODB.FileStorage.fsdump import Dumper; import sys; d = Dumper(sys.argv[1]); d.dump()' ../testdata/empty.fs >testdata/empty.fsdumpv.ok"
import
(
"bytes"
"fmt"
...
...
@@ -44,17 +50,22 @@ func loadFile(t *testing.T, path string) string {
}
func
testDump
(
t
*
testing
.
T
,
dir
fs1
.
IterDir
,
d
Dumper
)
{
buf
:=
bytes
.
Buffer
{}
testv
:=
[]
string
{
"1"
,
"empty"
}
for
_
,
tt
:=
range
testv
{
t
.
Run
(
"db="
+
tt
,
func
(
t
*
testing
.
T
)
{
buf
:=
bytes
.
Buffer
{}
err
:=
Dump
(
&
buf
,
"../testdata/1.fs"
,
dir
,
d
)
if
err
!=
nil
{
t
.
Fatalf
(
"%s: %v"
,
d
.
DumperName
(),
err
)
}
err
:=
Dump
(
&
buf
,
fmt
.
Sprintf
(
"../testdata/%s.fs"
,
tt
)
,
dir
,
d
)
if
err
!=
nil
{
t
.
Fatalf
(
"%s: %v"
,
d
.
DumperName
(),
err
)
}
dumpOk
:=
loadFile
(
t
,
fmt
.
Sprintf
(
"testdata/1.%s.ok"
,
d
.
DumperName
()))
dumpOk
:=
loadFile
(
t
,
fmt
.
Sprintf
(
"testdata/%s.%s.ok"
,
tt
,
d
.
DumperName
()))
if
dumpOk
!=
buf
.
String
()
{
t
.
Errorf
(
"%s: dump different:
\n
%v"
,
d
.
DumperName
(),
diff
.
Diff
(
dumpOk
,
buf
.
String
()))
if
dumpOk
!=
buf
.
String
()
{
t
.
Errorf
(
"%s: dump different:
\n
%v"
,
d
.
DumperName
(),
diff
.
Diff
(
dumpOk
,
buf
.
String
()))
}
})
}
}
...
...
go/zodb/storage/fs1/fs1tools/testdata/empty.fsdump.ok
0 → 100644
View file @
4c621541
go/zodb/storage/fs1/fs1tools/testdata/empty.fsdumpv.ok
0 → 100644
View file @
4c621541
************************************************************
file identifier: 'FS21'
go/zodb/storage/fs1/fs1tools/testdata/empty.fstail.ok
0 → 100644
View file @
4c621541
go/zodb/storage/fs1/testdata/empty.fs
0 → 100644
View file @
4c621541
FS21
\ No newline at end of file
go/zodb/zodbtools/dump_test.go
View file @
4c621541
...
...
@@ -20,10 +20,12 @@
package
zodbtools
//go:generate sh -c "python2 -m zodbtools.zodb dump ../../zodb/storage/fs1/testdata/1.fs >testdata/1.zdump.pyok"
//go:generate sh -c "python2 -m zodbtools.zodb dump ../../zodb/storage/fs1/testdata/empty.fs >testdata/empty.zdump.pyok"
import
(
"bytes"
"context"
"fmt"
"io/ioutil"
"regexp"
"testing"
...
...
@@ -64,8 +66,8 @@ func loadZdumpPy(t *testing.T, path string) string {
return
string
(
dump
)
}
func
withTestdata
1Fs
(
t
testing
.
TB
,
f
func
(
zstor
zodb
.
IStorage
))
{
zstor
,
err
:=
zodb
.
OpenStorage
(
context
.
Background
(),
"../../zodb/storage/fs1/testdata/1.fs"
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
func
withTestdata
Fs
(
t
testing
.
TB
,
db
string
,
f
func
(
zstor
zodb
.
IStorage
))
{
zstor
,
err
:=
zodb
.
OpenStorage
(
context
.
Background
(),
fmt
.
Sprintf
(
"../../zodb/storage/fs1/testdata/%s.fs"
,
db
)
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -76,26 +78,31 @@ func withTestdata1Fs(t testing.TB, f func(zstor zodb.IStorage)) {
}
func
TestZodbDump
(
t
*
testing
.
T
)
{
withTestdata1Fs
(
t
,
func
(
zstor
zodb
.
IStorage
)
{
buf
:=
bytes
.
Buffer
{}
err
:=
Dump
(
context
.
Background
(),
&
buf
,
zstor
,
0
,
zodb
.
TidMax
,
false
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dumpOk
:=
loadZdumpPy
(
t
,
"testdata/1.zdump.pyok"
)
if
dumpOk
!=
buf
.
String
()
{
t
.
Errorf
(
"dump different:
\n
%v"
,
diff
.
Diff
(
dumpOk
,
buf
.
String
()))
}
})
testv
:=
[]
string
{
"1"
,
"empty"
}
for
_
,
tt
:=
range
testv
{
t
.
Run
(
"db="
+
tt
,
func
(
t
*
testing
.
T
)
{
withTestdataFs
(
t
,
tt
,
func
(
zstor
zodb
.
IStorage
)
{
buf
:=
bytes
.
Buffer
{}
err
:=
Dump
(
context
.
Background
(),
&
buf
,
zstor
,
0
,
zodb
.
TidMax
,
false
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dumpOk
:=
loadZdumpPy
(
t
,
fmt
.
Sprintf
(
"testdata/%s.zdump.pyok"
,
tt
))
if
dumpOk
!=
buf
.
String
()
{
t
.
Errorf
(
"dump different:
\n
%v"
,
diff
.
Diff
(
dumpOk
,
buf
.
String
()))
}
})
})
}
}
func
BenchmarkZodbDump
(
b
*
testing
.
B
)
{
// FIXME small testdata/1.fs is not representative for benchmarking
withTestdata
1Fs
(
b
,
func
(
zstor
zodb
.
IStorage
)
{
withTestdata
Fs
(
b
,
"1"
,
func
(
zstor
zodb
.
IStorage
)
{
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
...
...
go/zodb/zodbtools/testdata/empty.zdump.pyok
0 → 100644
View file @
4c621541
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