@@ -23,6 +23,7 @@ package reconcile
23
23
import (
24
24
"context"
25
25
"fmt"
26
+ "github.com/arangodb/kube-arangodb/pkg/deployment/resources"
26
27
"io/ioutil"
27
28
"testing"
28
29
"time"
@@ -49,7 +50,6 @@ import (
49
50
"github.com/arangodb/kube-arangodb/pkg/deployment/patch"
50
51
pod2 "github.com/arangodb/kube-arangodb/pkg/deployment/pod"
51
52
"github.com/arangodb/kube-arangodb/pkg/deployment/reconciler"
52
- "github.com/arangodb/kube-arangodb/pkg/deployment/resources"
53
53
"github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned"
54
54
"github.com/arangodb/kube-arangodb/pkg/logging"
55
55
"github.com/arangodb/kube-arangodb/pkg/util"
@@ -81,13 +81,13 @@ type testContext struct {
81
81
PVC * core.PersistentVolumeClaim
82
82
PVCErr error
83
83
RecordedEvent * k8sutil.Event
84
+ ArangoTask * api.ArangoTask
84
85
85
86
Inspector inspectorInterface.Inspector
86
87
}
87
88
88
89
func (c * testContext ) GetNextTask (ctx context.Context ) (* api.ArangoTask , error ) {
89
- //TODO implement me
90
- panic ("implement me" )
90
+ return c .ArangoTask , nil
91
91
}
92
92
93
93
func (c * testContext ) GetAgencyHealth () (agencyCache.Health , bool ) {
@@ -696,6 +696,7 @@ type testCase struct {
696
696
ExpectedError error
697
697
ExpectedPlan api.Plan
698
698
ExpectedHighPlan api.Plan
699
+ ExpectedTaskPlan api.Plan
699
700
ExpectedLog string
700
701
ExpectedEvent * k8sutil.Event
701
702
@@ -761,6 +762,17 @@ func TestCreatePlan(t *testing.T) {
761
762
addAgentsToStatus (t , & deploymentTemplate .Status , 3 )
762
763
deploymentTemplate .Spec .SetDefaults ("createPlanTest" )
763
764
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
+
764
776
testCases := []testCase {
765
777
{
766
778
Name : "Can not create plan for single deployment" ,
@@ -1175,6 +1187,18 @@ func TestCreatePlan(t *testing.T) {
1175
1187
},
1176
1188
ExpectedLog : "Creating scale-down plan" ,
1177
1189
},
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
+ },
1178
1202
}
1179
1203
1180
1204
for _ , testCase := range testCases {
@@ -1244,6 +1268,17 @@ func TestCreatePlan(t *testing.T) {
1244
1268
assert .Equal (t , v .Reason , status .Plan [i ].Reason )
1245
1269
}
1246
1270
}
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
+ }
1247
1282
})
1248
1283
}
1249
1284
}
0 commit comments