typesafehub / conductr-lib

Other
8 stars 13 forks source link

Client Lib: implement method to obtain BundleDescriptor #134

Closed fsat closed 7 years ago

fsat commented 7 years ago

Also modify the Set declared within RequestAcl and its children to Seq. This is to ensure the order of the acls returned from ConductR is preserved.

fsat commented 7 years ago

Enhance conductr-lib with support for a new getBundleConfig function which retrieves the application/hocon

fsat commented 7 years ago

Manual test is completed successfully.

Setup

ConductR master branch is built and deployed to local sandbox.

The sandbox state is as following.

Felixs-MBP-2:conductr-bundle-lib felixsatyaputra$ conduct info
Licensed To: cc64df31-ec6b-4e08-bb6b-3216721a56b@lightbend
Max ConductR agents: 10
ConductR Version(s): 0.1.0, 2.1.*
Grants: akka-sbr, cinnamon, conductr

ID       NAME    TAG  #REP  #STR  #RUN  ROLES
3349b6b  eslite          1     0     1  elasticsearch

Bundle descriptor endpoint is returning the expected Hocon.

Felixs-MBP-2:conductr-bundle-lib felixsatyaputra$ curl -H "Accept: application/hocon" http://192.168.10.1:9005/bundles/3349b6b
compatibilityVersion="1",components{eslite{description=eslite,endpoints{akka-remote{bind-port=0,bind-protocol=tcp,services=[]},es{bind-port=0,bind-protocol=http,service-name=elastic-search,services=[]}},file-system-type=universal,start-command=["eslite/bin/eslite","-J-Xms134217728","-J-Xmx134217728","-Dhttp.address=$ES_BIND_IP","-Dhttp.port=$ES_BIND_PORT","-Dplay.crypto.secret=65736c697465"]}},diskSpace=200000000,memory=402653184,name=eslite,nrOfCpus=0.1,roles=[elasticsearch],system=eslite,systemVersion="1",version="1"

Test Result

The Client Lib to get bundle descriptor is called using the following code.

"for real - get bundle descriptor" in { f =>
  import ControlClientSpec._

  val sys = systemFixture(f)
  import sys._

  val result = Await.result(ControlClient(new URL("http://192.168.10.1:9005")).getBundleDescriptor("eslite"), timeout.duration)
  println(result)
}

The stdout shows BundleDescriptor in the response.

BundleDescriptorGetSuccess(BundleDescriptor(1,eslite,1,0.1,402653184,200000000,Buffer(elasticsearch),eslite,1,List(),None,Map(eslite -> Component(eslite,Universal,List(eslite/bin/eslite, -J-Xms134217728, -J-Xmx134217728, -Dhttp.address=$ES_BIND_IP, -Dhttp.port=$ES_BIND_PORT, -Dplay.crypto.secret=65736c697465),Map(akka-remote -> Endpoint(tcp,0,None,List()), es -> Endpoint(http,0,Some(elastic-search),List()))))))

The Client Lib to get bundle descriptor hocon is called using the following code.

"for real - get bundle descriptor config" in { f =>
  import ControlClientSpec._

  val sys = systemFixture(f)
  import sys._

  val result = Await.result(ControlClient(new URL("http://192.168.10.1:9005")).getBundleDescriptorConfig("eslite"), timeout.duration)
  println(result)
}

The stdout shows the hocon (i.e. SimpleConfigObject) in the response.

BundleDescriptorGetConfigSuccess(SimpleConfigObject({"compatibilityVersion":"1","components":{"eslite":{"description":"eslite","endpoints":{"akka-remote":{"bind-port":0,"bind-protocol":"tcp","services":[]},"es":{"bind-port":0,"bind-protocol":"http","service-name":"elastic-search","services":[]}},"file-system-type":"universal","start-command":["eslite/bin/eslite","-J-Xms134217728","-J-Xmx134217728","-Dhttp.address=$ES_BIND_IP","-Dhttp.port=$ES_BIND_PORT","-Dplay.crypto.secret=65736c697465"]}},"diskSpace":200000000,"memory":402653184,"name":"eslite","nrOfCpus":0.1,"roles":["elasticsearch"],"system":"eslite","systemVersion":"1","version":"1"}))

The get bundles method is tested for check the changes to the RequestAcl.

"for real - get bundle" in { f =>
  import ControlClientSpec._

  val sys = systemFixture(f)
  import sys._

  val result = Await.result(ControlClient(new URL("http://192.168.10.1:9005")).getBundlesInfo(), timeout.duration)
  println(result)
}

The stdout shows the bundle is returned as expected.

List(Bundle(3349b6bfbc09e8d88123fee5b33b2717,3349b6bfbc09e8d88123fee5b33b2717e07fb2a91de719c99e0403c9e4b28ea5,None,BundleAttributes(eslite,0.1,402653184,200000000,TreeSet(elasticsearch),eslite,1,1),Some(BundleConfig(Map(akka-remote -> BundleConfigEndpoint(tcp,None,Set(),List()), es -> BundleConfigEndpoint(http,Some(elastic-search),Set(),List())))),Some(BundleScale(1,None)),List(BundleExecution(192.168.10.1,Map(akka-remote -> BundleExecutionEndpoint(10822,10822), es -> BundleExecutionEndpoint(10007,10007)),true)),List(BundleInstallation(UniqueAddress(akka.tcp://conductr@192.168.10.1:9004,-710896895),file:///Users/felixsatyaputra/.conductr/images/tmp/conductr/192.168.10.1/bundles/3349b6bfbc09e8d88123fee5b33b2717e07fb2a91de719c99e0403c9e4b28ea5.zip,None)),false))