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

Cleanup tests #177

Merged
merged 6 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 0 additions & 14 deletions src/test/java/jenkins/branch/BranchNameContributorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
package jenkins.branch;

import hudson.EnvVars;
import hudson.model.Computer;
import hudson.model.EnvironmentContributor;
import hudson.model.Executor;
import hudson.model.FreeStyleProject;
import hudson.model.TopLevelItem;
import hudson.util.LogTaskListener;
Expand Down Expand Up @@ -69,18 +67,6 @@ public void cleanOutAllItems() throws Exception {
for (TopLevelItem i : r.getInstance().getItems()) {
i.delete();
}
for (Computer comp : r.jenkins.getComputers()) {
for (Executor e : comp.getExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
for (Executor e : comp.getOneOffExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void smokes() throws Exception {
sampleRepo.git("add", "server");
sampleRepo.git("commit", "--all", "--message=release");
MultiBranchImpl stuff = r.jenkins.createProject(MultiBranchImpl.class, "stuff");
BranchSource branchSource = new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false));
BranchSource branchSource = new BranchSource(new GitSCMSource(sampleRepo.toString()));
res0nance marked this conversation as resolved.
Show resolved Hide resolved
branchSource.setStrategy(new NamedExceptionsBranchPropertyStrategy(new BranchProperty[0], new NamedExceptionsBranchPropertyStrategy.Named[] {
new NamedExceptionsBranchPropertyStrategy.Named("release*", new BranchProperty[] {new NoTriggerBranchProperty()})
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void smokes() throws Exception {
assertEquals(".*", prop.getBranches());
top.getProperties().replace(new NoTriggerOrganizationFolderProperty("(?!release.*).*"));
top.getProjectFactories().add(new OrganizationFolderTest.MockFactory());
top.getNavigators().add(new SingleSCMNavigator("stuff", Collections.<SCMSource>singletonList(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false))));
top.getNavigators().add(new SingleSCMNavigator("stuff", Collections.<SCMSource>singletonList(new GitSCMSource(sampleRepo.toString()))));
r.configRoundtrip(top);
prop = top.getProperties().get(NoTriggerOrganizationFolderProperty.class);
assertNotNull(prop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import com.cloudbees.hudson.plugins.folder.health.FolderHealthMetric;
import com.cloudbees.hudson.plugins.folder.health.FolderHealthMetricDescriptor;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.TopLevelItem;
import hudson.util.DescribableList;
import integration.harness.BasicMultiBranchProject;
Expand Down Expand Up @@ -66,18 +64,6 @@ public void cleanOutAllItems() throws Exception {
for (TopLevelItem i : r.getInstance().getItems()) {
i.delete();
}
for (Computer comp : r.jenkins.getComputers()) {
for (Executor e : comp.getExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
for (Executor e : comp.getOneOffExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ public void cleanOutAllItems() throws Exception {
for (TopLevelItem i : r.getInstance().getItems()) {
i.delete();
}
for (Computer comp : r.jenkins.getComputers()) {
for (Executor e : comp.getExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
for (Executor e : comp.getOneOffExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ public void cleanOutAllItems() throws Exception {
for (TopLevelItem i : r.getInstance().getItems()) {
i.delete();
}
for (Computer comp : r.jenkins.getComputers()) {
for (Executor e : comp.getExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
for (Executor e : comp.getOneOffExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void overridesDisabledBranch() throws Exception {
sampleRepo.git("add", "server");
sampleRepo.git("commit", "--all", "--message=release");
MultiBranchImpl stuff = r.jenkins.createProject(MultiBranchImpl.class, "stuff");
BranchSource branchSource = new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false));
BranchSource branchSource = new BranchSource(new GitSCMSource(sampleRepo.toString()));
branchSource.setStrategy(new NamedExceptionsBranchPropertyStrategy(new BranchProperty[0], new NamedExceptionsBranchPropertyStrategy.Named[] {
new NamedExceptionsBranchPropertyStrategy.Named("release*", new BranchProperty[] {new NoTriggerBranchProperty()})
}));
Expand Down Expand Up @@ -128,7 +128,7 @@ public void overridesDisabledOrg() throws Exception {
assertEquals(".*", prop.getBranches());
top.getProperties().replace(new NoTriggerOrganizationFolderProperty("(?!release.*).*"));
top.getProjectFactories().add(new OrganizationFolderTest.MockFactory());
top.getNavigators().add(new SingleSCMNavigator("stuff", Collections.<SCMSource>singletonList(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false))));
top.getNavigators().add(new SingleSCMNavigator("stuff", Collections.<SCMSource>singletonList(new GitSCMSource(sampleRepo.toString()))));
r.configRoundtrip(top);
prop = top.getProperties().get(NoTriggerOrganizationFolderProperty.class);
assertNotNull(prop);
Expand Down Expand Up @@ -188,7 +188,7 @@ public void overridesEnabled() throws Exception {
sampleRepo.git("add", "stuff");
sampleRepo.git("commit", "--all", "--message=master-1");
MultiBranchImpl stuff = r.jenkins.createProject(MultiBranchImpl.class, "stuff");
BranchSource branchSource = new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false));
BranchSource branchSource = new BranchSource(new GitSCMSource(sampleRepo.toString()));
stuff.getSourcesList().add(branchSource);
r.configRoundtrip(stuff);
stuff.scheduleBuild2(0).getFuture().get();
Expand Down
14 changes: 0 additions & 14 deletions src/test/java/jenkins/branch/PrimaryBranchHealthMetricTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package jenkins.branch;

import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.FreeStyleProject;
import hudson.model.TopLevelItem;
import integration.harness.BasicMultiBranchProject;
Expand Down Expand Up @@ -30,18 +28,6 @@ public void cleanOutAllItems() throws Exception {
for (TopLevelItem i : r.getInstance().getItems()) {
i.delete();
}
for (Computer comp : r.jenkins.getComputers()) {
for (Executor e : comp.getExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
for (Executor e : comp.getOneOffExecutors()) {
if (e.getCauseOfDeath() != null) {
e.doYank();
}
}
}
}

@Test
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/jenkins/branch/RateLimitBranchPropertyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,12 @@ public void rateLimitsBlockBuilds(int rate) throws Exception {
assertThat(startCondition.isDone(), is(true));
// it can take more than the requested delay... that's ok, but it should not be
// more than 500ms longer (i.e. 5 of our Queue.maintain loops above)
final long delay = (long)(60.f * 60.f / rate * 1000);
assertThat("At least the rate implied delay but no more than 500ms longer",
System.currentTimeMillis() - startTime,
allOf(
greaterThanOrEqualTo(60 * 60 / rate * 1000L - 200L),
lessThanOrEqualTo(60 * 60 / rate * 1000L * 500L)
greaterThanOrEqualTo(delay - 200L),
lessThanOrEqualTo(delay + 500L)
)
);
future.get();
Expand Down Expand Up @@ -277,7 +278,7 @@ public void rateLimitsConcurrentBuilds() throws Exception {
// will pick up more responsively than the default 5s
startCondition = future2.getStartCondition();
long endTime = startTime + 60*60/rate*1000L*5; // at least 5 times the expected delay
while (!startCondition.isDone() && System.currentTimeMillis() < midTime) {
while (!startCondition.isDone() && System.currentTimeMillis() < endTime) {
Queue.getInstance().maintain();
Thread.sleep(100);
}
Expand All @@ -286,11 +287,12 @@ public void rateLimitsConcurrentBuilds() throws Exception {
FreeStyleBuild secondBuild = startCondition.get();
// it can take more than the requested delay... that's ok, but it should not be
// more than 500ms longer (i.e. 5 of our Queue.maintain loops above)
final long delay = (long)(60.f * 60.f / rate * 1000);
assertThat("At least the rate implied delay but no more than 500ms longer",
secondBuild.getStartTimeInMillis() - firstBuild.getStartTimeInMillis(),
allOf(
greaterThanOrEqualTo(60 * 60 / rate * 1000L - 200L),
lessThanOrEqualTo(60 * 60 / rate * 1000L * 500L)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The * in the less than condition from the comment seems to be a typo

greaterThanOrEqualTo(delay - 200L),
lessThanOrEqualTo(delay + 500L)
)
);
future.get();
Expand Down