orchestrationapi : enhancement discovery fail over test 75/204475/1
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Wed, 24 Apr 2019 06:30:28 +0000 (15:30 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Wed, 24 Apr 2019 06:30:28 +0000 (15:30 +0900)
Change-Id: I42dc0899a44489ecd9273aaf44ae7d723511cd75

src/orchestrationapi/orchestration_api_test.go
src/orchestrationapi/orchstration_api.go

index 4705ec356f48fbbc6090a726d4f67f4e9ad28481..880a6734a6c771202bb5449161d1cbcf7102aa78 100755 (executable)
  * limitations under the License.
  *
  *******************************************************************************/
+
+/*
+**************** HOW TO USE ********************
+$ source workspaceProfile.sh
+$ go test -failfast -v -count=1 orchestrationapi
+************************************************
+*/
 package orchestrationapi
 
 import (
@@ -26,8 +33,10 @@ import (
 
        configuremgr "configuremgr"
        confdescription "configuremgr/description"
+       errormsg "errormsg"
 
        // mockconfiguremgr "configuremgr/mock"
+
        discoverymgr "discoverymgr"
        scoringmgr "scoringmgr"
        mockscoringmgr "scoringmgr/mock"
@@ -37,68 +46,85 @@ import (
 
 var logPrefixTest = "[orchestrationapi test]"
 
-//jaehoon.hyun , jaehoon.hyun
-func TestConfigureMgrScoringMgrAlreadyScoring2Library(t *testing.T) {
-
+func TestPreCondition(t *testing.T) {
        //init scenario
+       //TODO : Need wifi off logic.
        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)
 
-       //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.IGetScore = scoringmgr.GetScore
        orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
-       //configuremgr interface
-       orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
+
+       orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = discoverymgr.AddNewServiceName
        orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
        orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
 
-       //discoverymgr interface
-       orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
+       orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
+       orcheMock.IServicemgr.ExecuteApp = servicemgr.ExecuteApp
 
-       //servicemgr interface
-       orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
+       //discoverymgr init
+       discoverymgr.InitDiscovery()
 
-       //start scoringmgr
+       //servicemgr init
+       servicemgr.Init()
+
+       //scoringmgr init
        orcheMock.IScoringmgr.Listening()
        orcheMock.IScoringmgr.IStartResourceService()
 
-       //start configuremgr
+       //securemgr init
+       securemgr.Init("../securemgr/test/key.txt")
+
+       //configuremgr init
        go orcheMock.IConfiguremgr.Watch(listeningDir)
 
        orcheMock.Ready = true
 
        //user scenario
        execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
-       time.Sleep(time.Duration(300) * time.Millisecond)
+       time.Sleep(time.Duration(100) * time.Millisecond)
+       ret := RequestService("ls", []string{"-al"})
+
+       switch ret {
+       case -2:
+       case -3:
+               t.Fatal(errormsg.ToString(ret))
+               break
+       default:
+               log.Println(logPrefixTest, "REEEEEEEEETTTTTTTTT == ", ret)
+               break
+       }
+
+       time.Sleep(time.Duration(100) * 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)
+       //release discoverymgr
+       discoverymgr.ExitChan <- 1
+       if discoverymgr.IsNilServer() == true {
+               discoverymgr.ExitPollingOutBoundCh <- 1
+       }
 
+       time.Sleep(time.Duration(100) * time.Millisecond)
 }
 
-//jaehoon.hyun, chacha, jaehoon.hyun
-func TestConfigureMgrServiceMgrScoringMgr(t *testing.T) {
+//jaehoon.hyun, damon92-lee
+func TestConfigureMgrDiscoveryMgr(t *testing.T) {
        //init scenario
        listeningDir := "/tmp/foo"
        execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
@@ -116,18 +142,15 @@ func TestConfigureMgrServiceMgrScoringMgr(t *testing.T) {
        orcheMock.IScoringmgr.IGetScore = mockscoringmgr.GetScoreRandom100Mock
        orcheMock.IScoringmgr.Ch = make(chan interface{}, 1024)
 
-       orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
+       orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = discoverymgr.AddNewServiceName
        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()
+       orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
+       orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
 
-       // securemgr init
-       securemgr.Init("../securemgr/test/key.txt")
+       //discoverymgr init
+       discoverymgr.InitDiscovery()
 
        //scoringmgr init
        orcheMock.IScoringmgr.Listening()
@@ -140,25 +163,37 @@ func TestConfigureMgrServiceMgrScoringMgr(t *testing.T) {
 
        //user scenario
        execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
-       RequestService("ls", []string{"-al"})
+       time.Sleep(time.Duration(3) * time.Second)
+       if ret := RequestService("ls", []string{"-al"}); ret < 0 {
+               t.Fatal(errormsg.ToString(ret))
+       }
        time.Sleep(time.Duration(3) * time.Second)
 
        //release scoringmgr
        orcheMock.IScoringmgr.IStopResourceService()
        orcheMock.IScoringmgr.RemoveAll()
 
-       //release configuremgr
+       //release configure
        orcheMock.IConfiguremgr.Done <- true
 
-       time.Sleep(time.Duration(100) * time.Millisecond)
+       //release discoverymgr
+       discoverymgr.ExitChan <- 1
+       if discoverymgr.IsNilServer() == true {
+               discoverymgr.ExitPollingOutBoundCh <- 1
+       }
+
+       //waiting resource thread stop
+       time.Sleep(time.Duration(1000) * time.Millisecond)
 }
 
 //jaehoon.hyun , jaehoon.hyun
-func TestConfigureMgrScoringMgr(t *testing.T) {
+func TestConfigureMgrScoringMgrAlreadyScoring2Library(t *testing.T) {
+
        //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)
 
        //make orche
@@ -196,7 +231,7 @@ func TestConfigureMgrScoringMgr(t *testing.T) {
 
        //user scenario
        execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
-       time.Sleep(time.Duration(3) * time.Second)
+       time.Sleep(time.Duration(300) * time.Millisecond)
 
        //release scoringmgr
        orcheMock.IScoringmgr.IStopResourceService()
@@ -208,10 +243,69 @@ func TestConfigureMgrScoringMgr(t *testing.T) {
 
        //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)
+
+       orcheMock.Ready = true
+
+       //user scenario
+       execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
+       if ret := RequestService("ls", []string{"-al"}); ret < 0 {
+               t.Fatalf(errormsg.ToString(ret))
+       }
+       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 TestConfigureMgrScoringMgrMyscoring2(t *testing.T) {
+func TestConfigureMgrScoringMgr(t *testing.T) {
        //init scenario
        listeningDir := "/tmp/foo"
        execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
@@ -252,7 +346,7 @@ func TestConfigureMgrScoringMgrMyscoring2(t *testing.T) {
        orcheMock.Ready = true
 
        //user scenario
-       execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring2/", listeningDir))
+       execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
        time.Sleep(time.Duration(3) * time.Second)
 
        //release scoringmgr
@@ -265,10 +359,10 @@ func TestConfigureMgrScoringMgrMyscoring2(t *testing.T) {
 
        //waiting resource thread stop
        time.Sleep(time.Duration(100) * time.Millisecond)
-
 }
 
-func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
+//jaehoon.hyun , jaehoon.hyun
+func TestConfigureMgrScoringMgrMyscoring2(t *testing.T) {
        //init scenario
        listeningDir := "/tmp/foo"
        execCommand(fmt.Sprintf("rm -rf %s", listeningDir))
@@ -276,7 +370,7 @@ func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
        time.Sleep(time.Duration(100) * time.Millisecond)
 
        //make orche
-       orcheMock := new(Orche)
+       orcheMock := Init("")
 
        //create modules
        orcheMock.IScoringmgr = scoringmgr.Init()
@@ -288,7 +382,6 @@ func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
        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
@@ -310,7 +403,7 @@ func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
        orcheMock.Ready = true
 
        //user scenario
-       execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
+       execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring2/", listeningDir))
        time.Sleep(time.Duration(3) * time.Second)
 
        //release scoringmgr
@@ -323,42 +416,46 @@ func TestConfigureMgrScoringMgrMyScoringLib(t *testing.T) {
 
        //waiting resource thread stop
        time.Sleep(time.Duration(100) * time.Millisecond)
+
 }
 
-//jaehoon.hyun, damon92-lee
-func TestConfigureMgrDiscoveryMgr(t *testing.T) {
+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)
 
-       orcheMock := Init("")
+       //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)
 
-       orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = discoverymgr.AddNewServiceName
+       //configuremgr interface
+       orcheMock.IConfiguremgr.IDiscoveryMgr.PushConfPath = PushConfPathDiscoveryDeviceMock
        orcheMock.IConfiguremgr.IScoringMgr.PushLibPath = scoringmgr.PushLibPath
        orcheMock.IConfiguremgr.IScoringMgr.Ch = orcheMock.IScoringmgr.Ch
 
-       orcheMock.IDiscoverymgr.GetEndpointDevices = discoverymgr.GetDeviceListWithService
-       orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
+       //discoverymgr interface
+       orcheMock.IDiscoverymgr.GetEndpointDevices = GetEndpointDevicesMock
 
-       //discoverymgr init
-       discoverymgr.InitDiscovery()
+       //servicemgr interface
+       orcheMock.IServicemgr.ExecuteApp = ExecuteAppMock
 
-       //scoringmgr init
+       //start scoringmgr
        orcheMock.IScoringmgr.Listening()
        orcheMock.IScoringmgr.IStartResourceService()
 
-       //configuremgr init
+       //start configuremgr
        go orcheMock.IConfiguremgr.Watch(listeningDir)
 
        orcheMock.Ready = true
@@ -366,24 +463,17 @@ func TestConfigureMgrDiscoveryMgr(t *testing.T) {
        //user scenario
        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()
+       time.Sleep(time.Duration(100) * time.Millisecond)
 
-       //release configure
+       //release configuremgr
        orcheMock.IConfiguremgr.Done <- true
 
-       //release discoverymgr
-       discoverymgr.ExitChan <- 1
-       if discoverymgr.IsNilServer() == true {
-               discoverymgr.ExitPollingOutBoundCh <- 1
-       }
-
        //waiting resource thread stop
-       time.Sleep(time.Duration(1000) * time.Millisecond)
+       time.Sleep(time.Duration(100) * time.Millisecond)
 }
 
 //jaehoon.hyun, chacha
@@ -703,9 +793,9 @@ func TestOrchestrationInitThreadAndRequestServiceThread(t *testing.T) {
        go func() {
                ret := RequestService("ls", []string{"-al"})
                if ret != -1 {
-                       t.Fatal("is it wifi on????? plz off and retry test")
+                       t.Fatal("is it wifi on????? plz off and retry test ", ret)
                } else {
-                       log.Println(logPrefixTest, "REEEEEEEEETTTTTTTTT == -1")
+                       log.Println(logPrefixTest, "REEEEEEEEETTTTTTTTT == ", ret)
                }
                time.Sleep(time.Duration(100) * time.Millisecond)
 
@@ -731,82 +821,7 @@ func TestOrchestrationInitThreadAndRequestServiceThread(t *testing.T) {
        time.Sleep(time.Duration(100) * time.Millisecond)
 }
 
-func TestTurnOffWifiErrorAtRequestServiceApi(t *testing.T) {
-       //init scenario
-       //TODO : Need wifi off logic.
-       turnOffWifi()
-       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 = 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
-
-       //discoverymgr init
-       discoverymgr.InitDiscovery()
-
-       //servicemgr init
-       servicemgr.Init()
-
-       //scoringmgr init
-       orcheMock.IScoringmgr.Listening()
-       orcheMock.IScoringmgr.IStartResourceService()
-
-       //securemgr init
-       securemgr.Init("../securemgr/test/key.txt")
-
-       //configuremgr init
-       go orcheMock.IConfiguremgr.Watch(listeningDir)
-
-       orcheMock.Ready = true
-
-       //user scenario
-       execCommand(fmt.Sprintf("cp -ar %s %s", "./mock/myscoring/", listeningDir))
-       time.Sleep(time.Duration(100) * time.Millisecond)
-       ret := RequestService("ls", []string{"-al"})
-       if ret != -2 {
-               t.Fatal("is it wifi on????? plz off and retry test ", ret)
-       } else {
-               log.Println(logPrefixTest, "REEEEEEEEETTTTTTTTT == ", ret)
-       }
-
-       time.Sleep(time.Duration(100) * time.Millisecond)
-
-       //release scoringmgr
-       orcheMock.IScoringmgr.IStopResourceService()
-       orcheMock.IScoringmgr.RemoveAll()
-
-       //release configuremgr
-       orcheMock.IConfiguremgr.Done <- true
-
-       //release discoverymgr
-       discoverymgr.ExitChan <- 1
-       if discoverymgr.IsNilServer() == true {
-               discoverymgr.ExitPollingOutBoundCh <- 1
-       }
-
-       //turnOn wifi
-       turnOnWifi()
-
-       time.Sleep(time.Duration(100) * time.Millisecond)
-}
-
+//=============== ORCHE MOCK =======================
 func PushConfPathDiscoveryDeviceMock(doc *confdescription.Doc) (err error) {
        log.Println("[orchestrationapi] pushConfPathDiscoveryDeviceMock")
        log.Println(*doc)
@@ -832,6 +847,8 @@ func ExecuteAppMock(target string, name string, args []string, notiChan chan str
        return
 }
 
+//=============== ORCHE MOCK =======================
+
 func execCommand(command string) {
        log.Println(command)
        cmd := exec.Command("sh", "-c", command)
index 8339db769b2e9490f1e51be4fb102c964cc82837..bce14fe79a92558d844076d4de527d01ea1997be 100755 (executable)
@@ -25,6 +25,7 @@ import (
        // "os/exec"
 
        configuremgr "configuremgr"
+       errormsg "errormsg"
        scoringmgr "scoringmgr"
        // discoverymgr     "discoverymgr"
        // servicemgr       "servicemgr"
@@ -59,19 +60,10 @@ type orcheClient struct {
 }
 
 var (
-       orchClientID int32
-       orcheClients = [1024]orcheClient{}
+       orchClientID int32 = -1
+       orcheClients       = [1024]orcheClient{}
 )
 
-type OrchestrationError int
-
-const (
-       eNotReadyOrchestrationError = ((1 + iota) ^ -1) + 1
-       eTurnOffWifiOrchestrationError
-)
-
-// func (orcheError OrchestrationError) toError() int { return }
-
 func Init(settingPath string) *Orche {
 
        orcheEngine = new(Orche)
@@ -84,17 +76,22 @@ func Init(settingPath string) *Orche {
 func RequestService(appName string, args []string) (handle int) {
 
        if orcheEngine.Ready == false {
-               return eNotReadyOrchestrationError
+               log.Println("AAAAAAAAADASDADDDS")
+               return errormsg.ErrorNotReadyOrchestrationInit
        }
 
-       clientID := atomic.LoadInt32(&orchClientID)
        atomic.AddInt32(&orchClientID, 1)
 
-       serviceClient := addServiceClient(clientID, appName, args)
+       handle = int(orchClientID)
+
+       serviceClient := addServiceClient(handle, appName, args)
        go serviceClient.listenNotify()
        endpoints, err := getEndpointDevices(appName)
+       log.Println("getttttttttttttttEndpointDevicessssssssssss ", err)
+       log.Println(errormsg.ErrorTurnOffWifi)
+       log.Println(errormsg.ErrorDisconnectWifi)
        if err != nil {
-               return eTurnOffWifiOrchestrationError
+               return errormsg.ToInt(err)
        }
        deviceScores := sortByScore(gatheringDevicesScore(endpoints, appName))
 
@@ -117,7 +114,7 @@ func (client *orcheClient) listenNotify() {
        }
 }
 
-func addServiceClient(clientID int32, appName string, args []string) (client *orcheClient) {
+func addServiceClient(clientID int, appName string, args []string) (client *orcheClient) {
        orcheClients[clientID].args = args
        orcheClients[clientID].appName = appName