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
Levin Zimmermann
neoppod
Commits
4852419c
Commit
4852419c
authored
Jul 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c4dae76e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
110 deletions
+4
-110
go/internal/xtesting/xtesting.go
go/internal/xtesting/xtesting.go
+3
-3
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+1
-107
No files found.
go/internal/xtesting/xtesting.go
View file @
4852419c
...
@@ -135,10 +135,10 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
...
@@ -135,10 +135,10 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
// XXX + ZPyCommitSrv ?
// XXX + ZPyCommitSrv ?
// ----
storage driver test
s ----
// ----
tests for storage driver
s ----
//
TestDrv
Watch verifies that storage driver watcher can observe commits done from outside.
//
DrvTest
Watch verifies that storage driver watcher can observe commits done from outside.
func
TestDrv
Watch
(
t
*
testing
.
T
,
zurl
string
,
drvOpen
zodb
.
DriverOpener
)
{
func
DrvTest
Watch
(
t
*
testing
.
T
,
zurl
string
,
drvOpen
zodb
.
DriverOpener
)
{
t
.
Helper
()
t
.
Helper
()
X
:=
func
(
err
error
)
{
X
:=
func
(
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
4852419c
...
@@ -350,116 +350,10 @@ func BenchmarkIterate(b *testing.B) {
...
@@ -350,116 +350,10 @@ func BenchmarkIterate(b *testing.B) {
b
.
StopTimer
()
b
.
StopTimer
()
}
}
/*
// b is syntatic sugar for byte literals.
//
// e.g.
//
// b("hello")
func b(data string) []byte {
return []byte(data)
}
*/
// TestWatch verifies that watcher can observe commits done from outside.
// TestWatch verifies that watcher can observe commits done from outside.
func
TestWatch
(
t
*
testing
.
T
)
{
func
TestWatch
(
t
*
testing
.
T
)
{
workdir
:=
xworkdir
(
t
)
workdir
:=
xworkdir
(
t
)
xtesting
.
TestDrvWatch
(
t
,
workdir
+
"/t.fs"
,
openByURL
)
xtesting
.
DrvTestWatch
(
t
,
workdir
+
"/t.fs"
,
openByURL
)
/*
X := exc.Raiseif
xtesting.NeedPy(t, "zodbtools")
workdir := xworkdir(t)
tfs := workdir + "/t.fs"
// xcommit commits new transaction into tfs with raw data specified by objv.
xcommit := func(at zodb.Tid, objv ...xtesting.ZRawObject) zodb.Tid {
t.Helper()
tid, err := xtesting.ZPyCommitRaw(tfs, at, objv...); X(err)
return tid
}
// force tfs creation & open tfs at go side
at := xcommit(0, xtesting.ZRawObject{0, b("data0")})
watchq := make(chan zodb.Event)
fs, at0 := xfsopenopt(t, tfs, &zodb.DriverOptions{ReadOnly: true, Watchq: watchq})
if at0 != at {
t.Fatalf("opened @ %s ; want %s", at0, at)
}
ctx := context.Background()
checkHead := func(headOk zodb.Tid) {
t.Helper()
head, err := fs.Sync(ctx); X(err)
if head != headOk {
t.Fatalf("check head: got %s; want %s", head, headOk)
}
}
checkHead(at)
checkLoad := func(at zodb.Tid, oid zodb.Oid, dataOk string, serialOk zodb.Tid) {
t.Helper()
xid := zodb.Xid{at, oid}
buf, serial, err := fs.Load(ctx, xid); X(err)
data := string(buf.XData())
if !(data == dataOk && serial == serialOk) {
t.Fatalf("check load %s:\nhave: %q %s\nwant: %q %s",
xid, data, serial, dataOk, serialOk)
}
}
// commit -> check watcher observes what we committed.
//
// XXX python `import pkg_resources` takes ~ 300ms.
// https://github.com/pypa/setuptools/issues/510
//
// Since pkg_resources are used everywhere (e.g. in zodburi to find all
// uri resolvers) this import slowness becomes the major part of time to
// run py `zodb commit`.
//
// if one day it is either fixed, or worked around, we could ↑ 10 to 100.
for i := zodb.Oid(1); i <= 10; i++ {
data0 := fmt.Sprintf("data0.%d", i)
datai := fmt.Sprintf("data%d", i)
at = xcommit(at,
xtesting.ZRawObject{0, b(data0)},
xtesting.ZRawObject{i, b(datai)})
// TODO also test for watcher errors
event := <-watchq
var δ *zodb.EventCommit
switch event := event.(type) {
default:
panic(fmt.Sprintf("unexpected event: %T", event))
case *zodb.EventError:
t.Fatal(event.Err)
case *zodb.EventCommit:
δ = event
}
if objvWant := []zodb.Oid{0, i}; !(δ.Tid == at && reflect.DeepEqual(δ.Changev, objvWant)) {
t.Fatalf("watch:\nhave: %s %s\nwant: %s %s", δ.Tid, δ.Changev, at, objvWant)
}
checkHead(at)
// make sure we can load what was committed.
checkLoad(at, 0, data0, at)
checkLoad(at, i, datai, at)
}
err := fs.Close(); X(err)
e, ok := <-watchq
if ok {
t.Fatalf("watch after close -> %v; want closed", e)
}
*/
}
}
// TestOpenRecovery verifies how Open handles data file with not-finished voted
// TestOpenRecovery verifies how Open handles data file with not-finished voted
...
...
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