@@ -23,6 +23,7 @@ package reconcile
2323import (
2424 "context"
2525 "fmt"
26+ "github.com/arangodb/kube-arangodb/pkg/deployment/resources"
2627 "io/ioutil"
2728 "testing"
2829 "time"
@@ -49,7 +50,6 @@ import (
4950 "github.com/arangodb/kube-arangodb/pkg/deployment/patch"
5051 pod2 "github.com/arangodb/kube-arangodb/pkg/deployment/pod"
5152 "github.com/arangodb/kube-arangodb/pkg/deployment/reconciler"
52- "github.com/arangodb/kube-arangodb/pkg/deployment/resources"
5353 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned"
5454 "github.com/arangodb/kube-arangodb/pkg/logging"
5555 "github.com/arangodb/kube-arangodb/pkg/util"
@@ -81,13 +81,13 @@ type testContext struct {
8181 PVC * core.PersistentVolumeClaim
8282 PVCErr error
8383 RecordedEvent * k8sutil.Event
84+ ArangoTask * api.ArangoTask
8485
8586 Inspector inspectorInterface.Inspector
8687}
8788
8889func (c * testContext ) GetNextTask (ctx context.Context ) (* api.ArangoTask , error ) {
89- //TODO implement me
90- panic ("implement me" )
90+ return c .ArangoTask , nil
9191}
9292
9393func (c * testContext ) GetAgencyHealth () (agencyCache.Health , bool ) {
@@ -696,6 +696,7 @@ type testCase struct {
696696 ExpectedError error
697697 ExpectedPlan api.Plan
698698 ExpectedHighPlan api.Plan
699+ ExpectedTaskPlan api.Plan
699700 ExpectedLog string
700701 ExpectedEvent * k8sutil.Event
701702
@@ -761,6 +762,17 @@ func TestCreatePlan(t *testing.T) {
761762 addAgentsToStatus (t , & deploymentTemplate .Status , 3 )
762763 deploymentTemplate .Spec .SetDefaults ("createPlanTest" )
763764
765+ arangoTaskTemplate := & api.ArangoTask {
766+ ObjectMeta : meta.ObjectMeta {
767+ Name : "test_task" ,
768+ Namespace : tests .FakeNamespace ,
769+ },
770+ Spec : api.ArangoTaskSpec {
771+ Type : api .ArangoTaskPingType ,
772+ DeploymentName : "test_depl" ,
773+ },
774+ }
775+
764776 testCases := []testCase {
765777 {
766778 Name : "Can not create plan for single deployment" ,
@@ -1175,6 +1187,18 @@ func TestCreatePlan(t *testing.T) {
11751187 },
11761188 ExpectedLog : "Creating scale-down plan" ,
11771189 },
1190+ {
1191+ Name : "ArangoTask - ping type" ,
1192+ context : & testContext {
1193+ ArangoDeployment : deploymentTemplate .DeepCopy (),
1194+ ArangoTask : arangoTaskTemplate ,
1195+ },
1196+
1197+ ExpectedTaskPlan : []api.Action {
1198+ actions .NewClusterAction (api .ActionTypePing , "Pinging database server" ),
1199+ },
1200+ ExpectedLog : "Pinging database server" ,
1201+ },
11781202 }
11791203
11801204 for _ , testCase := range testCases {
@@ -1244,6 +1268,17 @@ func TestCreatePlan(t *testing.T) {
12441268 assert .Equal (t , v .Reason , status .Plan [i ].Reason )
12451269 }
12461270 }
1271+
1272+ if len (testCase .ExpectedTaskPlan ) > 0 {
1273+ require .Len (t , status .TaskPlan , len (testCase .ExpectedTaskPlan ))
1274+ for i , v := range testCase .ExpectedTaskPlan {
1275+ assert .Equal (t , v .Type , status .TaskPlan [i ].Type )
1276+ assert .Equal (t , v .Group , status .TaskPlan [i ].Group )
1277+ if v .Reason != "*" {
1278+ assert .Equal (t , v .Reason , status .TaskPlan [i ].Reason )
1279+ }
1280+ }
1281+ }
12471282 })
12481283 }
12491284}
0 commit comments