Skip to content

Commit

Permalink
Fixed JENKINS-19658
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed Mar 5, 2014
1 parent b81c08e commit e2efade
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 9 deletions.
57 changes: 57 additions & 0 deletions src/test/java/net/praqma/hudson/test/CCUCMRule.java
Expand Up @@ -210,6 +210,63 @@ public FreeStyleProject setupProject( String projectName, String type, String co

return project;
}

/**
* New set of methods that sets up a freestyle build with a slave.
* @param projectName
* @param type
* @param component
* @param stream
* @param recommend
* @param tag
* @param description
* @param createBaseline
* @return
* @throws Exception
*/
public FreeStyleProject setupProjectWithASlave( String projectName, String type, String component, String stream, boolean recommend, boolean tag, boolean description, boolean createBaseline ) throws Exception {
return setupProjectWithASlave( projectName, type, component, stream, recommend, tag, description, createBaseline, false );
}

public FreeStyleProject setupProjectWithASlave( String projectName, String type, String component, String stream, boolean recommend, boolean tag, boolean description, boolean createBaseline, boolean forceDeliver ) throws Exception {
return setupProjectWithASlave( projectName, type, component, stream, recommend, tag, description, createBaseline, forceDeliver, "[project]_build_[number]" );
}

public FreeStyleProject setupProjectWithASlave( String projectName, String type, String component, String stream, boolean recommend, boolean tag, boolean description, boolean createBaseline, boolean forceDeliver, String template ) throws Exception {
return setupProjectWithASlave(projectName, type, component, stream, recommend, tag, description, createBaseline, forceDeliver, template, "INITIAL" );
}

public FreeStyleProject setupProjectWithASlave( String projectName, String type, String component, String stream, boolean recommend, boolean tag, boolean description, boolean createBaseline, boolean forceDeliver, String template, String promotionLevel ) throws Exception {
logger.info( "Setting up build for self polling, recommend:" + recommend + ", tag:" + tag + ", description:" + description );

System.out.println( "==== [Setting up ClearCase UCM project] ====" );
System.out.println( " * Stream : " + stream );
System.out.println( " * Component : " + component );
System.out.println( " * Level : " + promotionLevel );
System.out.println( " * Polling : " + type );
System.out.println( " * Recommend : " + recommend );
System.out.println( " * Tag : " + tag );
System.out.println( " * Description : " + description );
System.out.println( " * Create baseline: " + createBaseline );
System.out.println( " * Template : " + template );
System.out.println( " * Force deliver : " + forceDeliver );


FreeStyleProject project = createFreeStyleProject( "ccucm-project-" + projectName );
DumbSlave slave = createSlave();
project.setAssignedLabel(slave.getSelfLabel());

System.out.println( " * Slave : " + slave.getSelfLabel().getName() );
System.out.println( "============================================" );
// boolean createBaseline, String nameTemplate, boolean forceDeliver, boolean recommend, boolean makeTag, boolean setDescription
//CCUCMScm scm = new CCUCMScm( component, "INITIAL", "ALL", false, type, stream, "successful", createBaseline, "[project]_build_[number]", forceDeliver, recommend, tag, description, "jenkins" );
CCUCMScm scm = new CCUCMScm( component, promotionLevel, "ALL", false, type, stream, "successful", createBaseline, template, forceDeliver, recommend, tag, description, "", true, false );
this.scm = scm;

project.setScm( scm );

return project;
}

public CCUCMScm getCCUCM( String type, String component, String stream, String promotionLevel, boolean recommend, boolean tag, boolean description, boolean createBaseline, boolean forceDeliver, String template ) {
System.out.println( "==== [Setting up ClearCase UCM project] ====" );
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class Polling extends BaseTestClass {
@ClearCaseUniqueVobName( name = "changes-child" )
@TestDescription( title = "Child polling, polling", text = "baseline available" )
public void testPollingChildsWithChanges() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );

File path = setActivity();
Baseline b1 = getNewBaseline( path, "file1.txt" );
Expand All @@ -57,7 +57,7 @@ public void testPollingChildsWithChanges() throws Exception {
@ClearCaseUniqueVobName( name = "nochanges-child" )
@TestDescription( title = "Child polling, polling", text = "baseline available" )
public void testPollingChildsWithNoChanges() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );

File path = setActivity();
Baseline b1 = getNewBaseline( path, "file1.txt" );
Expand Down
Expand Up @@ -3,6 +3,7 @@
import hudson.model.AbstractBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.model.Slave;
import hudson.scm.PollingResult;
import net.praqma.clearcase.exceptions.ClearCaseException;
import net.praqma.clearcase.test.annotations.ClearCaseUniqueVobName;
Expand Down Expand Up @@ -75,9 +76,9 @@ public void testRecommend() throws Exception {
@Test
@ClearCaseUniqueVobName( name = "self-any-poll" )
@TestDescription( title = "Self polling", text = "baselines available, find the newest, poll" )
public void testPoll() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false, false, "", "ANY" );

public void testPoll() throws Exception {
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false, false, "", "ANY" );
/* BUILD 1 */
AbstractBuild<?, ?> build = null;
try {
Expand All @@ -100,7 +101,7 @@ public void testPoll() throws Exception {
@ClearCaseUniqueVobName( name = "self-any-poll2" )
@TestDescription( title = "Self polling", text = "baselines available, find the newest, add baselines, poll" )
public void testPollThree() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false, false, "", "ANY" );
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false, false, "", "ANY" );

/* BUILD 1 */
AbstractBuild<?, ?> build = null;
Expand Down
Expand Up @@ -20,15 +20,15 @@ public class Polling extends BaseTestClass {
@Test
@ClearCaseUniqueVobName( name = "self-create-baseline")
public void testPollingNoChangesWithCreateBaselines() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, true );
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, true );
PollingResult result = project.poll(jenkins.createTaskListener());
assertFalse(result.hasChanges());
}

@Test
@ClearCaseUniqueVobName( name = "self-changes" )
public void testPollingSelfWithBaselines() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );

/* BUILD 1 */
try {
Expand All @@ -43,7 +43,7 @@ public void testPollingSelfWithBaselines() throws Exception {
}

public void testPollingSelfWithNoBaselines() throws Exception {
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );
FreeStyleProject project = jenkins.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );

/* BUILD 1 */
try {
Expand Down

0 comments on commit e2efade

Please sign in to comment.