Skip to content

Commit 8f7d3c4

Browse files
authored
Bugfix: Set the status of devices to testing after the task is sure to run. (#273)
1 parent 9371eb1 commit 8f7d3c4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

center/src/main/java/com/microsoft/hydralab/center/service/DeviceAgentManagementService.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ private JSONObject runTestTaskByGroup(TestTaskSpec testTaskSpec) {
779779
if (deviceGroup.getIsPrivate()) {
780780
checkAccessInfo(testTaskSpec.deviceIdentifier, testTaskSpec.accessKey);
781781
}
782-
Map<String, List<String>> agents = new HashMap<>();
782+
Map<String, List<String>> testAgentDevicesMap = new HashMap<>();
783783
boolean isSingle = Const.DeviceGroup.SINGLE_TYPE.equals(testTaskSpec.groupTestType);
784784
boolean isAll = Const.DeviceGroup.ALL_TYPE.equals(testTaskSpec.groupTestType);
785785
Message message = new Message();
@@ -796,10 +796,9 @@ private JSONObject runTestTaskByGroup(TestTaskSpec testTaskSpec) {
796796
}
797797
isAllOffline = false;
798798
if (device.isOnline()) {
799-
updateDeviceStatus(deviceSerial, DeviceInfo.TESTING, testTaskSpec.testTaskId);
800-
List<String> devices = agents.getOrDefault(device.getAgentId(), new ArrayList<>());
799+
List<String> devices = testAgentDevicesMap.getOrDefault(device.getAgentId(), new ArrayList<>());
801800
devices.add(device.getSerialNum());
802-
agents.put(device.getAgentId(), devices);
801+
testAgentDevicesMap.put(device.getAgentId(), devices);
803802
testTaskSpec.agentIds.add(device.getAgentId());
804803
if (isSingle) {
805804
break;
@@ -809,9 +808,13 @@ private JSONObject runTestTaskByGroup(TestTaskSpec testTaskSpec) {
809808
}
810809
}
811810
Assert.isTrue(!isAllOffline, "All Device/Agent Offline!");
812-
for (String agentId : agents.keySet()) {
811+
for (String agentId : testAgentDevicesMap.keySet()) {
813812
AgentSessionInfo agentSessionInfoByAgentId = getAgentSessionInfoByAgentId(agentId);
814-
String groupDevices = String.join(",", agents.get(agentId));
813+
List<String> testDeviceSerials = testAgentDevicesMap.get(agentId);
814+
for (String temp : testDeviceSerials) {
815+
updateDeviceStatus(temp, DeviceInfo.TESTING, testTaskSpec.testTaskId);
816+
}
817+
String groupDevices = String.join(",", testDeviceSerials);
815818
Assert.notNull(agentSessionInfoByAgentId, "Device/Agent Offline!");
816819
if (result.get(Const.Param.TEST_DEVICE_SN) == null) {
817820
result.put(Const.Param.TEST_DEVICE_SN, groupDevices);

0 commit comments

Comments
 (0)