Commit 424718ea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e05d236b
// Copyright (C) 2017-2020 Nexedi SA and Contributors. // Copyright (C) 2017-2021 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
...@@ -29,10 +29,12 @@ import ( ...@@ -29,10 +29,12 @@ import (
"os" "os"
"os/exec" "os/exec"
"reflect" "reflect"
"strings"
"sync" "sync"
"testing" "testing"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xstrings"
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
) )
...@@ -135,6 +137,33 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err ...@@ -135,6 +137,33 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
// XXX + ZPyCommitSrv ? // XXX + ZPyCommitSrv ?
// ZPyRestore restores transactions specified by zin in zodbdump format.
//
// The restore is performed via zodbtools/py.
func ZPyRestore(zurl string, zin string) (tidv []zodb.Tid, err error) {
defer xerr.Contextf(&err, "%s: zpyrestore", zurl)
// run py `zodb restore`
cmd:= exec.Command("python", "-m", "zodbtools.zodb", "restore", zurl)
cmd.Stdin = strings.NewReader(zin)
cmd.Stderr = os.Stderr
out, err := cmd.Output()
if err != nil {
return nil, err
}
for _, line := range xstrings.SplitLines(string(out), "\n") {
tid, err := zodb.ParseTid(line)
if err != nil {
return nil, fmt.Errorf("restored, but invalid output: %s", err)
}
tidv = append(tidv, tid)
}
return tidv, nil
}
// ---- tests for storage drivers ---- // ---- tests for storage drivers ----
......
...@@ -19,13 +19,11 @@ ...@@ -19,13 +19,11 @@
package demo package demo
/*
import ( import (
"testing" "testing"
"lab.nexedi.com/kirr/neo/go/internal/xtesting" "lab.nexedi.com/kirr/neo/go/internal/xtesting"
) )
*/
// tOptions represents options for testing. // tOptions represents options for testing.
// TODO -> xtesting // TODO -> xtesting
...@@ -33,12 +31,12 @@ type tOptions struct { ...@@ -33,12 +31,12 @@ type tOptions struct {
Preload string // preload database with data from this location Preload string // preload database with data from this location
} }
/*
// withDemoStorage tests f with all kind of demo overlays. // withDemoStorage tests f with all kind of demo overlays.
func withDemoStorage(t *testing.T, f func(t *testing.T, dsrv XXX), optv ...tOptions) { func withDemoStorage(t *testing.T, f func(t *testing.T, dsrv *Storage/*XXX -> Srv ?*/), optv ...tOptions) {
t.Helper() t.Helper()
X := xtesting.FatalIf(t)
opt := t.Options{} opt := tOptions{}
if len(optv) > 1 { if len(optv) > 1 {
panic("multiple tOptions not allowed") panic("multiple tOptions not allowed")
} }
...@@ -47,6 +45,7 @@ func withDemoStorage(t *testing.T, f func(t *testing.T, dsrv XXX), optv ...tOpti ...@@ -47,6 +45,7 @@ func withDemoStorage(t *testing.T, f func(t *testing.T, dsrv XXX), optv ...tOpti
} }
// verify on all combinations of preload being split into base+δ // verify on all combinations of preload being split into base+δ
txnv, err := xtesting.LoadDBHistory(t.Preload) txnv, err := xtesting.LoadDBHistory(opt.Preload); X(err)
_ = txnv
} }
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment