Repository: incubator-samza
Updated Branches:
  refs/heads/master fd5ee548a -> 7d1a01c7b


SAMZA-325: Create unit test for Scaml-wrapped Scala


Project: http://git-wip-us.apache.org/repos/asf/incubator-samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-samza/commit/7d1a01c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/7d1a01c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/7d1a01c7

Branch: refs/heads/master
Commit: 7d1a01c7b0a6fc97496f09430d2de883242728a9
Parents: fd5ee54
Author: Chinmay Soman <chinmay dot cerebro at gmail dot com>
Authored: Fri Jul 11 09:23:37 2014 -0700
Committer: Jakob Homan <[email protected]>
Committed: Fri Jul 11 09:23:37 2014 -0700

----------------------------------------------------------------------
 .../job/yarn/TestSamzaAppMasterService.scala    | 45 ++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7d1a01c7/samza-yarn/src/test/scala/org/apache/samza/job/yarn/TestSamzaAppMasterService.scala
----------------------------------------------------------------------
diff --git 
a/samza-yarn/src/test/scala/org/apache/samza/job/yarn/TestSamzaAppMasterService.scala
 
b/samza-yarn/src/test/scala/org/apache/samza/job/yarn/TestSamzaAppMasterService.scala
index 811c996..d68dbdd 100644
--- 
a/samza-yarn/src/test/scala/org/apache/samza/job/yarn/TestSamzaAppMasterService.scala
+++ 
b/samza-yarn/src/test/scala/org/apache/samza/job/yarn/TestSamzaAppMasterService.scala
@@ -18,6 +18,9 @@
  */
 
 package org.apache.samza.job.yarn
+
+import scala.collection.JavaConversions._
+import org.apache.samza.config.MapConfig
 import org.junit.Assert._
 import org.junit.Test
 import java.io.BufferedReader
@@ -48,4 +51,46 @@ class TestSamzaAppMasterService {
 
     reader.close();
   }
+
+  /**
+   * This tests the rendering of the index.scaml file containing some Scala 
code. The objective
+   * is to ensure that the rendered scala code builds correctly
+   */
+  @Test
+  def testAppMasterDashboardWebServiceShouldStart {
+
+    // Create some dummy config
+    val config = new MapConfig(Map[String, String](
+      "yarn.container.count" -> "1",
+      "systems.test-system.samza.factory" -> 
"org.apache.samza.job.yarn.MockSystemFactory",
+      "yarn.container.memory.mb" -> "512",
+      "yarn.package.path" -> "/foo",
+      "task.inputs" -> "test-system.test-stream",
+      "systems.test-system.samza.key.serde" -> 
"org.apache.samza.serializers.JsonSerde",
+      "systems.test-system.samza.msg.serde" -> 
"org.apache.samza.serializers.JsonSerde",
+      "yarn.container.retry.count" -> "1",
+      "yarn.container.retry.window.ms" -> "1999999999"))
+
+
+    val state = new SamzaAppMasterState(-1, 
ConverterUtils.toContainerId("container_1350670447861_0003_01_000002"), "", 1, 
2)
+    val service = new SamzaAppMasterService(config, state, null, null)
+
+    // start the dashboard
+    service.onInit
+    assert(state.rpcPort > 0)
+    assert(state.trackingPort > 0)
+
+    // Do a GET Request on the tracking port: This in turn will render 
index.scaml
+    val url = new URL("http://127.0.0.1:%d/"; format state.trackingPort)
+    val is = url.openConnection().getInputStream();
+    val reader = new BufferedReader(new InputStreamReader(is));
+    var line: String = null;
+
+    do {
+      line = reader.readLine()
+    } while (line != null)
+
+    reader.close();
+  }
+
 }

Reply via email to