@@ -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" ,
@@ -1173,6 +1185,18 @@ func TestCreatePlan(t *testing.T) {
1173
1185
},
1174
1186
ExpectedLog : "Creating scale-down plan" ,
1175
1187
},
1188
+ {
1189
+ Name : "ArangoTask - ping type" ,
1190
+ context : & testContext {
1191
+ ArangoDeployment : deploymentTemplate .DeepCopy (),
1192
+ ArangoTask : arangoTaskTemplate ,
1193
+ },
1194
+
1195
+ ExpectedTaskPlan : []api.Action {
1196
+ actions .NewClusterAction (api .ActionTypePing , "Pinging database server" ),
1197
+ },
1198
+ ExpectedLog : "Pinging database server" ,
1199
+ },
1176
1200
}
1177
1201
1178
1202
for _ , testCase := range testCases {
@@ -1242,6 +1266,17 @@ func TestCreatePlan(t *testing.T) {
1242
1266
assert .Equal (t , v .Reason , status .Plan [i ].Reason )
1243
1267
}
1244
1268
}
1269
+
1270
+ if len (testCase .ExpectedTaskPlan ) > 0 {
1271
+ require .Len (t , status .TaskPlan , len (testCase .ExpectedTaskPlan ))
1272
+ for i , v := range testCase .ExpectedTaskPlan {
1273
+ assert .Equal (t , v .Type , status .TaskPlan [i ].Type )
1274
+ assert .Equal (t , v .Group , status .TaskPlan [i ].Group )
1275
+ if v .Reason != "*" {
1276
+ assert .Equal (t , v .Reason , status .TaskPlan [i ].Reason )
1277
+ }
1278
+ }
1279
+ }
1245
1280
})
1246
1281
}
1247
1282
}
0 commit comments