|
|
@ -10,10 +10,11 @@ import (
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"crypto/tls"
|
|
|
|
"crypto/tls"
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestGQL(t *testing.T) {
|
|
|
|
func TestGQL(t *testing.T) {
|
|
|
|
ctx := logTestContext(t, []string{"test", "gql", "policy"})
|
|
|
|
ctx := logTestContext(t, []string{"node", "test", "gql", "policy"})
|
|
|
|
|
|
|
|
|
|
|
|
TestNodeType := NodeType("TEST")
|
|
|
|
TestNodeType := NodeType("TEST")
|
|
|
|
err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType, ACLExtType})
|
|
|
|
err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType, ACLExtType})
|
|
|
@ -23,18 +24,14 @@ func TestGQL(t *testing.T) {
|
|
|
|
fatalErr(t, err)
|
|
|
|
fatalErr(t, err)
|
|
|
|
listener_ext := NewListenerExt(10)
|
|
|
|
listener_ext := NewListenerExt(10)
|
|
|
|
policy := NewAllNodesPolicy(Actions{MakeAction("+")})
|
|
|
|
policy := NewAllNodesPolicy(Actions{MakeAction("+")})
|
|
|
|
gql := NewNode(ctx, nil, GQLNodeType, 10, nil, NewLockableExt(), NewACLExt(policy), gql_ext, NewGroupExt(nil))
|
|
|
|
gql := NewNode(ctx, nil, GQLNodeType, 10, []QueuedSignal{
|
|
|
|
n1 := NewNode(ctx, nil, TestNodeType, 10, nil, NewLockableExt(), NewACLExt(policy), listener_ext)
|
|
|
|
QueuedSignal{uuid.New(), StateSignal{NewDirectSignal(GQLStateSignalType), "start_server"}, time.Now()},
|
|
|
|
|
|
|
|
}, NewLockableExt(), NewACLExt(policy), gql_ext, NewGroupExt(nil), listener_ext)
|
|
|
|
|
|
|
|
n1 := NewNode(ctx, nil, TestNodeType, 10, nil, NewLockableExt(), NewACLExt(policy))
|
|
|
|
|
|
|
|
|
|
|
|
err = LinkRequirement(ctx, gql.ID, n1.ID)
|
|
|
|
err = LinkRequirement(ctx, gql.ID, n1.ID)
|
|
|
|
fatalErr(t, err)
|
|
|
|
fatalErr(t, err)
|
|
|
|
|
|
|
|
|
|
|
|
_, err = WaitForSignal(ctx, listener_ext, time.Millisecond*10, LinkSignalType, func(sig StateSignal) bool {
|
|
|
|
|
|
|
|
return sig.State == "linked_as_dep"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fatalErr(t, err)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.Send(n1.ID, gql.ID, StateSignal{NewDirectSignal(GQLStateSignalType), "start_server"})
|
|
|
|
|
|
|
|
_, err = WaitForSignal(ctx, listener_ext, 100*time.Millisecond, GQLStateSignalType, func(sig StateSignal) bool {
|
|
|
|
_, err = WaitForSignal(ctx, listener_ext, 100*time.Millisecond, GQLStateSignalType, func(sig StateSignal) bool {
|
|
|
|
return sig.State == "server_started"
|
|
|
|
return sig.State == "server_started"
|
|
|
|
})
|
|
|
|
})
|
|
|
|