Skip to content

Commit

Permalink
Bugfix: Set the status of devices to testing after the task is sure t…
Browse files Browse the repository at this point in the history
…o run. (#273)
  • Loading branch information
zhou9584 authored Feb 15, 2023
1 parent 9371eb1 commit 8f7d3c4
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ private JSONObject runTestTaskByGroup(TestTaskSpec testTaskSpec) {
if (deviceGroup.getIsPrivate()) {
checkAccessInfo(testTaskSpec.deviceIdentifier, testTaskSpec.accessKey);
}
Map<String, List<String>> agents = new HashMap<>();
Map<String, List<String>> testAgentDevicesMap = new HashMap<>();
boolean isSingle = Const.DeviceGroup.SINGLE_TYPE.equals(testTaskSpec.groupTestType);
boolean isAll = Const.DeviceGroup.ALL_TYPE.equals(testTaskSpec.groupTestType);
Message message = new Message();
Expand All @@ -796,10 +796,9 @@ private JSONObject runTestTaskByGroup(TestTaskSpec testTaskSpec) {
}
isAllOffline = false;
if (device.isOnline()) {
updateDeviceStatus(deviceSerial, DeviceInfo.TESTING, testTaskSpec.testTaskId);
List<String> devices = agents.getOrDefault(device.getAgentId(), new ArrayList<>());
List<String> devices = testAgentDevicesMap.getOrDefault(device.getAgentId(), new ArrayList<>());
devices.add(device.getSerialNum());
agents.put(device.getAgentId(), devices);
testAgentDevicesMap.put(device.getAgentId(), devices);
testTaskSpec.agentIds.add(device.getAgentId());
if (isSingle) {
break;
Expand All @@ -809,9 +808,13 @@ private JSONObject runTestTaskByGroup(TestTaskSpec testTaskSpec) {
}
}
Assert.isTrue(!isAllOffline, "All Device/Agent Offline!");
for (String agentId : agents.keySet()) {
for (String agentId : testAgentDevicesMap.keySet()) {
AgentSessionInfo agentSessionInfoByAgentId = getAgentSessionInfoByAgentId(agentId);
String groupDevices = String.join(",", agents.get(agentId));
List<String> testDeviceSerials = testAgentDevicesMap.get(agentId);
for (String temp : testDeviceSerials) {
updateDeviceStatus(temp, DeviceInfo.TESTING, testTaskSpec.testTaskId);
}
String groupDevices = String.join(",", testDeviceSerials);
Assert.notNull(agentSessionInfoByAgentId, "Device/Agent Offline!");
if (result.get(Const.Param.TEST_DEVICE_SN) == null) {
result.put(Const.Param.TEST_DEVICE_SN, groupDevices);
Expand Down

0 comments on commit 8f7d3c4

Please sign in to comment.