package orchestrationapi
+//$
import (
- "testing"
- "time"
- "os/exec"
- "fmt"
+ "discoverymgr"
+ "fmt"
+ "os/exec"
+ "testing"
+ "time"
- configuremgr "configuremgr"
- mockconfiguremgr "configuremgr/mock"
+ configuremgr "configuremgr"
+ confdescription "configuremgr/description"
- scoringmgr "scoringmgr"
- mockscoringmgr "scoringmgr/mock"
+ // mockconfiguremgr "configuremgr/mock"
- discoverymgr "discoverymgr"
- servicemgr "servicemgr"
+ scoringmgr "scoringmgr"
+ mockscoringmgr "scoringmgr/mock"
- mockorchestrationapi "orchestrationapi/mock"
+ // discoverymgr "discoverymgr"
+ servicemgr "servicemgr"
)
//jaehoon.hyun , jaehoon.hyun
-func TestConfigureMgrScoringMgr(t *testing.T){
+func TestConfigureMgrScoringMgr(t *testing.T) {
- //copy event environment
- watchDir := "/tmp/foo"
- src := "../configuremgr/mock/mysum"
- dst := watchDir
+ //make orche
+ orcheMock := Init("")
- //mock function linking
- scoringHandlers := scoringmgr.Init()
- scoringHandlers.IloadScoringLibrary = mockscoringmgr.LoadScoringAdd
- scoringHandlers.Ch = make(chan interface{}, 1024)
+ //create modules
+ orcheMock.IScoringmgr = scoringmgr.Init()
+ orcheMock.IConfiguremgr = configuremgr.Init()
- configuremgrObj := configuremgr.Init()
- configuremgrObj.IDiscoveryMgr.PushConfPath = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
- configuremgrObj.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
- configuremgrObj.IScoringMgr.Ch = scoringHandlers.Ch
+ //scoringmgr interface
+ orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
+ orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
+ orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ 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
- scoringHandlers.Listening()
- go configuremgrObj.Watch(watchDir)
+ //discoverymgr interface
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
- time.Sleep(time.Duration(1) * time.Second)
+ //servicemgr interface
+ orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
- //user scenario
- command := fmt.Sprintf("cp -ar %s %s", src, dst)
- configuremgr.DLog.Println(command)
- cmd := exec.Command("sh", "-c", command)
- stdoutStderr, err := cmd.CombinedOutput()
- configuremgr.DLog.Printf("%s", stdoutStderr)
- if err != nil {
- configuremgr.ELog.Fatal(err)
- }
+ //start scoringmgr
+ orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
+ //start configuremgr
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
- time.Sleep(time.Duration(5) * time.Second)
+ //init scenario
+ execCommand("rm -rf /tmp/foo/mysum")
+ time.Sleep(time.Duration(1) * time.Second)
- configuremgrObj.Done <- true
+ //user scenario
+ execCommand(fmt.Sprintf("cp -arR %s %s", "./mock/mysum/", "/tmp/foo"))
+ time.Sleep(time.Duration(3) * time.Second)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveLib("ls")
+
+ //release configuremgr
+ orcheMock.IConfiguremgr.Done <- true
}
+func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
+
+ //make orche
+ orcheMock := new(Orche)
+
+ //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("/tmp/foo")
+
+ //init scenario
+ execCommand("rm -rf /tmp/foo/myscoring")
+ time.Sleep(time.Duration(1) * time.Second)
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -arR %s %s", "./mock/myscoring/", "/tmp/foo"))
+ time.Sleep(time.Duration(3) * time.Second)
+
+ //release scoringmgr
+ orcheMock.IScoringmgr.IStopResourceService()
+ orcheMock.IScoringmgr.RemoveLib("ls")
+
+ //release configuremgr
+ orcheMock.IConfiguremgr.Done <- true
+}
+
//jaehoon.hyun, damon92-lee
func TestConfigureMgrDiscoveryMgr(t *testing.T) {
+ orcheMock := Init("")
+
+ orcheMock.IScoringmgr = scoringmgr.Init()
+ orcheMock.IConfiguremgr = configuremgr.Init()
- orcheEngine := new(orchestrationapi.Iorche)
+ orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringInterfaceAdd
+ orcheMock.IScoringmgr.IStartResourceService = mockscoringmgr.StartResourceServiceAdd
+ orcheMock.IScoringmgr.IStopResourceService = mockscoringmgr.StopResourceServiceAdd
+ orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
+ orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
- orcheEngine.IScoringmgr = scoringmgr.Init()
- orcheEngine.IConfiguremgr = configuremgr.Init()
+ orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = discoverymgr.AddNewServiceName
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
- orcheEngine.IScoringmgr.IloadScoringLibrary = mockscoringmgr.LoadScoringAdd
- orcheEngine.IScoringmgr.GetScore = mockscoringmgr.GetScore
- orcheEngine.IScoringmgr.Ch = make(chan interface{}, 1024)
+ orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
+ orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
- orcheEngine.IConfiguremgr.IDiscoveryMgr.PushConfPath = mockorchestrationapi.PushConfPathDiscoveryDeviceMock
- orcheEngine.IConfiguremgr.IAppExecuteMgr.PushConfPath = mockorchestrationapi.PushConfPathAppExecuteMock
- orcheEngine.IConfiguremgr.IScoringMgr.PushLibPath = mockorchestrationapi.PushLibPath
- orcheEngine.IConfiguremgr.IScoringMgr.Ch = IScoringmgr.Ch
+ discoverymgr.InitDiscovery()
- orcheEngine.IDiscoverymgr.GetEndpointDevices = mockorchestrationapi.GetEndpointDevices
- orcheEngine.IServicemgr.InitServiceMgr = mockorchestrationapi.InitServiceMgr
- orcheEngine.IServicemgr.ExecuteApp = mockorchestrationapi.ExecuteApp
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
- orcheEngine.IScoringmgr.Listening()
- go orcheEngine.IConfiguremgr.Watch(watchDir)
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+ //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"))
+ time.Sleep(time.Duration(3) * time.Second)
+ RequestService("ls", []string{"-al"})
+
+ //resource release
+ time.Sleep(time.Duration(1) * time.Second)
+ orcheMock.IScoringmgr.RemoveLib("ls")
+ orcheMock.IConfiguremgr.Done <- true
+ discoverymgr.ExitChan <- 1
}
//jaehoon.hyun, chacha
-func TestScoringMgrServiceMgr(t *testing.T){
+func TestRequestServiceFunctionServiceMgr(t *testing.T) {
- //I can do that , anyone have a idea, implement please or ask for jaehoon
-}
+ orcheMock := Init("")
-//daemon92-lee, chacha
-func TestDiscoveryMgrServiceMgr(t *testing.T){
+ 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 = 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
+
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
+
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+
+ //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"))
+ time.Sleep(time.Duration(3) * time.Second)
+ RequestService("ls", []string{"-al"})
+
+ //resource release
+ time.Sleep(time.Duration(1) * time.Second)
+ orcheMock.IScoringmgr.RemoveLib("ls")
+ orcheMock.IConfiguremgr.Done <- true
+
+}
+
+//daemon92-lee, chacha
+func testDiscoveryMgrServiceMgr(t *testing.T) {
+ // @TODO
}
//jaehoon.hyun, daemon92-lee, jaehoon.hyun
-func TestConfigureMgrDiscoveryMgrScoringMgr(t *testing.T){
+func TestConfigureMgrDiscoveryMgrScoringMgr(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 = discoverymgr.AddNewServiceName
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
+ orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
+ orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
+
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
+
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+
+ //init scenario
+ execCommand("rm -rf /tmp/foo/mysum")
+ time.Sleep(time.Duration(1) * time.Second)
+
+ discoverymgr.InitDiscovery()
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "../scoringmgr/mock/mysum/", "/tmp/foo"))
+ time.Sleep(time.Duration(3) * time.Second)
+ RequestService("ls", []string{"-al"})
+
+ //resource release
+ time.Sleep(time.Duration(1) * time.Second)
+ orcheMock.IScoringmgr.RemoveLib("ls")
+ orcheMock.IConfiguremgr.Done <- true
+ discoverymgr.ExitChan <- 1
}
//jaehoon.hyun, daemon92-lee, chacha
-func TestConfigureMgrDiscoveryMgrServiceMgr(t *testing.T){
+func TestConfigureMgrDiscoveryMgrServiceMgr(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 = mockscoringmgr.GetScoreRandom100Mock
+ orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
+
+ orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = discoverymgr.AddNewServiceName
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
+ orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
+ orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
+
+ discoverymgr.InitDiscovery()
+ servicemgr.Init()
+
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
+
+ //init scenario
+ execCommand("rm -rf /tmp/foo/mysum")
+ time.Sleep(time.Duration(1) * time.Second)
+
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ time.Sleep(time.Duration(3) * time.Second)
+ RequestService("ls", []string{"-al"})
+
+ //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){
+func TestConfigureMgrServiceMgrScoringMgr(t *testing.T) {
+ orcheMock := Init("")
+ orcheMock.IScoringmgr = scoringmgr.Init()
+ orcheMock.IConfiguremgr = configuremgr.Init()
- //mock function linking
- scoringHandlers := scoringmgr.Init()
- scoringHandlers.IloadScoringLibrary = mockscoringmgr.LoadScoringAdd
- scoringHandlers.Ch = make(chan interface{}, 1024)
+ 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)
- configuremgrObj := configuremgr.Init()
- configuremgrObj.IDiscoveryMgr.PushConfPath = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
- configuremgrObj.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
- configuremgrObj.IScoringMgr.Ch = scoringHandlers.Ch
+ orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
- scoringHandlers.Listening()
- go configuremgrObj.Watch(watchDir)
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
+ orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
- time.Sleep(time.Duration(1) * time.Second)
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
- //user scenario
- targetLocalAddr := "localhost"
- serviceName := "ls"
- args := []string{"-al"}
- notiChan := make(chan string)
- servicemgr.ExecuteApp(targetLocalAddr, serviceName, args, notiChan)
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
- <- notiChan
+ //init scenario
+ execCommand("rm -rf /tmp/foo/mysum")
+ time.Sleep(time.Duration(1) * time.Second)
+ servicemgr.Init()
- time.Sleep(time.Duration(5) * time.Second)
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ time.Sleep(time.Duration(3) * time.Second)
+ RequestService("ls", []string{"-al"})
- configuremgrObj.Done <- true
+ //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){
+func TestConfigureMgrDiscoveryMgrScoringMgrServiceMgr(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 = discoverymgr.AddNewServiceName
+ orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
+ orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
+
+ orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
+ orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
+
+ //scoringmgr init
+ orcheMock.IScoringmgr.Listening()
+
+ //configuremgr init
+ go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+
+ //init scenario
+ execCommand("rm -rf /tmp/foo/mysum")
+ time.Sleep(time.Duration(1) * time.Second)
+
+ discoverymgr.InitDiscovery()
+ servicemgr.Init()
+
+ //user scenario
+ execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ time.Sleep(time.Duration(3) * time.Second)
+ RequestService("ls", []string{"-al"})
+
+ //resource release
+ time.Sleep(time.Duration(1) * time.Second)
+ orcheMock.IScoringmgr.RemoveLib("ls")
+ orcheMock.IConfiguremgr.Done <- true
+ discoverymgr.ExitChan <- 1
+
+}
+
+func PushConfPathDiscoveryDeviceMock(doc *confdescription.Doc) (err error) {
+ ILog.Println("pushConfPathDiscoveryDeviceMock")
+ ILog.Println(*doc)
+ return
+}
+
+func PushLibPathScoringAppMock(libPath string, doc *confdescription.Doc, handlersCh chan<- interface{}) (err error) {
+ ILog.Println("pushLibPathScoringAppMock")
+ ILog.Println(libPath)
+ return
+}
+
+func GetEndpointDevicesMock(serviceName string) ([]string, error) {
+ DLog.Printf("GetEndpointDevicesMock serviceName: %s\n", serviceName)
+ return []string{"localhost"}, nil
+}
+
+func ExecuteAppMock(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error) {
+ ILog.Println("ExecuteApp")
+ ILog.Println(target)
+ ILog.Println(name)
+ ILog.Println(args)
+ return
+}
+func execCommand(command string) {
+ configuremgr.DLog.Println(command)
+ cmd := exec.Command("sh", "-c", command)
+ stdoutStderr, err := cmd.CombinedOutput()
+ configuremgr.DLog.Printf("%s", stdoutStderr)
+ if err != nil {
+ configuremgr.ELog.Fatal(err)
+ }
}