Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
run: mvn -B -e clean test -Dselenium.headless=true || true
env:
CHROME_OPTIONS: --remote-allow-origins=*;--disable-gpu;--no-sandbox;--disable-dev-shm-usage;--headless=new;--window-size=1920,1080

INFLUX_URL: ${{ secrets.INFLUX_URL }}
INFLUX_TOKEN: ${{ secrets.INFLUX_TOKEN }}
INFLUX_ORG: ${{ secrets.INFLUX_ORG }}
INFLUX_BUCKET: ${{ secrets.INFLUX_BUCKET }}
# 4. Output failed tests
- name: Print failed tests
if: failure()
Expand Down Expand Up @@ -94,3 +97,16 @@ jobs:
with:
name: allure-report
path: allure-report

# 11 Print all metrics
- name: Print test metrics summary
if: always()
run: |
mvn -q exec:java -Dexec.mainClass=utils.InfluxReader > influx-summary.txt
echo "### Test metrics from InfluxDB" >> $GITHUB_STEP_SUMMARY
cat influx-summary.txt >> $GITHUB_STEP_SUMMARY
env:
INFLUX_URL: ${{ secrets.INFLUX_URL }}
INFLUX_TOKEN: ${{ secrets.INFLUX_TOKEN }}
INFLUX_ORG: ${{ secrets.INFLUX_ORG }}
INFLUX_BUCKET: ${{ secrets.INFLUX_BUCKET }}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
<artifactId>selenide</artifactId>
<version>7.8.0</version>
</dependency>
<!-- Metrics InfluxDB from allure-report-->
<dependency>
<groupId>com.influxdb</groupId>
<artifactId>influxdb-client-java</artifactId>
<version>6.11.0</version>
</dependency>
</dependencies>

<build>
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/ui/testing/base/BasePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public WebDriver getDriver() {
return driver;
}

public WebDriverWait wait4() {
return new WebDriverWait(getDriver(), Duration.ofSeconds(4));
public WebDriverWait wait10() {
return new WebDriverWait(getDriver(), Duration.ofSeconds(10));
}
}
4 changes: 4 additions & 0 deletions src/test/java/ui/testing/base/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.asserts.SoftAssert;
import ui.testing.utils.InfluxReader;

public class BaseTest {
protected WebDriver driver;
Expand Down Expand Up @@ -36,8 +37,11 @@ public void setUp() {

@AfterMethod(alwaysRun = true)
public void tearDown() {
InfluxReader.printAllureMetrics();
if (driver != null) {
driver.quit();
}
}

}

2 changes: 1 addition & 1 deletion src/test/java/ui/testing/page/ClassAttributePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ClassAttributePage(WebDriver driver) {

public String getAlert() {
buttonPrimary.click();
wait4().until(ExpectedConditions.alertIsPresent());
wait10().until(ExpectedConditions.alertIsPresent());
Alert alert = getDriver().switchTo().alert();
String text = alert.getText();
alert.accept();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/ui/testing/page/HiddenLayersPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public HiddenLayersPage(WebDriver driver) {
public String notAllowedClickMoreThanOne() {
String message = "";
boolean clickable = true;
WebElement enableButton = wait4().until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id = 'greenButton']")));
WebElement enableButton = wait10().until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id = 'greenButton']")));
try {
enableButton.click();
message = "Green button visible and clicked. Click : ";
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/ui/testing/page/LoadDelayPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public LoadDelayPage(WebDriver driver) {
@Step("Wait until button will be presence on page")
public String confirmAppearedButton() {
WebElement btnAppeared = getDriver().findElement(By.xpath("//button[@class = 'btn btn-primary']"));
wait4().until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//button[@class = 'btn btn-primary']")));
wait10().until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//button[@class = 'btn btn-primary']")));

return btnAppeared.getText();
}
Expand Down
48 changes: 48 additions & 0 deletions src/test/java/ui/testing/utils/InfluxReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ui.testing.utils;

import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.query.FluxTable;

import java.util.List;

public class InfluxReader {

public static void printAllureMetrics() {
String url = System.getenv("INFLUX_URL");
String token = System.getenv("INFLUX_TOKEN");
String org = System.getenv("INFLUX_ORG");
String bucket = System.getenv("INFLUX_BUCKET");
// 👇 Добавь проверки
if (url == null || token == null || org == null || bucket == null) {
System.err.println("⚠️ InfluxDB environment variables are not set!");
System.err.println("Set: INFLUX_URL, INFLUX_TOKEN, INFLUX_ORG, INFLUX_BUCKET");
return;
}

try (InfluxDBClient client = InfluxDBClientFactory.create(url, token.toCharArray(), org)) {

String flux = String.format("""
from(bucket: "%s")
|> range(start: -24h)
|> filter(fn: (r) => r["_measurement"] == "allure_test")
|> group(columns: ["status"])
|> count()
""", bucket);

List<FluxTable> tables = client.getQueryApi().query(flux, org);

System.out.println("🧪 Test results from InfluxDB (last 24h):");
for (FluxTable table : tables) {
table.getRecords().forEach(rec -> {
System.out.printf("%s : %s%n",
rec.getValueByKey("status"),
rec.getValue());
});
}

} catch (Exception e) {
System.err.println("⚠️ Failed to query InfluxDB: " + e.getMessage());
}
}
}
Loading