Skip to content
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

Sleep longer in the Windows tests #427

Merged
merged 5 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -662,12 +662,18 @@ private static final class HelloNote extends ConsoleNote<Run<?, ?>> {
@Test public void deadStep() throws Exception {
logging.record(DurableTaskStep.class, Level.INFO).record(CpsStepContext.class, Level.INFO).capture(100);
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("try {node {isUnix() ? sh('sleep 1000000') : bat('ping -t 127.0.0.1 > nul')}} catch (e) {sleep 1; throw e}", true));
// Test fails on ci.jenkins.io with timeout == 1 on Windows
int sleepTime = Functions.isWindows() ? 13 : 1;
p.setDefinition(new CpsFlowDefinition("try {node {isUnix() ? sh('sleep 1000000') : bat('ping -t 127.0.0.1 > nul')}} catch (e) {sleep " + sleepTime + "; throw e}", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
j.waitForMessage(Functions.isWindows() ? ">ping" : "+ sleep", b);
b.doTerm();
j.waitForCompletion(b);
j.assertBuildStatus(Result.ABORTED, b);
// Test fails on ci.jenkins.io with timeout == 1 on Windows
if (Functions.isWindows()) {
Thread.sleep(sleepTime * 1000L);
}
for (LogRecord record : logging.getRecords()) {
assertNull(record.getThrown());
}
@@ -701,10 +707,11 @@ private static final class HelloNote extends ConsoleNote<Run<?, ?>> {
@Issue("JENKINS-28822")
@Test public void interruptingAbortsBuild() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
// Test fails unexpectedly on ci.jenkins.io Windows agents with fewer pings
p.setDefinition(new CpsFlowDefinition("node {\n" +
" timeout(time: 1, unit: 'SECONDS') {" +
(Functions.isWindows()
? "bat 'ping -n 6 127.0.0.1 >nul'\n"
? "bat 'ping -n 19 127.0.0.1 >nul'\n"
: "sh 'sleep 5'\n") +
" }" +
"}", true));
@@ -718,10 +725,11 @@ private static final class HelloNote extends ConsoleNote<Run<?, ?>> {
@Issue("JENKINS-28822")
@Test public void interruptingAbortsBuildEvenWithReturnStatus() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
// Test fails unexpectedly on ci.jenkins.io Windows agents with fewer pings
p.setDefinition(new CpsFlowDefinition("node() {\n" +
" timeout(time: 1, unit: 'SECONDS') {\n" +
(Functions.isWindows()
? "bat(returnStatus: true, script: 'ping -n 6 127.0.0.1 >nul')\n"
? "bat(returnStatus: true, script: 'ping -n 19 127.0.0.1 >nul')\n"
: "sh(returnStatus: true, script: 'sleep 5')\n") +
" }\n" +
"}", true));