mirror of https://github.com/jenkinsci/jenkins.git
Reduce test flakiness (#10809)
* Reduce inQueueTaskLookupByAPI flakiness https://app.launchableinc.com/organizations/jenkins/workspaces/jenkins/data/test-paths/class%3Dhudson.model.QueueTest%23%23%23testcase%3DinQueueTaskLookupByAPI?dateFilter=90d reports that inQueueTaskLookupByAPI has been flaky in th epast 90 days. The flakiness seems to be specific to Windows and seems to be related to the job not be in the queue quickly enough after the call toe schedule the build. If the job is not queued, sleep for 3 seonds to allow it time to queue. Testing done: Confirmed that the job queues consistently on my Linux computer, so the sleep statement is not executed. * Replace SCSS 1x with 1dppx to silence HTMLUnit warning Per https://developer.mozilla.org/en-US/docs/Web/CSS/resolution , `x` is an alias for `dppx`, so let's use `dppx` to avoid warnings from HTMLUnit. * Reduce flakiness of ComputerStateTest#testUiForConnected https://app.launchableinc.com/organizations/jenkins/workspaces/jenkins/data/test-paths/class%3Dhudson.cli.ComputerStateTest%23%23%23testcase%3DtestUiForConnected?dateFilter=90d reports that there have been multiple failures of ComputerStateTest#testUiForConnected in the last 90 days. The failures seem to be related to a race condition that the agent is not yet disconnected when the state of the agent is checked. Wait for 1 second to allow the agent to disconnect before checking agent status. The average time to run the test is 34 seconds. This will increase that average time by 1 second. Not a significant increase compared to the benefit of avoiding a flaky test. * Reduce preventXssInBadgeTooltip flakes with a 2 second sleep https://app.launchableinc.com/organizations/jenkins/workspaces/jenkins/data/test-paths/class%3Dhudson.model.RunTest%23%23%23testcase%3DpreventXssInBadgeTooltip?dateFilter=90d shows there have been random test failures of preventXssInBadgeTooltip in the last 90 days. Reeduce failures by sleeping before the key assertions in order to allow Jenkins to complete the initialization of the page.
This commit is contained in:
parent
f610669e01
commit
f59a5d4536
|
@ -138,7 +138,7 @@ $semantics: (
|
||||||
--jenkins-border--subtle-shadow: 0 0 0 var(--jenkins-border-width)
|
--jenkins-border--subtle-shadow: 0 0 0 var(--jenkins-border-width)
|
||||||
var(--jenkins-border-color--subtle);
|
var(--jenkins-border-color--subtle);
|
||||||
|
|
||||||
@media (resolution <= 1x) {
|
@media (resolution <= 1dppx) {
|
||||||
--jenkins-border-width: 2px;
|
--jenkins-border-width: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,9 @@ class ComputerStateTest {
|
||||||
|
|
||||||
slave.toComputer().disconnect(null);
|
slave.toComputer().disconnect(null);
|
||||||
|
|
||||||
|
// Test fails sometimes because agent is not yet disconnected
|
||||||
|
// Wait 1 second for disconnect to complete
|
||||||
|
Thread.sleep(1009);
|
||||||
HtmlPage page = wc.getPage(slave);
|
HtmlPage page = wc.getPage(slave);
|
||||||
|
|
||||||
assertLinkDoesNotExist(page, "Disconnect");
|
assertLinkDoesNotExist(page, "Disconnect");
|
||||||
|
|
|
@ -462,6 +462,13 @@ public class QueueTest {
|
||||||
p.setAssignedLabel(label);
|
p.setAssignedLabel(label);
|
||||||
p.scheduleBuild2(0);
|
p.scheduleBuild2(0);
|
||||||
|
|
||||||
|
// Wait 3 seconds if job is not already in the queue, reduce test flakes
|
||||||
|
if (!p.isInQueue()) {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(p.isInQueue(), "Build not queued");
|
||||||
|
|
||||||
JenkinsRule.WebClient webclient = r.createWebClient();
|
JenkinsRule.WebClient webclient = r.createWebClient();
|
||||||
|
|
||||||
XmlPage queueItems = webclient.goToXml("queue/api/xml");
|
XmlPage queueItems = webclient.goToXml("queue/api/xml");
|
||||||
|
|
|
@ -196,6 +196,9 @@ class RunTest {
|
||||||
|
|
||||||
// keeping the minimum to validate it's working and it's not exploitable as there are some modifications
|
// keeping the minimum to validate it's working and it's not exploitable as there are some modifications
|
||||||
// like adding double quotes
|
// like adding double quotes
|
||||||
|
// Some test flakes due to JavaScript objects not yet available
|
||||||
|
// Wait 2 seconds before checking the assertion
|
||||||
|
Thread.sleep(2003);
|
||||||
ensureXssIsPrevented(up, "Down", "<img");
|
ensureXssIsPrevented(up, "Down", "<img");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue