Skip to content

Commit

Permalink
Merge pull request #232 from SonicCloudOrg/dev
Browse files Browse the repository at this point in the history
rcReady
  • Loading branch information
ZhouYixun authored Jun 29, 2022
2 parents ca32611 + 2d87f22 commit 77ad74f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
10 changes: 5 additions & 5 deletions config/application-sonic-agent.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
sonic:
agent:
# 替换为部署Agent机器的ipv4
host: 192.168.1.6
host: 192.168.1.4
# 替换为Agent服务的端口,可以自行更改
port: 7777
# 替换为前端新增Agent生成的key
key: 29002272-4659-4808-a804-08ce3388b136
server:
# 改成server的SERVER_HOST
host: 192.168.1.6
# 改成server的SERVER_PORT
# 改成server的SONIC_SERVER_HOST
host: 192.168.1.4
# 改成server的SONIC_SERVER_PORT
port: 3000

modules:
Expand All @@ -20,7 +20,7 @@ modules:
use-adbkit: true
ios:
# 如果不需要连接iOS设备,请将true改为false。开启的windows用户请确保本机已安装iTunes
enable: true
enable: false
# 替换为你自己使用的wda的bundleId,如果没有.xctrunner后缀会自动补全,建议使用公司的开发者证书
wda-bundle-id: com.sonic.WebDriverAgentRunner.xctrunner
appium:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.cloud.sonic</groupId>
<artifactId>sonic-agent</artifactId>
<version>1.4.1-beta</version>
<version>1.4.1-rc</version>
<packaging>jar</packaging>

<properties>
Expand Down
8 changes: 4 additions & 4 deletions src/main/docker/config/application-sonic-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ sonic:
# 替换为前端新增Agent生成的key
key: ${AGENT_KEY:235a35fd-5d0d-4533-905d-30d32902a12b}
server:
# 改成server的SERVER_HOST
host: ${SERVER_HOST:192.168.1.1}
# 改成server的SERVER_PORT
port: ${SERVER_PORT:3000}
# 改成server的SONIC_SERVER_HOST
host: ${SONIC_SERVER_HOST:192.168.1.1}
# 改成server的SONIC_SERVER_PORT
port: ${SONIC_SERVER_PORT:3000}

modules:
android:
Expand Down
6 changes: 3 additions & 3 deletions src/main/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: '3'
services:
sonic-agent:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-beta"
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-rc"
environment:
# 对应server的env配置,注意防火墙关闭对应端口
- SERVER_HOST=192.168.1.1
- SERVER_PORT=3000
- SONIC_SERVER_HOST=192.168.1.1
- SONIC_SERVER_PORT=3000
# 替换为部署Agent机器的ipv4
- AGENT_HOST=192.168.1.1
# 替换为Agent服务的端口,可以自行更改
Expand Down
6 changes: 3 additions & 3 deletions src/main/docker/docker-compose2.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: '3'
services:
sonic-agent:
image: "sonicorg/sonic-agent-linux:v1.4.1-beta"
image: "sonicorg/sonic-agent-linux:v1.4.1-rc"
environment:
# 对应server的env配置,注意防火墙关闭对应端口
- SERVER_HOST=192.168.1.1
- SERVER_PORT=3000
- SONIC_SERVER_HOST=192.168.1.1
- SONIC_SERVER_PORT=3000
# 替换为部署Agent机器的ipv4
- AGENT_HOST=192.168.1.1
# 替换为Agent服务的端口,可以自行更改
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,9 @@ public WebElement findEle(String selector, String pathValue) {
case "cssSelectorAndText":
we = getWebElementByCssAndText(pathValue);
break;
case "androidUIAutomator":
//仅限自动化引擎为UIAutomator2时生效
we = androidDriver.findElementByAndroidUIAutomator(pathValue);
default:
log.sendStepLog(StepType.ERROR, "查找控件元素失败", "这个控件元素类型: " + selector + " 不存在!!!");
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public void onMessage(String s) {
log.info("Agent <- Server message: {}", jsonObject);
TransportWorker.cachedThreadPool.execute(() -> {
switch (jsonObject.getString("msg")) {
case "pong":{
break;
}
case "auth": {
if (jsonObject.getString("result").equals("pass")) {
log.info("server auth successful!");
Expand Down Expand Up @@ -174,7 +177,7 @@ public void onMessage(String s) {
@Override
public void onClose(int i, String s, boolean b) {
if (TransportWorker.isKeyAuth) {
log.info("Server disconnected. Retry in 10s...");
log.info("Server disconnected. Retry in 30s...");
}
TransportWorker.client = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.cloud.sonic.agent.transport;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.cloud.sonic.agent.tools.SpringTool;

Expand All @@ -31,7 +32,7 @@ public class TransportConnectionThread implements Runnable {
/**
* second
*/
public static final long DELAY = 10;
public static final long DELAY = 30;

public static final String THREAD_NAME = "transport-connection-thread";

Expand All @@ -45,15 +46,19 @@ public class TransportConnectionThread implements Runnable {
public void run() {
Thread.currentThread().setName(THREAD_NAME);
if (TransportWorker.client == null) {
if(!TransportWorker.isKeyAuth){
if (!TransportWorker.isKeyAuth) {
return;
}
//开发环境去掉/server
String url = String.format("ws://%s:%d/server/websockets/agent/%s",
serverHost, serverPort, key).replace(":80/","/");
serverHost, serverPort, key).replace(":80/", "/");
URI uri = URI.create(url);
TransportClient transportClient = new TransportClient(uri);
transportClient.connect();
} else {
JSONObject ping = new JSONObject();
ping.put("msg", "ping");
TransportWorker.send(ping);
}
}
}

0 comments on commit 77ad74f

Please sign in to comment.