1 package orchestrationapi
10 configuremgr "configuremgr"
11 confdescription "configuremgr/description"
13 // mockconfiguremgr "configuremgr/mock"
15 scoringmgr "scoringmgr"
16 mockscoringmgr "scoringmgr/mock"
18 // discoverymgr "discoverymgr"
19 // servicemgr "servicemgr"
24 //jaehoon.hyun , jaehoon.hyun
25 func TestConfigureMgrScoringMgr(t *testing.T){
28 orcheMock := new(Orche)
30 orcheMock.IScoringmgr = scoringmgr.Init()
31 orcheMock.IConfiguremgr = configuremgr.Init()
33 orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringAddInterface
34 orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
35 orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
37 orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = pushConfPathDiscoveryDeviceMock
38 orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
39 orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
41 orcheMock.IDiscoverymgr.GetEndpointDevices = getEndpointDevicesMock
42 orcheMock.IServicemgr.ExecuteApp = executeAppMock
45 //start module function
46 orcheMock.IScoringmgr.Listening()
47 go orcheMock.IConfiguremgr.Watch("/tmp/foo")
50 execCommand("rm -rf /tmp/foo/mysum")
51 time.Sleep(time.Duration(1) * time.Second)
54 execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
55 time.Sleep(time.Duration(5) * time.Second)
58 orcheMock.IScoringmgr.RemoveLib("/tmp/foo/mysum/libmysum.so")
60 orcheMock.IConfiguremgr.Done <- true
64 //jaehoon.hyun, damon92-lee
65 func TestConfigureMgrDiscoveryMgr(t *testing.T) {
69 //jaehoon.hyun, chacha
70 func TestRequestServiceFunctionServiceMgr(t *testing.T){
73 // orcheMock := new(Orche)
75 // orcheMock.IScoringmgr = scoringmgr.Init()
76 // orcheMock.IConfiguremgr = configuremgr.Init()
78 // orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringAddInterface
79 // orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
80 // orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
82 // orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = pushConfPathDiscoveryDeviceMock
83 // orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
84 // orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
86 // orcheMock.IDiscoverymgr.GetEndpointDevices = getEndpointDevicesMock
87 // orcheMock.IServicemgr.ExecuteApp = executeAppMock
91 // orcheMock.IScoringmgr.Listening()
93 // //configuremgr init
94 // go orcheMock.IConfiguremgr.Watch("/tmp/foo")
97 // servicemgr.InitServiceMap()
100 // RequestService("mysum", "ls", []string{"-al"})
104 //daemon92-lee, chacha
105 func TestDiscoveryMgrServiceMgr(t *testing.T){
110 //jaehoon.hyun, daemon92-lee, jaehoon.hyun
111 func TestConfigureMgrDiscoveryMgrScoringMgr(t *testing.T){
115 //jaehoon.hyun, daemon92-lee, chacha
116 func TestConfigureMgrDiscoveryMgrServiceMgr(t *testing.T){
121 //jaehoon.hyun, chacha, jaehoon.hyun
122 func TestConfigureMgrServiceMgrScoringMgr(t *testing.T){
126 //jaehoon.hyun, daemon92-lee, chacha, jaehoon.hyun
127 func TestConfigureMgrDiscoveryMgrScoringMgrServiceMgr(t *testing.T){
133 func pushConfPathDiscoveryDeviceMock (doc *confdescription.Doc) (err error) {
134 ILog.Println("pushConfPathDiscoveryDeviceMock")
139 func pushLibPathScoringAppMock(libPath string, doc *confdescription.Doc, handlersCh chan<- interface{}) (err error) {
140 ILog.Println("pushLibPathScoringAppMock")
141 ILog.Println(libPath)
145 func getEndpointDevicesMock(serviceName string) []string {
146 return []string{"localhost", "localhost"}
149 func executeAppMock(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error) {
150 ILog.Println("ExecuteApp")
158 func execCommand(command string) {
159 configuremgr.DLog.Println(command)
160 cmd := exec.Command("sh", "-c", command)
161 stdoutStderr, err := cmd.CombinedOutput()
162 configuremgr.DLog.Printf("%s", stdoutStderr)
164 configuremgr.ELog.Fatal(err)