Skip to content

Commit

Permalink
[smcontroller, amqp, monitorctrl] Change Monitoring::disk to partition
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Kobets <[email protected]>
  • Loading branch information
mykola-kobets-epam committed Sep 5, 2024
1 parent b90bf15 commit af06de5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
10 changes: 5 additions & 5 deletions amqphandler/amqphandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func TestSendMessages(t *testing.T) {
nodeMonitoring := cloudprotocol.NodeMonitoringData{
Items: []aostypes.MonitoringData{
{
RAM: 1024, CPU: 50, Download: 8192, Upload: 4096, Disk: []aostypes.PartitionUsage{{
RAM: 1024, CPU: 50, Download: 8192, Upload: 4096, Partitions: []aostypes.PartitionUsage{{
Name: "p1", UsedSize: 100,
}},
Timestamp: time.Now().UTC(),
Expand All @@ -479,25 +479,25 @@ func TestSendMessages(t *testing.T) {
{
NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1},
Items: []aostypes.MonitoringData{
{RAM: 1024, CPU: 50, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
{RAM: 1024, CPU: 50, Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
},
},
{
NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "subj1", Instance: 1},
Items: []aostypes.MonitoringData{
{RAM: 128, CPU: 60, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
{RAM: 128, CPU: 60, Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
},
},
{
NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "subj1", Instance: 1},
Items: []aostypes.MonitoringData{
{RAM: 256, CPU: 70, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
{RAM: 256, CPU: 70, Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
},
},
{
NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service3", SubjectID: "subj1", Instance: 1},
Items: []aostypes.MonitoringData{
{RAM: 512, CPU: 80, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
{RAM: 512, CPU: 80, Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}},
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions monitorcontroller/monitorcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func getTestMonitoringData() (aostypes.NodeMonitoring, cloudprotocol.Monitoring)
Items: []aostypes.MonitoringData{
{
RAM: 1024, CPU: 50, Download: 8192, Upload: 4096, Timestamp: timestamp,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
},
},
}
Expand All @@ -195,7 +195,7 @@ func getTestMonitoringData() (aostypes.NodeMonitoring, cloudprotocol.Monitoring)
Items: []aostypes.MonitoringData{
{
RAM: 1024, CPU: 50, Timestamp: timestamp,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
},
},
}
Expand Down
56 changes: 28 additions & 28 deletions smcontroller/smcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,16 @@ func TestSMMonitoringNotifications(t *testing.T) {
NodeID: nodeID,
NodeData: aostypes.MonitoringData{
RAM: 10, CPU: 20, Download: 40, Upload: 50,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: now,
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: now,
},
InstancesData: []aostypes.InstanceMonitoring{},
},
sendMonitoring: &pbsm.InstantMonitoring{
NodeMonitoring: &pbsm.MonitoringData{
Ram: 10, Cpu: 20, Download: 40, Upload: 50,
Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(now),
Partitions: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(now),
},
},
},
Expand All @@ -564,49 +564,49 @@ func TestSMMonitoringNotifications(t *testing.T) {
NodeID: nodeID,
NodeData: aostypes.MonitoringData{
RAM: 10, CPU: 20, Download: 40, Upload: 50,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: now,
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: now,
},
InstancesData: []aostypes.InstanceMonitoring{
{
InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "s1", Instance: 1},
MonitoringData: aostypes.MonitoringData{
RAM: 10, CPU: 20, Download: 40, Upload: 0,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: now,
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: now,
},
},
{
InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "s1", Instance: 1},
MonitoringData: aostypes.MonitoringData{
RAM: 20, CPU: 30, Download: 50, Upload: 10,
Disk: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: now,
Partitions: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: now,
},
},
},
},
sendMonitoring: &pbsm.InstantMonitoring{
NodeMonitoring: &pbsm.MonitoringData{
Ram: 10, Cpu: 20, Download: 40, Upload: 50,
Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(now),
Partitions: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(now),
},
InstancesMonitoring: []*pbsm.InstanceMonitoring{
{
Instance: &pbcommon.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1},
MonitoringData: &pbsm.MonitoringData{
Ram: 10, Cpu: 20, Download: 40, Upload: 0,
Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(now),
Partitions: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(now),
},
},
{
Instance: &pbcommon.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1},
MonitoringData: &pbsm.MonitoringData{
Ram: 20, Cpu: 30, Download: 50, Upload: 10,
Disk: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: timestamppb.New(now),
Partitions: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: timestamppb.New(now),
},
},
},
Expand Down Expand Up @@ -1146,24 +1146,24 @@ func TestGetAverageMonitoring(t *testing.T) {
NodeID: nodeID,
NodeData: aostypes.MonitoringData{
RAM: 10, CPU: 20, Download: 40, Upload: 50,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: currentTime,
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: currentTime,
},
InstancesData: []aostypes.InstanceMonitoring{
{
InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "s1", Instance: 1},
MonitoringData: aostypes.MonitoringData{
RAM: 10, CPU: 20, Download: 40, Upload: 0,
Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: currentTime,
Partitions: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: currentTime,
},
},
{
InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "s1", Instance: 1},
MonitoringData: aostypes.MonitoringData{
RAM: 20, CPU: 30, Download: 50, Upload: 10,
Disk: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: currentTime,
Partitions: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: currentTime,
},
},
},
Expand All @@ -1172,24 +1172,24 @@ func TestGetAverageMonitoring(t *testing.T) {
AverageMonitoring: &pbsm.AverageMonitoring{
NodeMonitoring: &pbsm.MonitoringData{
Ram: 10, Cpu: 20, Download: 40, Upload: 50,
Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(currentTime),
Partitions: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(currentTime),
},
InstancesMonitoring: []*pbsm.InstanceMonitoring{
{
Instance: &pbcommon.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1},
MonitoringData: &pbsm.MonitoringData{
Ram: 10, Cpu: 20, Download: 40, Upload: 0,
Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(currentTime),
Partitions: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}},
Timestamp: timestamppb.New(currentTime),
},
},
{
Instance: &pbcommon.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1},
MonitoringData: &pbsm.MonitoringData{
Ram: 20, Cpu: 30, Download: 50, Upload: 10,
Disk: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: timestamppb.New(currentTime),
Partitions: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}},
Timestamp: timestamppb.New(currentTime),
},
},
},
Expand Down
16 changes: 8 additions & 8 deletions smcontroller/smhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,16 +755,16 @@ func instantMonitoringFromPB(instantMonitoring *pb.InstantMonitoring) aostypes.N

func monitoringDataFromPB(pbMonitoring *pb.MonitoringData) aostypes.MonitoringData {
monitoringData := aostypes.MonitoringData{
Timestamp: pbMonitoring.GetTimestamp().AsTime(),
RAM: pbMonitoring.GetRam(),
CPU: pbMonitoring.GetCpu(),
Download: pbMonitoring.GetDownload(),
Upload: pbMonitoring.GetUpload(),
Disk: make([]aostypes.PartitionUsage, len(pbMonitoring.GetDisk())),
Timestamp: pbMonitoring.GetTimestamp().AsTime(),
RAM: pbMonitoring.GetRam(),
CPU: pbMonitoring.GetCpu(),
Download: pbMonitoring.GetDownload(),
Upload: pbMonitoring.GetUpload(),
Partitions: make([]aostypes.PartitionUsage, len(pbMonitoring.GetPartitions())),
}

for i, pbData := range pbMonitoring.GetDisk() {
monitoringData.Disk[i] = aostypes.PartitionUsage{Name: pbData.GetName(), UsedSize: pbData.GetUsedSize()}
for i, pbData := range pbMonitoring.GetPartitions() {
monitoringData.Partitions[i] = aostypes.PartitionUsage{Name: pbData.GetName(), UsedSize: pbData.GetUsedSize()}
}

return monitoringData
Expand Down

0 comments on commit af06de5

Please sign in to comment.