@@ -3,6 +3,7 @@ package actions
33import (
44 "context"
55 "testing"
6+ "time"
67
78 "github.com/google/uuid"
89 "github.com/samber/lo"
@@ -24,6 +25,7 @@ func TestPatchNodeHandler(t *testing.T) {
2425
2526 t .Run ("patch successfully" , func (t * testing.T ) {
2627 nodeName := "node1"
28+ providerID := "provider-id-123"
2729 node := & v1.Node {
2830 ObjectMeta : metav1.ObjectMeta {
2931 Name : nodeName ,
@@ -35,6 +37,7 @@ func TestPatchNodeHandler(t *testing.T) {
3537 },
3638 },
3739 Spec : v1.NodeSpec {
40+ ProviderID : providerID ,
3841 Taints : []v1.Taint {
3942 {
4043 Key : "t1" ,
@@ -59,7 +62,8 @@ func TestPatchNodeHandler(t *testing.T) {
5962 action := & castai.ClusterAction {
6063 ID : uuid .New ().String (),
6164 ActionPatchNode : & castai.ActionPatchNode {
62- NodeName : "node1" ,
65+ NodeName : "node1" ,
66+ ProviderId : providerID ,
6367 Labels : map [string ]string {
6468 "-l1" : "" ,
6569 "l2" : "v2" ,
@@ -113,6 +117,7 @@ func TestPatchNodeHandler(t *testing.T) {
113117
114118 t .Run ("skip patch when node not found" , func (t * testing.T ) {
115119 nodeName := "node1"
120+ nodeID := "node-id-123"
116121 node := & v1.Node {
117122 ObjectMeta : metav1.ObjectMeta {
118123 Name : nodeName ,
@@ -124,11 +129,13 @@ func TestPatchNodeHandler(t *testing.T) {
124129 ID : uuid .New ().String (),
125130 ActionPatchNode : & castai.ActionPatchNode {
126131 NodeName : "already-deleted-node" ,
132+ NodeID : nodeID ,
127133 },
128134 }
129135 h := PatchNodeHandler {
130- log : log ,
131- clientset : clientset ,
136+ retryTimeout : time .Millisecond ,
137+ log : log ,
138+ clientset : clientset ,
132139 }
133140
134141 err := h .Handle (context .Background (), action )
@@ -140,9 +147,13 @@ func TestPatchNodeHandler(t *testing.T) {
140147
141148 t .Run ("cordoning node" , func (t * testing.T ) {
142149 nodeName := "node1"
150+ nodeID := "node-id-123"
143151 node := & v1.Node {
144152 ObjectMeta : metav1.ObjectMeta {
145153 Name : nodeName ,
154+ Labels : map [string ]string {
155+ castai .LabelNodeID : nodeID ,
156+ },
146157 },
147158 Spec : v1.NodeSpec {
148159 Unschedulable : false ,
@@ -159,6 +170,7 @@ func TestPatchNodeHandler(t *testing.T) {
159170 ID : uuid .New ().String (),
160171 ActionPatchNode : & castai.ActionPatchNode {
161172 NodeName : "node1" ,
173+ NodeID : nodeID ,
162174 Unschedulable : lo .ToPtr (true ),
163175 },
164176 }
0 commit comments