From a2ee6b59472e1124b1fcbf5d35fe41f003012783 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Mon, 27 May 2024 08:21:14 -0400 Subject: [PATCH 1/4] When clicking on the Liberty Tool window try three times Signed-off-by: Paul Gooderham --- .github/workflows/build.yaml | 5 ++-- .../it/SingleModJakartaLSTestCommon.java | 5 ++-- .../it/SingleModLibertyLSTestCommon.java | 5 ++-- .../intellij/it/SingleModMPLSTestCommon.java | 5 ++-- .../it/SingleModMPProjectTestCommon.java | 4 +-- .../it/SingleModNLTRestProjectTestCommon.java | 1 + .../tools/intellij/it/UIBotTestUtils.java | 27 ++++++++++++++++--- 7 files changed, 35 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6abd261a1..20d6a5c88 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,7 +5,7 @@ on: push: branches: '**' pull_request: - branches: [ main, code-action-unification-2 ] + branches: [ main ] jobs: build: @@ -69,5 +69,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ matrix.reportName }} - path: | - liberty-tools-intellij/build/reports/ + path: liberty-tools-intellij/build/reports/ diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index d3183ad82..d2e4a393e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -178,11 +178,10 @@ public static void prepareEnv(String projectPath, String projectName) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.openLibertyToolWindow(remoteRobot); - UIBotTestUtils.validateImportedProjectShowsInLTW(remoteRobot, projectName); + UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.closeLibertyToolWindow(remoteRobot); - UIBotTestUtils.waitForIndexing(remoteRobot); // pre-open project tree before attempting to open files needed by testcases ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 0629fedcc..0e3114b18 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -389,11 +389,10 @@ public static void prepareEnv(String projectPath, String projectName) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.openLibertyToolWindow(remoteRobot); - UIBotTestUtils.validateImportedProjectShowsInLTW(remoteRobot, projectName); + UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.closeLibertyToolWindow(remoteRobot); - UIBotTestUtils.waitForIndexing(remoteRobot); // get a JTreeFixture reference to the file project viewer entry ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 8bbec665e..029d002c4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -309,15 +309,14 @@ public static void prepareEnv(String projectPath, String projectName) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.openLibertyToolWindow(remoteRobot); - UIBotTestUtils.validateImportedProjectShowsInLTW(remoteRobot, projectName); + UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.closeLibertyToolWindow(remoteRobot); // pre-open project tree before attempting to open files needed by testcases ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health"); UIBotTestUtils.openFile(remoteRobot, projectName, "microprofile-config.properties", projectName, "src", "main", "resources", "META-INF"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index 339893a6a..bbabccbd8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -906,9 +906,9 @@ public static void prepareEnv(String projectPath, String projectName) { waitForIgnoringError(Duration.ofMinutes(4), Duration.ofSeconds(5), "Wait for IDE to start", "IDE did not start", () -> remoteRobot.callJs("true")); remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.openLibertyToolWindow(remoteRobot); - UIBotTestUtils.validateImportedProjectShowsInLTW(remoteRobot, projectName); + UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.expandLibertyToolWindowProjectTree(remoteRobot, projectName); // Close all open editors. diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 3dd1e67fa..38643b2e2 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -225,6 +225,7 @@ public static void prepareEnv(String projectPath, String projectName) { waitForIgnoringError(Duration.ofMinutes(4), Duration.ofSeconds(5), "Wait for IDE to start", "IDE did not start", () -> remoteRobot.callJs("true")); remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); UIBotTestUtils.openLibertyToolWindow(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index c5a88d2eb..b968a5ef0 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -361,9 +361,10 @@ public static RemoteText findProjectInLibertyToolWindow(RemoteRobot remoteRobot, * @param remoteRobot The RemoteRobot instance. * @param treeItem The name of tree item to look for. */ - public static void validateImportedProjectShowsInLTW(RemoteRobot remoteRobot, String treeItem) { + public static boolean validateImportedProjectShowsInLTW(RemoteRobot remoteRobot, String treeItem) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + // The following comment refers to indexing but more recent changes wait for indexing to stop // There is a window between which the Liberty tool window content may show // and suddenly disappear when indexing starts. It is not known when indexing may start. // It can be immediate or take a few seconds (10+). Wait a bit for it to start. @@ -374,13 +375,14 @@ public static void validateImportedProjectShowsInLTW(RemoteRobot remoteRobot, St // that the project is displayed in the Liberty tool window. } - // Wait for the project to appear in the Liberty tool window. Indexing is a long process right now. - ComponentFixture treeFixture = projectFrame.getTree("LibertyTree", treeItem, "600"); + // Wait for the project to appear in the Liberty tool window. This line is sensitive to indexing and depends on the code that waits for indexing before continuing. + ComponentFixture treeFixture = projectFrame.getTree("LibertyTree", treeItem, "10"); RepeatUtilsKt.waitFor(Duration.ofSeconds(10), Duration.ofSeconds(2), "Waiting for tree item" + treeItem + " to show in the Liberty tool window.", "Tree item " + treeItem + " did not show in Liberty tool window.", treeFixture::isShowing); + return treeFixture.isShowing(); } /** @@ -392,6 +394,25 @@ public static void validateProjectFrameClosed(RemoteRobot remoteRobot) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); } + /** + * Open and validate the Liberty tool window is open + */ + public static void openAndValidateLibertyToolWindow(RemoteRobot remoteRobot, String treeItem) { + // Try multiple times in case the O/S is displaying a modal dialog that blocks the button. + for (int i = 1; i <=3; i++) { + try { + UIBotTestUtils.openLibertyToolWindow(remoteRobot); + if (UIBotTestUtils.validateImportedProjectShowsInLTW(remoteRobot, treeItem)) { + break; + } + } catch (Exception e) { + // Any of the operations above could end up in an exception if the element is + // not found etc. Wait and retry. + } + TestUtils.sleepAndIgnoreException(3); + } + } + /** * Opens the Liberty tool window if it is not already open. * From 95c8a025dcde54be952006fe170e5d739634fa26 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Wed, 21 Aug 2024 18:22:20 -0400 Subject: [PATCH 2/4] Extend time waiting for indexing to start to 1 min Signed-off-by: Paul Gooderham --- .../java/io/openliberty/tools/intellij/it/UIBotTestUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index b968a5ef0..aa2b73e1d 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -1789,7 +1789,7 @@ public static void waitForLTWTextAreaMessage(RemoteRobot remoteRobot, String mes */ public static void waitForIndexing(RemoteRobot remoteRobot) { String xPath = "//div[@class='InlineProgressPanel']"; - boolean needToWait = waitForIndexingToStart(remoteRobot, xPath, 5); + boolean needToWait = waitForIndexingToStart(remoteRobot, xPath, 60); if (needToWait) { waitForIndexingToStop(remoteRobot, xPath, 600); } From a581f5ba1b496c532706deeb8c351ce7ef672d9e Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Thu, 22 Aug 2024 14:28:04 -0400 Subject: [PATCH 3/4] Move wait for indexing after open project view Signed-off-by: Paul Gooderham --- .../tools/intellij/it/SingleModJakartaLSTestCommon.java | 3 ++- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 3 ++- .../openliberty/tools/intellij/it/SingleModMPLSTestCommon.java | 3 ++- .../tools/intellij/it/SingleModMPProjectTestCommon.java | 3 ++- .../tools/intellij/it/SingleModNLTRestProjectTestCommon.java | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index d2e4a393e..7768d5c47 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -178,8 +178,9 @@ public static void prepareEnv(String projectPath, String projectName) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); - UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); + // IntelliJ does not start building and indexing until the project is open in the UI + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.closeLibertyToolWindow(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 0e3114b18..999c9f5c9 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -389,8 +389,9 @@ public static void prepareEnv(String projectPath, String projectName) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); - UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); + // IntelliJ does not start building and indexing until the project is open in the UI + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.closeLibertyToolWindow(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 029d002c4..6263fc79f 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -309,8 +309,9 @@ public static void prepareEnv(String projectPath, String projectName) { remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); - UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); + // IntelliJ does not start building and indexing until the project is open in the UI + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.closeLibertyToolWindow(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index bbabccbd8..8b75a27ba 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -906,8 +906,9 @@ public static void prepareEnv(String projectPath, String projectName) { waitForIgnoringError(Duration.ofMinutes(4), Duration.ofSeconds(5), "Wait for IDE to start", "IDE did not start", () -> remoteRobot.callJs("true")); remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); - UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); + // IntelliJ does not start building and indexing until the project is open in the UI + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); UIBotTestUtils.expandLibertyToolWindowProjectTree(remoteRobot, projectName); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 38643b2e2..e0f812aee 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -225,8 +225,9 @@ public static void prepareEnv(String projectPath, String projectName) { waitForIgnoringError(Duration.ofMinutes(4), Duration.ofSeconds(5), "Wait for IDE to start", "IDE did not start", () -> remoteRobot.callJs("true")); remoteRobot.find(WelcomeFrameFixture.class, Duration.ofMinutes(2)); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); - UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openProjectView(remoteRobot); + // IntelliJ does not start building and indexing until the project is open in the UI + UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openLibertyToolWindow(remoteRobot); // Wait for indexing to complete. Once indexing completes and Liberty Tools to take control From a8778a4547571a7998ce765ace4e79e3e4ba6bd4 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Fri, 23 Aug 2024 17:22:39 -0400 Subject: [PATCH 4/4] Add Entry/Exit logging, increase some timeouts Signed-off-by: Paul Gooderham --- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 1 + .../io/openliberty/tools/intellij/it/UIBotTestUtils.java | 6 +++++- .../tools/intellij/it/fixtures/ProjectFrameFixture.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 999c9f5c9..906afc9ed 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -141,6 +141,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); + TestUtils.sleepAndIgnoreException(2); // wait for editor to update Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml"); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index aa2b73e1d..3c5c61581 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -467,6 +467,7 @@ public static void closeLibertyToolWindow(RemoteRobot remoteRobot) { * @param remoteRobot The RemoteRobot instance. */ public static void openProjectView(RemoteRobot remoteRobot) { + TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "UIBotTestUtils.openProjectView Entry"); int maxRetries = 6; Exception error = null; for (int i = 0; i < maxRetries; i++) { @@ -492,6 +493,7 @@ public static void openProjectView(RemoteRobot remoteRobot) { if (error != null) { throw new RuntimeException("Unable to open the project tool window.", error); } + TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "UIBotTestUtils.openProjectView Exit"); } /** @@ -1788,11 +1790,13 @@ public static void waitForLTWTextAreaMessage(RemoteRobot remoteRobot, String mes * Look for the indexing message and if it is found wait up to 10 minutes for it to stop. */ public static void waitForIndexing(RemoteRobot remoteRobot) { + TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "UIBotTestUtils.waitForIndexing Entry"); String xPath = "//div[@class='InlineProgressPanel']"; boolean needToWait = waitForIndexingToStart(remoteRobot, xPath, 60); if (needToWait) { waitForIndexingToStop(remoteRobot, xPath, 600); } + TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "UIBotTestUtils.waitForIndexing Exit"); } /** @@ -2286,7 +2290,7 @@ public static void stopDebugger(RemoteRobot remoteRobot) { } Locator locator = byXpath("//div[contains(@myvisibleactions, 'Get')]//div[contains(@myaction.key, 'action.Stop.text')]"); - ActionButtonFixture stopButton = projectFrame.actionButton(locator, Duration.ofSeconds(5)); + ActionButtonFixture stopButton = projectFrame.actionButton(locator, Duration.ofSeconds(60)); stopButton.click(); } diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index 5aaefb97c..2416c2fef 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -76,7 +76,7 @@ public ComponentFixture getActionMenu(String... xpathVars) { */ public ComponentFixture getActionMenuItem(String... xpathVars) { String text = xpathVars[0]; - RepeatUtilsKt.waitFor(Duration.ofSeconds(10), + RepeatUtilsKt.waitFor(Duration.ofSeconds(16), Duration.ofSeconds(1), "Waiting for menu items containing the " + text + " text", "Menu items containing the " + text + " text were not found",