orchestration_api changed EDGE-299
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 2 Apr 2019 10:12:01 +0000 (19:12 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 2 Apr 2019 10:12:01 +0000 (19:12 +0900)
src/orchestrationapi/orchestration_api_test.go

index 2b8cbba..ce81fa2 100644 (file)
@@ -16,7 +16,7 @@ import (
   mockscoringmgr   "scoringmgr/mock"
   
   // discoverymgr     "discoverymgr"
-  // servicemgr       "servicemgr"
+  servicemgr       "servicemgr"
 
 )
 
@@ -52,11 +52,10 @@ func TestConfigureMgrScoringMgr(t *testing.T){
 
   //user scenario
   execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/mysum/", "/tmp/foo"))
-  time.Sleep(time.Duration(5) * time.Second)
-
-
-  orcheMock.IScoringmgr.RemoveLib("/tmp/foo/mysum/libmysum.so")
+  time.Sleep(time.Duration(3) * time.Second)
 
+  //resource release
+  orcheMock.IScoringmgr.RemoveLib("mysum")
   orcheMock.IConfiguremgr.Done <- true
 
 }
@@ -69,36 +68,49 @@ func TestConfigureMgrDiscoveryMgr(t *testing.T) {
 //jaehoon.hyun, chacha
 func TestRequestServiceFunctionServiceMgr(t *testing.T){
 
-  //make orche
-  // orcheMock := new(Orche)
+  orcheMock := Init("")
 
-  // orcheMock.IScoringmgr    = scoringmgr.Init()
-  // orcheMock.IConfiguremgr  = configuremgr.Init()
+  orcheMock.IScoringmgr    = scoringmgr.Init()
+  orcheMock.IConfiguremgr  = configuremgr.Init()
 
-  // orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringAddInterface
-  // orcheMock.IScoringmgr.IGetScore     = mockscoringmgr.GetScoreRandom100Mock
-  // orcheMock.IScoringmgr.Ch            = make(chan interface{}, 1024)
+  orcheMock.IScoringmgr.IRunningScore = mockscoringmgr.LoadScoringAddInterface
+  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.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
+  orcheMock.IDiscoverymgr.GetEndpointDevices = getEndpointDevicesMock
+  orcheMock.IServicemgr.ExecuteApp           = servicemgr.ExecuteApp
 
 
-  // //scoringmgr init
-  // orcheMock.IScoringmgr.Listening()
+  //scoringmgr init
+  orcheMock.IScoringmgr.Listening()
 
-  // //configuremgr init
-  // go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+  //configuremgr init
+  go orcheMock.IConfiguremgr.Watch("/tmp/foo")
+
+  //servicemgr init
+  servicemgr.InitServiceMap()
+
+  
+  //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("mysum", "ls", []string{"-al"})
 
-  // //servicemgr init
-  // servicemgr.InitServiceMap()
 
-  // //user scenario
-  // RequestService("mysum", "ls", []string{"-al"})
+  //resource release
+  time.Sleep(time.Duration(1) * time.Second)
+  orcheMock.IScoringmgr.RemoveLib("mysum")
+  orcheMock.IConfiguremgr.Done <- true
 
+  for {}
 }
 
 //daemon92-lee, chacha
@@ -143,6 +155,7 @@ func pushLibPathScoringAppMock(libPath string, doc *confdescription.Doc, handler
 }
 
 func getEndpointDevicesMock(serviceName string) []string {
+  DLog.Printf("getEndpointDevicesMock serviceName: %s\n", serviceName)
   return []string{"localhost", "localhost"}
 }