Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added test for JENKINS-29975
  • Loading branch information
MadsNielsen committed Aug 17, 2015
1 parent 49fdabd commit a30718c
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 5 deletions.
Expand Up @@ -23,13 +23,10 @@

public class ClearCaseUCMConfiguration extends AbstractConfiguration<ClearCaseUCMConfigurationComponent> {

private static Logger logger = Logger.getLogger( ClearCaseUCMConfiguration.class.getName() );

private static final Logger logger = Logger.getLogger( ClearCaseUCMConfiguration.class.getName() );
private SnapshotView view;

public ClearCaseUCMConfiguration() {
}

public ClearCaseUCMConfiguration() { }

@Override
public ClearCaseUCMConfiguration clone() {
Expand Down
@@ -0,0 +1,105 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.praqma.jenkins.configrotator.functional.scm.clearcase;

import hudson.model.AbstractBuild;
import hudson.model.Cause;
import hudson.model.Result;
import hudson.model.Slave;
import net.praqma.clearcase.test.junit.ClearCaseRule;
import net.praqma.jenkins.configrotator.ConfigRotatorProject;
import net.praqma.jenkins.configrotator.ConfigRotatorRule2;
import net.praqma.jenkins.configrotator.ProjectBuilder;
import net.praqma.jenkins.configrotator.SystemValidator;
import static net.praqma.jenkins.configrotator.functional.scm.clearcase.JENKINS22058.ccenv;
import net.praqma.jenkins.configrotator.scm.clearcaseucm.ClearCaseUCM;
import net.praqma.jenkins.configrotator.scm.clearcaseucm.ClearCaseUCMTarget;
import net.praqma.logging.PraqmaticLogFormatter;
import net.praqma.util.test.junit.LoggingRule;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;

/**
*
* @author Mads
*/
public class NoLabelsFilterTest {
private static final String ISSUE_NR = "jenkins_29975";
public static final ClearCaseRule ccenv = new ClearCaseRule(ISSUE_NR,"setup_no_label.xml");
public static final LoggingRule lrule = new LoggingRule( "net.praqma" ).setFormat( PraqmaticLogFormatter.TINY_FORMAT );

@ClassRule
public static final TestRule chain = RuleChain.outerRule( lrule ).around( ccenv );

@ClassRule
public static final ConfigRotatorRule2 crrule = new ConfigRotatorRule2(NoLabelsFilterTest.class);

@Test
public void testJENKINS29975() throws Exception {
ProjectBuilder builder = new ProjectBuilder( new ClearCaseUCM( ccenv.getPVob() ) ).setName( ISSUE_NR );
Slave sl = crrule.createSlave();

ConfigRotatorProject project = builder.getProject();
project.addTarget( new ClearCaseUCMTarget( "model-1@" + ccenv.getPVob() + ", INITIAL, false" ) ).
addTarget( new ClearCaseUCMTarget( "client-1@" + ccenv.getPVob() + ", INITIAL, false" ) );

hudson.model.Project<?, ?> jProject = project.getJenkinsProject();

//model-1
//client-1
AbstractBuild<?,?> build1 = jProject.scheduleBuild2(0, new Cause.UserIdCause()).get();

SystemValidator<ClearCaseUCMTarget> targets1 = new SystemValidator<ClearCaseUCMTarget>(build1);
targets1.checkAction(true)
.checkTargets( new ClearCaseUCMTarget( "model-1@" + ccenv.getPVob() + ", INITIAL, false" ), new ClearCaseUCMTarget( "client-1@" + ccenv.getPVob() + ", INITIAL, false" ) )
.checkExpectedResult(Result.SUCCESS).validate();

//model-2
//client-1
AbstractBuild<?,?> build2 = jProject.scheduleBuild2(0, new Cause.UserIdCause()).get();

SystemValidator<ClearCaseUCMTarget> targets2 = new SystemValidator<ClearCaseUCMTarget>(build2);
targets2.checkAction(true)
.checkTargets( new ClearCaseUCMTarget( "model-2@" + ccenv.getPVob() + ", INITIAL, false" ), new ClearCaseUCMTarget( "client-1@" + ccenv.getPVob() + ", INITIAL, false" ) )
.checkExpectedResult(Result.SUCCESS).validate();

//model-3
//client-1
AbstractBuild<?,?> build3 = jProject.scheduleBuild2(0, new Cause.UserIdCause()).get();

SystemValidator<ClearCaseUCMTarget> targets3 = new SystemValidator<ClearCaseUCMTarget>(build3);
targets3.checkAction(true)
.checkTargets( new ClearCaseUCMTarget( "model-3@" + ccenv.getPVob() + ", INITIAL, false" ), new ClearCaseUCMTarget( "client-1@" + ccenv.getPVob() + ", INITIAL, false" ) )
.checkExpectedResult(Result.SUCCESS).validate();

//model-3
//client-2
AbstractBuild<?,?> build4 = jProject.scheduleBuild2(0, new Cause.UserIdCause()).get();

SystemValidator<ClearCaseUCMTarget> targets4 = new SystemValidator<ClearCaseUCMTarget>(build4);
targets4.checkAction(true)
.checkTargets( new ClearCaseUCMTarget( "model-3@" + ccenv.getPVob() + ", INITIAL, false" ), new ClearCaseUCMTarget( "client-2@" + ccenv.getPVob() + ", INITIAL, false" ) )
.checkExpectedResult(Result.SUCCESS).validate();

//model-3
//client-3
AbstractBuild<?,?> build5 = jProject.scheduleBuild2(0, new Cause.UserIdCause()).get();

SystemValidator<ClearCaseUCMTarget> targets5 = new SystemValidator<ClearCaseUCMTarget>(build5);
targets5.checkAction(true)
.checkTargets( new ClearCaseUCMTarget( "model-3@" + ccenv.getPVob() + ", INITIAL, false" ), new ClearCaseUCMTarget( "client-3@" + ccenv.getPVob() + ", INITIAL, false" ) )
.checkExpectedResult(Result.SUCCESS).validate();

AbstractBuild<?,?> build6 = jProject.scheduleBuild2(0, new Cause.UserIdCause()).get();

//Last build. We have an unlabeled baseline. We should NOT build this.
SystemValidator<ClearCaseUCMTarget> targets6 = new SystemValidator<ClearCaseUCMTarget>(build6);
targets6.checkExpectedResult(Result.NOT_BUILT);

}
}
164 changes: 164 additions & 0 deletions src/test/resources/setup_no_label.xml
@@ -0,0 +1,164 @@
<ccenv>
<var name="name" value="praqma" />
<var name="pvobname" value="${name}_PVOB" />
<var name="vobname" value="${name}" />

<vob storetag="pvobname" tag="\${pvobname}" linuxtag="/vobs/${pvobname}" comment="PVOB" ucmproject="true" stgloc="-auto" mounted="true"/>
<vob storetag="vobname" tag="\${vobname}" linuxtag="/vobs/${vobname}" stgloc="-auto" mounted="true"/>

<view tag="${name}_setupview" stgloc="-auto"/>
<context mvfs="m:\" linux="/view" view="${name}_setupview" vob="${vobname}"/>

<component root="" comment="" name="_System" pvob="${pvobname}" />
<component root="" comment="" name="_Server" pvob="${pvobname}" />
<component root="" comment="" name="_Client" pvob="${pvobname}" />
<component root="Service" comment="" name="Service" pvob="${pvobname}" />
<component root="Model" comment="" name="Model" pvob="${pvobname}" />
<component root="Clientapp" comment="" name="Clientapp" pvob="${pvobname}" />

<folder name="one_folder" in="RootFolder" pvob="${pvobname}" />

<project name="bootstrap" comment="" model="SIMPLE" pvob="${pvobname}" in="one_folder">
<components>
<component name="Service" pvob="${pvobname}" />
<component name="Model" pvob="${pvobname}" />
<component name="Clientapp" pvob="${pvobname}" />
</components>
<policies>
<policy>POLICY_INTERPROJECT_DELIVER</policy>
</policies>
</project>

<stream name="bootstrap_int" in="bootstrap" comment="" pvob="${pvobname}" type="integration">
<baselines>
<baseline name="_System_INITIAL" pvob="${pvobname}" />
<baseline name="_Server_INITIAL" pvob="${pvobname}" />
<baseline name="_Client_INITIAL" pvob="${pvobname}" />
<baseline name="Service_INITIAL" pvob="${pvobname}" />
<baseline name="Model_INITIAL" pvob="${pvobname}" />
<baseline name="Clientapp_INITIAL" pvob="${pvobname}" />
</baselines>
</stream>

<view tag="${name}_bootstrap_int" stgloc="-auto">
<stream name="bootstrap_int" pvob="${pvobname}" />
</view>

<context mvfs="m:\" linux="/view" view="${name}_bootstrap_int" vob="${vobname}"/>

<baseline name="_Server_1.0" label="none" comment="" component="_Server" pvob="${pvobname}">
<dependencies>
<component name="Service" pvob="${pvobname}" />
<component name="Model" pvob="${pvobname}" />
</dependencies>
</baseline>

<baseline name="_Client_1.0" label="none" comment="" component="_Client" pvob="${pvobname}">
<dependencies>
<component name="Clientapp" pvob="${pvobname}" />
<component name="Model" pvob="${pvobname}" />
</dependencies>
</baseline>

<baseline name="_System_1.0" label="full" comment="" component="_System" pvob="${pvobname}">
<dependencies>
<component name="_Server" pvob="${pvobname}" />
<component name="_Client" pvob="${pvobname}" />
</dependencies>
</baseline>


<project name="one" comment="" pvob="${pvobname}" in="one_folder">
<components>
<component name="Service" pvob="${pvobname}" />
<component name="Model" pvob="${pvobname}" />
<component name="Clientapp" pvob="${pvobname}" />
</components>
<policies>
<policy>POLICY_INTERPROJECT_DELIVER</policy>
</policies>
</project>

<stream name="one_int" in="one" comment="" pvob="${pvobname}" type="integration">
<baselines>
<baseline name="_System_1.0" pvob="${pvobname}" />
</baselines>
</stream>

<project name="jenkins" comment="" pvob="${pvobname}" in="one_folder">
<policies>
<policy>POLICY_INTERPROJECT_DELIVER</policy>
</policies>
</project>

<stream name="jenkins_int" in="jenkins" comment="" pvob="${pvobname}" type="integration">
</stream>

<view tag="${name}_one_int" stgloc="-auto">
<stream name="one_int" pvob="${pvobname}" />
</view>

<context mvfs="m:\" linux="/view" view="${name}_one_int" vob="${vobname}"/>

<activity comment="" headline="Adding initial files into components" in="one_int" name="initial_files" pvob="${pvobname}" />

<setactivity activity="initial_files" pvob="${pvobname}" />

<!-- First -->
<add file="Model/model.h" content="#1" />

<baseline name="model-1" label="full" comment="" component="Model" pvob="${pvobname}" />

<!-- Second -->
<add file="Clientapp/client.h" content="#1" />

<baseline name="client-1" label="full" comment="" component="Clientapp" pvob="${pvobname}" />

<!-- Third -->
<checkout comment="" file="Model/model.h" />

<content file="Model/model.h" content="#2" />

<checkin file="Model/model.h" />

<baseline name="model-2" label="full" comment="" component="Model" pvob="${pvobname}" />


<!-- Fourth -->
<checkout comment="" file="Model/model.h" />

<content file="Model/model.h" content="#3" />

<checkin file="Model/model.h" />

<baseline name="model-3" label="full" comment="" component="Model" pvob="${pvobname}" />

<!-- Fifth -->
<checkout comment="" file="Clientapp/client.h" />

<content file="Clientapp/client.h" content="#2" />

<checkin file="Clientapp/client.h" />

<baseline name="client-2" label="full" comment="" component="Clientapp" pvob="${pvobname}" />

<!-- Sixth -->
<checkout comment="" file="Clientapp/client.h" />

<content file="Clientapp/client.h" content="#3" />

<checkin file="Clientapp/client.h" />

<baseline name="client-3" label="full" comment="" component="Clientapp" pvob="${pvobname}" />

<!-- Seventh -->
<checkout comment="" file="Clientapp/client.h" />

<content file="Clientapp/client.h" content="#3-nolabel" />

<checkin file="Clientapp/client.h" />

<baseline name="client-3-nolabel" label="none" comment="" component="Clientapp" pvob="${pvobname}" />
</ccenv>


0 comments on commit a30718c

Please sign in to comment.