continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1150083 - in /continuum/trunk: continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ continuum-buildagent/...
Date Sat, 23 Jul 2011 10:21:28 GMT
Author: ctan
Date: Sat Jul 23 10:21:27 2011
New Revision: 1150083

URL: http://svn.apache.org/viewvc?rev=1150083&view=rev
Log:
fixed unit test

Modified:
    continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.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/manager/BuildAgentManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java?rev=1150083&r1=1150082&r2=1150083&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
Sat Jul 23 10:21:27 2011
@@ -124,7 +124,8 @@ public interface ContinuumBuildAgentServ
     void removeFromBuildQueue( List<String> hashCodes )
         throws ContinuumBuildAgentException;
 
-    boolean ping();
+    boolean ping()
+        throws ContinuumBuildAgentException;
     
     /**
      * Get build agent's platform.

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=1150083&r1=1150082&r2=1150083&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 Jul 23 10:21:27 2011
@@ -34,6 +34,7 @@ import org.apache.commons.lang.StringEsc
 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.manager.BuildAgentReleaseManager;
 import org.apache.continuum.buildagent.model.Installation;
 import org.apache.continuum.buildagent.taskqueue.PrepareBuildProjectsTask;
@@ -91,6 +92,11 @@ public class ContinuumBuildAgentServiceI
      */
     private BuildAgentReleaseManager buildAgentReleaseManager;
 
+    /**
+     * @plexus.requirement
+     */
+    private BuildAgentManager buildAgentManager;
+
     public void buildProjects( List<Map<String, Object>> projectsBuildContext
)
         throws ContinuumBuildAgentException
     {
@@ -907,10 +913,17 @@ public class ContinuumBuildAgentServiceI
     }
 
     public boolean ping()
+        throws ContinuumBuildAgentException
     {
-        log.debug( "Ping Ok" );
-
-        return Boolean.TRUE;
+        try
+        {
+            // check first if it can ping the master
+            return buildAgentManager.pingMaster();
+        }
+        catch ( ContinuumException e )
+        {
+            throw new ContinuumBuildAgentException( e.getMessage() );
+        }
     }
 
     public String getBuildAgentPlatform() 

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java?rev=1150083&r1=1150082&r2=1150083&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java
Sat Jul 23 10:21:27 2011
@@ -47,4 +47,7 @@ public interface BuildAgentManager
 
     void endPrepareBuild( Map<String, Object> context )
         throws ContinuumException;
+
+    boolean pingMaster()
+        throws ContinuumException;
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java?rev=1150083&r1=1150082&r2=1150083&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
Sat Jul 23 10:21:27 2011
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
 import org.apache.continuum.distributed.transport.master.MasterBuildAgentTransportClient;
 import org.apache.maven.continuum.ContinuumException;
+import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -206,4 +207,35 @@ public class DefaultBuildAgentManager
             throw new ContinuumException( "Error while finishing prepare build", e );
         }
     }
+
+    public boolean pingMaster()
+        throws ContinuumException
+    {
+        String continuumServerUrl = buildAgentConfigurationService.getContinuumServerUrl();
+
+        try
+        {
+            if ( StringUtils.isBlank( continuumServerUrl ) )
+            {
+                throw new ContinuumException( "Build agent is not configured properly. Missing
continuumServerUrl in the configuration file" );
+            }
+
+            MasterBuildAgentTransportClient client = 
+                new MasterBuildAgentTransportClient( new URL( continuumServerUrl ) )
+            ;
+            return client.ping();
+        }
+        catch ( MalformedURLException e )
+        {
+            log.error(
+                "Invalid continuum server URL '" + continuumServerUrl + "'", e );
+            throw new ContinuumException(
+                "Invalid continuum server URL '" + continuumServerUrl + "'", e );
+        }
+        catch ( Exception e )
+        {
+            log.error( "Unable to ping master " + continuumServerUrl, e );
+            throw new ContinuumException( "Unable to ping master " + continuumServerUrl,
e );
+        }
+    }
 }

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java?rev=1150083&r1=1150082&r2=1150083&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
Sat Jul 23 10:21:27 2011
@@ -523,6 +523,8 @@ public class DefaultDistributedBuildMana
                 one( configurationService ).getBuildAgents();
                 will( returnValue( buildAgents ) );
 
+                one( overallDistributedBuildQueue1 ).getBuildAgentUrl();
+
                 one( overallDistributedBuildQueue1 ).addToDistributedBuildQueue( with( any(
Task.class ) ) );
             }
         } );
@@ -571,6 +573,8 @@ public class DefaultDistributedBuildMana
                 one( configurationService ).getBuildAgents();
                 will( returnValue( buildAgents ) );
 
+                one( overallDistributedBuildQueue2 ).getBuildAgentUrl();
+
                 one( overallDistributedBuildQueue2 ).addToDistributedBuildQueue( with( any(
Task.class ) ) );
             }
         } );



Mime
View raw message