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

Avoid unnecessary sleep in Linux tests #1256

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
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
Expand Up @@ -17,6 +17,7 @@
import com.dabsquared.gitlabjenkins.trigger.TriggerOpenMergeRequest;
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterFactory;
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterType;
import hudson.Functions;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
Expand Down Expand Up @@ -507,16 +508,20 @@ private MergeRequestObjectAttributesBuilder defaultMergeRequestObjectAttributes(
.build());
}

@After
/* Add sleep(5000) on after to avoid following error on Windows test
Unable to delete 'C:\Jenkins\workspace\Plugins_gitlab-plugin_PR-1121\target\tmp\j h4861043637706712359'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
*/
public void after()
{
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {

@After
public void after() {
/*
* Add Thread.sleep(5000) to avoid the following error on Windows:
*
* Unable to delete 'C:\Jenkins\workspace\Plugins_gitlab-plugin_PR-1121\target\tmp\j h4861043637706712359'.
* Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
*/
if (Functions.isWindows()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.dabsquared.gitlabjenkins.gitlab.hook.model.PipelineHook;
import com.dabsquared.gitlabjenkins.gitlab.hook.model.User;
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterType;
import hudson.Functions;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
Expand Down Expand Up @@ -135,12 +136,21 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
buildTriggered.block(10000);
assertThat(buildTriggered.isSignaled(), is(true));
}
@After
public void after() {
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {

@After
public void after() {
/*
* Add Thread.sleep(5000) to avoid the following error on Windows:
*
* Unable to delete 'C:\Jenkins\workspace\Plugins_gitlab-plugin_PR-1121\target\tmp\j h4861043637706712359'.
* Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
*/
if (Functions.isWindows()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.dabsquared.gitlabjenkins.gitlab.hook.model.builder.generated.PushHookBuilder;
import com.dabsquared.gitlabjenkins.trigger.filter.BranchFilterType;
import hudson.Functions;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
Expand Down Expand Up @@ -177,12 +178,19 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
}

@After
public void after() {
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {

public void after() {
/*
* Add Thread.sleep(5000) to avoid the following error on Windows:
*
* Unable to delete 'C:\Jenkins\workspace\Plugins_gitlab-plugin_PR-1121\target\tmp\j h4861043637706712359'.
* Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
*/
if (Functions.isWindows()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
}
}

}