*******************************************************************************/
package orchestrationapi
-//$
-
import (
- "discoverymgr"
"fmt"
"log"
"os/exec"
configuremgr "configuremgr"
confdescription "configuremgr/description"
-
// mockconfiguremgr "configuremgr/mock"
+ scoringmgr "scoringmgr"
+ mockscoringmgr "scoringmgr/mock"
+ discoverymgr "discoverymgr"
+ securemgr "securemgr"
+ servicemgr "servicemgr"
+)
+
+//jaehoon.hyun , jaehoon.hyun
+func TestConfigureMgrScoringMgrAlreadyScoring2Library(t *testing.T) {
- scoringmgr "scoringmgr"
- mockscoringmgr "scoringmgr/mock"
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring2/", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
- // discoverymgr "discoverymgr"
- servicemgr "servicemgr"
-)
+ //make orche
+ orcheMock := Init("")
+
+ //create modules
+ orcheMock.IScoringmgr = scoringmgr.Init()
+ orcheMock.IConfiguremgr = configuremgr.Init()
+
+ //scoringmgr interface
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
+ orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
+ orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
+ //configuremgr interface
+ orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
+
+ //discoverymgr interface
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
+
+ //servicemgr interface
+ orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
+
+ //start scoringmgr
+ orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
+
+ //start configuremgr
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
+ //release configuremgr
+ orcheMock.IConfiguremgr.Done <- true
+
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
+}
+
+//jaehoon.hyun, chacha, jaehoon.hyun
+func TestConfigureMgrServiceMgrScoringMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
+ orcheMock := Init("")
+
+ orcheMock.IScoringmgr = scoringmgr.Init()
+ orcheMock.IConfiguremgr = configuremgr.Init()
+
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
+ orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
+ orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
+
+ orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
+
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
+ orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
+
+ //servicemgr init
+ servicemgr.Init()
+
+ // securemgr init
+ securemgr.Init("../securemgr/test/key.txt")
+
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
+
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
+ RequestService("ls", []string{"-al"})
+ time.Sleep(time.Duration(3) * time.Second)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
+
+ //release configuremgr
+ orcheMock.IConfiguremgr.Done <- true
+
+ time.Sleep(time.Duration(100) * time.Millisecond)
+}
//jaehoon.hyun , jaehoon.hyun
func TestConfigureMgrScoringMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
//make orche
orcheMock := Init("")
orcheMock.IConfiguremgr = configuremgr.Init()
//scoringmgr interface
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
//configuremgr interface
orcheMock.IScoringmgr.IStartResourceService()
//start configuremgr
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
+ time.Sleep(time.Duration(3) * time.Second)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
+ //release configuremgr
+ orcheMock.IConfiguremgr.Done <- true
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
+}
+
+//jaehoon.hyun , jaehoon.hyun
+func TestConfigureMgrScoringMgrMyscoring2(t *testing.T) {
//init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
+ //make orche
+ orcheMock := Init("")
+
+ //create modules
+ orcheMock.IScoringmgr = scoringmgr.Init()
+ orcheMock.IConfiguremgr = configuremgr.Init()
+
+ //scoringmgr interface
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
+ orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
+ orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
+ //configuremgr interface
+ orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
+
+ //discoverymgr interface
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
+
+ //servicemgr interface
+ orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
+
+ //start scoringmgr
+ orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
+
+ //start configuremgr
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//user scenario
- execCommand(fmt.Sprintf("cp -arR %s %s", "./mock/mysum/", "/tmp/foo"))
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring2/", listeningDir))
time.Sleep(time.Duration(3) * time.Second)
//release scoringmgr
orcheMock.IScoringmgr.IStopResourceService()
- orcheMock.IScoringmgr.RemoveLib("ls")
+ orcheMock.IScoringmgr.RemoveAll()
+ time.Sleep(time.Duration(100) * time.Millisecond)
//release configuremgr
orcheMock.IConfiguremgr.Done <- true
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
}
func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
//make orche
orcheMock := new(Orche)
orcheMock.IScoringmgr.IStartResourceService()
//start configuremgr
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
-
- //init scenario
- execCommand("rm -rf /tmp/foo/myscoring")
- time.Sleep(time.Duration(1) * time.Second)
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//user scenario
- execCommand(fmt.Sprintf("cp -arR %s %s", "./mock/myscoring/", "/tmp/foo"))
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
time.Sleep(time.Duration(3) * time.Second)
//release scoringmgr
orcheMock.IScoringmgr.IStopResourceService()
- orcheMock.IScoringmgr.RemoveLib("ls")
+ orcheMock.IScoringmgr.RemoveAll()
+ time.Sleep(time.Duration(100) * time.Millisecond)
//release configuremgr
orcheMock.IConfiguremgr.Done <- true
+
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
}
//jaehoon.hyun, damon92-lee
func TestConfigureMgrDiscoveryMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
orcheMock := Init("")
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
+ //discoverymgr init
discoverymgr.InitDiscovery()
//scoringmgr init
orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
//configuremgr init
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
-
- //init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
time.Sleep(time.Duration(3) * time.Second)
RequestService("ls", []string{"-al"})
+ time.Sleep(time.Duration(3) * time.Second)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
- //resource release
- time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("ls")
+ //release configure
orcheMock.IConfiguremgr.Done <- true
+
+ //release discoverymgr
discoverymgr.ExitChan <- 1
+
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
}
//jaehoon.hyun, chacha
func TestRequestServiceFunctionServiceMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
orcheMock := Init("")
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
//scoringmgr init
orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
//configuremgr init
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//servicemgr init
servicemgr.Init()
- //init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
-
//user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
time.Sleep(time.Duration(3) * time.Second)
RequestService("ls", []string{"-al"})
+ time.Sleep(time.Duration(3) * time.Second)
- //resource release
- time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("ls")
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
+
+ //release configuremgr
orcheMock.IConfiguremgr.Done <- true
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
}
//daemon92-lee, chacha
//jaehoon.hyun, daemon92-lee, jaehoon.hyun
func TestConfigureMgrDiscoveryMgrScoringMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
orcheMock := Init("")
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
orcheMock.IScoringmgr.IGetScore = scoringmgr.GetScore
orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
//scoringmgr init
orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
- //configuremgr init
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+ //discoverymgr init
+ discoverymgr.InitDiscovery()
- //init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
+ //securemgr init
+ securemgr.Init("../securemgr/test/key.txt")
- discoverymgr.InitDiscovery()
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "../scoringmgr/mock/mysum/", "/tmp/foo"))
- time.Sleep(time.Duration(3) * time.Second)
+ execCommand(fmt.Sprintf("cp -ar %s %s", "../scoringmgr/mock/myscoring/", listeningDir))
+ time.Sleep(time.Duration(300) * time.Millisecond)
RequestService("ls", []string{"-al"})
+ time.Sleep(time.Duration(100) * time.Millisecond)
- //resource release
- time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("ls")
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
+
+ //release configuremgr
orcheMock.IConfiguremgr.Done <- true
+
+ //release discoverymgr
discoverymgr.ExitChan <- 1
+
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
}
//jaehoon.hyun, daemon92-lee, chacha
func TestConfigureMgrDiscoveryMgrServiceMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
orcheMock := Init("")
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
+ //discoverymgr init
discoverymgr.InitDiscovery()
+
+ //servicemgr init
servicemgr.Init()
//scoringmgr init
orcheMock.IScoringmgr.Listening()
-
- //init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
+ orcheMock.IScoringmgr.IStartResourceService()
//configuremgr init
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
time.Sleep(time.Duration(3) * time.Second)
RequestService("ls", []string{"-al"})
+ time.Sleep(time.Duration(100) * time.Millisecond)
- //resource release
- time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("ls")
- orcheMock.IConfiguremgr.Done <- true
- discoverymgr.ExitChan <- 1
-
-}
-
-//jaehoon.hyun, chacha, jaehoon.hyun
-func TestConfigureMgrServiceMgrScoringMgr(t *testing.T) {
- orcheMock := Init("")
-
- orcheMock.IScoringmgr = scoringmgr.Init()
- orcheMock.IConfiguremgr = configuremgr.Init()
-
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
- orcheMock.IScoringmgr.IGetScore = scoringmgr.GetScore
- orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
-
- orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
- orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
- orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
-
- orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
- orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
-
- //scoringmgr init
- orcheMock.IScoringmgr.Listening()
-
- //configuremgr init
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
- //init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
+ //release configuremgr
+ orcheMock.IConfiguremgr.Done <- true
- servicemgr.Init()
+ //release discoverymgr
+ discoverymgr.ExitChan <- 1
- //user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
- time.Sleep(time.Duration(3) * time.Second)
- RequestService("ls", []string{"-al"})
+ //waiting resource thread stop
+ time.Sleep(time.Duration(100) * time.Millisecond)
- //resource release
- time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("ls")
- orcheMock.IConfiguremgr.Done <- true
}
//jaehoon.hyun, daemon92-lee, chacha, jaehoon.hyun
func TestConfigureMgrDiscoveryMgrScoringMgrServiceMgr(t *testing.T) {
+ //init scenario
+ listeningDir := "/tmp/foo"
+ execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
+ execCommand(fmt.Sprintf("mkdir -p %s", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
orcheMock := Init("")
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
- orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
- orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IRunningScore = scoringmgr.LoadScoringGeneralInterface
+ orcheMock.IScoringmgr.IStartResourceService = scoringmgr.StartResourceService
+ orcheMock.IScoringmgr.IStopResourceService = scoringmgr.StopResourceService
orcheMock.IScoringmgr.IGetScore = scoringmgr.GetScore
orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
+ //discoverymgr init
+ discoverymgr.InitDiscovery()
+
+ //servicemgr init
+ servicemgr.Init()
+
//scoringmgr init
orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
- //configuremgr init
- go orcheMock.IConfiguremgr.Watch("/tmp/foo")
-
- //init scenario
- execCommand("rm -rf /tmp/foo/mysum")
- time.Sleep(time.Duration(1) * time.Second)
+ //securemgr init
+ securemgr.Init("../securemgr/test/key.txt")
- discoverymgr.InitDiscovery()
- servicemgr.Init()
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch(listeningDir)
//user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
- time.Sleep(time.Duration(3) * time.Second)
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
+ time.Sleep(time.Duration(100) * time.Millisecond)
RequestService("ls", []string{"-al"})
+ time.Sleep(time.Duration(100) * time.Millisecond)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStartResourceService()
+ orcheMock.IScoringmgr.RemoveAll()
- //resource release
- time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("ls")
+ //release configuremgr
orcheMock.IConfiguremgr.Done <- true
+
+ //release discoverymgr
discoverymgr.ExitChan <- 1
+ time.Sleep(time.Duration(100) * time.Millisecond)
}
func PushConfPathDiscoveryDeviceMock(doc *confdescription.Doc) (err error) {