orchestration compile error fix
[platform/core/system/edge-orchestration.git] / src / orchestrationapi / orchestration_api_test.go
1 package orchestrationapi
2
3
4 import (
5   "testing"
6   "time"
7   "os/exec"
8   "fmt"
9
10   configuremgr     "configuremgr"
11   mockconfiguremgr "configuremgr/mock"
12
13   scoringmgr       "scoringmgr"
14   mockscoringmgr   "scoringmgr/mock"
15
16   // discoverymgr     "discoverymgr"
17   // servicemgr       "servicemgr"
18
19   mockorchestrationapi "orchestrationapi/mock"
20 )
21
22 //jaehoon.hyun , jaehoon.hyun
23 func TestConfigureMgrScoringMgr(t *testing.T){
24
25   //copy event environment
26   watchDir := "/tmp/foo"
27   src := "../configuremgr/mock/mysum"
28   dst := watchDir
29
30   //mock function linking
31   scoringHandlers := scoringmgr.Init()
32   scoringHandlers.IloadScoringLibrary = mockscoringmgr.LoadScoringAdd
33   scoringHandlers.Ch                  = make(chan interface{}, 1024)
34
35   configuremgrObj  := configuremgr.Init()
36   configuremgrObj.IDiscoveryMgr.PushConfPath  = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
37   configuremgrObj.IScoringMgr.PushLibPath     = scoringmgr.PushLibPath
38   configuremgrObj.IScoringMgr.Ch              = scoringHandlers.Ch
39
40   scoringHandlers.Listening()
41   go configuremgrObj.Watch(watchDir)
42
43   time.Sleep(time.Duration(1) * time.Second)
44
45   //user scenario
46   command := fmt.Sprintf("cp -ar %s %s", src, dst)
47   configuremgr.DLog.Println(command)
48   cmd := exec.Command("sh", "-c", command)
49   stdoutStderr, err := cmd.CombinedOutput()
50   configuremgr.DLog.Printf("%s", stdoutStderr)
51   if err != nil {
52     configuremgr.ELog.Fatal(err)
53   }
54
55
56   time.Sleep(time.Duration(5) * time.Second)
57
58   configuremgrObj.Done <- true
59
60 }
61
62 //jaehoon.hyun, damon92-lee
63 func TestConfigureMgrDiscoveryMgr(t *testing.T) {
64
65   orcheEngine = new(Iorche)
66
67   orcheEngine.IScoringmgr    = scoringmgr.Init()
68   orcheEngine.IConfiguremgr    = configuremgr.Init()
69
70   orcheEngine.IScoringmgr.IloadScoringLibrary = mockscoringmgr.LoadScoringAdd
71   orcheEngine.IScoringmgr.GetScore            = mockorchestrationapi.GetScore
72   orcheEngine.IScoringmgr.Ch                  = make(chan interface{}, 1024)
73
74   orcheEngine.IConfiguremgr.IDiscoveryMgr.PushConfPath  = mockorchestrationapi.PushConfPathDiscoveryDeviceMock
75   orcheEngine.IConfiguremgr.IScoringMgr.PushLibPath     = mockorchestrationapi.PushLibPathScoringAppMock
76   orcheEngine.IConfiguremgr.IScoringMgr.Ch              = orcheEngine.IScoringmgr.Ch
77
78   orcheEngine.IDiscoverymgr.GetEndpointDevices = mockorchestrationapi.GetEndpointDevices
79   orcheEngine.IServicemgr.InitServiceMgr       = mockorchestrationapi.InitServiceMgr
80   orcheEngine.IServicemgr.ExecuteApp           = mockorchestrationapi.ExecuteApp
81
82   orcheEngine.IScoringmgr.Listening()
83
84   //TODO :  get watch path of attribute in settingpath
85   go orcheEngine.IConfiguremgr.Watch("/tmp/foo")
86
87
88 }
89
90 //jaehoon.hyun, chacha
91 func TestScoringMgrServiceMgr(t *testing.T){
92
93   //I can do that , anyone have a idea, implement please or ask for jaehoon
94 }
95
96 //daemon92-lee, chacha
97 func TestDiscoveryMgrServiceMgr(t *testing.T){
98
99
100 }
101
102 //jaehoon.hyun, daemon92-lee, jaehoon.hyun
103 func TestConfigureMgrDiscoveryMgrScoringMgr(t *testing.T){
104
105 }
106
107 //jaehoon.hyun, daemon92-lee, chacha
108 func TestConfigureMgrDiscoveryMgrServiceMgr(t *testing.T){
109
110
111 }
112
113 //jaehoon.hyun, chacha, jaehoon.hyun
114 func TestConfigureMgrServiceMgrScoringMgr(t *testing.T){
115
116 }
117
118 //jaehoon.hyun, daemon92-lee, chacha, jaehoon.hyun
119 func TestConfigureMgrDiscoveryMgrScoringMgrServiceMgr(t *testing.T){
120
121
122 }