mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 13:02:19 +00:00
Merge branch 'wip-loadstats-refactor'
This commit is contained in:
commit
86954de76e
7 files changed
+657
-69
No files matched your search
@@ -24,6 +24,7 @@
|
||||
package hudson.model;
|
||||
|
||||
import hudson.model.MultiStageTimeSeries.TimeScale;
|
||||
import hudson.model.queue.SubTask;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
@@ -35,6 +36,9 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@@ -54,17 +58,28 @@ public class LoadStatisticsTest {
|
||||
public int computeQueueLength() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@Override
|
||||
protected Iterable<Node> getNodes() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matches(SubTask item) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
ls.totalExecutors.update(4);
|
||||
ls.onlineExecutors.update(4);
|
||||
ls.busyExecutors.update(3);
|
||||
ls.availableExecutors.update(1);
|
||||
ls.queueLength.update(3);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
ls.totalExecutors.update(0);
|
||||
ls.onlineExecutors.update(0);
|
||||
ls.busyExecutors.update(0);
|
||||
ls.availableExecutors.update(0);
|
||||
ls.queueLength.update(1);
|
||||
}
|
||||
|
||||
@@ -80,4 +95,42 @@ public class LoadStatisticsTest {
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isModernWorks() throws Exception {
|
||||
assertThat(LoadStatistics.isModern(Modern.class), is(true));
|
||||
assertThat(LoadStatistics.isModern(LoadStatistics.class), is(false));
|
||||
}
|
||||
|
||||
private class Modern extends LoadStatistics {
|
||||
|
||||
protected Modern(int initialOnlineExecutors, int initialBusyExecutors) {
|
||||
super(initialOnlineExecutors, initialBusyExecutors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int computeIdleExecutors() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int computeTotalExecutors() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int computeQueueLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Node> getNodes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matches(SubTask item) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user