Commit 2de637bb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 114b7fd6
......@@ -28,8 +28,6 @@ import (
"reflect"
"testing"
"golang.org/x/sync/errgroup"
"github.com/kylelemons/godebug/pretty"
"lab.nexedi.com/kirr/neo/go/neo/proto"
......@@ -145,8 +143,8 @@ func TestMasterStorage(t0 *testing.T) {
// ----------------------------------------
// M <- start cmd
wg := &errgroup.Group{}
gox(wg, func() {
wg := xsync.NewWorkGroup(bg)
gox(wg, func(ctx context.Context) {
err := M.Start(); X(err)
})
......@@ -252,9 +250,9 @@ func TestMasterStorage(t0 *testing.T) {
// ----------------------------------------
// C asks M about last tid XXX better master sends it itself on new client connected
wg = &errgroup.Group{}
gox(wg, func() {
cLastTid, err := C.Sync(bg); X(err)
wg = xsync.NewWorkGroup(bg)
gox(wg, func(ctx context.Context) {
cLastTid, err := C.Sync(ctx); X(err)
if cLastTid != lastTid {
exc.Raisef("C.LastTid -> %v ; want %v", cLastTid, lastTid)
......@@ -262,21 +260,18 @@ func TestMasterStorage(t0 *testing.T) {
})
tCM.Expect(conntx("c:1", "m:3", 5, &proto.LastTransaction{}))
tCM.Expect(conntx("m:3", "c:1", 5, &proto.AnswerLastTransaction{
Tid: lastTid,
}))
tCM.Expect(conntx("m:3", "c:1", 5, &proto.AnswerLastTransaction{lastTid}))
xwait(wg)
// ----------------------------------------
// C starts loading first object ...
wg = &errgroup.Group{}
wg = xsync.NewWorkGroup(bg)
xid1 := zodb.Xid{Oid: 1, At: zodb.TidMax}
buf1, serial1, err := zstor.Load(bg, xid1); X(err)
gox(wg, func() {
buf, serial, err := C.Load(bg, xid1); X(err)
gox(wg, func(ctx context.Context) {
buf, serial, err := C.Load(ctx, xid1); X(err)
if !(bytes.Equal(buf.Data, buf1.Data) && serial==serial1) {
exc.Raisef("C.Load(%v) ->\ndata:\n%s\nserial:\n%s\n", xid1,
......@@ -328,11 +323,11 @@ func TestMasterStorage(t0 *testing.T) {
// verify NextSerial is properly returned in AnswerObject via trace-loading prev. revision of obj1
// (XXX we currently need NextSerial for neo/py client cache)
wg = &errgroup.Group{}
wg = xsync.NewWorkGroup(bg)
xid1prev := zodb.Xid{Oid: 1, At: serial1 - 1}
buf1prev, serial1prev, err := zstor.Load(bg, xid1prev); X(err)
gox(wg, func() {
buf, serial, err := C.Load(bg, xid1prev); X(err)
gox(wg, func(ctx context.Context) {
buf, serial, err := C.Load(ctx, xid1prev); X(err)
if !(bytes.Equal(buf.Data, buf1prev.Data) && serial==serial1prev) {
exc.Raisef("C.Load(%v) ->\ndata:\n%s\nserial:\n%s\n", xid1prev,
......
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......@@ -36,8 +36,12 @@ func xwait(w interface { Wait() error }) {
exc.Raiseif(err)
}
func gox(wg interface { Go(func() error) }, xf func()) {
wg.Go(exc.Funcx(xf))
func gox(wg interface { Go(func(context.Context) error) }, xf func(context.Context)) {
wg.Go(func(ctx context.Context) error {
return exc.Funcx(func() {
xf(ctx)
})()
})
}
func xfs1stor(path string) *zfs1.FileStorage {
......
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