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
d731fd4e
Commit
d731fd4e
authored
Mar 17, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f6560f86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
go/zodb/storage/demo/demo_test.go
go/zodb/storage/demo/demo_test.go
+9
-10
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+2
-2
No files found.
go/zodb/storage/demo/demo_test.go
View file @
d731fd4e
...
@@ -41,7 +41,7 @@ import (
...
@@ -41,7 +41,7 @@ import (
// DemoData represents data for a demo: storage.
// DemoData represents data for a demo: storage.
type
DemoData
struct
{
type
DemoData
struct
{
base
string
//
path for
base.fs
base
string
//
url for
base.fs
δ
string
// ----/---- δ.fs
δ
string
// ----/---- δ.fs
}
}
...
@@ -56,7 +56,7 @@ type tOptions struct {
...
@@ -56,7 +56,7 @@ type tOptions struct {
Preload
string
// preload database with data from this location
Preload
string
// preload database with data from this location
}
}
// withDemoData tests f with all kind
of demo data splits
.
// withDemoData tests f with all kind
s of opt.Preload data split into base + δ
.
func
withDemoData
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
ddat
*
DemoData
),
optv
...
tOptions
)
{
func
withDemoData
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
ddat
*
DemoData
),
optv
...
tOptions
)
{
t
.
Helper
()
t
.
Helper
()
X
:=
xtesting
.
FatalIf
(
t
)
X
:=
xtesting
.
FatalIf
(
t
)
...
@@ -89,18 +89,14 @@ func withDemoData(t *testing.T, f func(t *testing.T, ddat *DemoData), optv ...tO
...
@@ -89,18 +89,14 @@ func withDemoData(t *testing.T, f func(t *testing.T, ddat *DemoData), optv ...tO
pos
int
// where this transaction starts in the dump
pos
int
// where this transaction starts in the dump
}
}
var
txnv
[]
zdumpTxn
var
txnv
[]
zdumpTxn
// fmt.Printf("%s\n\n\n", zdump)
for
_
,
m
:=
range
txnRe
.
FindAllStringSubmatchIndex
(
zdump
,
-
1
)
{
for
_
,
m
:=
range
txnRe
.
FindAllStringSubmatchIndex
(
zdump
,
-
1
)
{
// fmt.Println(m)
// [m[0]:m[1]] refers to whole txn line
// [m[0]:m[1]] refer to whole txn line
__
:=
zdump
[
m
[
2
]
:
m
[
3
]]
__
:=
zdump
[
m
[
2
]
:
m
[
3
]]
tid
,
err
:=
zodb
.
ParseTid
(
__
);
X
(
err
)
tid
,
err
:=
zodb
.
ParseTid
(
__
);
X
(
err
)
txnv
=
append
(
txnv
,
zdumpTxn
{
tid
,
m
[
0
]})
txnv
=
append
(
txnv
,
zdumpTxn
{
tid
,
m
[
0
]})
}
}
// fmt.Printf("\n\n\ntxnv: %v\n", txnv)
// verify f on all combinations of preload being split into base+δ
// verify on all combinations of preload being split into base+δ
work
:=
xtempdir
(
t
)
work
:=
xtempdir
(
t
)
defer
os
.
RemoveAll
(
work
)
defer
os
.
RemoveAll
(
work
)
test1
:=
func
(
δstart
zodb
.
Tid
,
zdumpBase
,
zdumpδ
string
)
{
test1
:=
func
(
δstart
zodb
.
Tid
,
zdumpBase
,
zdumpδ
string
)
{
...
@@ -115,8 +111,11 @@ func withDemoData(t *testing.T, f func(t *testing.T, ddat *DemoData), optv ...tO
...
@@ -115,8 +111,11 @@ func withDemoData(t *testing.T, f func(t *testing.T, ddat *DemoData), optv ...tO
δ
:=
"file://"
+
work1
+
"/δ.fs"
δ
:=
"file://"
+
work1
+
"/δ.fs"
ddat
:=
&
DemoData
{
base
,
δ
}
ddat
:=
&
DemoData
{
base
,
δ
}
_
,
err
=
xtesting
.
ZPyRestore
(
base
,
zdumpBase
);
X
(
err
)
_
,
err
=
xtesting
.
ZPyRestore
(
base
,
zdumpBase
);
X
(
err
)
// XXX + explain why demo instead of δ (restoring copy without original present fails)
// restore δ part via `demo:(base)/(δ)` - not `file:δ`.
// The reason we do this is because restoring δ via
// just its file will fail when restoring copy data
// record with copy_from transaction being in base.
_
,
err
=
xtesting
.
ZPyRestore
(
ddat
.
URL
(),
zdumpδ
);
X
(
err
)
_
,
err
=
xtesting
.
ZPyRestore
(
ddat
.
URL
(),
zdumpδ
);
X
(
err
)
f
(
t
,
ddat
)
f
(
t
,
ddat
)
...
...
go/zodb/storage/fs1/filestorage.go
View file @
d731fd4e
// Copyright (C) 2017-202
0
Nexedi SA and Contributors.
// Copyright (C) 2017-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -132,7 +132,7 @@ func (fs *FileStorage) LastOid(_ context.Context) (zodb.Oid, error) {
...
@@ -132,7 +132,7 @@ func (fs *FileStorage) LastOid(_ context.Context) (zodb.Oid, error) {
}
}
func
(
fs
*
FileStorage
)
URL
()
string
{
func
(
fs
*
FileStorage
)
URL
()
string
{
return
fs
.
file
.
Name
()
return
fs
.
file
.
Name
()
// XXX + file://
}
}
// freelist(DataHeader)
// freelist(DataHeader)
...
...
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