typesafehub / conductr-lib

Other
8 stars 13 forks source link

Implement get bundle endpoint #110

Closed fsat closed 8 years ago

fsat commented 8 years ago

Marked as wip - still need to do unit test.

fsat commented 8 years ago

conductr-client-lib support for ConductR CLI support for GET /bundles:bundleId

fsat commented 8 years ago

A separate test is performed by invoking modified ControlClient against actual running ConductR. This test is completed successfully.

Setup

Felixs-MBP-2:~ felixsatyaputra$ conduct info
ID               NAME                           #REP  #STR  #RUN
abf6045-a53237c  reactive-maps-backend-summary     1     0     0
ebb2ad6          visualizer                        1     0     0

Akka 2.3 Client Lib

The Akka 2.3 ControlClient is invoked using the following bit of code.

class Foo23Spec extends AkkaUnitTest {
  "bundle with config" in {
    implicit val cc = ConnectionContext()
    implicit val mat = cc.actorMaterializer
    implicit val ec = cc.actorMaterializer.executionContext
    implicit val HostUrl = new URL(s"http://127.0.0.1:9005")

    val client = ControlClient(HostUrl)
    val result = Await.result(client.getBundle("react"), 5.minutes)
    println(result)
  }

  "bundle" in {
    implicit val cc = ConnectionContext()
    implicit val mat = cc.actorMaterializer
    implicit val ec = cc.actorMaterializer.executionContext
    implicit val HostUrl = new URL(s"http://127.0.0.1:9005")

    val client = ControlClient(HostUrl)
    val result = Await.result(client.getBundle("vis"), 5.minutes)

    println(result)
  }

  "not found" in {
    implicit val cc = ConnectionContext()
    implicit val mat = cc.actorMaterializer
    implicit val ec = cc.actorMaterializer.executionContext
    implicit val HostUrl = new URL(s"http://127.0.0.1:9005")

    val client = ControlClient(HostUrl)
    val result = Await.result(client.getBundle("bla"), 5.minutes)

    println(result)
  }

}

The bundle and config is obtained successfully (as shown by the println).

BundleGetSuccess(react,/var/folders/ls/f4kkzrhd2tl80ztkmg93j92r0000gn/T/reactive-maps-backend-summary-v1-abf60451c6af18adcc851d67b369b7f54810d12f3a0ef80a89bdc2d9dff49a10.zip,Some(/var/folders/ls/f4kkzrhd2tl80ztkmg93j92r0000gn/T/reactive-maps-backend-summary-configuration-v1-a53237c1f4a067e13ef00090627fb3de8f31c1957ba2758a4fcd181a510c2e72.zip))

The bundle is obtained successfully (as shown by the println).

BundleGetSuccess(vis,/var/folders/ls/f4kkzrhd2tl80ztkmg93j92r0000gn/T/visualizer-v1.1-ebb2ad603559b77dc6a93741af0262c629f3869f79f292247d23699e6e99c052.zip,None)

The invalid bundle id results in failure (as shown by the println).

BundleGetFailure(404,No bundle found by the specified Bundle ID/name: 'bla')

Akka 2.4 Client Lib

The Akka 2.4 ControlClient is invoked using the following bit of code.

class Foo24Spec extends AkkaUnitTest {
  "bundle with config" in {
    implicit val cc = ConnectionContext()
    implicit val mat = cc.actorMaterializer
    implicit val ec = cc.actorMaterializer.executionContext
    implicit val HostUrl = new URL(s"http://127.0.0.1:9005")

    val client = ControlClient(HostUrl)
    val result = Await.result(client.getBundle("react"), 5.minutes)
    println(result)
  }

  "bundle" in {
    implicit val cc = ConnectionContext()
    implicit val mat = cc.actorMaterializer
    implicit val ec = cc.actorMaterializer.executionContext
    implicit val HostUrl = new URL(s"http://127.0.0.1:9005")

    val client = ControlClient(HostUrl)
    val result = Await.result(client.getBundle("vis"), 5.minutes)
    println(result)
  }

  "not found" in {
    implicit val cc = ConnectionContext()
    implicit val mat = cc.actorMaterializer
    implicit val ec = cc.actorMaterializer.executionContext
    implicit val HostUrl = new URL(s"http://127.0.0.1:9005")

    val client = ControlClient(HostUrl)
    val result = Await.result(client.getBundle("bla"), 5.minutes)

    println(result)
  }
}

The bundle and config is obtained successfully (as shown by the println).

BundleGetSuccess(react,/var/folders/ls/f4kkzrhd2tl80ztkmg93j92r0000gn/T/reactive-maps-backend-summary-v1-abf60451c6af18adcc851d67b369b7f54810d12f3a0ef80a89bdc2d9dff49a10.zip,Some(/var/folders/ls/f4kkzrhd2tl80ztkmg93j92r0000gn/T/reactive-maps-backend-summary-configuration-v1-a53237c1f4a067e13ef00090627fb3de8f31c1957ba2758a4fcd181a510c2e72.zip))

The bundle is obtained successfully (as shown by the println).

BundleGetSuccess(vis,/var/folders/ls/f4kkzrhd2tl80ztkmg93j92r0000gn/T/visualizer-v1.1-ebb2ad603559b77dc6a93741af0262c629f3869f79f292247d23699e6e99c052.zip,None)

The invalid bundle id results in failure (as shown by the println).

BundleGetFailure(404,No bundle found by the specified Bundle ID/name: 'bla')
fsat commented 8 years ago

Marked as wip - will address PR feedback as separate commits to be merged later.

fsat commented 8 years ago

Marked as wip for now - still want to squash PR feedback commits later.