Skip to content

Commit

Permalink
Merge pull request #382 from gujingit/feature/update-route-controller…
Browse files Browse the repository at this point in the history
…-test

test: update route controller tests
  • Loading branch information
k8s-ci-robot authored Oct 11, 2023
2 parents 814b1aa + 94c33ae commit 89a4262
Showing 1 changed file with 19 additions and 33 deletions.
52 changes: 19 additions & 33 deletions pkg/controller/route/route_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,30 @@ var (

func TestUpdateNetworkingCondition(t *testing.T) {
r := getReconcileRoute()
node := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: NodeName,
},
Spec: v1.NodeSpec{
PodCIDR: "10.96.0.64/26",
ProviderID: "cn-hangzhou.ecs-id",
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{
Type: v1.NodeReady,
Reason: string(v1.NodeReady),
Status: v1.ConditionTrue,
},
{
Type: v1.NodeNetworkUnavailable,
Reason: string(v1.NodeNetworkUnavailable),
Status: v1.ConditionTrue,
},
},
},
}

err := r.updateNetworkingCondition(context.TODO(), node, true)
if err != nil {
t.Error(err)
}
nodes := &v1.NodeList{}

updatedNode := &v1.Node{}
err = r.client.Get(context.TODO(), util.NamespacedName(node), updatedNode)
err := r.client.List(context.TODO(), nodes)
if err != nil {
t.Error(err)
panic(err)
}
for _, node := range nodes.Items {

err := r.updateNetworkingCondition(context.TODO(), &node, true)
if err != nil {
t.Error(err)
}

updatedNode := &v1.Node{}
err = r.client.Get(context.TODO(), util.NamespacedName(&node), updatedNode)
if err != nil {
t.Error(err)
}

networkCondition, ok := helper.FindCondition(updatedNode.Status.Conditions, v1.NodeNetworkUnavailable)
if !ok || networkCondition.Status != v1.ConditionFalse {
t.Error("node condition update failed")
networkCondition, ok := helper.FindCondition(updatedNode.Status.Conditions, v1.NodeNetworkUnavailable)
if !ok || networkCondition.Status != v1.ConditionFalse {
t.Error("node condition update failed")
}
}

}
Expand Down

0 comments on commit 89a4262

Please sign in to comment.