Browse Source

Merge pull request #7906 from Seraphym-Tuhai/UITests_ConfigUrl

Add guide for run tests on built UI
pull/8369/head
Andrew Shvayka 4 years ago
committed by GitHub
parent
commit
631c529b97
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      msa/black-box-tests/README.md
  2. 27
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestProperties.java
  3. 3
      msa/black-box-tests/src/test/resources/config.properties

7
msa/black-box-tests/README.md

@ -54,6 +54,7 @@ As result, in REPOSITORY column, next images should be present:
mvn clean install -DblackBoxTests.skip=false -Dsuite=all
### To run a separate test manually on a built UI:
1. Add the black-box-tests module in the [pom.xml](../pom.xml) or add as a Maven project
2. Add Vm Option "*-DrunLocal=true -Dtb.baseUiUrl=http://localhost:4200/*" in "Run" -> "Edit Configuration" -> "Edit Configuration Templates" -> "TestNG"
3. To run a specific test, go to the test class in the [UI tests package](../black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests) and run the test. Alternatively, go to the [resources](../black-box-tests/src/test/resources) in the black-box-tests module and run the test suite that you need.

27
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestProperties.java

@ -18,10 +18,6 @@ package org.thingsboard.server.msa;
import lombok.extern.slf4j.Slf4j;
import org.testcontainers.DockerClientFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@Slf4j
public class TestProperties {
@ -31,41 +27,26 @@ public class TestProperties {
private static final ContainerTestSuite instance = ContainerTestSuite.getInstance();
private static Properties properties;
public static String getBaseUrl() {
if (instance.isActive()) {
return HTTPS_URL;
}
return getProperties().getProperty("tb.baseUrl");
return System.getProperty("tb.baseUrl", "http://localhost:8080");
}
public static String getBaseUiUrl() {
if (instance.isActive()) {
//return "https://host.docker.internal" // this alternative requires docker-selenium.yml extra_hosts: - "host.docker.internal:host-gateway"
//return "https://host.docker.internal"; // this alternative requires docker-selenium.yml extra_hosts: - "host.docker.internal:host-gateway"
//return "https://" + DockerClientFactory.instance().dockerHostIpAddress(); //this alternative will get Docker IP from testcontainers
return "https://haproxy"; //communicate inside current docker-compose network to the load balancer container
}
return getProperties().getProperty("tb.baseUiUrl");
return System.getProperty("tb.baseUiUrl", "http://localhost:8080");
}
public static String getWebSocketUrl() {
if (instance.isActive()) {
return WSS_URL;
}
return getProperties().getProperty("tb.wsUrl");
}
private static Properties getProperties() {
if (properties == null) {
try (InputStream input = TestProperties.class.getClassLoader().getResourceAsStream("config.properties")) {
properties = new Properties();
properties.load(input);
} catch (IOException ex) {
log.error("Exception while reading test properties " + ex.getMessage());
}
}
return properties;
return System.getProperty("tb.wsUrl", "ws://localhost:8080");
}
}

3
msa/black-box-tests/src/test/resources/config.properties

@ -1,3 +0,0 @@
tb.baseUrl=http://localhost:8080
tb.baseUiUrl=http://localhost:8080
tb.wsUrl=ws://localhost:8080
Loading…
Cancel
Save