Skip to content

Commit

Permalink
[all] Update cloud protocol component status
Browse files Browse the repository at this point in the history
Signed-off-by: Mykhailo Lohvynenko <[email protected]>
  • Loading branch information
mlohvynenko committed Sep 10, 2024
1 parent 148dbf0 commit 494d596
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion umcontroller/umcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ func (umCtrl *Controller) notifyNewComponents(umID string, componsStatus []syste
ComponentID: status.componentID,
ComponentType: status.componentType,
Version: status.version,
NodeID: umID,
NodeID: &umID,
Status: status.status,
}

Expand Down
8 changes: 6 additions & 2 deletions umcontroller/umcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ func TestNewComponentsUpdate(t *testing.T) {
select {
case newComponents := <-umCtrl.NewComponentsChannel():
if !reflect.DeepEqual(newComponents, []cloudprotocol.ComponentStatus{
{ComponentID: "component3", Version: "1.0.0", Status: "installed", NodeID: "umID2"},
{ComponentID: "component4", Version: "1.0.0", Status: "installed", NodeID: "umID2"},
{ComponentID: "component3", Version: "1.0.0", Status: "installed", NodeID: convertToNodeID("umID2")},
{ComponentID: "component4", Version: "1.0.0", Status: "installed", NodeID: convertToNodeID("umID2")},
}) {
t.Errorf("Incorrect new components: %v", newComponents)
}
Expand Down Expand Up @@ -1897,3 +1897,7 @@ func generateFile(fileName string, size uint64) (err error) {
func convertToComponentID(id string) *string {
return &id
}

func convertToNodeID(nodeID string) *string {
return &nodeID
}
10 changes: 7 additions & 3 deletions unitstatushandler/unitstatushandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,15 +1175,15 @@ func TestNewComponents(t *testing.T) {
newComponents := []cloudprotocol.ComponentStatus{
{
ComponentID: "comp1", ComponentType: "type1", Version: "1.0.0",
Status: cloudprotocol.InstalledStatus, NodeID: "node1",
Status: cloudprotocol.InstalledStatus, NodeID: convertToNodeID("node1"),
},
{
ComponentID: "comp2", ComponentType: "type2", Version: "1.0.0",
Status: cloudprotocol.InstalledStatus, NodeID: "node2",
Status: cloudprotocol.InstalledStatus, NodeID: convertToNodeID("node2"),
},
{
ComponentID: "comp3", ComponentType: "type3", Version: "1.0.0",
Status: cloudprotocol.InstalledStatus, NodeID: "node3",
Status: cloudprotocol.InstalledStatus, NodeID: convertToNodeID("node3"),
},
}

Expand Down Expand Up @@ -1388,3 +1388,7 @@ func handleUpdateStatus(handler *unitstatushandler.Instance) {
func convertToComponentID(id string) *string {
return &id
}

func convertToNodeID(nodeID string) *string {
return &nodeID
}

0 comments on commit 494d596

Please sign in to comment.