continuum-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marica Tan <marica....@gmail.com>
Subject Re: svn commit: r947263 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/utils/build/ continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ continuum-buildagent/continuum-buildagent-core/
Date Wed, 26 May 2010 01:07:29 GMT
Hi Jev,

Can you add a selenium test for this.

Thanks,
--
Marica

On Sat, May 22, 2010 at 3:30 PM, <jzurbano@apache.org> wrote:

> Author: jzurbano
> Date: Sat May 22 07:30:44 2010
> New Revision: 947263
>
> URL: http://svn.apache.org/viewvc?rev=947263&view=rev
> Log:
> [CONTINUUM-2503] 'Triggered by' should not be blank when it's a scheduled
> build
> * refactored BuildTrigger; renamed "username" to "triggeredBy"
> * set schedule name for "triggeredBy" field during scheduled builds
> * added unit tests to check the username/schedule name is set in context
> * updated documentation
>
>
> Modified:
>
>  continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/build/BuildTrigger.java
>
>  continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
>
>  continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
>
>  continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
>
>  continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
>
>  continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
>
>  continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
>
>  continuum/trunk/continuum-docs/src/site/apt/user_guides/building_project/build_results.apt
>
>  continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildProjectAction.java
>
> Modified:
> continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/build/BuildTrigger.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/build/BuildTrigger.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/build/BuildTrigger.java
> (original)
> +++
> continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/build/BuildTrigger.java
> Sat May 22 07:30:44 2010
> @@ -28,22 +28,22 @@ public class BuildTrigger
>  {
>     private int trigger;
>
> -    private String username;
> +    private String triggeredBy;
>
>     public BuildTrigger( int trigger )
>     {
>         this.trigger = trigger;
>     }
>
> -    public BuildTrigger( String username )
> +    public BuildTrigger( String triggeredBy )
>     {
> -        this.username = username;
> +        this.triggeredBy = triggeredBy;
>     }
>
> -    public BuildTrigger( int trigger, String username )
> +    public BuildTrigger( int trigger, String triggeredBy )
>     {
>         this.trigger = trigger;
> -        this.username = username;
> +        this.triggeredBy = triggeredBy;
>     }
>
>     public void setTrigger( int trigger )
> @@ -56,14 +56,14 @@ public class BuildTrigger
>         return this.trigger;
>     }
>
> -    public void setUsername( String username )
> +    public void setTriggeredBy( String triggeredBy )
>     {
> -        this.username = username;
> +        this.triggeredBy = triggeredBy;
>     }
>
> -    public String getUsername()
> +    public String getTriggeredBy()
>     {
> -        return this.username;
> +        return this.triggeredBy;
>     }
>  }
>
>
> Modified:
> continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
> (original)
> +++
> continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
> Sat May 22 07:30:44 2010
> @@ -614,7 +614,7 @@ public class ContinuumBuildAgentServiceI
>                 map.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ID, new
> Integer( task.getScmRootId() ) );
>                 map.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS,
> task.getScmRootAddress() );
>                 map.put( ContinuumBuildAgentUtil.KEY_TRIGGER,
> task.getBuildTrigger().getTrigger() );
> -                map.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getUsername() );
> +                map.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getTriggeredBy() );
>
>                 projects.add( map );
>             }
> @@ -670,7 +670,7 @@ public class ContinuumBuildAgentServiceI
>                 map.put( ContinuumBuildAgentUtil.KEY_PROJECT_ID, new
> Integer( task.getProjectId() ) );
>                 map.put( ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION_ID,
> new Integer( task.getBuildDefinitionId() ) );
>                 map.put( ContinuumBuildAgentUtil.KEY_TRIGGER,
> task.getBuildTrigger().getTrigger() );
> -                map.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getUsername() );
> +                map.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getTriggeredBy() );
>                 map.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, new
> Integer( task.getProjectGroupId() ) );
>                 map.put(
> ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION_LABEL,
> task.getBuildDefinitionLabel() );
>
> @@ -701,7 +701,7 @@ public class ContinuumBuildAgentServiceI
>                 project.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ID, new
> Integer( task.getScmRootId() ) );
>                 project.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS,
> task.getScmRootAddress() );
>                 project.put( ContinuumBuildAgentUtil.KEY_TRIGGER,
> task.getBuildTrigger().getTrigger() );
> -                project.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getUsername() );
> +                project.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getTriggeredBy() );
>             }
>
>             return project;
> @@ -757,7 +757,7 @@ public class ContinuumBuildAgentServiceI
>                 project.put( ContinuumBuildAgentUtil.KEY_PROJECT_ID, new
> Integer( task.getProjectId() ) );
>                 project.put(
> ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION_ID, new Integer(
> task.getBuildDefinitionId() ) );
>                 project.put( ContinuumBuildAgentUtil.KEY_TRIGGER,
> task.getBuildTrigger().getTrigger() );
> -                project.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getUsername() );
> +                project.put( ContinuumBuildAgentUtil.KEY_USERNAME,
> task.getBuildTrigger().getTriggeredBy() );
>                 project.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID,
> new Integer( task.getProjectGroupId() ) );
>                 project.put(
> ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION_LABEL,
> task.getBuildDefinitionLabel() );
>             }
>
> Modified:
> continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
> (original)
> +++
> continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
> Sat May 22 07:30:44 2010
> @@ -361,7 +361,7 @@ public class ContinuumBuildAgentUtil
>
>     public static String getUsername( Map<String, Object> context )
>     {
> -         return getString( context, KEY_USERNAME, "" );
> +         return getString( context, KEY_USERNAME, "scheduled" );
>     }
>
>     public static BuildTrigger getBuildTrigger( Map<String, Object> context
> )
>
> Modified:
> continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
> (original)
> +++
> continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
> Sat May 22 07:30:44 2010
> @@ -229,7 +229,16 @@ public class DistributedBuildProjectTask
>                     context.put( ContinuumBuildConstant.KEY_ARGUMENTS,
> buildDef.getArguments() );
>                 }
>                 context.put( ContinuumBuildConstant.KEY_TRIGGER,
> buildTrigger.getTrigger() );
> -                context.put( ContinuumBuildConstant.KEY_USERNAME,
> buildTrigger.getUsername() );
> +
> +                if ( buildTrigger.getTrigger() ==
> ContinuumProjectState.TRIGGER_FORCED )
> +                {
> +                    context.put( ContinuumBuildConstant.KEY_USERNAME,
> buildTrigger.getTriggeredBy() );
> +                }
> +                else
> +                {
> +                    context.put( ContinuumBuildConstant.KEY_USERNAME,
> buildDef.getSchedule().getName() );
> +                }
> +
>                 context.put( ContinuumBuildConstant.KEY_BUILD_FRESH,
> buildDef.isBuildFresh() );
>                 context.put( ContinuumBuildConstant.KEY_ALWAYS_BUILD,
> buildDef.isAlwaysBuild() );
>                 context.put( ContinuumBuildConstant.KEY_OLD_SCM_CHANGES,
> @@ -283,7 +292,7 @@ public class DistributedBuildProjectTask
>                         buildResult.setError( error );
>                         buildResult.setState( ContinuumProjectState.ERROR
> );
>                         buildResult.setTrigger(
> task.getBuildTrigger().getTrigger() );
> -                        buildResult.setUsername(
> task.getBuildTrigger().getUsername() );
> +                        buildResult.setUsername(
> task.getBuildTrigger().getTriggeredBy() );
>                         buildResult.setStartTime( startTime );
>                         buildResult.setEndTime( endTime );
>
>
> Modified:
> continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
> (original)
> +++
> continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
> Sat May 22 07:30:44 2010
> @@ -337,8 +337,6 @@ public class DefaultBuildController
>
>         context.setStartTime( System.currentTimeMillis() );
>
> -        context.setBuildTrigger( buildTrigger );
> -
>         Map actionContext = context.getActionContext();
>
>         try
> @@ -348,6 +346,15 @@ public class DefaultBuildController
>             context.setProject( project );
>
>             BuildDefinition buildDefinition =
> buildDefinitionDao.getBuildDefinition( buildDefinitionId );
> +
> +            BuildTrigger newBuildTrigger = buildTrigger;
> +
> +            if ( newBuildTrigger.getTrigger() ==
> ContinuumProjectState.TRIGGER_SCHEDULED )
> +            {
> +                newBuildTrigger.setTriggeredBy(
> buildDefinition.getSchedule().getName() );
> +            }
> +
> +            context.setBuildTrigger( newBuildTrigger );
>
>             context.setBuildDefinition( buildDefinition );
>
> @@ -733,7 +740,7 @@ public class DefaultBuildController
>
>         build.setTrigger( context.getBuildTrigger().getTrigger() );
>
> -        build.setUsername( context.getBuildTrigger().getUsername() );
> +        build.setUsername( context.getBuildTrigger().getTriggeredBy() );
>
>         build.setStartTime( context.getStartTime() );
>
>
> Modified:
> continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
> (original)
> +++
> continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
> Sat May 22 07:30:44 2010
> @@ -108,7 +108,7 @@ public class ExecuteBuilderContinuumActi
>
>         buildResult.setTrigger( buildTrigger.getTrigger() );
>
> -        buildResult.setUsername( buildTrigger.getUsername() );
> +        buildResult.setUsername( buildTrigger.getTriggeredBy() );
>
>         buildResult.setScmResult( scmResult );
>
>
> Modified:
> continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
> (original)
> +++
> continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
> Sat May 22 07:30:44 2010
> @@ -30,6 +30,7 @@ import org.apache.maven.continuum.model.
>  import org.apache.maven.continuum.model.project.BuildResult;
>  import org.apache.maven.continuum.model.project.Project;
>  import org.apache.maven.continuum.model.project.ProjectDependency;
> +import org.apache.maven.continuum.model.project.Schedule;
>  import org.apache.maven.continuum.model.scm.ScmResult;
>  import org.apache.maven.continuum.project.ContinuumProjectState;
>
> @@ -45,7 +46,11 @@ public class DefaultBuildControllerTest
>     extends AbstractContinuumTest
>  {
>     private DefaultBuildController controller;
> -
> +
> +    private static String FORCED_BUILD_USER = "TestUsername";
> +
> +    private static String SCHEDULE_NAME = "TEST_SCHEDULE";
> +
>     int projectId1;
>
>     int projectId2;
> @@ -121,23 +126,33 @@ public class DefaultBuildControllerTest
>     private BuildDefinition createBuildDefinition()
>     {
>         BuildDefinition builddef = new BuildDefinition();
> +        Schedule schedule = new Schedule();
> +        schedule.setName( SCHEDULE_NAME );
> +        builddef.setSchedule( schedule );
>         builddef.setBuildFile( "pom.xml" );
>         builddef.setGoals( "clean" );
>         builddef.setDefaultForProject( true );
>         return builddef;
>     }
>
> -    private BuildContext getContext()
> +    private BuildContext getScheduledBuildContext()
> +        throws Exception
> +    {
> +        return controller.initializeBuildContext( projectId2,
> buildDefinitionId2,
> +                          new BuildTrigger(
> ContinuumProjectState.TRIGGER_SCHEDULED ), new ScmResult() );
> +    }
> +
> +    private BuildContext getForcedBuildContext()
>         throws Exception
>     {
>         return controller.initializeBuildContext( projectId2,
> buildDefinitionId2,
> -                          new BuildTrigger(
> ContinuumProjectState.TRIGGER_SCHEDULED, "" ), new ScmResult() );
> +                          new BuildTrigger(
> ContinuumProjectState.TRIGGER_FORCED, FORCED_BUILD_USER ), new ScmResult()
> );
>     }
>
>     private BuildContext getContext( int hourOfLastExecution )
>         throws Exception
>     {
> -        BuildContext context = getContext();
> +        BuildContext context = getScheduledBuildContext();
>         BuildResult oldBuildResult = new BuildResult();
>         oldBuildResult.setEndTime( Calendar.getInstance().getTimeInMillis()
> + ( hourOfLastExecution * 3600000 ) );
>         context.setOldBuildResult( oldBuildResult );
> @@ -172,7 +187,7 @@ public class DefaultBuildControllerTest
>         p2.setState( ContinuumProjectState.NEW );
>         getProjectDao().updateProject( p2 );
>
> -        BuildContext context = getContext();
> +        BuildContext context = getScheduledBuildContext();
>         controller.checkProjectDependencies( context );
>         assertEquals( 0, context.getModifiedDependencies().size() );
>         assertTrue( controller.shouldBuild( context ) );
> @@ -181,7 +196,7 @@ public class DefaultBuildControllerTest
>     public void testWithNewBuildDefinition()
>         throws Exception
>     {
> -        BuildContext context = getContext();
> +        BuildContext context = getScheduledBuildContext();
>         assertNull( context.getOldBuildResult() );
>         assertTrue( controller.shouldBuild( context ) );
>     }
> @@ -205,6 +220,33 @@ public class DefaultBuildControllerTest
>         assertFalse( controller.shouldBuild( context ) );
>     }
>
> +    public void testForcedBuildTriggeredByField()
> +        throws Exception
> +    {
> +        BuildContext context = getForcedBuildContext();
> +        assertEquals( FORCED_BUILD_USER,
> context.getBuildTrigger().getTriggeredBy() );
> +    }
> +
> +    public void testScheduledBuildTriggeredByField()
> +        throws Exception
> +    {
> +        BuildContext context = getScheduledBuildContext();
> +        assertEquals( SCHEDULE_NAME,
> context.getBuildTrigger().getTriggeredBy() );
> +    }
> +
> +    public void testScheduledBuildTriggeredByField_UsernameProvided()
> +        throws Exception
> +    {
> +        BuildTrigger buildTrigger = new BuildTrigger(
> ContinuumProjectState.TRIGGER_SCHEDULED, "test-user" );
> +
> +        BuildContext context = controller.initializeBuildContext(
> projectId2, buildDefinitionId2,
> +
>  buildTrigger, new ScmResult() );
> +
> +        String contextTriggeredBy =
> context.getBuildTrigger().getTriggeredBy();
> +        assertFalse( "test-user".equals( contextTriggeredBy ) );
> +        assertEquals( SCHEDULE_NAME, contextTriggeredBy );
> +    }
> +
>     private File getWorkingDirectory()
>         throws Exception
>     {
>
> Modified:
> continuum/trunk/continuum-docs/src/site/apt/user_guides/building_project/build_results.apt
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-docs/src/site/apt/user_guides/building_project/build_results.apt?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-docs/src/site/apt/user_guides/building_project/build_results.apt
> (original)
> +++
> continuum/trunk/continuum-docs/src/site/apt/user_guides/building_project/build_results.apt
> Sat May 22 07:30:44 2010
> @@ -32,8 +32,8 @@ Build Results Management
>
>  [../../images/build_result-1.png] Build Results page
>
> -    The <<Triggered by>> field displays the username of the person who
> forced the build.
> -    However, this field is empty when the build is triggered by a
> schedule.
> +    The <<Triggered by>> field displays the username of the person who
> forced the build,
> +    or the name of the schedule if the build is triggered by a schedule.
>
>     Or you can click on the name of the project that you want to delete
> build results from.
>
>
> Modified:
> continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildProjectAction.java
> URL:
> http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildProjectAction.java?rev=947263&r1=947262&r2=947263&view=diff
>
> ==============================================================================
> ---
> continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildProjectAction.java
> (original)
> +++
> continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildProjectAction.java
> Sat May 22 07:30:44 2010
> @@ -74,7 +74,7 @@ public class BuildProjectAction
>                 }
>                 else
>                 {
> -                       getContinuum().buildProject( projectId,
> buildTrigger.getUsername() );
> +                       getContinuum().buildProject( projectId,
> buildTrigger.getTriggeredBy() );
>                 }
>             }
>             else
> @@ -87,7 +87,7 @@ public class BuildProjectAction
>                 {
>                     //TODO: Check if this code is called, I don't think
>                     //If it is, it should used the projectId
> -                       getContinuum().buildProjects(
> buildTrigger.getUsername() );
> +                       getContinuum().buildProjects(
> buildTrigger.getTriggeredBy() );
>                 }
>             }
>         }
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message