Skip to content
Permalink
Browse files
[JENKINS-23462] Sectioned views are not evaluated for job priority
 * Need to use getItems() not getItem() to get the items in the View
 * Added test-case for Sectioned View Plugin
  • Loading branch information
emsa23 committed Jun 17, 2014
1 parent daa7287 commit 4ec547ee116f5e6f7a78d08e9af606c5813f74ec
@@ -48,6 +48,15 @@
-->
</developers>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>sectioned-view</artifactId>
<version>1.18</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
@@ -303,7 +303,7 @@ private boolean isJobInView(Job<?, ?> job, View view) {
return true;
}
// Then try to get the Items (Sectioned View)
if(view.getItem(job.getName()) != null) {
if(view.getItems().contains(job)) {
return true;
}
// Then try to iterate over the ViewGroup (Nested View)
@@ -0,0 +1,31 @@
package jenkins.advancedqueue.test;

import hudson.cli.BuildCommand.CLICause;
import jenkins.advancedqueue.testutil.ExpectedItem;
import jenkins.advancedqueue.testutil.JobHelper;
import jenkins.advancedqueue.testutil.TestRunListener;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;

public class SectionedViewTest {

@Rule
public JenkinsRule j = new JenkinsRule();

private JobHelper jobHelper = new JobHelper(j);

@Test
@LocalData
public void sectioned_view_test() throws Exception {
// Job 2 matches Sectioned View and All -> Sectioned View is before All -> priority is 1
// Job 1 matches View1 and All -> View1 is before All -> priority is 2
// Job 0 matched only All -> priority is 3
TestRunListener.init(new ExpectedItem("Job 2", 1), new ExpectedItem("Job 1", 2), new ExpectedItem("Job 0", 3));
jobHelper.scheduleProjects(new CLICause(), new CLICause(), new CLICause());
j.waitUntilNoActivity();
TestRunListener.assertStartedItems();
}
}
@@ -0,0 +1,90 @@
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors>
<string>OldData</string>
</disabledAdministrativeMonitors>
<version>1.520</version>
<numExecutors>0</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.SecurityRealm$None"/>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${ITEM_ROOTDIR}/workspace</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.RawHtmlMarkupFormatter">
<disableSyntaxHighlighting>false</disableSyntaxHighlighting>
</markupFormatter>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<slaves/>
<quietPeriod>5</quietPeriod>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
<listView>
<owner class="hudson" reference="../../.."/>
<name>View1</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
<jobNames>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
<string>Job 1</string>
</jobNames>
<jobFilters/>
<columns>
<hudson.views.StatusColumn/>
<hudson.views.WeatherColumn/>
<hudson.views.JobColumn/>
<hudson.views.LastSuccessColumn/>
<hudson.views.LastFailureColumn/>
<hudson.views.LastDurationColumn/>
<hudson.views.BuildButtonColumn/>
<hudson.queueSorter.PrioritySorterJobColumn/>
</columns>
<recurse>false</recurse>
</listView>
<hudson.plugins.sectioned__view.SectionedView plugin="sectioned-view@1.18">
<owner class="hudson" reference="../../.."/>
<name>Sectioned View</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
<sections>
<hudson.plugins.sectioned__view.ListViewSection>
<jobNames>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
<string>Job 2</string>
</jobNames>
<jobFilters/>
<name>List View Section</name>
<width>FULL</width>
<alignment>CENTER</alignment>
<columns>
<hudson.views.StatusColumn/>
<hudson.views.WeatherColumn/>
<hudson.views.JobColumn/>
<hudson.views.LastSuccessColumn/>
<hudson.views.LastFailureColumn/>
<hudson.views.LastDurationColumn/>
<hudson.views.BuildButtonColumn/>
</columns>
</hudson.plugins.sectioned__view.ListViewSection>
</sections>
</hudson.plugins.sectioned__view.SectionedView>
</views>
<primaryView>All</primaryView>
<slaveAgentPort>0</slaveAgentPort>
<label></label>
<nodeProperties/>
<globalNodeProperties/>
</hudson>
@@ -0,0 +1,35 @@
<?xml version='1.0' encoding='UTF-8'?>
<jenkins.advancedqueue.PriorityConfiguration plugin="PrioritySorter@2.3-SNAPSHOT">
<jobGroups class="linked-list">
<jenkins.advancedqueue.JobGroup>
<id>0</id>
<priority>1</priority>
<view>Sectioned View</view>
<runExclusive>false</runExclusive>
<useJobFilter>false</useJobFilter>
<jobPattern>.*</jobPattern>
<usePriorityStrategies>false</usePriorityStrategies>
<priorityStrategies/>
</jenkins.advancedqueue.JobGroup>
<jenkins.advancedqueue.JobGroup>
<id>1</id>
<priority>2</priority>
<view>View1</view>
<runExclusive>false</runExclusive>
<useJobFilter>false</useJobFilter>
<jobPattern>.*</jobPattern>
<usePriorityStrategies>false</usePriorityStrategies>
<priorityStrategies/>
</jenkins.advancedqueue.JobGroup>
<jenkins.advancedqueue.JobGroup>
<id>2</id>
<priority>3</priority>
<view>All</view>
<runExclusive>false</runExclusive>
<useJobFilter>false</useJobFilter>
<jobPattern>.*</jobPattern>
<usePriorityStrategies>false</usePriorityStrategies>
<priorityStrategies/>
</jenkins.advancedqueue.JobGroup>
</jobGroups>
</jenkins.advancedqueue.PriorityConfiguration>
@@ -0,0 +1,18 @@
<?xml version='1.0' encoding='UTF-8'?>
<jenkins.advancedqueue.PrioritySorterConfiguration>
<legacyMode>false</legacyMode>
<legacyMaxPriority>2147483647</legacyMaxPriority>
<legacyMinPriority>-2147483648</legacyMinPriority>
<allowPriorityOnJobs>true</allowPriorityOnJobs>
<strategy class="jenkins.advancedqueue.sorter.strategy.AbsoluteStrategy">
<ifCondition></ifCondition>
<unlessCondition></unlessCondition>
<children/>
<location>
<lineNumber>0</lineNumber>
<columnNumber>0</columnNumber>
</location>
<numberOfPriorities>10</numberOfPriorities>
<defaultPriority>9</defaultPriority>
</strategy>
</jenkins.advancedqueue.PrioritySorterConfiguration>

0 comments on commit 4ec547e

Please sign in to comment.