(t *testing.T)
| 506 | } |
| 507 | |
| 508 | func TestTaintOutOfService(t *testing.T) { |
| 509 | client := fake.NewSimpleClientset() |
| 510 | _, err := client.CoreV1().Nodes().Create( |
| 511 | context.Background(), |
| 512 | &v1.Node{ |
| 513 | ObjectMeta: metav1.ObjectMeta{Name: nodeName}, |
| 514 | }, |
| 515 | metav1.CreateOptions{}) |
| 516 | h.Ok(t, err) |
| 517 | |
| 518 | tNode, err := newNode(config.Config{EnableOutOfServiceTaint: true}, client) |
| 519 | h.Ok(t, err) |
| 520 | h.Equals(t, true, tNode.GetNthConfig().EnableOutOfServiceTaint) |
| 521 | h.Equals(t, false, tNode.GetNthConfig().CordonOnly) |
| 522 | |
| 523 | err = tNode.TaintOutOfService(nodeName) |
| 524 | h.Ok(t, err) |
| 525 | |
| 526 | updatedNode, err := client.CoreV1().Nodes().Get(context.Background(), nodeName, metav1.GetOptions{}) |
| 527 | h.Ok(t, err) |
| 528 | taintFound := false |
| 529 | expectedTaint := v1.Taint{ |
| 530 | Key: outOfServiceTaintKey, |
| 531 | Value: outOfServiceTaintValue, |
| 532 | Effect: v1.TaintEffectNoExecute, |
| 533 | } |
| 534 | for _, taint := range updatedNode.Spec.Taints { |
| 535 | if taint.Key == expectedTaint.Key && |
| 536 | taint.Value == expectedTaint.Value && |
| 537 | taint.Effect == expectedTaint.Effect { |
| 538 | taintFound = true |
| 539 | break |
| 540 | } |
| 541 | } |
| 542 | h.Equals(t, true, taintFound) |
| 543 | } |
nothing calls this directly
no test coverage detected