-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JunitTestSample and generate code coverage report(#137)
- Loading branch information
Showing
26 changed files
with
571 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
|
||
import java.io.File; | ||
|
||
@Service | ||
@Data | ||
@Slf4j | ||
public class MetricUtil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
server: | ||
port: 8886 | ||
|
||
spring: | ||
application: | ||
name: ${app.registry.name:device-network-agent} | ||
output: | ||
ansi: | ||
enabled: always | ||
servlet: | ||
multipart: | ||
max-file-size: 1024MB | ||
max-request-size: 2048MB | ||
datasource: | ||
url: jdbc:sqlite:${app.location}/hydra_lab_agent_db.sqlite | ||
username: sqlite | ||
password: 98765432 | ||
driver-class-name: org.sqlite.JDBC | ||
hikari: | ||
maximum-pool-size: 1 | ||
jpa: | ||
database-platform: org.sqlite.hibernate.dialect.SQLiteDialect | ||
show-sql: false | ||
hibernate: | ||
dialect: org.sqlite.hibernate.dialect.SQLiteDialect | ||
ddl-auto: update | ||
properties: | ||
hibernate: | ||
format_sql: false | ||
order_inserts: true | ||
order_updates: true | ||
jdbc: | ||
batch_size: 400 | ||
batch_versioned_data: true | ||
|
||
logging: | ||
config: classpath:logback-common.xml | ||
level: | ||
org.hibernate.SQL: INFO | ||
|
||
app: | ||
# register to Hydra Lab Center | ||
registry: | ||
# The url of Hydra Lab Center. If nginx enabled, switch to port of nginx | ||
server: "localhost:9886" | ||
# The Agent info registered in Hydra Lab Center | ||
id: ${AGENT_ID} | ||
secret: ${AGENT_SECRET} | ||
name: ${AGENT_NAME:default} | ||
# Agent Type {1 : 1*WINDOWS + n*ANDROIDS , 2 : 1*WINDOWS+1*ANDROID , 3 : iOS} | ||
agent-type: ${AGENT_TYPE:1} | ||
# config Azure Blob | ||
blob: | ||
connection: ${BLOB_CONNECTION_STR:@null} | ||
fileLimitDay: 6 | ||
CDNUrl: ${CDN_URL:} | ||
# Device Stability Monitor Configuration | ||
device: | ||
state-change: | ||
count-threshold: ${STATE_CHANGE_COUNT_THRESHOLD:12} | ||
window-time: ${STATE_CHANGE_WINDOW_TIME:5} | ||
recovery-time: ${STATE_RECOVERY_TIME:3} | ||
location: ${user.dir} | ||
# Prometheus Configuration | ||
management: | ||
endpoints: | ||
web: | ||
exposure: | ||
include: prometheus | ||
health: | ||
show-details: always | ||
metrics: | ||
tags: | ||
application: ${spring.application.name} | ||
metrics: | ||
export: | ||
prometheus: | ||
pushgateway: | ||
base-url: ${app.registry.server}/prometheus/pushgateway | ||
enabled: false | ||
job: ${spring.application.name} | ||
push-rate: 10s |
46 changes: 46 additions & 0 deletions
46
agent/src/test/java/com/microsoft/hydralab/agent/service/DeviceControlServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.microsoft.hydralab.agent.service; | ||
|
||
import com.microsoft.hydralab.agent.runner.espresso.EspressoRunner; | ||
import com.microsoft.hydralab.agent.test.BaseTest; | ||
import com.microsoft.hydralab.common.entity.center.TestTaskSpec; | ||
import com.microsoft.hydralab.common.entity.common.TestTask; | ||
import com.microsoft.hydralab.common.management.DeviceManager; | ||
import com.microsoft.hydralab.common.management.impl.AndroidDeviceManager; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
import javax.annotation.Resource; | ||
|
||
public class DeviceControlServiceTest extends BaseTest { | ||
|
||
@Resource | ||
DeviceControlService deviceControlService; | ||
@Resource | ||
DeviceManager deviceManager; | ||
@MockBean | ||
EspressoRunner espressoRunner; | ||
|
||
|
||
@Test | ||
public void getAllConnectedDevice() { | ||
|
||
} | ||
|
||
@Test | ||
public void cancelTestTaskById() { | ||
} | ||
|
||
@Test | ||
public void runTestTask() { | ||
TestTaskSpec taskSpec = new TestTaskSpec(); | ||
taskSpec.runningType = TestTask.TestRunningType.INSTRUMENTATION; | ||
TestTask testTask = deviceControlService.runTestTask(taskSpec); | ||
} | ||
|
||
@Test | ||
public void getDeviceManager() { | ||
baseLogger.info(String.valueOf(deviceManager instanceof AndroidDeviceManager)); | ||
Assertions.assertTrue(deviceManager instanceof AndroidDeviceManager, "Init DeviceManager Bean Error!"); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
agent/src/test/java/com/microsoft/hydralab/agent/test/BaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
package com.microsoft.hydralab.agent.test; | ||
|
||
import com.microsoft.hydralab.agent.service.AgentWebSocketClientService; | ||
import com.microsoft.hydralab.agent.socket.AgentWebSocketClient; | ||
import com.microsoft.hydralab.agent.util.MetricUtil; | ||
import com.microsoft.hydralab.common.util.blob.BlobStorageClient; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.annotation.Rollback; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
/** | ||
* @author zhoule | ||
* @date 11/10/2022 | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ExtendWith(SpringExtension.class) | ||
@ActiveProfiles("test") | ||
@Transactional | ||
@Rollback | ||
@Disabled | ||
public class BaseTest { | ||
protected Logger baseLogger = LoggerFactory.getLogger(BaseTest.class); | ||
@MockBean | ||
BlobStorageClient blobStorageClient; | ||
@MockBean | ||
AgentWebSocketClient AgentWebSocketClient; | ||
@MockBean | ||
AgentWebSocketClientService agentWebSocketClientService; | ||
@MockBean | ||
@Qualifier("getMetricUtil") | ||
MetricUtil metricUtil; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
server: | ||
port: 9886 | ||
compression: | ||
enabled: true | ||
min-response-size: 102400 | ||
spring: | ||
application: | ||
name: device-network-center | ||
output: | ||
ansi: | ||
enabled: always | ||
servlet: | ||
multipart: | ||
max-file-size: 1024MB | ||
max-request-size: 2048MB | ||
datasource: | ||
url: jdbc:sqlite:hydra_lab_center_db.sqlite | ||
username: sqlite | ||
password: 98765432 | ||
driver-class-name: org.sqlite.JDBC | ||
jpa: | ||
database-platform: org.sqlite.hibernate.dialect.SQLiteDialect | ||
show-sql: false | ||
hibernate: | ||
dialect: org.sqlite.hibernate.dialect.SQLiteDialect | ||
ddl-auto: update | ||
properties: | ||
hibernate: | ||
format_sql: false | ||
order_inserts: true | ||
order_updates: true | ||
jdbc: | ||
batch_size: 400 | ||
batch_versioned_data: true | ||
security: | ||
oauth2: | ||
enabled: false | ||
|
||
# log file split | ||
logging: | ||
config: classpath:logback-common.xml | ||
level: | ||
org.hibernate.SQL: INFO | ||
|
||
app: | ||
access-token-limit: 2 | ||
# Mail Address Format | ||
default-user: '[email protected]' | ||
blob: | ||
connection: '' | ||
fileLimitDay: 6 | ||
CDNUrl: ${CDN_URL:@null} | ||
SASExpiryTimeFont: ${BLOB_SAS_EXPIRY_FONT:120} | ||
SASExpiryTimeAgent: ${BLOB_SAS_EXPIRY_AGENT:120} | ||
SASExpiryUpdate: ${BLOB_SAS_EXPIRY_UPDATE:10} | ||
|
||
management: | ||
endpoints: | ||
web: | ||
exposure: | ||
include: prometheus | ||
health: | ||
show-details: always | ||
metrics: | ||
tags: | ||
application: ${spring.application.name} | ||
metrics: | ||
export: | ||
prometheus: | ||
pushgateway: | ||
enabled: ${PUSHGATEWAY_ENABLED:false} | ||
base-url: http://localhost:9091 | ||
job: ${spring.application.name} | ||
push-rate: 10s |
Oops, something went wrong.