Browse Source
Merge pull request #6415 from smatvienko-tb/test-speeup-transport-edge-develop34
[3.4] Test speed up: transport, edge
pull/6441/head
Andrew Shvayka
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with
41 additions and
1 deletions
-
application/src/test/java/org/thingsboard/server/controller/BaseEdgeControllerTest.java
-
application/src/test/java/org/thingsboard/server/controller/BaseEdgeEventControllerTest.java
-
application/src/test/java/org/thingsboard/server/controller/BaseEntityViewControllerTest.java
-
application/src/test/java/org/thingsboard/server/edge/BaseEdgeTest.java
-
application/src/test/java/org/thingsboard/server/system/BaseHttpDeviceApiTest.java
-
application/src/test/java/org/thingsboard/server/transport/coap/AbstractCoapIntegrationTest.java
-
application/src/test/java/org/thingsboard/server/transport/lwm2m/AbstractLwM2MIntegrationTest.java
-
application/src/test/java/org/thingsboard/server/transport/mqtt/AbstractMqttIntegrationTest.java
-
application/src/test/resources/application-test.properties
|
|
|
@ -23,6 +23,7 @@ import org.junit.After; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.thingsboard.server.common.data.Customer; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.EntitySubtype; |
|
|
|
@ -54,6 +55,9 @@ import static org.hamcrest.Matchers.containsString; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"edges.enabled=true", |
|
|
|
}) |
|
|
|
public abstract class BaseEdgeControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
public static final String EDGE_HOST = "localhost"; |
|
|
|
|
|
|
|
@ -22,6 +22,7 @@ import org.junit.After; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.Tenant; |
|
|
|
import org.thingsboard.server.common.data.User; |
|
|
|
@ -40,6 +41,9 @@ import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"edges.enabled=true", |
|
|
|
}) |
|
|
|
@Slf4j |
|
|
|
public abstract class BaseEdgeEventControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +27,7 @@ import org.junit.After; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.thingsboard.server.common.data.Customer; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.EntityView; |
|
|
|
@ -59,6 +60,9 @@ import static org.junit.Assert.assertTrue; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"transport.mqtt.enabled=true", |
|
|
|
}) |
|
|
|
@Slf4j |
|
|
|
public abstract class BaseEntityViewControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
|
|
|
|
@ -32,6 +32,7 @@ import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.thingsboard.common.util.JacksonUtil; |
|
|
|
import org.thingsboard.server.cluster.TbClusterService; |
|
|
|
import org.thingsboard.server.common.data.Customer; |
|
|
|
@ -131,6 +132,9 @@ import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"edges.enabled=true", |
|
|
|
}) |
|
|
|
abstract public class BaseEdgeTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
private static final String CUSTOM_DEVICE_PROFILE_NAME = "Thermostat"; |
|
|
|
|
|
|
|
@ -17,6 +17,7 @@ package org.thingsboard.server.system; |
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.springframework.test.web.servlet.ResultActions; |
|
|
|
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
@ -35,6 +36,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. |
|
|
|
/** |
|
|
|
* @author Andrew Shvayka |
|
|
|
*/ |
|
|
|
@TestPropertySource(properties = { |
|
|
|
"transport.http.enabled=true", |
|
|
|
}) |
|
|
|
public abstract class BaseHttpDeviceApiTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
private static final AtomicInteger idSeq = new AtomicInteger(new Random(System.currentTimeMillis()).nextInt()); |
|
|
|
|
|
|
|
@ -18,6 +18,7 @@ package org.thingsboard.server.transport.coap; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.eclipse.californium.core.CoapClient; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.thingsboard.server.common.data.CoapDeviceType; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
@ -49,6 +50,9 @@ import org.thingsboard.server.transport.AbstractTransportIntegrationTest; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertNotNull; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"transport.coap.enabled=true", |
|
|
|
}) |
|
|
|
@Slf4j |
|
|
|
public abstract class AbstractCoapIntegrationTest extends AbstractTransportIntegrationTest { |
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +27,7 @@ import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.test.mock.mockito.SpyBean; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.springframework.util.SocketUtils; |
|
|
|
import org.thingsboard.common.util.JacksonUtil; |
|
|
|
import org.thingsboard.common.util.ThingsBoardThreadFactory; |
|
|
|
@ -98,6 +99,9 @@ import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClient |
|
|
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType; |
|
|
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"transport.lwm2m.enabled=true", |
|
|
|
}) |
|
|
|
@Slf4j |
|
|
|
@DaoSqlTest |
|
|
|
public abstract class AbstractLwM2MIntegrationTest extends AbstractWebsocketTest { |
|
|
|
|
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.paho.client.mqttv3.MqttException; |
|
|
|
import org.eclipse.paho.client.mqttv3.MqttMessage; |
|
|
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.springframework.test.context.TestPropertySource; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
|
@ -53,6 +54,9 @@ import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertNotNull; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
|
|
|
|
@TestPropertySource(properties = { |
|
|
|
"transport.mqtt.enabled=true", |
|
|
|
}) |
|
|
|
@Slf4j |
|
|
|
public abstract class AbstractMqttIntegrationTest extends AbstractTransportIntegrationTest { |
|
|
|
|
|
|
|
|
|
|
|
@ -8,7 +8,15 @@ transport.lwm2m.security.trust-credentials.enabled=true |
|
|
|
transport.lwm2m.security.trust-credentials.type=KEYSTORE |
|
|
|
transport.lwm2m.security.trust-credentials.keystore.store_file=lwm2m/credentials/lwm2mtruststorechain.jks |
|
|
|
|
|
|
|
edges.enabled=true |
|
|
|
# Edge disabled to speed up the context init. Will be enabled by @TestPropertySource in respective tests |
|
|
|
edges.enabled=false |
|
|
|
edges.storage.no_read_records_sleep=500 |
|
|
|
edges.storage.sleep_between_batches=500 |
|
|
|
actors.rpc.sequential=true |
|
|
|
|
|
|
|
# Transports disabled to speed up the context init. Particular transport will be enabled with @TestPropertySource in respective tests |
|
|
|
transport.http.enabled=false |
|
|
|
transport.mqtt.enabled=false |
|
|
|
transport.coap.enabled=false |
|
|
|
transport.lwm2m.enabled=false |
|
|
|
transport.snmp.enabled=false |
|
|
|
|