Skip to content

Commit

Permalink
fix default nodeMode change nodeMode (#606)
Browse files Browse the repository at this point in the history
* fix default nodeMode change nodeMode
  • Loading branch information
miaow999 authored Oct 12, 2023
1 parent 4ab8269 commit 38863c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (api *API) UpdateNode(c *common.Context) (interface{}, error) {
common.LabelNodeName: node.Name,
common.LabelAccelerator: node.Accelerator,
common.LabelCluster: strconv.FormatBool(node.Cluster),
common.LabelNodeMode: node.NodeMode,
common.LabelNodeMode: oldNode.NodeMode,
})
node.Version = oldNode.Version
node.Attributes = oldNode.Attributes
Expand Down
23 changes: 17 additions & 6 deletions api/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ func TestUpdateNodeAddSysApp(t *testing.T) {
specV1.KeyAccelerator: "",
UserID: "",
},
NodeMode: context.RunModeKube,
}

sNode.EXPECT().Get(nil, gomock.Any(), gomock.Any()).Return(mNode, nil).Times(1)
Expand All @@ -817,7 +818,8 @@ func TestUpdateNodeAddSysApp(t *testing.T) {
specV1.KeyAccelerator: "",
specV1.KeyOptionalSysApps: interface{}([]interface{}{"a"}),
},
SysApps: []string{"a"},
SysApps: []string{"a"},
NodeMode: context.RunModeKube,
}

sNode.EXPECT().Get(nil, gomock.Any(), gomock.Any()).Return(mNode2, nil).Times(1)
Expand Down Expand Up @@ -850,7 +852,8 @@ func TestUpdateNodeAddSysApp(t *testing.T) {
specV1.KeyOptionalSysApps: interface{}([]interface{}{"a"}),
UserID: "",
},
SysApps: []string{"a"},
SysApps: []string{"a"},
NodeMode: context.RunModeKube,
}
sNode.EXPECT().Update(mNode.Namespace, mNode3).Return(mNode3, nil)
// equal
Expand All @@ -875,6 +878,7 @@ func TestUpdateNodeAddSysApp(t *testing.T) {
specV1.BaetylCoreFrequency: common.DefaultCoreFrequency,
specV1.KeyAccelerator: "",
},
NodeMode: context.RunModeKube,
}

sNode.EXPECT().Get(nil, mNode4.Namespace, mNode4.Name).Return(mNode4, nil).Times(1)
Expand All @@ -900,7 +904,8 @@ func TestUpdateNodeAddSysApp(t *testing.T) {
specV1.KeyAccelerator: "",
UserID: "",
},
SysApps: []string{"a"},
SysApps: []string{"a"},
NodeMode: context.RunModeKube,
}
sNode.EXPECT().Update(mNode.Namespace, mNode6).Return(mNode6, nil)

Expand All @@ -917,7 +922,8 @@ func TestUpdateNodeAddSysApp(t *testing.T) {
specV1.BaetylCoreFrequency: common.DefaultCoreFrequency,
specV1.KeyAccelerator: "",
},
SysApps: []string{"a"},
SysApps: []string{"a"},
NodeMode: context.RunModeKube,
}
w = httptest.NewRecorder()
body, _ = json.Marshal(mNode5)
Expand Down Expand Up @@ -967,8 +973,9 @@ func TestUpdateNodeDeleteSysApp(t *testing.T) {
specV1.BaetylCoreFrequency: common.DefaultCoreFrequency,
specV1.KeyAccelerator: "",
},
SysApps: []string{"rule-node12"},
Desire: desire,
SysApps: []string{"rule-node12"},
Desire: desire,
NodeMode: context.RunModeKube,
}

sNode.EXPECT().Get(nil, mNode7.Namespace, mNode7.Name).Return(mNode7, nil).Times(1)
Expand Down Expand Up @@ -1021,6 +1028,7 @@ func TestUpdateNodeDeleteSysApp(t *testing.T) {
specV1.KeyAccelerator: "",
UserID: "",
},
NodeMode: context.RunModeKube,
}
sNode.EXPECT().Update(mNode7.Namespace, mNode9).Return(mNode9, nil)

Expand All @@ -1037,6 +1045,7 @@ func TestUpdateNodeDeleteSysApp(t *testing.T) {
specV1.BaetylCoreFrequency: common.DefaultCoreFrequency,
specV1.KeyAccelerator: "",
},
NodeMode: context.RunModeKube,
}
w := httptest.NewRecorder()
body, _ := json.Marshal(mNode8)
Expand Down Expand Up @@ -1068,6 +1077,7 @@ func TestUpdateNodeAccelerator(t *testing.T) {
api.Facade = facade

mNode := &specV1.Node{
NodeMode: context.RunModeKube,
Namespace: "default",
Name: "abc",
Labels: map[string]string{
Expand Down Expand Up @@ -1100,6 +1110,7 @@ func TestUpdateNodeAccelerator(t *testing.T) {
},
}
newNode := &specV1.Node{
NodeMode: context.RunModeKube,
Namespace: "default",
Name: "abc",
Labels: map[string]string{
Expand Down

0 comments on commit 38863c6

Please sign in to comment.