Implement Test with test 01/177401/2
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Wed, 29 Nov 2017 17:53:58 +0000 (18:53 +0100)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Thu, 28 Jun 2018 14:50:17 +0000 (16:50 +0200)
Change-Id: Ic44cd543be463ef3434a23de679547c5e52e6fe9
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
manager/dryad_job_runner.go
manager/dryad_job_runner_test.go

index d2889ae..e21e033 100644 (file)
@@ -99,7 +99,21 @@ func (d *dryadJobRunner) Boot() (err error) {
 
 // Test is part of DryadJobRunner interface.
 func (d *dryadJobRunner) Test() error {
-       // TODO(amistewicz): implement.
-       _, _, err := d.rusalka.Exec("echo", "healthcheck")
-       return err
+       for _, testcase := range d.conf.Action.Test.TestCases {
+               for _, testaction := range testcase.TestActions {
+                       switch action := testaction.(type) {
+                       case weles.Push:
+                               d.device.CopyFilesTo([]string{action.Path}, action.Dest)
+                       case weles.Run:
+                               // Exec joins arguments in a single string.
+                               // Split and then Join are avoided.
+                               d.device.Exec(action.Name)
+                       case weles.Pull:
+                               d.device.CopyFilesFrom([]string{action.Src}, action.Path)
+                       default:
+                               panic("unknown test action type")
+                       }
+               }
+       }
+       return nil
 }
index 1681ed7..b0d0bb2 100644 (file)
@@ -68,5 +68,16 @@ var _ = Describe("DryadJobRunner", func() {
                )
 
                Expect(djr.Boot()).To(Succeed())
+
+               By("Test")
+               gomock.InOrder(
+                       mockDevice.EXPECT().CopyFilesTo([]string{basicConfig.Action.Test.TestCases[0].TestActions[0].(weles.Push).Path},
+                               basicConfig.Action.Test.TestCases[0].TestActions[0].(weles.Push).Dest),
+                       mockDevice.EXPECT().Exec("command to be run"),
+                       mockDevice.EXPECT().CopyFilesFrom([]string{basicConfig.Action.Test.TestCases[0].TestActions[2].(weles.Pull).Src},
+                               basicConfig.Action.Test.TestCases[0].TestActions[2].(weles.Pull).Path),
+               )
+
+               Expect(djr.Test()).To(Succeed())
        })
 })