Skip to content

Commit

Permalink
Bugfix: reset available count when canceling Analysis Task (#643)
Browse files Browse the repository at this point in the history
<!-- Please provide brief information about the PR, what it contains &
its purpose, new behaviors after the change. And let us know here if you
need any help: https://github.com/microsoft/HydraLab/issues/new -->

## Description

<!-- A few words to explain your changes -->

### Linked GitHub issue ID: #  

## Pull Request Checklist
<!-- Put an x in the boxes that apply. This is simply a reminder of what
we are going to look for before merging your code. -->

- [ ] Tests for the changes have been added (for bug fixes / features)
- [x] Code compiles correctly with all tests are passed.
- [x] I've read the [contributing
guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code)
and followed the recommended practices.
- [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or
[README](https://github.com/microsoft/HydraLab/blob/main/README.md) have
been reviewed and added / updated if needed (for bug fixes / features)

### Does this introduce a breaking change?
*If this introduces a breaking change for Hydra Lab users, please
describe the impact and migration path.*

- [x] Yes
- [ ] No

## How you tested it
*Please make sure the change is tested, you can test it by adding UTs,
do local test and share the screenshots, etc.*


Please check the type of change your PR introduces:
- [x] Bugfix
- [ ] Feature
- [ ] Technical design
- [ ] Build related changes
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Code style update (formatting, renaming) or Documentation content
changes
- [ ] Other (please describe): 

### Feature UI screenshots or Technical design diagrams
*If this is a relatively large or complex change, kick it off by drawing
the tech design with PlantUML and explaining why you chose the solution
you did and what alternatives you considered, etc...*
  • Loading branch information
zhou9584 committed Jan 22, 2024
1 parent 100ca07 commit a923cae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ public void loadAttachments(Task task) {
task.setAppFile(appFile);
break;
case StorageFileInfo.FileType.TEST_APP_FILE:
if (!(task instanceof TestTask)) {
return;
}
File testAppFile = downloadFile(attachment);
Assert.isTrue(testAppFile != null && testAppFile.exists() && task instanceof TestTask, "Download test app file failed!");
Assert.isTrue(testAppFile != null && testAppFile.exists(), "Download test app file failed!");
((TestTask) task).setTestAppFile(testAppFile);
break;
case StorageFileInfo.FileType.T2C_JSON_FILE:
if (!(task instanceof TestTask)) {
return;
}
File testJsonFile = downloadFile(attachment);
Assert.isTrue(testJsonFile != null && testJsonFile.exists() && task instanceof TestTask, "Download test json file failed!");
Assert.isTrue(testJsonFile != null && testJsonFile.exists(), "Download test json file failed!");
((TestTask) task).addTestJsonFile(testJsonFile);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,17 @@ public void updateAccessInfo(AccessInfo accessInfo) {

public void cancelTestTaskById(String taskId, String reason) {
Set<String> agentIds = testDataService.cancelTaskById(taskId, reason);
Task task = testDataService.getTaskDetail(taskId);
JSONObject data = new JSONObject();
Message message = new Message();
data.put(Const.AgentConfig.TASK_ID_PARAM, taskId);
message.setPath(Const.Path.TEST_TASK_CANCEL);
message.setBody(data);
for (String agentId : agentIds) {
if (Task.RunnerType.APK_SCANNER.name().equals(task.getRunnerType())) {
agentDeviceGroups.get(agentId).finishAnalysisTask(task.getRunnerType());
}

AgentSessionInfo agentSession = getAgentSessionInfoByAgentId(agentId);
if (agentSession == null || agentSession.session == null) {
continue;
Expand Down

0 comments on commit a923cae

Please sign in to comment.