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

Flakes in Security2180Test #150

Merged
merged 1 commit into from
Aug 22, 2023
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
Expand Up @@ -23,6 +23,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import jenkins.model.DirectlyModifiableTopLevelItemGroup;
import jenkins.model.Jenkins;
import org.htmlunit.Page;
Expand All @@ -31,9 +32,12 @@
import org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy;
import org.jenkinsci.plugins.matrixauth.inheritance.InheritanceStrategy;
import org.jenkinsci.plugins.matrixauth.inheritance.NonInheritingStrategy;
import org.junit.After;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.SleepBuilder;

Expand All @@ -43,9 +47,26 @@
private static final Map<Permission, Set<String>> ANONYMOUS_CAN_ITEM_READ =
Collections.singletonMap(Item.READ, Collections.singleton("anonymous"));

private static final Logger LOGGER = Logger.getLogger(Security2180Test.class.getName());

@ClassRule
public static BuildWatcher watcher = new BuildWatcher();
Comment on lines +52 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes, but you might some day wish to edit the test.


@Rule
public JenkinsRule j = new JenkinsRule();

@After
public void stopBuilds() throws Exception {
for (FreeStyleProject p : j.jenkins.allItems(FreeStyleProject.class)) {
for (FreeStyleBuild b : p.getBuilds()) {
LOGGER.info(() -> "Stopping " + b + "…");
b.doStop();
j.waitForCompletion(b);
LOGGER.info(() -> "…done.");
}
}
}

/**
* Helper method that creates a nested folder structure: Each parameter but the last creates a folder, the last one
* creates a freestyle job. Every non-null argument will be added as that item's property.
Expand Down Expand Up @@ -101,7 +122,7 @@
private void assertJobVisibility(FreeStyleProject job, boolean visibleWithFix, boolean visibleWithEscapeHatch)
throws Exception {
final String jobUrl = job.getUrl();
// TODO robustness: check queue contents / executor status before scheduling

Check warning on line 125 in src/test/java/org/jenkinsci/plugins/matrixauth/Security2180Test.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: robustness: check queue contents / executor status before scheduling
FreeStyleBuild build =
job.scheduleBuild2(0, new Cause.UserIdCause("admin")).waitForStart(); // schedule one build now
QueueTaskFuture<FreeStyleBuild> future =
Expand Down
Loading