scala-academy / castalia

API stub server
Other
8 stars 3 forks source link

As a stubserver consumer I want to be able to define the latency of a stub in the stub config file #9

Closed jordi133 closed 8 years ago

jordi133 commented 8 years ago

Acceptance criteria:

background: given that the stubserver is started and configured to use a stub called "latencystub" and that a stub config file with name "latencystub.json" is on the classpath

given that latencystub.json contains a response with property "id" equal to "{stubId}" and a delay specified as always 100 ms when I do a HTTP GET to .../castalia/stubs/latencystub/{stubId} then after roughly 100 ms I should get a HTTP 200 response containing the stub response with id "{stubId}"

given that latencystub.json contains a response with property "id" equal to "{stubId}" and not a property "delay" when I do a HTTP GET to .../castalia/stubs/latencystub/{stubId} then I should get a HTTP 200 response containing the stub response with id "{stubId}" without any significant latency (faster than 10 ms)

jordi133 commented 8 years ago

Example json:

{ "endpoint": "jsonconfiguredstub", "responses": [ { "id": "1", "delay": { "distribution": "constant", "mean": "100 ms" }, "httpStatusCode": 200, "response": { "id": "een", "someValue": "123123" } }, { "id": "2", "httpStatusCode": 200, "response": { "id": "twee", "someValue": "123123", "someAdditionalValue": "345345" } }, { "id": "0", "delay": { "distribution": "constant", "mean": "2 s" }, "httpStatusCode": 404 } ] }

effibennekers commented 8 years ago

Are "ms" and "s" good unit decriptors? I would prefer a Java duration (ie 100 millis, 2 seconds)

DieBauer commented 8 years ago

Aangepaste future van spray utils met delay functie: https://github.com/spray/spray/blob/master/spray-util/src/main/scala/spray/util/pimps/PimpedFuture.scala

DieBauer commented 8 years ago

Proposal: Make "mean" an int in milliseconds. => "mean": 2000 instead of "mean": "2 s". This is less error-prone. And it is still clear what is meant.