package orchestrationapi
+//$
+
import (
+ "discoverymgr"
"fmt"
"os/exec"
"testing"
func TestConfigureMgrScoringMgr(t *testing.T) {
//make orche
- orcheMock := new(Orche)
+ orcheMock := Init("")
+ //create modules
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringAddInterface
+ //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)
-
- orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = pushConfPathDiscoveryDeviceMock
+ //configuremgr interface
+ 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 = executeAppMock
+ //discoverymgr interface
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
+
+ //servicemgr interface
+ orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
- //start module function
+ //start scoringmgr
orcheMock.IScoringmgr.Listening()
+ orcheMock.IScoringmgr.IStartResourceService()
+
+ //start configuremgr
go orcheMock.IConfiguremgr.Watch("/tmp/foo")
//init scenario
time.Sleep(time.Duration(1) * time.Second)
//user scenario
- execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
+ execCommand(fmt.Sprintf("cp -arR %s %s", "./mock/mysum/", "/tmp/foo"))
time.Sleep(time.Duration(3) * time.Second)
- //resource release
- orcheMock.IScoringmgr.RemoveLib("mysum")
+ //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()
+
+ 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 = ExecuteAppMock
+
+ discoverymgr.InitDiscovery()
+
+ //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)
+
+ //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
orcheMock.IScoringmgr = scoringmgr.Init()
orcheMock.IConfiguremgr = configuremgr.Init()
- orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringAddInterface
+ 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.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
- orcheMock.IDiscoverymgr.GetEndpointDevices = getEndpointDevicesMock
+ orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
//scoringmgr init
//user scenario
execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
time.Sleep(time.Duration(3) * time.Second)
- RequestService("mysum", "ls", []string{"-al"})
+ RequestService("ls", []string{"-al"})
//resource release
time.Sleep(time.Duration(1) * time.Second)
- orcheMock.IScoringmgr.RemoveLib("mysum")
+ orcheMock.IScoringmgr.RemoveLib("ls")
orcheMock.IConfiguremgr.Done <- true
- // for {
- // }
}
//daemon92-lee, chacha
-func TestDiscoveryMgrServiceMgr(t *testing.T) {
-
+func testDiscoveryMgrServiceMgr(t *testing.T) {
+ // @TODO
}
//jaehoon.hyun, daemon92-lee, jaehoon.hyun
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) {
+ 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) {
+ 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")
+
+ //init scenario
+ execCommand("rm -rf /tmp/foo/mysum")
+ time.Sleep(time.Duration(1) * time.Second)
+
+ 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
}
//jaehoon.hyun, daemon92-lee, chacha, jaehoon.hyun
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) {
+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) {
+func PushLibPathScoringAppMock(libPath string, doc *confdescription.Doc, handlersCh chan<- interface{}) (err error) {
ILog.Println("pushLibPathScoringAppMock")
ILog.Println(libPath)
return
}
-func getEndpointDevicesMock(serviceName string) []string {
- DLog.Printf("getEndpointDevicesMock serviceName: %s\n", serviceName)
- return []string{"localhost", "localhost"}
+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) {
+func ExecuteAppMock(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error) {
ILog.Println("ExecuteApp")
ILog.Println(target)
ILog.Println(name)