continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r926018 - in /continuum/trunk/continuum-buildagent/continuum-buildagent-core: ./ src/main/java/org/apache/continuum/buildagent/taskqueue/execution/ src/test/java/org/apache/continuum/buildagent/action/ src/test/java/org/apache/continuum/bui...
Date Mon, 22 Mar 2010 10:14:38 GMT
Author: oching
Date: Mon Mar 22 10:14:37 2010
New Revision: 926018

URL: http://svn.apache.org/viewvc?rev=926018&view=rev
Log:
[CONTINUUM-2391] Master should not pass full path to local repository to the agent
o add test for the local repo config set in the build context (in BuildProjectTaskExecutor)

Added:
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/action/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/action/ContinuumActionStub.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/execution/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/execution/
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.xml
Modified:
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml?rev=926018&r1=926017&r2=926018&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml Mon Mar 22 10:14:37
2010
@@ -130,7 +130,34 @@ under the License.
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <scope>test</scope>
-    </dependency>    
+    </dependency>  
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-junit3</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <scope>test</scope>
+    </dependency>  
+     <!-- dependency of jmock3 -->
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- dependency of jmock3 -->
+    <dependency>
+      <groupId>org.objenesis</groupId>
+      <artifactId>objenesis</artifactId>  
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java?rev=926018&r1=926017&r2=926018&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
Mon Mar 22 10:14:37 2010
@@ -169,6 +169,7 @@ public class BuildProjectTaskExecutor
         actionContext.put( ContinuumBuildAgentUtil.KEY_ENVIRONMENTS,
                            getEnvironments( buildContext.getBuildDefinitionId(),
                                             getInstallationType( buildContext ) ) );
+        
         // CONTINUUM-2391        
         if( buildContext.getLocalRepository() != null )
         {
@@ -551,4 +552,29 @@ public class BuildProjectTaskExecutor
 
         return mavenProject;
     }
