github.com/whamcloud/lemur@v0.0.0-20190827193804-4655df8a52af/cmd/lhsmd/agent/agent_test.go (about) 1 // Copyright (c) 2018 DDN. All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package agent_test 6 7 import ( 8 "testing" 9 "time" 10 11 "github.com/intel-hpdd/lemur/cmd/lhsmd/agent" 12 _ "github.com/intel-hpdd/lemur/cmd/lhsmd/transport/grpc" 13 "github.com/intel-hpdd/lemur/pkg/fsroot" 14 "github.com/intel-hpdd/go-lustre/hsm" 15 16 "golang.org/x/net/context" 17 ) 18 19 func TestAgentStartStop(t *testing.T) { 20 cfg := agent.DefaultConfig() 21 cfg.Transport.SocketDir = "/tmp" 22 as := hsm.NewTestSource() 23 ta, err := agent.New(cfg, fsroot.Test(cfg.AgentMountpoint()), as) 24 if err != nil { 25 t.Fatal(err) 26 } 27 28 go func() { 29 if err := ta.Start(context.Background()); err != nil { 30 t.Fatalf("Test agent startup failed: %s", err) 31 } 32 }() 33 34 // Wait for the agent to signal that it has started 35 ta.StartWaitFor(5 * time.Second) 36 37 ta.Stop() 38 }