Repository: incubator-gearpump
Updated Branches:
  refs/heads/master 2fe4abd72 -> 833f4d732


fix GEARPUMP-165, RestServiceSpec failed

Author: manuzhang <[email protected]>

Closes #50 from manuzhang/GEARPUMP-165.


Project: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-gearpump/commit/833f4d73
Tree: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/tree/833f4d73
Diff: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/diff/833f4d73

Branch: refs/heads/master
Commit: 833f4d73275919db45525716108aadcd0ed5a06e
Parents: 2fe4abd
Author: manuzhang <[email protected]>
Authored: Fri Jun 24 11:18:47 2016 +0800
Committer: manuzhang <[email protected]>
Committed: Fri Jun 24 11:18:47 2016 +0800

----------------------------------------------------------------------
 .../apache/gearpump/cluster/ClusterConfig.scala |  4 +-
 .../apache/gearpump/cluster/main/MainSpec.scala | 57 ++++++++++----------
 .../gearpump/integrationtest/TestSpecBase.scala |  1 +
 .../checklist/RestServiceSpec.scala             |  4 +-
 4 files changed, 34 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/833f4d73/core/src/main/scala/org/apache/gearpump/cluster/ClusterConfig.scala
----------------------------------------------------------------------
diff --git 
a/core/src/main/scala/org/apache/gearpump/cluster/ClusterConfig.scala 
b/core/src/main/scala/org/apache/gearpump/cluster/ClusterConfig.scala
index 332e770..e0751f9 100644
--- a/core/src/main/scala/org/apache/gearpump/cluster/ClusterConfig.scala
+++ b/core/src/main/scala/org/apache/gearpump/cluster/ClusterConfig.scala
@@ -66,7 +66,7 @@ object ClusterConfig {
     load(configFile).master
   }
 
-  /*
+  /**
    * configuration for worker node
    */
   def worker(configFile: String = null): Config = {
@@ -90,7 +90,7 @@ object ClusterConfig {
         LOG.info("loading config file " + path + "..........")
         load(ClusterConfigSource(path))
       case None =>
-        LOG.info("loading config file application.conf...")
+        LOG.info(s"loading config file $configFile...")
         load(ClusterConfigSource(configFile))
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/833f4d73/daemon/src/test/scala/org/apache/gearpump/cluster/main/MainSpec.scala
----------------------------------------------------------------------
diff --git 
a/daemon/src/test/scala/org/apache/gearpump/cluster/main/MainSpec.scala 
b/daemon/src/test/scala/org/apache/gearpump/cluster/main/MainSpec.scala
index 205bb49..90fdd39 100644
--- a/daemon/src/test/scala/org/apache/gearpump/cluster/main/MainSpec.scala
+++ b/daemon/src/test/scala/org/apache/gearpump/cluster/main/MainSpec.scala
@@ -18,10 +18,17 @@
 
 package org.apache.gearpump.cluster.main
 
+import java.util.Properties
+
+import akka.testkit.TestProbe
+import org.apache.gearpump.cluster.MasterToWorker.WorkerRegistered
+import org.apache.gearpump.cluster.master.MasterProxy
+import org.apache.gearpump.transport.HostPort
+
 import scala.concurrent.Future
 import scala.util.{Success, Try}
 
-import com.typesafe.config.Config
+import com.typesafe.config.{ConfigFactory, Config}
 import org.scalatest._
 
 import org.apache.gearpump.cluster.ClientToMaster.{ResolveAppId, 
ShutdownApplication}
@@ -71,33 +78,27 @@ class MainSpec extends FlatSpec with Matchers with 
BeforeAndAfterEach with Maste
     }
   }
 