+    
+    public void setBuildContextManager( BuildContextManager buildContextManager )
+    {
+        this.buildContextManager = buildContextManager;
+    }
+
+    public void setActionManager( ActionManager actionManager )
+    {
+        this.actionManager = actionManager;
+    }
+
+    public void setBuildAgentConfigurationService( BuildAgentConfigurationService buildAgentConfigurationService
)
+    {
+        this.buildAgentConfigurationService = buildAgentConfigurationService;
+    }
+
+    public void setBuildAgentManager( BuildAgentManager buildAgentManager )
+    {
+        this.buildAgentManager = buildAgentManager;
+    }
+
+    public void setBuildAgentBuildExecutorManager( BuildAgentBuildExecutorManager buildAgentBuildExecutorManager
)
+    {
+        this.buildAgentBuildExecutorManager = buildAgentBuildExecutorManager;
+    }
 }

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/action/ContinuumActionStub.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/action/ContinuumActionStub.java?rev=926018&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/action/ContinuumActionStub.java
(added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/action/ContinuumActionStub.java
Mon Mar 22 10:14:37 2010
@@ -0,0 +1,42 @@
+package org.apache.continuum.buildagent.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+
+import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
+import org.codehaus.plexus.action.AbstractAction;
+
+/**
+ * This is used for testing the fix for CONTINUUM-2391. See BuildPRrojectTaskExecutorTest.java
and
+ * BuildProjectTaskExecutorTest.xml for details.
+ */
+public class ContinuumActionStub
+    extends AbstractAction
+{
+    public void execute( Map context )
+        throws Exception
+    {
+        if ( !ContinuumBuildAgentUtil.getLocalRepository( context ).equals( "/home/user/.m2/repository"
) )
+        {
+            throw new Exception( "Local repository set in the build context should not have
been a full path!" );
+        }
+    }
+}

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.java?rev=926018&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.java
(added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.java
Mon Mar 22 10:14:37 2010
@@ -0,0 +1,213 @@
+package org.apache.continuum.buildagent.taskqueue.execution;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildExecutor;
+import org.apache.continuum.buildagent.build.execution.manager.BuildAgentBuildExecutorManager;
+import org.apache.continuum.buildagent.buildcontext.BuildContext;
+import org.apache.continuum.buildagent.buildcontext.manager.BuildContextManager;
+import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
+import org.apache.continuum.buildagent.manager.BuildAgentManager;
+import org.apache.continuum.buildagent.model.LocalRepository;
+import org.apache.continuum.taskqueue.BuildProjectTask;
+import org.apache.continuum.utils.build.BuildTrigger;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.scm.ScmResult;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit3.JUnit3Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+
+public class BuildProjectTaskExecutorTest
+    extends PlexusInSpringTestCase
+{
+    private Mockery context;
+
+    private BuildContextManager buildContextManager;
+
+    private BuildAgentBuildExecutorManager buildAgentBuildExecutorManager;
+
+    private BuildAgentConfigurationService buildAgentConfigurationService;
+
+    private BuildAgentManager buildAgentManager;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        context = new JUnit3Mockery();
+        context.setImposteriser( ClassImposteriser.INSTANCE );
+
+        buildContextManager = context.mock( BuildContextManager.class );
+
+        buildAgentBuildExecutorManager = context.mock( BuildAgentBuildExecutorManager.class
);
+
+        buildAgentConfigurationService = context.mock( BuildAgentConfigurationService.class
);
+
+        buildAgentManager = context.mock( BuildAgentManager.class );
+    }
+
+    // CONTINUUM-2391
+    // Note: The checking of the local repo set in the context is in ContinuumActionStub.
If the
+    // local repo path is incorrect, an exception will be thrown by the action stub.
+    public void testBuildProjectLocalRepository()
+        throws Exception
+    {
+        BuildProjectTaskExecutor buildProjectExecutor =
+            (BuildProjectTaskExecutor) lookup( TaskExecutor.class, "build-agent" );
+
+        buildProjectExecutor.setBuildAgentBuildExecutorManager( buildAgentBuildExecutorManager
);
+
+        buildProjectExecutor.setBuildAgentConfigurationService( buildAgentConfigurationService
);
+
+        buildProjectExecutor.setBuildContextManager( buildContextManager );
+
+        buildProjectExecutor.setBuildAgentManager( buildAgentManager );
+
+        final BuildContext buildContext = createBuildContext();
+
+        final List<LocalRepository> localRepos = new ArrayList<LocalRepository>();
+
+        LocalRepository localRepo = new LocalRepository();
+        localRepo.setName( "temp" );
+        localRepo.setLocation( "/tmp/.m2/repository" );
+        localRepo.setLayout( "default" );
+
+        localRepos.add( localRepo );
+
+        localRepo = new LocalRepository();
+        localRepo.setName( "default" );
+        localRepo.setLocation( "/home/user/.m2/repository" );
+        localRepo.setLayout( "default" );
+
+        localRepos.add( localRepo );
+
+        final Map<String, String> buildEnvironments = new HashMap<String, String>();
+        buildEnvironments.put( "M2_HOME", "/tmp/apache-maven-2.2.1" );
+
+        final ContinuumAgentBuildExecutor executor = context.mock( ContinuumAgentBuildExecutor.class
);
+        final File workingDir = new File( "/tmp/data/working-directory/project-test" );
+        final MavenProject project = new MavenProject();
+        final File outputFile = new File( "/tmp/data/build-output-directory/output.txt" );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( buildContextManager ).getBuildContext( 1 );
+                will( returnValue( buildContext ) );
+
+                one( buildAgentManager ).getEnvironments( 1, "maven2" );
+                will( returnValue( buildEnvironments ) );
+
+                one( buildAgentConfigurationService ).getLocalRepositories();
+                will( returnValue( localRepos ) );
+
+                one( buildAgentManager ).shouldBuild( with( any( Map.class ) ) );
+                will( returnValue( true ) );
+
+                one( buildAgentBuildExecutorManager ).getBuildExecutor(
+                                                                        ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR
);
+                will( returnValue( executor ) );
+
+                one( buildAgentConfigurationService ).getWorkingDirectory( 1 );
+                will( returnValue( workingDir ) );
+
+                one( executor ).getMavenProject( with( any( File.class ) ), with( any( BuildDefinition.class
) ) );
+                will( returnValue( project ) );
+
+                one( buildAgentManager ).startProjectBuild( 1 );
+
+                one( buildAgentConfigurationService ).getBuildOutputFile( 1 );
+                will( returnValue( outputFile ) );
+
+                one( buildAgentManager ).returnBuildResult( with( any( Map.class ) ) );
+
+                one( buildContextManager ).removeBuildContext( 1 );
+            }
+        } );
+
+        try
+        {
+            buildProjectExecutor.executeTask( createBuildProjectTask() );
+        }
+        catch ( Exception e )
+        {
+            fail( "An exception should not have been thrown!" );
+        }
+    }
+
+    private BuildProjectTask createBuildProjectTask()
+    {
+        BuildProjectTask task =
+            new BuildProjectTask( 1, 1, new BuildTrigger( 1 ), "Test Project", "Default Build
Definition",
+                                  new ScmResult(), 1 );
+        return task;
+    }
+
+    private BuildContext createBuildContext()
+    {
+        BuildContext context = new BuildContext();
+        context.setProjectId( 1 );
+        context.setProjectVersion( "1.0-SNAPSHOT" );
+        context.setBuildDefinitionId( 1 );
+        context.setBuildFile( "pom.xml" );
+        context.setExecutorId( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
+        context.setGoals( "clean intall" );
+        context.setArguments( "--batch --non-recursive" );
+        context.setScmUrl( "scm:svn:http://svn.example.com/repos/dummy/trunk" );
+        context.setScmUsername( "" );
+        context.setScmPassword( "" );
+        context.setBuildFresh( false );
+        context.setProjectGroupId( 1 );
+        context.setProjectGroupName( "Test Project Group" );
+        context.setScmRootAddress( "scm:svn:http://svn.example.com/repos/dummy" );
+        context.setScmRootId( 1 );
+        context.setProjectName( "Test Project" );
+        context.setProjectState( 1 );
+        context.setTrigger( 1 );
+        context.setUsername( "" );
+        context.setLocalRepository( "default" );
+        context.setBuildNumber( 1 );
+
+        ScmResult scmResult = new ScmResult();
+        scmResult.setSuccess( true );
+
+        context.setScmResult( scmResult );
+        context.setLatestUpdateDate( Calendar.getInstance().getTime() );
+        context.setBuildAgentUrl( "http://localhost:8181/continuum-buildagent/xmlrpc" );
+        context.setMaxExecutionTime( 7200 );
+        context.setBuildDefinitionLabel( "Default Build Definition" );
+        context.setScmTag( "scm:svn:http://svn.example.com/repos/dummy/tags" );
+
+        return context;
+    }
+}
\ No newline at end of file

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.xml?rev=926018&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.xml
(added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/test/resources/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutorTest.xml
Mon Mar 22 10:14:37 2010
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<plexus>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.action.Action</role>
+      <role-hint>update-project-from-agent-working-directory</role-hint>
+     <implementation>org.apache.continuum.buildagent.action.ContinuumActionStub</implementation>
+    </component>
+    <component>
+      <role>org.codehaus.plexus.action.Action</role>
+      <role-hint>execute-agent-builder</role-hint>
+      <implementation>org.apache.continuum.buildagent.action.ContinuumActionStub</implementation>
+    </component>
+  </components>
+</plexus>
\ No newline at end of file



Mime
View raw message