Skip to content
Permalink
Browse files
Final fix for JENKINS-19658
  • Loading branch information
MadsNielsen committed Mar 21, 2014
1 parent 474130a commit 8857f0ca8f8a482cddb487c0cc8c446cb9bd5f4d
40 pom.xml
@@ -10,8 +10,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>1.4.12</powermock.version>
</properties>

<!--<groupId>net.praqma</groupId>-->

<artifactId>clearcase-ucm-plugin</artifactId>
<version>1.5.2-SNAPSHOT</version>
<name>ClearCase UCM Plugin!</name>
@@ -24,7 +23,6 @@
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>

<repository>
<id>praqma-repo</id>
<url>http://code.praqma.net/repo/maven/</url>
@@ -39,7 +37,7 @@
</pluginRepositories>

<developers>
<developer>
<developer>
<id>jes-struck</id>
<name>Jes Struck</name>
</developer>
@@ -56,7 +54,12 @@
<name>Lars Kruse</name>
<email>support@praqma.net</email>
</developer>
<developer>
<id>MadsNielsen</id>
<name>Mads Nielsen</name>
</developer>
</developers>

<!-- This profile executes ALL static analysis -->
<profiles>
<profile>
@@ -290,7 +293,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<formats>
<format>html</format>
@@ -324,9 +326,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<version>2.16</version>
<configuration>
<argLine>-Xms256m -Xmx256m -Xss1m</argLine>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xms512m -Xmx512m -Xss1m</argLine>
<includes>
<include>net/praqma/hudson/test/unit/*.java</include>
</includes>
@@ -343,20 +347,18 @@

<profile>
<id>integration-tests</id>

<build>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<version>2.16</version>
<configuration>
<argLine>-Xms256m -Xmx256m -Xss1m</argLine>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xms512m -Xmx512m -Xss1m</argLine>
<includes>
<!-- <include>net/praqma/hudson/test/integration/child/*.java</include> -->
<include>net/praqma/hudson/test/integration/*/*.java</include>
<!-- <include>net/praqma/hudson/test/integration/child/GetBaselinesTest.java</include> -->
</includes>
</configuration>
</plugin>
@@ -367,23 +369,23 @@

<profile>
<id>integration-tests-with-slaves</id>

<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<version>2.16</version>
<configuration>
<argLine>-Xms256m -Xmx256m -Xss1m</argLine>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xms512m -Xmx512m -Xss1m</argLine>
<includes>
<include>net/praqma/hudson/test/enslaved/*</include>
<include>net/praqma/hudson/test/integration/*/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>

</build>
</profile>

@@ -19,7 +19,7 @@

public class BaseTestClass {

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

@ClassRule
public static CCUCMRule jenkins = new CCUCMRule();
@@ -16,10 +16,7 @@
import java.util.concurrent.Future;
import java.util.logging.Logger;

import hudson.tasks.Builder;
import jenkins.model.Jenkins;
import net.praqma.clearcase.ucm.entities.*;
import net.praqma.clearcase.ucm.view.UCMView;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestBuilder;

@@ -36,7 +33,7 @@

public class CCUCMRule extends JenkinsRule {

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

private CCUCMScm scm;

@@ -240,6 +237,7 @@ public FreeStyleProject setupProjectWithASlave( String projectName, String type,

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] ====" );
printInfo(projectName, type, component, stream, recommend, tag, description, createBaseline, forceDeliver, template, promotionLevel);
FreeStyleProject project = createFreeStyleProject( "ccucm-project-" + projectName );
DumbSlave slave = createSlave();
@@ -1,26 +1,24 @@
package net.praqma.hudson.test.integration.child;

import static org.junit.Assert.*;

import java.io.File;

import net.praqma.hudson.test.BaseTestClass;
import org.junit.Rule;
import org.junit.Test;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.scm.PollingResult;
import java.io.File;
import net.praqma.clearcase.exceptions.ClearCaseException;
import net.praqma.clearcase.test.annotations.ClearCaseUniqueVobName;
import net.praqma.clearcase.test.junit.ClearCaseRule;
import net.praqma.clearcase.ucm.entities.Activity;
import net.praqma.clearcase.ucm.entities.Baseline;
import net.praqma.clearcase.ucm.entities.Stream;
import net.praqma.clearcase.ucm.entities.Baseline.LabelBehaviour;
import net.praqma.clearcase.ucm.entities.Stream;
import net.praqma.clearcase.ucm.view.UCMView;
import net.praqma.clearcase.util.ExceptionUtils;
import net.praqma.util.test.junit.TestDescription;
import net.praqma.hudson.test.BaseTestClass;
import net.praqma.util.debug.Logger;
import net.praqma.util.test.junit.TestDescription;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;

public class Polling extends BaseTestClass {

@@ -33,7 +31,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.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );
FreeStyleProject project = jenkins.setupProject( "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" );
@@ -44,6 +42,7 @@ public void testPollingChildsWithChanges() throws Exception {
build = project.scheduleBuild2( 0 ).get();
} catch( Exception e ) {
logger.info( "Build failed: " + e.getMessage() );
fail("The test failed with exception message: "+e.getMessage());
}

logger.info( "Build DONE, now polling" );
@@ -57,22 +56,28 @@ 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.setupProjectWithASlave( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );

//Fixme: This test should run on a slave. Currently the setActivity() method exphibits sporadic behaviour
FreeStyleProject project = jenkins.setupProject( "polling-test-with-baselines-" + ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, false, false, false );

File path = setActivity();
System.out.println("Activity set...");

Baseline b1 = getNewBaseline( path, "file1.txt" );

System.out.println("Baseline gotten..");

FreeStyleBuild build = null;
try {
build = project.scheduleBuild2( 0 ).get();
} catch( Exception e ) {
logger.info( "Build failed: " + e.getMessage() );
fail("The test failed with exception message: "+e.getMessage());
}

logger.info( "Build DONE, now polling" );

System.out.println("Build DONE, Begin poll");
PollingResult result = project.poll( jenkins.createTaskListener() );

System.out.println( String.format( "Poll result was: "+result.hasChanges() ) );
assertTrue( result.hasChanges() );
}

@@ -85,9 +90,15 @@ protected File setActivity() throws ClearCaseException {
System.out.println( "PATH: " + path );

Stream stream = Stream.get( "one_dev", ccenv.getPVob() );
Activity activity = Activity.create( "ccucm-activity", stream, ccenv.getPVob(), true, "ccucm activity", null, path );

System.out.println("Stream found..");

Activity activity = Activity.create( "ccucm-activity", stream, ccenv.getPVob(), true, null , null, path );

System.out.println("Activity created");
UCMView.setActivity( activity, path, null, null );


System.out.println("Activity set");
return path;
}

0 comments on commit 8857f0c

Please sign in to comment.