Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
pod-status - Add comments to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
cscetbon committed Nov 21, 2019
1 parent 7bc47f6 commit 46ceaf8
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions pkg/controller/cassandracluster/pod_operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func TestPodsSlice(t *testing.T) {
dcRackName := "dc1-rack1"
podLastOperation := &status.CassandraRackStatus[dcRackName].PodLastOperation
podLastOperation.Name = operationName

// Conditions to return checkOnly set to true with an empty podsSlice
podLastOperation.Status = api.StatusOngoing
podLastOperation.OperatorName = oldOperatorName

Expand All @@ -44,19 +46,15 @@ func TestPodsSlice(t *testing.T) {
assert.Equal(len(podsSlice), 0)
assert.Equal(checkOnly, true)

// Missing condition sets checkOnly to false
podLastOperation.Status = api.StatusDone

podsSlice, checkOnly = rcc.podsSlice(cc, status, *podLastOperation, dcRackName, operationName, operatorName)

assert.Equal(len(podsSlice), 0)
assert.Equal(checkOnly, false)

podLastOperation.Status = api.StatusOngoing
podLastOperation.OperatorName = operatorName
assert.Equal(len(podsSlice), 0)
assert.Equal(checkOnly, false)

//Create the Pods wanted by the statefulset dc2-rack1 (1 node)
//Create a pod to have something to put in podsSlice
pod := &v1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
Expand All @@ -65,26 +63,18 @@ func TestPodsSlice(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "cassandra-demo-dc1-rack1-0",
Namespace: "ns",
Labels: map[string]string{
"app": "cassandracluster",
"cassandracluster": "cassandra-demo",
"cassandraclusters.db.orange.com.dc": "dc1",
"cassandraclusters.db.orange.com.rack": "rack1",
"cluster": "k8s.pic",
"dc-rack": "dc1-rack1",
},
Labels: map[string]string{"app": "cassandracluster"},
},
}
pod.Status.Phase = v1.PodRunning
rcc.CreatePod(pod)

podLastOperation.Status = api.StatusOngoing
podLastOperation.Pods = []string{"cassandra-demo-dc1-rack1-0"}
// Set the operator name to a different value than the current operator name
podLastOperation.OperatorName = oldOperatorName

podsSlice, checkOnly = rcc.podsSlice(cc, status, *podLastOperation, dcRackName, operationName, operatorName)

assert.Equal(podsSlice, []v1.Pod{*pod})
assert.Equal(len(podsSlice), 1)
assert.Equal(checkOnly, true)

}

0 comments on commit 46ceaf8

Please sign in to comment.