forked from eficode/ClearCaseUCMPlugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3e085f
commit d9e5211
Showing
4 changed files
with
185 additions
and
237 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/test/java/net/praqma/hudson/test/integration/enslaved/Story06WithSlaves.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.praqma.hudson.test.integration.enslaved; | ||
|
||
import hudson.model.Slave; | ||
import hudson.model.labels.LabelAtom; | ||
import net.praqma.clearcase.test.annotations.ClearCaseUniqueVobName; | ||
import net.praqma.clearcase.test.junit.ClearCaseRule; | ||
import net.praqma.clearcase.ucm.entities.Stream; | ||
import net.praqma.hudson.test.BaseTestClass; | ||
import net.praqma.hudson.test.integration.userstories.Story06Base; | ||
import net.praqma.junit.DescriptionRule; | ||
import net.praqma.junit.TestDescription; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import java.util.logging.Logger; | ||
|
||
|
||
public class Story06WithSlaves extends Story06Base { | ||
|
||
private static Logger logger = Logger.getLogger( Story06WithSlaves.class.getName() ); | ||
|
||
@Test | ||
@ClearCaseUniqueVobName( name = "dip4" ) | ||
@TestDescription( title = "Story 6", text = "New baseline on dev stream. Deliver in progress from another stream, different view", configurations = { "Force deliver = true", "Poll childs", "On slave" } ) | ||
public void story06_4() throws Exception { | ||
Stream dev1 = ccenv.context.streams.get( "one_dev" ); | ||
Stream dev2 = ccenv.context.streams.get( "two_dev" ); | ||
Slave slave = jenkins.createSlave( new LabelAtom( "ClearCaseSlave" ) ); | ||
run( dev1, dev2, ccenv.getUniqueName() + "_one_dev", ccenv.getUniqueName() + "_two_dev", slave, false ); | ||
} | ||
|
||
@Test | ||
@ClearCaseUniqueVobName( name = "dip5" ) | ||
@TestDescription( title = "Story 6", text = "New baseline on dev stream. Deliver in progress from same stream, different view", configurations = { "Force deliver = true", "Poll childs", "On slave" } ) | ||
public void story06_5() throws Exception { | ||
Stream dev1 = ccenv.context.streams.get( "one_dev" ); | ||
Slave slave = jenkins.createSlave( new LabelAtom( "ClearCaseSlave" ) ); | ||
run( dev1, dev1, ccenv.getUniqueName() + "_one_dev", ccenv.getUniqueName() + "_one_dev", slave, false ); | ||
} | ||
|
||
@Test | ||
@ClearCaseUniqueVobName( name = "dip6" ) | ||
@TestDescription( title = "Story 6", text = "New baseline on dev stream. Deliver in progress from previous build, different view", configurations = { "Force deliver = true", "Poll childs", "On slave" } ) | ||
public void story06_6() throws Exception { | ||
Stream dev1 = ccenv.context.streams.get( "one_dev" ); | ||
Slave slave = jenkins.createSlave( new LabelAtom( "ClearCaseSlave" ) ); | ||
run( null, dev1, null, ccenv.getUniqueName() + "_one_dev", slave, true ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/test/java/net/praqma/hudson/test/integration/userstories/Story06Base.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package net.praqma.hudson.test.integration.userstories; | ||
|
||
import hudson.model.AbstractBuild; | ||
import hudson.model.Project; | ||
import hudson.model.Result; | ||
import hudson.model.Slave; | ||
import net.praqma.clearcase.Deliver; | ||
import net.praqma.clearcase.exceptions.ClearCaseException; | ||
import net.praqma.clearcase.test.junit.ClearCaseRule; | ||
import net.praqma.clearcase.ucm.entities.Baseline; | ||
import net.praqma.clearcase.ucm.entities.Baseline.LabelBehaviour; | ||
import net.praqma.clearcase.ucm.entities.Project.PromotionLevel; | ||
import net.praqma.clearcase.ucm.entities.Stream; | ||
import net.praqma.clearcase.util.ExceptionUtils; | ||
import net.praqma.hudson.CCUCMBuildAction; | ||
import net.praqma.hudson.notifier.CCUCMNotifier; | ||
import net.praqma.hudson.scm.CCUCMScm; | ||
import net.praqma.hudson.test.BaseTestClass; | ||
import net.praqma.hudson.test.CCUCMRule; | ||
import net.praqma.hudson.test.SystemValidator; | ||
import net.praqma.junit.DescriptionRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import static net.praqma.hudson.test.CCUCMRule.ProjectCreator.Type; | ||
|
||
public abstract class Story06Base extends BaseTestClass { | ||
|
||
@Rule | ||
public static ClearCaseRule ccenv = new ClearCaseRule( "ccucm-story06", "setup-story5.xml" ); | ||
|
||
@Rule | ||
public static DescriptionRule desc = new DescriptionRule(); | ||
|
||
private static Logger logger = Logger.getLogger( Story06Base.class.getName() ); | ||
|
||
/** | ||
* | ||
* @param stream1 If set a new baseline will be delivered from this stream in a view | ||
* @param streamToMakeAnotherBaseline The stream used to make the baseline found for the second build | ||
* @param viewTag1 .... Using this view tag to create the first baseline | ||
* @param viewTagToMakeAnotherBaseline .... Using this view tag to create the second baseline | ||
* @param slave The slave executing the build, null if on master | ||
* @param jenkinsWorkspace If true, the first build will not run the post build and therefore not complete the deliver | ||
* @throws Exception | ||
*/ | ||
public void run( Stream stream1, Stream streamToMakeAnotherBaseline, String viewTag1, String viewTagToMakeAnotherBaseline, Slave slave, boolean jenkinsWorkspace ) throws Exception { | ||
|
||
/* First build to create a view */ | ||
Project project = new CCUCMRule.ProjectCreator( ccenv.getUniqueName(), "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob() ) | ||
.setType( Type.child ) | ||
.setForceDeliver( true ) | ||
.setCreateBaseline( true ) | ||
.getProject(); | ||
|
||
if( jenkinsWorkspace ) { | ||
//project.getBuildersList().add( builder ); | ||
project.getPublishersList().remove( CCUCMNotifier.class ); | ||
( (CCUCMScm)project.getScm() ).setAddPostBuild( false ); | ||
} | ||
|
||
AbstractBuild<?, ?> firstbuild = jenkins.buildProject( project, false, slave ); | ||
|
||
Stream target = null; | ||
if( firstbuild != null ) { | ||
CCUCMBuildAction preaction = jenkins.getBuildAction( firstbuild ); | ||
target = preaction.getStream(); | ||
} else { | ||
target = Stream.get( ( (CCUCMScm)project.getScm() ).getStream() ); | ||
} | ||
|
||
logger.fine( "Target stream is " + target ); | ||
|
||
if( !jenkinsWorkspace ) { | ||
/* Set deliver one up and make sure the baseline is not found by polling */ | ||
Baseline bl1 = createNewContent( stream1, viewTag1, 1, PromotionLevel.BUILT ); | ||
|
||
/* Do not complete deliver */ | ||
Deliver deliver1 = new Deliver( stream1, target ); | ||
deliver1.deliver( true, false, true, false ); | ||
} | ||
|
||
/* Setup dev 2 with new baseline */ | ||
Baseline bl2 = createNewContent( streamToMakeAnotherBaseline, viewTagToMakeAnotherBaseline, 2, null ); | ||
|
||
if( jenkinsWorkspace ) { | ||
//project.getBuildersList().remove( builder.getClass() ); | ||
project.getPublishersList().add( new CCUCMNotifier() ); | ||
|
||
CCUCMBuildAction preaction = jenkins.getBuildAction( firstbuild ); | ||
preaction.getBaseline().setPromotionLevel( PromotionLevel.BUILT ); | ||
} | ||
|
||
AbstractBuild<?, ?> build = jenkins.buildProject( firstbuild.getProject(), false, slave ); | ||
|
||
/* Validate */ | ||
SystemValidator validator = new SystemValidator( build ); | ||
validator.validateBuild( Result.SUCCESS ).validateBuiltBaseline( PromotionLevel.BUILT, bl2, false ).validateCreatedBaseline( true ).validate(); | ||
} | ||
|
||
protected Baseline createNewContent( Stream stream, String viewtag, int num, PromotionLevel level ) throws ClearCaseException { | ||
File path = null; | ||
try { | ||
path = ccenv.setDynamicActivity( stream, viewtag, "dip-" + stream.getShortname() ); | ||
} catch ( Exception e ) { | ||
logger.log( Level.WARNING, "failed", e ); | ||
path = ccenv.getDynamicPath( viewtag ); | ||
} | ||
|
||
Baseline baseline = getNewBaseline( path, "dip" + num + ".txt", "dip" + num + "_" + stream.getShortname() ); | ||
if( level != null ) { | ||
baseline.setPromotionLevel( level ); | ||
} | ||
|
||
return baseline; | ||
} | ||
|
||
protected Baseline getNewBaseline( File path, String filename, String bname ) throws ClearCaseException { | ||
|
||
try { | ||
ccenv.addNewElement( ccenv.context.components.get( "Model" ), path, filename ); | ||
} catch( Exception e ) { | ||
ExceptionUtils.print( e, System.out, true ); | ||
} | ||
return Baseline.create( bname, ccenv.context.components.get( "_System" ), path, LabelBehaviour.FULL, false ); | ||
} | ||
} |
Oops, something went wrong.