MCPcopy Index your code
hub / github.com/aws/aws-node-termination-handler / TestTaintOutOfService

Function TestTaintOutOfService

pkg/node/node_test.go:508–543  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

506}
507
508func 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}

Callers

nothing calls this directly

Calls 3

newNodeFunction · 0.85
GetNthConfigMethod · 0.80
TaintOutOfServiceMethod · 0.80

Tested by

no test coverage detected