overflow_probes/service/ContainerService_test.go
crusader f073163bf7 ing
2018-03-15 22:52:23 +09:00

70 lines
1.4 KiB
Go

package service
import (
"fmt"
"path"
"testing"
lfcc "git.loafle.net/commons_go/config"
crc "git.loafle.net/commons_go/rpc/client"
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
"git.loafle.net/overflow/overflow_probes/config"
"github.com/stretchr/testify/assert"
)
func initConfig() {
dir, err := lfcc.ABSPathify("../")
if nil != err {
panic("Config path is not valid")
}
config.ConfigDir = &dir
cfp := path.Join(*config.ConfigDir, ooccp.ConfigFileName)
config.ConfigFilePath = &cfp
conf := lfcc.New()
config.Config = &ooccp.Config{}
if err := conf.Load(config.Config, *config.ConfigFilePath); nil != err {
panic(fmt.Sprintf("Config is not valid: %v", err))
}
}
func TestGetClient(t *testing.T) {
initConfig()
cs := GetService("ContainerService").(*ContainerService)
var c crc.Client
var err error
// // General
// c, err = cs.GetClient(ooccp.ContainerGeneralName)
// assert.Nil(t, err)
// assert.NotNil(t, c)
// err = cs.killProcess(ooccp.ContainerGeneralName)
// assert.Nil(t, err)
// Network
c, err = cs.GetClient(ooccp.ContainerNetworkName)
assert.Nil(t, err)
assert.NotNil(t, c)
cs.killProcess(ooccp.ContainerNetworkName)
assert.Nil(t, err)
// // Discovery
// c, err = cs.GetClient(ooccp.ContainerDiscoveryName)
// assert.Nil(t, err)
// assert.NotNil(t, c)
// cs.killProcess(ooccp.ContainerDiscoveryName)
// assert.Nil(t, err)
}