-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment/selenium logs #1412
Merged
Merged
Experiment/selenium logs #1412
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7ace9de
use chrome instead of firefox and enable console logs integration
4002984
direct Selenium Chrome's console logs to log4j
4f0b122
suppress superfluous log entries
60cca2c
try to improve error handling / logging code especially for Selenium …
2744998
another attempt to make Chrome + Selenium error stack readable
4013f1b
another attempt to make Chrome + Selenium error stack readable
f8e73b1
make the error logging code a bit more explicit and fall back to logg…
9d595b2
Merge branch 'master' into experiment/selenium-logs
8865161
switch nightwatch config to use chrome
af4c8de
update the "deletePipeline" logic to delete by repo name instead of o…
d0f62f0
hide editor's Cancel and Save buttons until the pipeline is loaded
05d72b9
just remove the browser name altogether from messaging
cede23b
try to fix an issue in ATH where pipeline scripts were not properly s…
ebcf1b5
use the latest Chrome, since the rest of the world will too
c9f0bf7
add some TODOs around areas of test fragility
27b37ba
Merge branch 'master' into experiment/selenium-logs
48928b3
wait for Branches tab to be visible before clicking it
f03aabf
asserting the location immediately could fail since a redirect needs …
00934a3
wait for Branches tab to be visible before clicking it
9e30db6
be more specific about which "replay" button to click
b113970
add another note about a flaky assertion / test
6c5aec2
more tweaks to get nightwatch tests to cooperate
e620e63
more tweaks to get nightwatch tests to cooperate
17cc48a
hide warning about password field on non-https page
34faca8
try to address an error in CI about span.IconButton-text not being cl…
21f7d43
remove unused obsolete element corresponding to the old "single repo"…
20782ff
try to fix an apparent timing issue where "create pipeline" would be …
ea4e0c6
use string concat for logging unhandled errors since selenium likes t…
2bfb300
Merge branch 'master' into experiment/selenium-logs
f296d07
lock version of docker chrome image
5226edc
introduce "click" utility methods that wait for element to be clickab…
d3b5372
use an anchor instead of span for sheet's back button with the hope i…
fe13d06
implement retry logic for click
f4e6174
Merge branch 'master' into experiment/selenium-logs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
acceptance-tests/src/main/java/io/blueocean/ath/LogEntryLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.blueocean.ath; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.apache.log4j.Logger; | ||
import org.openqa.selenium.logging.LogEntry; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Writes a Selenium LogEntry to log4j | ||
* @author cliffmeyers | ||
*/ | ||
class LogEntryLogger { | ||
private static final Logger logger = Logger.getLogger(LogEntryLogger.class); | ||
private static final ObjectMapper jsonMapper = new ObjectMapper(); | ||
private static final TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {}; | ||
|
||
static void recordLogEntry(LogEntry entry) { | ||
if (!logger.isInfoEnabled() || isSuperfluousLogEntry(entry)) { | ||
return; | ||
} | ||
|
||
String time; | ||
String level; | ||
String text; | ||
|
||
try { | ||
// handle messages written by @jenkins-cd/js-logging | ||
Map<String, Object> messageJson = jsonMapper.readValue(entry.getMessage(), typeRef); | ||
Map<String, Object> message = (Map<String, Object>) messageJson.get("message"); | ||
time = String.valueOf(message.get("timestamp")); | ||
level = String.valueOf(message.get("level")); | ||
text = String.valueOf(message.get("text")); | ||
} catch (IOException e) { | ||
// handle messages written natively by console.error|warn|log|debug | ||
time = String.valueOf(entry.getTimestamp()); | ||
level = String.valueOf(entry.getLevel()); | ||
text = entry.getMessage(); | ||
} | ||
|
||
logger.info(String.format("%s - %s - %s", time, level, text)); | ||
} | ||
|
||
// special handling to suppress some repetitive logging messages that are not helpful | ||
private static final String MESSAGE_JS_LOGGING = "@jenkins-cd/logging is explained"; | ||
private static final String MESSAGE_CHROME_CONSOLE = "Chrome displays console errors"; | ||
private static final String MESSAGE_PASSWORD_INSECURE = "page includes a password or credit card input"; | ||
|
||
static boolean isSuperfluousLogEntry(LogEntry entry) { | ||
String message = entry.getMessage(); | ||
return message.contains(MESSAGE_JS_LOGGING) || message.contains(MESSAGE_CHROME_CONSOLE) || | ||
message.contains(MESSAGE_PASSWORD_INSECURE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really pass this in from tests so we can run on multiple browsers at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to take a look at selenium-grid as it's the "selenium way" of firing off multiple test runs in different browsers.