Hi Vincent,

Where do you stop your ActorSystem?

-Endre

On Wed, Nov 25, 2015 at 10:33 AM, vincent chow <[email protected]>
wrote:

> I'm using akka cluster sharding & spray to providing RESTful service. And
> It works well for the past few month.
>
> But recently our project failed to package because test cases are not pass
> sometimes. It is quite strange, because sometimes it package successfully,
> but most of time it doesn't.
>
> Here are some key classes in my project:
>
> Boot.scala  (start the whole cluster)
>
> object Boot {
>
>   val localhostAddress = NetworkUtil.getIpaddress
>
>   val config = localhostAddress match {
>     case Success(addr) =>
>
> ConfigFactory.parseString(s"""akka.remote.netty.tcp.hostname="${addr}"""")
>       .withFallback(ConfigFactory.load())
>
>     case Failure(exp) =>
>       throw new Exception("failed to get ip address")
>       ConfigFactory.load()
>   }
>
>   implicit val system = ActorSystem(GlobalConfig.clusterName, config)
>
>   val settings = AppSettings.default
>
>   val service = system.actorOf(Props[ServiceActor], "service")
>
>   val esAddr =
> config.getString("com.cisco.icam.iws.service.elasticsearch.default.url").stripPrefix("http://
> ")
>   EntityStore.init(esAddr)
>
>   //implicit value for Http.Bind()
>   implicit val timeout = new Timeout(5.seconds)
>
>
>   //start cluster sharding
>   ClusterSharding(system).start(
>     typeName = ActionWorkerActor.shardName,
>     entryProps = Some(ActionWorkerActor.props()),
>     idExtractor = ActionWorkerActor.idExtractor,
>     shardResolver = ActionWorkerActor.shardResolver)
>
>   //start cluster tool
>   ClusterTool.init
>
>   def main(args: Array[String]): Unit = {
>
>     IO(Http) ? Http.Bind(service, interface = settings.bind.host, port =
> settings.bind.port)
>
>   }
>
> }
>
>
> one test case example: (other test cases are similar to this one)
> class EndUserSpec extends FunSuite with AmsRoute with ScalatestRouteTest {
>
>   implicit val routeTestTimeout = RouteTestTimeout(60 second)
>
>   def actorRefFactory: ActorRefFactory = Boot.system
>
>   var id = BoxTestHelper.createNewBoxAlert
>
>   val userHeader = RawHeader("userId", "limhu")
>
>
>   test("new -> escalate to user") {
>     Thread.sleep(3000)
>
>     val postJson = """{
>                      |  "comment": "no comment",
>                      |  "escalateTo": [
>                      |    "xinszhou"
>                      |  ]
>                      |}""".stripMargin
>
>
>     Post( s"""/ams/${id}/escalate2user""",
>       HttpEntity(ContentTypes.`application/json`,
> postJson)).withHeaders(userHeader) ~> routes ~> check {
>
>       assert(status === OK)
>     }
>
>     assert(TestHelper.esStatus(id) === "escalated")
>   }
>
>   id = "icam-testams-1488799388"
>
>   test("Escalated -> confirm -> Pending close") {
>     val postJson = """{
>                      |  "comment": "no comment",
>                      |
>                      |  "confirm_result": [
>                      |    {
>                      |      "classlvl": "HIGHLY CONFIDENTIAL",
>                      |      "file_url": "
> https://cisco.app.box.com/files/0/f/3448966556/1/f_31679491830";,
>                      |      "confirm_type": "removed",
>                      |      "file_id": "31679491830",
>                      |      "path": "/All
> Files/Folder_Not_Allow_HC/nice(1).docx",
>                      |      "name": "xxx(1).docx"
>                      |    }
>                      |  ]
>                      |}""".stripMargin
>
>     Post( s"""/ams/${id}/confirm""",
>       HttpEntity(ContentTypes.`application/json`,
> postJson)).withHeaders(userHeader) ~> routes ~> check {
>       assert(status === OK)
>     }
>
>     println(TestHelper.esStatus(id))
>
>     assert(TestHelper.esStatus(id) != "escalated")
>   }
>
>
> }
>
>
> assembly.sbt (I explicit set parallelExecution to false)
> assemblySettings
>
> coverageEnabled.in(Test, test) := true
>
> //coverageEnabled := true
> //coverageMinimum := 80
> //coverageFailOnMinimum := true
> //parallelExecution := false
>
> parallelExecution in Test := false
>
> assemblyOption in assembly ~= {
>   _.copy(cacheOutput = false)
> }
>
> mergeStrategy in assembly := {
>   case PathList("org", "joda", "convert", xs@_*) => MergeStrategy.first
>
>   case "OSGI-INF/bundle.info" => MergeStrategy.filterDistinctLines
>
>   case "META-INF/maven/jline/jline/pom.properties" => MergeStrategy.first
>   case "META-INF/maven/jline/jline/pom.xml" => MergeStrategy.first
>
>   case "unwanted.txt" => MergeStrategy.discard
>
>   case x =>
>     val oldStrategy = (mergeStrategy in assembly).value
>     oldStrategy(x)
> }
>
>
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to