This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 47b253df2 [CI] Fix flaky e2e test (#3781)
47b253df2 is described below
commit 47b253df23b13f5a5b9570b0a45a989ee32cb454
Author: xiangzihao <[email protected]>
AuthorDate: Wed Jun 19 18:03:23 2024 +0800
[CI] Fix flaky e2e test (#3781)
* fix flaky e2e test
---
.../e2e/pages/apacheflink/FlinkHomePage.java | 13 +++++------
.../apacheflink/applications/ApplicationForm.java | 3 ++-
.../apacheflink/applications/ApplicationsPage.java | 9 +++++++-
.../streampark/e2e/pages/common/Constants.java | 27 ++++++++++++++++++++++
.../streampark/e2e/pages/common/NavBarPage.java | 4 ++--
5 files changed, 45 insertions(+), 11 deletions(-)
diff --git
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/FlinkHomePage.java
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/FlinkHomePage.java
index 261a1424c..a80d99b5b 100644
---
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/FlinkHomePage.java
+++
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/FlinkHomePage.java
@@ -21,8 +21,6 @@ package org.apache.streampark.e2e.pages.apacheflink;
import lombok.Getter;
import org.apache.streampark.e2e.pages.common.NavBarPage;
-import org.apache.streampark.e2e.pages.system.entity.UserManagementStatus;
-import org.apache.streampark.e2e.pages.system.entity.UserManagementUserType;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
@@ -62,7 +60,7 @@ public class FlinkHomePage extends NavBarPage implements
ApacheFlinkPage.Tab {
createFlinkHomeForm.inputDescription().sendKeys(description);
createFlinkHomeForm.buttonSubmit().click();
- waitForClickFinish();
+ waitForClickFinish("create successful");
return this;
}
@@ -83,7 +81,7 @@ public class FlinkHomePage extends NavBarPage implements
ApacheFlinkPage.Tab {
createFlinkHomeForm.inputFlinkName().sendKeys(newFlinkName);
createFlinkHomeForm.buttonSubmit().click();
- waitForClickFinish();
+ waitForClickFinish("update successful");
return this;
}
@@ -101,7 +99,7 @@ public class FlinkHomePage extends NavBarPage implements
ApacheFlinkPage.Tab {
deleteConfirmButton.click();
- waitForClickFinish();
+ waitForClickFinish("flink home is removed");
return this;
}
@@ -109,8 +107,9 @@ public class FlinkHomePage extends NavBarPage implements
ApacheFlinkPage.Tab {
new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.urlContains("/flink/home"));
}
- private void waitForClickFinish() {
- new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(buttonCreateFlinkHome));
+ private void waitForClickFinish(String message) {
+ new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format("//*[contains(text(),'%s')]",
message))));
+ new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format("//*[contains(text(),'%s')]",
message))));
}
@Getter
diff --git
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationForm.java
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationForm.java
index 217e0c307..131bef903 100644
---
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationForm.java
+++
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationForm.java
@@ -22,6 +22,7 @@ package
org.apache.streampark.e2e.pages.apacheflink.applications;
import lombok.Getter;
import lombok.SneakyThrows;
import
org.apache.streampark.e2e.pages.apacheflink.applications.entity.ApplicationsDynamicParams;
+import org.apache.streampark.e2e.pages.common.Constants;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
@@ -78,7 +79,7 @@ public final class ApplicationForm {
String applicationName,
String flinkVersion,
ApplicationsDynamicParams
applicationsDynamicParams) {
- Thread.sleep(1000);
+ Thread.sleep(Constants.DEFAULT_SLEEP_SECONDS);
new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(buttonDevelopmentModeDropdown));
buttonDevelopmentModeDropdown.click();
new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfAllElements(selectDevelopmentMode));
diff --git
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationsPage.java
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationsPage.java
index 17a24be36..c516ff87f 100644
---
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationsPage.java
+++
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/apacheflink/applications/ApplicationsPage.java
@@ -20,7 +20,9 @@
package org.apache.streampark.e2e.pages.apacheflink.applications;
import lombok.Getter;
+import lombok.SneakyThrows;
import org.apache.streampark.e2e.pages.apacheflink.ApacheFlinkPage;
+import org.apache.streampark.e2e.pages.common.Constants;
import org.apache.streampark.e2e.pages.common.NavBarPage;
import org.apache.streampark.e2e.pages.system.entity.UserManagementStatus;
import org.apache.streampark.e2e.pages.system.entity.UserManagementUserType;
@@ -102,9 +104,14 @@ public class ApplicationsPage extends NavBarPage
implements ApacheFlinkPage.Tab
.orElseThrow(() -> new RuntimeException("No start button in
applications list"))
.click();
- new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(startJobForm().radioFromSavepoint()));
+ String startJobFormMessage = "Start Job";
+ new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format("//*[contains(.,'%s')]",
startJobFormMessage))));
+ new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(startJobForm.radioFromSavepoint()));
startJobForm.radioFromSavepoint().click();
startJobForm.buttonSubmit().click();
+ String startPopUpMessage = "The current job is starting";
+ new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format("//*[contains(text(),'%s')]",
startPopUpMessage))));
+ new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format("//*[contains(text(),'%s')]",
startPopUpMessage))));
return this;
}
diff --git
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/Constants.java
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/Constants.java
new file mode 100644
index 000000000..5d3fd13bd
--- /dev/null
+++
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/Constants.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to Apache Software Foundation (ASF) under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Apache Software Foundation (ASF) licenses this file to you 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.apache.streampark.e2e.pages.common;
+
+import lombok.experimental.UtilityClass;
+
+@UtilityClass
+public class Constants {
+ public static final Integer DEFAULT_SLEEP_SECONDS = 1000;
+}
diff --git
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/NavBarPage.java
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/NavBarPage.java
index 36f0a178a..f7ebde03b 100644
---
a/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/NavBarPage.java
+++
b/streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/common/NavBarPage.java
@@ -59,7 +59,7 @@ public class NavBarPage {
public <T extends NavBarItem> T goToNav(Class<T> nav) {
if (nav == ApacheFlinkPage.class) {
new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(apacheFlinkTab));
- String tabOpenStateXpath = "//span[contains(@class, 'ml-2') and
contains(@class, 'streampark-simple-menu-sub-title') and contains(text(),
'Apache Flink')]/../../li[contains(@class, 'streampark-menu-opened')]";
+ String tabOpenStateXpath = "//span[contains(@class, 'ml-2') and
contains(@class, 'streampark-simple-menu-sub-title') and contains(text(),
'Apache Flink')]/../parent::li[contains(@class, 'streampark-menu-opened')]";
if (driver.findElements(By.xpath(tabOpenStateXpath)).isEmpty()) {
apacheFlinkTab.click();
}
@@ -68,7 +68,7 @@ public class NavBarPage {
if (nav == SystemPage.class) {
new WebDriverWait(driver,
Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(systemTab));
- String tabOpenStateXpath = "//span[contains(@class, 'ml-2') and
contains(@class, 'streampark-simple-menu-sub-title') and contains(text(),
'System')]/../../li[contains(@class, 'streampark-menu-opened')]";
+ String tabOpenStateXpath = "//span[contains(@class, 'ml-2') and
contains(@class, 'streampark-simple-menu-sub-title') and contains(text(),
'System')]/../parent::li[contains(@class, 'streampark-menu-opened')]";
if (driver.findElements(By.xpath(tabOpenStateXpath)).isEmpty()) {
systemTab.click();
}