Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: handle deprecated filed instrumentationArgs #660

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> instrumentationArgs = testTask.getTaskRunArgs();
if (instrumentationArgs == null) {
instrumentationArgs = new HashMap<>();
Map<String, String> taskRunArgs = testTask.getTaskRunArgs();
if (taskRunArgs == null) {
taskRunArgs = new HashMap<>();
}
AppiumParam appiumParam = new AppiumParam(
testRunDevice.getDeviceInfo().getSerialNum(),
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> instrumentationArgs, boolean enableTestOrchestrator, String pathToTestServicePack) {
String testRunnerName, String scope, Map<String, String> 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|\"", "")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void initUnitCase(String caseName, int testSeconds) {
ongoingTestUnit = new AndroidTestUnit();
ongoingTestUnit.setNumtests(index);
ongoingTestUnit.setStartTimeMillis(System.currentTimeMillis() - testSeconds * 1000);
ongoingTestUnit.setRelStartTimeInVideo(ongoingTestUnit.getStartTimeMillis() - testSeconds * 1000 - recordingStartTimeMillis);
ongoingTestUnit.setRelStartTimeInVideo(ongoingTestUnit.getStartTimeMillis() - recordingStartTimeMillis);
ongoingTestUnit.setCurrentIndexNum(unitIndex);
ongoingTestUnit.setTestName(caseName);
ongoingTestUnit.setTestedClass("MaestroTest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ private File generateResultXMLFile(TestRun testRun) {
return xmlFile;
}

private String buildCommand(TestRunDevice testRunDevice, TestRun testRun, Map<String, String> instrumentationArgs, File xmlFile) {
private String buildCommand(TestRunDevice testRunDevice, TestRun testRun, Map<String, String> 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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> instrumentationArgs = testTask.getTaskRunArgs();
if (instrumentationArgs != null && !instrumentationArgs.isEmpty()) {
instrumentationArgs.forEach((k, v) -> argString.append(" ").append(v));
Map<String, String> taskRunArgs = testTask.getTaskRunArgs();
if (taskRunArgs != null && !taskRunArgs.isEmpty()) {
taskRunArgs.forEach((k, v) -> argString.append(" ").append(v));
}
String commFormat;
if (StringUtils.isBlank(argString.toString())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ private ArrayList<String> runXctest(TestRunDevice testRunDevice, Logger logger,
}
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 0, logger);
StringBuilder argString = new StringBuilder();
Map<String, String> instrumentationArgs = testTask.getTaskRunArgs();
if (instrumentationArgs != null && !instrumentationArgs.isEmpty()) {
instrumentationArgs.forEach((k, v) -> argString.append(" ").append(k).append(" ").append(v));
Map<String, String> 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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -167,6 +166,7 @@ public TestTaskSpec convertToTaskSpec() {
return testTaskSpec;
}

@SuppressWarnings("deprecation")
public Task(TestTaskSpec testTaskSpec) {
setId(testTaskSpec.testTaskId);
setAccessKey(testTaskSpec.accessKey);
Expand All @@ -175,6 +175,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);
Expand Down
14 changes: 7 additions & 7 deletions react/src/component/RunnerView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class RunnerView extends BaseView {
maxStepCount: "",
deviceTestCount: "",
testTimeOutSec: "",
instrumentationArgs: "",
testRunArgs: "",
frameworkType: "JUnit4",
testRunnerName: "androidx.test.runner.AndroidJUnitRunner",
enableTestOrchestrator: false,
Expand Down Expand Up @@ -760,12 +760,12 @@ export default class RunnerView extends BaseView {
<Stack direction="row" alignItems="flex-end">
<TextField
margin="dense"
name="instrumentationArgs"
name="testRunArgs"
type="text"
label="Test config"
fullWidth
variant="standard"
value={this.state.instrumentationArgs}
value={this.state.testRunArgs}
onChange={this.handleValueChange}
/>
<Tooltip title="Additional parameters">
Expand Down Expand Up @@ -1036,7 +1036,7 @@ export default class RunnerView extends BaseView {
maxStepCount: "",
deviceTestCount: "",
testTimeOutSec: "",
instrumentationArgs: "",
testRunArgs: "",
})
})

Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions react/src/component/TasksView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -979,12 +979,12 @@ class TasksView extends BaseView {
/>
<TextField
margin="dense"
name="instrumentationArgs"
name="testRunArgs"
type="text"
label="Test config"
fullWidth
variant="standard"
value={this.state.instrumentationArgs}
value={this.state.testRunArgs}
onChange={this.handleValueChange}
/>
<Button
Expand All @@ -1003,9 +1003,9 @@ class TasksView extends BaseView {
return
}
let argsObj = {}
if (this.state.instrumentationArgs !== "") {
if (this.state.testRunArgs !== "") {
try {
argsObj = JSON.parse(this.state.instrumentationArgs)
argsObj = JSON.parse(this.state.testRunArgs)
} catch (error) {
this.snackBarMsg("Error Test config, please input JSON Object")
return
Expand All @@ -1028,7 +1028,7 @@ class TasksView extends BaseView {
frameworkType: task.frameworkType,

testTimeOutSec: this.state.timeOutSecond,
instrumentationArgs: argsObj
testRunArgs: argsObj
}

axios.post('/api/test/task/run/', formParams, {
Expand All @@ -1048,7 +1048,7 @@ class TasksView extends BaseView {
})
this.setState({
testTimeOutSec: null,
instrumentationArgs: null
testRunArgs: null
})
}
}
Expand Down
Loading