-  //  This UT fails a lot on Travis, temporarily delete it.
-  //  "Master" should "accept worker RegisterNewWorker when started" in {
-  //    val worker = TestProbe()(getActorSystem)
-  //
-  //    val port = Util.findFreePort.get
-  //
-  //    val masterConfig =  
Array(s"-D${Constants.GEARPUMP_CLUSTER_MASTERS}.0=127.0.0.1:$port",
-  //      s"-D${Constants.GEARPUMP_HOSTNAME}=127.0.0.1")
-  //
-  //    val masterProcess = Util.startProcess(masterConfig,
-  //      getContextClassPath,
-  //      getMainClassName(org.apache.gearpump.cluster.main.Master),
-  //      Array("-ip", "127.0.0.1", "-port", port.toString))
-  //
-  //    //wait for master process to be started
-  //
-  //    try {
-  //
-  //      val masterProxy = getActorSystem.actorOf(
-  //        MasterProxy.props(List(HostPort("127.0.0.1", port))), "mainSpec")
-  //
-  //      worker.send(masterProxy, RegisterNewWorker)
-  //      worker.expectMsgType[WorkerRegistered](PROCESS_BOOT_TIME)
-  //    } finally {
-  //      masterProcess.destroy()
-  //    }
-  //  }
+  "Master" should "accept worker RegisterNewWorker when started" in {
+    val worker = TestProbe()(getActorSystem)
+
+    val host = "127.0.0.1"
+    val port = Util.findFreePort().get
+
+    val properties = new Properties()
+    properties.put(s"${GEARPUMP_CLUSTER_MASTERS}.0", s"$host:$port")
+    properties.put(s"${GEARPUMP_HOSTNAME}", s"$host")
+    val masterConfig = ConfigFactory.parseProperties(properties)
+      .withFallback(TestUtil.MASTER_CONFIG)
+    Future {
+      Master.main(masterConfig, Array("-ip", "127.0.0.1", "-port", 
port.toString))
+    }
+
+    val masterProxy = getActorSystem.actorOf(
+      MasterProxy.props(List(HostPort("127.0.0.1", port))), "mainSpec")
+
+    worker.send(masterProxy, RegisterNewWorker)
+    worker.expectMsgType[WorkerRegistered](PROCESS_BOOT_TIME)
+  }
 
   "Info" should "be started without exception" in {
 

http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/833f4d73/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/TestSpecBase.scala
----------------------------------------------------------------------
diff --git 
a/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/TestSpecBase.scala
 
b/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/TestSpecBase.scala
index f480475..1e49236 100644
--- 
a/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/TestSpecBase.scala
+++ 
b/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/TestSpecBase.scala
@@ -53,6 +53,7 @@ trait TestSpecBase
 
   lazy val wordCountJar = cluster.queryBuiltInExampleJars("wordcount-").head
   lazy val wordCountName = "wordCount"
+  lazy val wordCountClass = 
"org.apache.gearpump.streaming.examples.wordcount.WordCount"
 
   var restartClusterRequired: Boolean = false
 

http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/833f4d73/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/checklist/RestServiceSpec.scala
----------------------------------------------------------------------
diff --git 
a/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/checklist/RestServiceSpec.scala
 
b/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/checklist/RestServiceSpec.scala
index 992533b..8b5b82a 100644
--- 
a/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/checklist/RestServiceSpec.scala
+++ 
b/integrationtest/core/src/it/scala/org/apache/gearpump/integrationtest/checklist/RestServiceSpec.scala
@@ -87,7 +87,7 @@ class RestServiceSpec extends TestSpecBase {
 
       // exercise
       val success = restClient.submitApp(wordCountJar, 
cluster.getWorkerHosts.length,
-        s"-split $splitNum -sum $sumNum")
+        s"$wordCountClass -split $splitNum -sum $sumNum")
       success shouldBe true
       expectAppIsRunning(appId, wordCountName)
       val processors = restClient.queryStreamingAppDetail(appId).processors
@@ -332,7 +332,7 @@ class RestServiceSpec extends TestSpecBase {
       val originSumNum = 3
       val originAppId = restClient.getNextAvailableAppId()
       val success = restClient.submitApp(wordCountJar, 
cluster.getWorkerHosts.length,
-        s"-split $originSplitNum -sum $originSumNum")
+        s"$wordCountClass -split $originSplitNum -sum $originSumNum")
       success shouldBe true
       expectAppIsRunning(originAppId, wordCountName)
       val originAppDetail = restClient.queryStreamingAppDetail(originAppId)

Reply via email to