World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#10235]fix(test): improve test stability by handling stale elements and ensuring HDFS readiness (#10240)
geyanggang709759510bdc
diff --git a/integration-test-common/docker-script/launch.sh b/integration-test-common/docker-script/launch.shindex 1cc340de29..e75d74da72 100755--- a/integration-test-common/docker-script/launch.sh+++ b/integration-test-common/docker-script/launch.sh@@ -74,5 +74,28 @@ while true; dosleep 1done+# Wait for HDFS to be fully ready+echo "Waiting for HDFS to be fully ready..."+hdfs_attempts=0+hdfs_max_attempts=60++while true; do+ # Check if HDFS DataNode is ready by testing file creation+ docker compose exec -T hive hdfs dfs -test -d / >/dev/null 2>&1 && \+ docker compose exec -T hive hdfs dfsadmin -report 2>/dev/null | grep -q "Live datanodes" && {+ echo "HDFS is ready."+ # Give HDFS a bit more time to stabilize+ sleep 5+ break;+ }++ if [ "$hdfs_attempts" -ge "$hdfs_max_attempts" ]; then+ echo "WARNING: HDFS did not become fully ready within $hdfs_max_attempts seconds, but continuing..."+ break+ fi++ ((hdfs_attempts++))+ sleep 1+doneecho "All docker compose service is now available."diff --git a/web-v2/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java b/web-v2/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.javaindex 5ea601cfd6..2b6eeaeb32 100644--- a/web-v2/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java+++ b/web-v2/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java@@ -1618,25 +1618,45 @@ public class CatalogsPage extends BaseWebIT {public boolean verifyTreeNodes(List<String> treeNodes) {WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(ACTION_SLEEP));- List<WebElement> list =- wait.until(- ExpectedConditions.visibilityOfAllElementsLocatedBy(- By.xpath(- "//div[@data-refer='tree-view']"- + "//div[@class='ant-tree-list-holder']"- + "/div/div[@class='ant-tree-list-holder-inner']"- + "/div[contains(@class, 'ant-tree-treenode')]")));- List<String> texts = new ArrayList<>();- for (WebElement webElement : list) {- String nodeName =- webElement.findElement(By.xpath(".//span[@class='ant-tree-title']")).getText();- texts.add(nodeName);- }- if (!treeNodes.containsAll(texts)) {- LOG.error("tree nodes list: {} does not containsAll treeNodes: {}", texts, treeNodes);- return false;++ // Retry logic to handle stale element references+ int maxRetries = 3;+ for (int attempt = 0; attempt < maxRetries; attempt++) {+ try {+ List<WebElement> list =+ wait.until(+ ExpectedConditions.visibilityOfAllElementsLocatedBy(+ By.xpath(+ "//div[@data-refer='tree-view']"+ + "//div[@class='ant-tree-list-holder']"+ + "/div/div[@class='ant-tree-list-holder-inner']"+ + "/div[contains(@class, 'ant-tree-treenode')]")));+ List<String> texts = new ArrayList<>();+ for (WebElement webElement : list) {+ String nodeName =+ webElement.findElement(By.xpath(".//span[@class='ant-tree-title']")).getText();+ texts.add(nodeName);+ }+ if (!treeNodes.containsAll(texts)) {+ LOG.error("tree nodes list: {} does not containsAll treeNodes: {}", texts, treeNodes);+ return false;+ }+ return true;+ } catch (org.openqa.selenium.StaleElementReferenceException e) {+ if (attempt == maxRetries - 1) {+ LOG.error(+ "Failed to verify tree nodes after {} attempts due to stale elements", maxRetries);+ throw e;+ }+ LOG.warn("Stale element encountered, retrying... (attempt {}/{})", attempt + 1, maxRetries);+ try {+ Thread.sleep(500);+ } catch (InterruptedException ie) {+ Thread.currentThread().interrupt();+ }+ }}- return true;+ return false;}public boolean verifySelectedNode(String nodeName) {