Commit e0fff1ea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6b9c53a4
......@@ -49,36 +49,39 @@ func TestMasterStorage(t *testing.T) {
func tracetestMasterStorage(t0 *tracetest.T) {
X := exc.Raiseif
t := tNewCluster(t0, "abc1")
defer t.Stop()
M := t.NewMaster("m")
zstor := xfs1stor("../zodb/storage/fs1/testdata/1.fs")
zback := xfs1back("../zodb/storage/fs1/testdata/1.fs")
_ = t.NewStorage("s", "m:1", zback) // XXX do we need to provide Mlist here?
t := tNewCluster_MS(t0, "abc1", zback)
defer t.Stop()
M := t.Master("m")
C := t.NewClient("c", "m:1")
lastTid, err := zstor.Sync(bg); X(err)
tM := t.Checker("m")
tS := t.Checker("s")
// tS := t.Checker("s")
tC := t.Checker("c")
tMS := t.Checker("m-s")
tSM := t.Checker("s-m")
// tSM := t.Checker("s-m")
tCM := t.Checker("c-m")
tMC := t.Checker("m-c")
tCS := t.Checker("c-s")
// ----------------------------------------
// TODO create C; C tries connect to master - rejected ("not yet operational")
// TODO test ID rejects (uuid already registered, ...)
// XXX convert prologue to tNewCluster_MS
/*
// M starts listening
tM.Expect(netlisten("m:1"))
tM.Expect(δnode("m", "m:1", proto.MASTER, 1, proto.RUNNING, proto.IdTimeNone))
tM.Expect(clusterState("m", proto.ClusterRecovering))
// TODO create C; C tries connect to master - rejected ("not yet operational")
// S starts listening
tS.Expect(netlisten("s:1"))
......@@ -106,8 +109,6 @@ func tracetestMasterStorage(t0 *tracetest.T) {
YourUUID: proto.UUID(proto.STORAGE, 1),
}))
// TODO test ID rejects (uuid already registered, ...)
// M starts recovery on S
tMS.Expect(conntx("m:2", "s:2", 0, &proto.Recovery{}))
tMS.Expect(conntx("s:2", "m:2", 0, &proto.AnswerRecovery{
......@@ -128,6 +129,7 @@ func tracetestMasterStorage(t0 *tracetest.T) {
tM.Expect(masterStartReady("m", true))
// ----------------------------------------
*/
// M <- start cmd
wg := xsync.NewWorkGroup(bg)
......
......@@ -66,24 +66,23 @@ type tCluster struct {
runCancel func()
}
// tNode represents information about a test node ... XXX
// tNode represents information about a tested node.
type tNode struct {
net xnet.Networker
itest interface{} // ITest{Master,Storage,Client}
net xnet.Networker
}
// XXX stub
// ITestMaster represents tested master node.
type ITestMaster interface {
// Run(ctx context.Context) error
Start() error
}
// ITestStorage represents tested storage node.
type ITestStorage interface {
// Run(ctx context.Context) error
}
// ITestClient represents tested client node.
type ITestClient interface {
// Run(ctx context.Context) error
zodb.IStorageDriver
}
......@@ -208,7 +207,7 @@ func (t *tCluster) registerNewNode(name string) *tNode {
}
node := &tNode{}
node.net = xnet.NetTrace(host, t.gotracer)
node.net = xnet.NetTrace(host, t.gotracer)
t.nodeTab[name] = node
return node
......@@ -218,12 +217,11 @@ func (t *tCluster) registerNewNode(name string) *tNode {
// NewMaster creates new master on node name.
//
// The master will be accepting incoming connections at node:1.
// The node must be not yet existing and will be dedicated to the created master fully. XXX
//
// XXX error of creating py process? -> t.Fatal
// The node must be not yet existing and will be fully dedicated to the created master.
func (t *tCluster) NewMaster(name string) ITestMaster {
node := t.registerNewNode(name)
m := tNewMaster(t.name, ":1", node.net)
tnode := t.registerNewNode(name)
m := tNewMaster(t.name, ":1", tnode.net)
tnode.itest = m
// let tracer know how to map state addresses to node names
t.gotracer.RegisterNode(m.node, name)
......@@ -236,6 +234,22 @@ func (t *tCluster) NewMaster(name string) ITestMaster {
return m
}
// Master returns master node that was previouslt created via NewMaster(name).
func (t *tCluster) Master(name string) ITestMaster {
t.tabMu.Lock()
defer t.tabMu.Unlock()
tnode, ok := t.nodeTab[name]
if !ok {
t.Fatalf("no node %q", name)
}
m, ok := tnode.itest.(ITestMaster)
if !ok {
t.Fatalf("node %q if of type %T, not master", name, tnode.itest)
}
return m
}
func (t *tCluster) NewStorage(name, masterAddr string, back storage.Backend) ITestStorage {
node := t.registerNewNode(name)
s := tNewStorage(t.name, masterAddr, ":1", node.net, back)
......
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