Skip to content

Commit

Permalink
[JENKINS-17067] Updated story 6 test
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgarnet committed Mar 7, 2013
1 parent 00aff67 commit 00aadca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
13 changes: 12 additions & 1 deletion src/test/java/net/praqma/hudson/test/CCUCMRule.java
Expand Up @@ -14,6 +14,7 @@
import java.util.logging.Logger;

import hudson.tasks.Builder;
import jenkins.model.Jenkins;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestBuilder;

Expand Down Expand Up @@ -271,8 +272,18 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe
return false;
}
}

public AbstractBuild<?, ?> buildProject( AbstractProject<?, ?> project, boolean fail ) throws IOException {
return buildProject( project, fail, null );
}

public AbstractBuild<?, ?> buildProject( AbstractProject<?, ?> project, boolean fail ) throws IOException {
public AbstractBuild<?, ?> buildProject( AbstractProject<?, ?> project, boolean fail, Slave slave ) throws IOException {

if( slave != null ) {
logger.fine( "Running on " + slave );
project.setAssignedNode( slave );
}

AbstractBuild<?, ?> build = null;
try {
build = project.scheduleBuild2( 0, new Cause.UserCause() ).get();
Expand Down
Expand Up @@ -3,17 +3,13 @@
import java.io.File;
import java.util.logging.Level;

import hudson.model.*;
import net.praqma.hudson.test.BaseTestClass;
import net.praqma.util.test.junit.LoggingRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.model.TaskListener;
import hudson.scm.PollingResult;
import net.praqma.clearcase.Deliver;
import net.praqma.clearcase.ucm.entities.Baseline;
Expand Down Expand Up @@ -45,14 +41,12 @@ public class Story06 extends BaseTestClass {
private static Logger logger = Logger.getLogger();

@Test
public void placeholder() throws Exception {
/* We need at least one test, or else the whole test will fail */
assertTrue( true );
}

//@Test
@TestDescription( title = "Story 6", text = "New baseline, bl1, on dev stream, poll on childs. Deliver in progress, forced cancelled", configurations = { "Force deliver = true" } )
public void story06() throws Exception {
run( null );
}

public void run( Slave slave ) throws Exception{

/* First build to create a view */
AbstractBuild<?, ?> firstbuild = jenkins.initiateBuild( ccenv.getUniqueName(), "child", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false, true, true );
Expand Down Expand Up @@ -84,7 +78,7 @@ public void story06() throws Exception {
Baseline bl2 = getNewBaseline( d2path, "dip2.txt", "dip2" );


AbstractBuild<?, ?> build = jenkins.buildProject( firstbuild.getProject(), false );
AbstractBuild<?, ?> build = jenkins.buildProject( firstbuild.getProject(), false, slave );


/* Build validation */
Expand Down
Expand Up @@ -3,17 +3,14 @@
import java.io.File;
import java.util.logging.Level;

import hudson.model.*;
import hudson.model.labels.LabelAtom;
import net.praqma.hudson.test.BaseTestClass;
import net.praqma.util.test.junit.LoggingRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.model.TaskListener;
import hudson.scm.PollingResult;
import net.praqma.clearcase.Deliver;
import net.praqma.clearcase.ucm.entities.Baseline;
Expand Down Expand Up @@ -47,14 +44,18 @@ public class Story06_2 extends BaseTestClass {


@Test
public void placeholder() throws Exception {
/* We need at least one test, or else the whole test will fail */
assertTrue( true );
}

//@Test
@TestDescription( title = "Story 6", text = "New baseline, bl1, on dev stream, poll on childs. Deliver in progress, forced cancelled", configurations = { "Force deliver = true" } )
public void story06() throws Exception {
@TestDescription( title = "Story 6", text = "New baseline, bl1, on dev stream, poll on childs. Deliver in progress, forced cancelled", configurations = { "Force deliver = true" } )
public void story06_1() throws Exception {
run( null );
}

//@Test
@TestDescription( title = "Story 6", text = "New baseline, bl1, on dev stream, poll on childs. Deliver in progress, forced cancelled", configurations = { "Force deliver = true", "Slave = YES" } )
public void story06_2() throws Exception {
run( jenkins.createSlave( new LabelAtom( "ClearCaseSlave" ) ) );
}

public void run( Slave slave ) throws Exception{

/* First build to create a view */
AbstractBuild<?, ?> firstbuild = jenkins.initiateBuild( ccenv.getUniqueName(), "child", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false, true, true );
Expand All @@ -68,22 +69,10 @@ public void story06() throws Exception {
File d2path = ccenv.setDynamicActivity( dev2, d2viewtag, "dip2" );
Baseline bl2 = getNewBaseline( d2path, "dip2.txt", "dip2" );

AbstractBuild<?, ?> build = jenkins.buildProject( firstbuild.getProject(), false );
AbstractBuild<?, ?> build = jenkins.buildProject( firstbuild.getProject(), false, slave );

SystemValidator validator = new SystemValidator( build );
validator.validateBuild( Result.SUCCESS ).validateBuiltBaseline( PromotionLevel.BUILT, bl2, false ).validateCreatedBaseline( true ).validate();

// /* Build validation */
// assertTrue( build.getResult().isBetterOrEqualTo( Result.SUCCESS ) );
//
// /* Expected build baseline */
// Baseline buildBaseline = jenkins.getBuildBaseline( build );
// assertEquals( bl2, buildBaseline );
// assertEquals( PromotionLevel.BUILT, buildBaseline.getPromotionLevel( true ) );
//
// /* Created baseline */
// Baseline createdBaseline = jenkins.getCreatedBaseline( build );
// assertNotNull( createdBaseline );
}


Expand Down

0 comments on commit 00aadca

Please sign in to comment.