Skip to content

Commit

Permalink
Make E2E tests screenshots available in report on CI (#10939)
Browse files Browse the repository at this point in the history
* Make E2E tests screenshots available in report on CI

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>

* Add links to htmldumps, webdriver and workspace logs into the failsafe-report.html

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>

* Fix style for screenshot displaying in the report

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
  • Loading branch information
dmytro-ndp authored Aug 30, 2018
1 parent 2b7ebd8 commit cc06caa
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
25 changes: 22 additions & 3 deletions selenium/che-selenium-core/bin/webdriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,11 @@ generateFailSafeReport () {
done

# attach screenshots
for f in target/screenshots/*
for file in target/site/screenshots/*
do
local test=$(basename ${f} | sed 's/\(.*\)_.*/\1/')
local test=$(basename ${file} | sed 's/\(.*\)_.*/\1/')
local divTag="<div id=\""${test}"error\" style=\"display:none;\">"
local imgTag="<img src=\"..\/screenshots\/"$(basename ${f})"\">"
local imgTag="<p><img src=\"screenshots\/"$(basename ${file})"\"><p>"
sed -i "s/${divTag}/${divTag}${imgTag}/" ${FAILSAFE_REPORT}
done

Expand All @@ -824,6 +824,25 @@ generateFailSafeReport () {
echo -e "[TEST] \t${BLUE}file://${CUR_DIR}/${FAILSAFE_REPORT}${NO_COLOUR}"
echo "[TEST]"
echo "[TEST]"

attachLinkToTestReport workspace-logs
attachLinkToTestReport webdriver-logs
attachLinkToTestReport htmldumps
}

# first argument - relative path to directory inside target/site
attachLinkToTestReport() {
# attach links to resource related to failed test
local relativePathToResource=$1
local dirWithResources="target/site/$relativePathToResource/*"
for file in $dirWithResources
do
local test=$(basename ${file} | sed 's/\(.*\)\.zip/\1/' | sed 's/\(.*\)_.*/\1/')
local divTag="<div id=\""${test}"error\" style=\"display:none;\">"
local filename=$(basename ${file})
local aTag="<p><li><a href=\"$relativePathToResource\/$filename\" target=\"_blank\">$relativePathToResource<\/a><\/li><\/p>"
sed -i "s/${divTag}/${divTag}${aTag}/" ${FAILSAFE_REPORT}
done
}

storeTestReport() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
import java.util.stream.Stream;
import javax.annotation.PreDestroy;
import javax.validation.constraints.NotNull;
import org.apache.commons.io.FileUtils;
import org.eclipse.che.commons.json.JsonParseException;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.commons.lang.ZipUtils;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.TestGitHubServiceClient;
Expand Down Expand Up @@ -369,8 +371,22 @@ private void captureTestWorkspaceLogs(ITestResult result) {
continue;
}

Path pathToStoreWorkspaceLogs = Paths.get(workspaceLogsDir, getTestReference(result));
String testReference = getTestReference(result);
Path pathToStoreWorkspaceLogs = Paths.get(workspaceLogsDir, testReference);
testWorkspaceLogsReader.read((TestWorkspace) obj, pathToStoreWorkspaceLogs);
Path pathToZipWithWorkspaceLogs =
pathToStoreWorkspaceLogs.getParent().resolve(testReference + ".zip");

try {
ZipUtils.zipDir(
pathToStoreWorkspaceLogs.toFile().getAbsolutePath(),
pathToStoreWorkspaceLogs.toFile(),
pathToZipWithWorkspaceLogs.toFile(),
null);
FileUtils.deleteQuietly(pathToStoreWorkspaceLogs.toFile());
} catch (IOException e) {
LOG.warn("Error of creation zip-file with workspace logs.", e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#

# Directory to store test resources
tests.screenshots_dir=target/screenshots
tests.htmldumps_dir=target/htmldumps
tests.workspacelogs_dir=target/workspace-logs
tests.webdriverlogs_dir=target/webdriver-logs
tests.screenshots_dir=target/site/screenshots
tests.htmldumps_dir=target/site/htmldumps
tests.workspacelogs_dir=target/site/workspace-logs
tests.webdriverlogs_dir=target/site/webdriver-logs
tests.tmp_dir=/tmp

# Che workspace parameters
Expand Down

0 comments on commit cc06caa

Please sign in to comment.