Skip to content

Commit

Permalink
Merge pull request #1121 from minurajeeve/bug-fix-for-log-viewer-feature
Browse files Browse the repository at this point in the history
[CDAP-20843] Bug fix for log viewer e2e tests
  • Loading branch information
minurajeeve authored Oct 16, 2023
2 parents 1b4457c + 000c283 commit b5e61b6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
18 changes: 16 additions & 2 deletions src/e2e-test/features/logviewer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
@Integration_Tests
Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Deploy and run pipeline till complete
Background: Deploy and run pipeline
When Deploy and test pipeline "logs_generator" with timestamp with pipeline JSON file "logs_generator.json"
Then Run the pipeline
Then Deployed pipeline status is "Running"

@LOGVIEWER_TEST
Scenario: Deploy and run pipeline till complete
Then Deployed pipeline status is "Succeeded"

@LOGVIEWER_TEST
Scenario: Log viewer should show
Then Click on log viewer button
Expand All @@ -35,6 +38,7 @@ Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Log level popover should work
Then Click on log viewer button
Then Click on log level toggle
Then Log level "ERROR" should exist
Then Log level "WARN" should exist
Expand All @@ -50,6 +54,7 @@ Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Log viewer content should contain correct information
Then Click on log viewer button
Then Log viewer content should contain message "is started by user"
Then Log viewer content should not contain message "This is a WARN"
Then Click on advanced logs
Expand All @@ -61,12 +66,21 @@ Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Log viewer should fetch next logs when scroll to bottom
Then Click on log viewer button
Then Click on advanced logs
Then Click on log level toggle
Then Click on log level "TRACE"
Then Scroll up to center
Then Scroll to latest should be enabled
Then Debug message should update

@LOGVIEWER_TEST
Scenario: Log viewer should fetch previous logs when scroll to top
Then Deployed pipeline status is "Succeeded"
Then Click on log viewer button
Then Click on advanced logs
Then Click on log level toggle
Then Click on log level "TRACE"
Then Scroll up to center
Then Click on scroll to latest button
Then Previous logs should show
13 changes: 13 additions & 0 deletions src/e2e-test/java/io/cdap/cdap/ui/stepsdesign/Logviewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;

import java.util.List;

Expand Down Expand Up @@ -170,6 +172,17 @@ public void scrollUpToCenter() {
WebElement element = Helper.locateElementByCssSelector(
Helper.getCssSelectorByDataTestId("log-viewer-content")
);

SeleniumDriver.getWaitDriver().until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
Integer scrollHeight = Integer.valueOf(element.getDomProperty("scrollHeight"));
String heightInPixels = element.getCssValue("height");
Integer height = Integer.valueOf(heightInPixels.substring(0, heightInPixels.length() - 2));

return scrollHeight > height + 50;
}});

js.executeScript("arguments[0].scrollBy(0, -1500);", element);
Commands.waitForLoading();
}
Expand Down
8 changes: 5 additions & 3 deletions src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ public static JsonObject getPipelineStageJson(String stageName) {

public static void waitForLoading() {
if (Helper.isElementExists(Helper.getCssSelectorByDataTestId("loading-indicator"))) {
WaitHelper.waitForElementToBeHidden(
Helper.locateElementByCssSelector(Helper.getCssSelectorByDataTestId("loading-indicator"))
);
try {
WaitHelper.waitForElementToBeHidden(
Helper.locateElementByCssSelector(Helper.getCssSelectorByDataTestId("loading-indicator"))
);
} catch (Exception e) { }
}
}
}

0 comments on commit b5e61b6

Please sign in to comment.