merge listeners, rm suites from all.xml
This commit is contained in:
parent
79fa735c46
commit
ad895876f0
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright © 2016-2022 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.msa;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface DisableUIListeners {
|
||||
|
||||
}
|
||||
|
||||
@ -16,18 +16,22 @@
|
||||
package org.thingsboard.server.msa;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.testng.ITestContext;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.testng.ITestListener;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.TestListenerAdapter;
|
||||
import org.testng.internal.ConstructorOrMethod;
|
||||
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
|
||||
|
||||
import static org.testng.internal.Utils.log;
|
||||
import static org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest.captureScreen;
|
||||
|
||||
@Slf4j
|
||||
public class TestListener extends TestListenerAdapter {
|
||||
public class TestListener implements ITestListener {
|
||||
|
||||
WebDriver driver;
|
||||
|
||||
@Override
|
||||
public void onTestStart(ITestResult result) {
|
||||
super.onTestStart(result);
|
||||
log.info("===>>> Test started: " + result.getName());
|
||||
}
|
||||
|
||||
@ -36,10 +40,14 @@ public class TestListener extends TestListenerAdapter {
|
||||
*/
|
||||
@Override
|
||||
public void onTestSuccess(ITestResult result) {
|
||||
super.onTestSuccess(result);
|
||||
if (result != null) {
|
||||
log.info("<<<=== Test completed successfully: " + result.getName());
|
||||
log.info("<<<=== Test completed successfully: " + result.getName());
|
||||
ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod();
|
||||
DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class);
|
||||
if (disable != null) {
|
||||
return;
|
||||
}
|
||||
driver = ((AbstractDriverBaseTest) result.getInstance()).getDriver();
|
||||
captureScreen(driver, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +55,28 @@ public class TestListener extends TestListenerAdapter {
|
||||
*/
|
||||
@Override
|
||||
public void onTestFailure(ITestResult result) {
|
||||
super.onTestFailure(result);
|
||||
log.info("<<<=== Test failed: " + result.getName());
|
||||
ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod();
|
||||
DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class);
|
||||
if (disable != null) {
|
||||
return;
|
||||
}
|
||||
driver = ((AbstractDriverBaseTest) result.getInstance()).getDriver();
|
||||
captureScreen(driver, "failure");
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a test skipped
|
||||
*/
|
||||
@Override
|
||||
public void onTestSkipped(ITestResult result) {
|
||||
log.info("<<<=== Test skipped: " + result.getName());
|
||||
ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod();
|
||||
DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class);
|
||||
if (disable != null) {
|
||||
return;
|
||||
}
|
||||
driver = ((AbstractDriverBaseTest) result.getInstance()).getDriver();
|
||||
captureScreen(driver, "skipped");
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ package org.thingsboard.server.msa.connectivity;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@ -29,11 +28,13 @@ import org.thingsboard.server.common.data.DeviceProfileProvisionType;
|
||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||
import org.thingsboard.server.common.msg.session.FeatureType;
|
||||
import org.thingsboard.server.msa.AbstractContainerTest;
|
||||
import org.thingsboard.server.msa.DisableUIListeners;
|
||||
import org.thingsboard.server.msa.TestCoapClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultDevicePrototype;
|
||||
|
||||
@DisableUIListeners
|
||||
public class CoapClientTest extends AbstractContainerTest {
|
||||
private TestCoapClient client;
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ import org.thingsboard.server.common.data.DeviceProfile;
|
||||
import org.thingsboard.server.common.data.DeviceProfileProvisionType;
|
||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||
import org.thingsboard.server.msa.AbstractContainerTest;
|
||||
import org.thingsboard.server.msa.DisableUIListeners;
|
||||
import org.thingsboard.server.msa.WsClient;
|
||||
import org.thingsboard.server.msa.mapper.WsTelemetryResponse;
|
||||
|
||||
@ -37,6 +38,7 @@ import static org.thingsboard.server.common.data.DataConstants.DEVICE;
|
||||
import static org.thingsboard.server.common.data.DataConstants.SHARED_SCOPE;
|
||||
import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultDevicePrototype;
|
||||
|
||||
@DisableUIListeners
|
||||
public class HttpClientTest extends AbstractContainerTest {
|
||||
private Device device;
|
||||
@BeforeMethod
|
||||
|
||||
@ -46,6 +46,7 @@ import org.thingsboard.server.common.data.rule.RuleChainMetaData;
|
||||
import org.thingsboard.server.common.data.rule.RuleNode;
|
||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||
import org.thingsboard.server.msa.AbstractContainerTest;
|
||||
import org.thingsboard.server.msa.DisableUIListeners;
|
||||
import org.thingsboard.server.msa.WsClient;
|
||||
import org.thingsboard.server.msa.mapper.AttributesResponse;
|
||||
import org.thingsboard.server.msa.mapper.WsTelemetryResponse;
|
||||
@ -68,6 +69,7 @@ import static org.thingsboard.server.common.data.DataConstants.DEVICE;
|
||||
import static org.thingsboard.server.common.data.DataConstants.SHARED_SCOPE;
|
||||
import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultDevicePrototype;
|
||||
|
||||
@DisableUIListeners
|
||||
@Slf4j
|
||||
public class MqttClientTest extends AbstractContainerTest {
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ import org.thingsboard.server.common.data.relation.EntityRelation;
|
||||
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||
import org.thingsboard.server.msa.AbstractContainerTest;
|
||||
import org.thingsboard.server.msa.DisableUIListeners;
|
||||
import org.thingsboard.server.msa.WsClient;
|
||||
import org.thingsboard.server.msa.mapper.WsTelemetryResponse;
|
||||
|
||||
@ -66,6 +67,7 @@ import static org.thingsboard.server.common.data.DataConstants.DEVICE;
|
||||
import static org.thingsboard.server.common.data.DataConstants.SHARED_SCOPE;
|
||||
import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultGatewayPrototype;
|
||||
|
||||
@DisableUIListeners
|
||||
@Slf4j
|
||||
public class MqttGatewayClientTest extends AbstractContainerTest {
|
||||
private Device gatewayDevice;
|
||||
|
||||
@ -34,14 +34,11 @@ import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||
import org.thingsboard.server.msa.AbstractContainerTest;
|
||||
import org.thingsboard.server.msa.ContainerTestSuite;
|
||||
import org.thingsboard.server.msa.ui.listeners.TestListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
@ -51,7 +48,6 @@ import java.util.stream.Collectors;
|
||||
import static org.thingsboard.server.msa.TestProperties.getBaseUiUrl;
|
||||
|
||||
@Slf4j
|
||||
@Listeners(TestListener.class)
|
||||
abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
|
||||
protected WebDriver driver;
|
||||
@ -65,7 +61,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
@SneakyThrows
|
||||
@BeforeMethod
|
||||
public void openBrowser() {
|
||||
log.info("*----------------------* Setup driver *----------------------*");
|
||||
log.info("===>>> Setup driver");
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.setAcceptInsecureCerts(true);
|
||||
if (instance.isActive()) {
|
||||
@ -81,7 +77,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
|
||||
@AfterMethod
|
||||
public void closeBrowser() {
|
||||
log.info("*----------------------* Teardown *----------------------*");
|
||||
log.info("<<<=== Teardown");
|
||||
driver.quit();
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@ package org.thingsboard.server.msa.ui.listeners;
|
||||
|
||||
import org.testng.IRetryAnalyzer;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.internal.ConstructorOrMethod;
|
||||
import org.thingsboard.server.msa.DisableUIListeners;
|
||||
|
||||
public class RetryAnalyzer implements IRetryAnalyzer {
|
||||
|
||||
@ -25,6 +27,11 @@ public class RetryAnalyzer implements IRetryAnalyzer {
|
||||
|
||||
@Override
|
||||
public boolean retry(ITestResult result) {
|
||||
ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod();
|
||||
DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class);
|
||||
if (disable != null) {
|
||||
return false;
|
||||
}
|
||||
if (retryCount < MAX_RETRY_COUNT) {
|
||||
System.out.printf("Retrying test %s for the %d time(s).%n", result.getName(), retryCount + 1);
|
||||
retryCount++;
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2022 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.msa.ui.listeners;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestListener;
|
||||
import org.testng.ITestResult;
|
||||
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
|
||||
|
||||
import static org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest.captureScreen;
|
||||
|
||||
@Slf4j
|
||||
public class TestListener implements ITestListener {
|
||||
|
||||
WebDriver driver;
|
||||
|
||||
public void onTestSuccess(ITestResult tr) {
|
||||
String str = "Test " + tr.getMethod().getMethodName() + " success";
|
||||
log.info("*----------------------* " + str + " *----------------------*");
|
||||
driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver();
|
||||
captureScreen(driver, "success");
|
||||
}
|
||||
|
||||
public void onTestFailure(ITestResult tr) {
|
||||
String str = "Test " + tr.getMethod().getMethodName() + " failure";
|
||||
String str1 = "Failed because of - " + tr.getThrowable();
|
||||
log.info("*----------------------* " + str + " *----------------------*");
|
||||
log.info("*----------------------* " + str1 + " *----------------------*");
|
||||
driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver();
|
||||
captureScreen(driver, "failure");
|
||||
}
|
||||
|
||||
public void onTestSkipped(ITestResult tr) {
|
||||
String str = "Test " + tr.getMethod().getMethodName() + " skipped";
|
||||
String str1 = "Skipped because of - " + tr.getThrowable();
|
||||
log.info("*----------------------* " + str + " *----------------------*");
|
||||
log.info("*----------------------* " + str1 + " *----------------------*");
|
||||
driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver();
|
||||
captureScreen(driver, "skipped");
|
||||
}
|
||||
|
||||
public void onStart(ITestContext testContext) {
|
||||
String str = "Test " + testContext.getCurrentXmlTest().getName() + " start";
|
||||
log.info("*----------------------* " + str + " *----------------------*");
|
||||
}
|
||||
|
||||
public void onFinish(ITestContext testContext) {
|
||||
String str = "Test " + testContext.getCurrentXmlTest().getName() + " finish";
|
||||
log.info("*----------------------* " + str + " *----------------------*");
|
||||
}
|
||||
}
|
||||
@ -19,8 +19,22 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="All tests">
|
||||
<suite-files>
|
||||
<suite-file path="connectivity.xml"/>
|
||||
<suite-file path="uiTests.xml"/>
|
||||
</suite-files>
|
||||
<listeners>
|
||||
<listener class-name="org.thingsboard.server.msa.ui.listeners.RetryTestListener"/>
|
||||
</listeners>
|
||||
<test verbose="2" name="Connectivity tests" preserve-order="false">
|
||||
<packages>
|
||||
<package name="org.thingsboard.server.msa.connectivity" />
|
||||
</packages>
|
||||
</test>
|
||||
<test name="Smoke rule chains tests">
|
||||
<packages>
|
||||
<package name="org.thingsboard.server.msa.ui.tests.ruleChainsSmoke"/>
|
||||
</packages>
|
||||
</test>
|
||||
<test name="Smoke customers tests">
|
||||
<packages>
|
||||
<package name="org.thingsboard.server.msa.ui.tests.customerSmoke"/>
|
||||
</packages>
|
||||
</test>
|
||||
</suite>
|
||||
Loading…
x
Reference in New Issue
Block a user