From b3077d32417bca5cf873b5505fbf422698206519 Mon Sep 17 00:00:00 2001 From: Le Zhou <2428499107@qq.com> Date: Mon, 24 Jun 2024 11:58:15 +0800 Subject: [PATCH 1/3] Bugfix: handle deprecated filed instrumentationArgs --- .../hydralab/agent/runner/appium/AppiumRunner.java | 10 +++++----- .../agent/runner/espresso/EspressoRunner.java | 6 +++--- .../agent/runner/maestro/MaestroRunner.java | 6 +++--- .../agent/runner/monkey/AdbMonkeyRunner.java | 6 +++--- .../hydralab/agent/runner/xctest/XCTestRunner.java | 6 +++--- .../hydralab/common/entity/common/KeyValue.java | 2 +- .../hydralab/common/entity/common/Task.java | 4 +++- react/src/component/RunnerView.jsx | 14 +++++++------- react/src/component/TasksView.jsx | 14 +++++++------- 9 files changed, 35 insertions(+), 33 deletions(-) diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/AppiumRunner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/AppiumRunner.java index 2ef197b5a..187390803 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/AppiumRunner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/AppiumRunner.java @@ -83,9 +83,9 @@ protected File runAndGetGif(File appiumJarFile, String appiumCommand, TestRunDev TestRun testRun, File deviceTestResultFolder, Logger reportLogger) { //set appium test property reportLogger.info("Start set appium test property"); - Map instrumentationArgs = testTask.getTaskRunArgs(); - if (instrumentationArgs == null) { - instrumentationArgs = new HashMap<>(); + Map taskRunArgs = testTask.getTaskRunArgs(); + if (taskRunArgs == null) { + taskRunArgs = new HashMap<>(); } AppiumParam appiumParam = new AppiumParam( testRunDevice.getDeviceInfo().getSerialNum(), @@ -94,9 +94,9 @@ protected File runAndGetGif(File appiumJarFile, String appiumCommand, TestRunDev IOSUtils.getWdaPortByUdid(testRunDevice.getDeviceInfo().getSerialNum(), reportLogger), testTask.getAppFile().getAbsolutePath(), deviceTestResultFolder.getAbsolutePath()); - ThreadParam.init(appiumParam, instrumentationArgs); + ThreadParam.init(appiumParam, taskRunArgs); reportLogger.info("ThreadParam init success, AppiumParam is {} , args is {}", appiumParam, - LogUtils.scrubSensitiveArgs(instrumentationArgs.toString())); + LogUtils.scrubSensitiveArgs(taskRunArgs.toString())); File gifFile = null; if (TestTask.TestFrameworkType.JUNIT5.equals(testTask.getFrameworkType())) { reportLogger.info("Start init listener"); diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/espresso/EspressoRunner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/espresso/EspressoRunner.java index e4d839e17..9437f6af7 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/espresso/EspressoRunner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/espresso/EspressoRunner.java @@ -155,10 +155,10 @@ public String startInstrument(DeviceInfo deviceInfo, Logger logger, IShellOutput @NotNull private String buildCommand(String suiteName, String testPkgName, - String testRunnerName, String scope, Map instrumentationArgs, boolean enableTestOrchestrator, String pathToTestServicePack) { + String testRunnerName, String scope, Map taskRunArgs, boolean enableTestOrchestrator, String pathToTestServicePack) { StringBuilder argString = new StringBuilder(); - if (instrumentationArgs != null && !instrumentationArgs.isEmpty()) { - instrumentationArgs.forEach( + if (taskRunArgs != null && !taskRunArgs.isEmpty()) { + taskRunArgs.forEach( (k, v) -> argString.append(" -e ").append(k.replaceAll("\\s|\"", "")).append(" ") .append(v.replaceAll("\\s|\"", ""))); } diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/maestro/MaestroRunner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/maestro/MaestroRunner.java index 196096df7..9ece46344 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/maestro/MaestroRunner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/maestro/MaestroRunner.java @@ -100,11 +100,11 @@ private File generateResultXMLFile(TestRun testRun) { return xmlFile; } - private String buildCommand(TestRunDevice testRunDevice, TestRun testRun, Map instrumentationArgs, File xmlFile) { + private String buildCommand(TestRunDevice testRunDevice, TestRun testRun, Map taskRunArgs, File xmlFile) { // sample: maestro --device 123456 test -e var=aaa --format junit --output /tmp/result.xml /tmp/caseFolder/ StringBuilder argString = new StringBuilder(); - if (instrumentationArgs != null && !instrumentationArgs.isEmpty()) { - instrumentationArgs.forEach((k, v) -> argString.append(" -e ").append(k.replaceAll("\\s|\"", "")).append("=").append(v.replaceAll("\\s|\"", ""))); + if (taskRunArgs != null && !taskRunArgs.isEmpty()) { + taskRunArgs.forEach((k, v) -> argString.append(" -e ").append(k.replaceAll("\\s|\"", "")).append("=").append(v.replaceAll("\\s|\"", ""))); } String commFormat; if (StringUtils.isBlank(argString.toString())) { diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/monkey/AdbMonkeyRunner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/monkey/AdbMonkeyRunner.java index 5b73ad4c5..099235894 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/monkey/AdbMonkeyRunner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/monkey/AdbMonkeyRunner.java @@ -128,9 +128,9 @@ public long runMonkeyTestOnce(TestRunDevice testRunDevice, TestTask testTask, Te System.currentTimeMillis() - testRun.getTestStartTimeMillis()); testRunDeviceOrchestrator.setRunningTestName(testRunDevice, ongoingMonkeyTest.getTitle()); StringBuilder argString = new StringBuilder(); - Map instrumentationArgs = testTask.getTaskRunArgs(); - if (instrumentationArgs != null && !instrumentationArgs.isEmpty()) { - instrumentationArgs.forEach((k, v) -> argString.append(" ").append(v)); + Map taskRunArgs = testTask.getTaskRunArgs(); + if (taskRunArgs != null && !taskRunArgs.isEmpty()) { + taskRunArgs.forEach((k, v) -> argString.append(" ").append(v)); } String commFormat; if (StringUtils.isBlank(argString.toString())) { diff --git a/agent/src/main/java/com/microsoft/hydralab/agent/runner/xctest/XCTestRunner.java b/agent/src/main/java/com/microsoft/hydralab/agent/runner/xctest/XCTestRunner.java index 755924bb9..d7b42fa64 100644 --- a/agent/src/main/java/com/microsoft/hydralab/agent/runner/xctest/XCTestRunner.java +++ b/agent/src/main/java/com/microsoft/hydralab/agent/runner/xctest/XCTestRunner.java @@ -93,9 +93,9 @@ private ArrayList runXctest(TestRunDevice testRunDevice, Logger logger, } testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 0, logger); StringBuilder argString = new StringBuilder(); - Map instrumentationArgs = testTask.getTaskRunArgs(); - if (instrumentationArgs != null && !instrumentationArgs.isEmpty()) { - instrumentationArgs.forEach((k, v) -> argString.append(" ").append(k).append(" ").append(v)); + Map taskRunArgs = testTask.getTaskRunArgs(); + if (taskRunArgs != null && !taskRunArgs.isEmpty()) { + taskRunArgs.forEach((k, v) -> argString.append(" ").append(k).append(" ").append(v)); } String commFormat; if (StringUtils.isBlank(argString.toString())) { diff --git a/common/src/main/java/com/microsoft/hydralab/common/entity/common/KeyValue.java b/common/src/main/java/com/microsoft/hydralab/common/entity/common/KeyValue.java index 024c5b17d..882a33383 100644 --- a/common/src/main/java/com/microsoft/hydralab/common/entity/common/KeyValue.java +++ b/common/src/main/java/com/microsoft/hydralab/common/entity/common/KeyValue.java @@ -12,7 +12,7 @@ public class KeyValue implements Serializable { @Id private String keyid; - @Column(name = "value", columnDefinition = "CLOB", nullable = true) + @Column(name = "value", columnDefinition = "text", nullable = true) private String value; public KeyValue() { diff --git a/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java b/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java index 42ac0a0b6..74830489d 100644 --- a/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java +++ b/common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java @@ -84,7 +84,6 @@ public class Task implements Serializable { private String notifyUrl; @Transient private boolean disableRecording = false; - @Column(columnDefinition = "boolean default false") private boolean isSucceed = false; @Transient @@ -175,6 +174,9 @@ public Task(TestTaskSpec testTaskSpec) { setPipelineLink(testTaskSpec.pipelineLink); setTimeOutSecond(testTaskSpec.testTimeOutSec); setDeviceActions(testTaskSpec.deviceActions); + if (testTaskSpec.instrumentationArgs != null) { + testTaskSpec.testRunArgs.putAll(testTaskSpec.instrumentationArgs); + } setTaskRunArgs(testTaskSpec.testRunArgs); setFileSetId(testTaskSpec.fileSetId); setPkgName(testTaskSpec.pkgName); diff --git a/react/src/component/RunnerView.jsx b/react/src/component/RunnerView.jsx index 3c36e828a..3011fb2d9 100644 --- a/react/src/component/RunnerView.jsx +++ b/react/src/component/RunnerView.jsx @@ -109,7 +109,7 @@ export default class RunnerView extends BaseView { maxStepCount: "", deviceTestCount: "", testTimeOutSec: "", - instrumentationArgs: "", + testRunArgs: "", frameworkType: "JUnit4", testRunnerName: "androidx.test.runner.AndroidJUnitRunner", enableTestOrchestrator: false, @@ -760,12 +760,12 @@ export default class RunnerView extends BaseView { @@ -1036,7 +1036,7 @@ export default class RunnerView extends BaseView { maxStepCount: "", deviceTestCount: "", testTimeOutSec: "", - instrumentationArgs: "", + testRunArgs: "", }) }) @@ -1098,11 +1098,11 @@ export default class RunnerView extends BaseView { } runTest = () => { - let instrumentationArgsObj = {}; + let testRunArgsObj = {}; let neededPermissionsObj = []; let deviceActionsObj = {}; try { - instrumentationArgsObj = this.handleJSONParams(this.state.instrumentationArgs); + testRunArgsObj = this.handleJSONParams(this.state.testRunArgs); neededPermissionsObj = this.handleJSONParams(this.state.neededPermissions, []); deviceActionsObj = this.handleJSONParams(this.state.deviceActions); } catch (error) { @@ -1124,7 +1124,7 @@ export default class RunnerView extends BaseView { maxStepCount: this.state.maxStepCount, deviceTestCount: this.state.deviceTestCount, testTimeOutSec: this.state.testTimeOutSec, - instrumentationArgs: instrumentationArgsObj, + testRunArgs: testRunArgsObj, frameworkType: this.state.frameworkType, testRunnerName: this.state.testRunnerName, neededPermissions: neededPermissionsObj, diff --git a/react/src/component/TasksView.jsx b/react/src/component/TasksView.jsx index bdcbd4390..95d812f9f 100644 --- a/react/src/component/TasksView.jsx +++ b/react/src/component/TasksView.jsx @@ -105,7 +105,7 @@ class TasksView extends BaseView { page: this.props.page ? this.props.page : 1, testTimeOutSec: null, - instrumentationArgs: null, + testRunArgs: null, selectedParams: ls.get('selectedParams') ? ls.get('selectedParams') : defaultSelectedParams, }; @@ -979,12 +979,12 @@ class TasksView extends BaseView { />