Play's approach to Rapid Application Development in Java/Scala is good, however not great :-) Great will be to take it forward to Rapid Application Deployment in cloud and in real life environments - Dev, Integration, QA, Prod, ...
4. Great for most environments
◦ Dev, Integration, QA
Very nice for production
◦ Just a bit slower to launch
◦ Less secure
◦ But, can be optimized to both
5. The Concept
◦ “Stateless” machine image
No code, no credentials, no data.
◦ “Dependency Injection” of the environment parameters
◦ Init script
◦ Run app
Ideal for AWS - Play! - Git
◦ AMI
◦ User Data
◦ Download code
◦ Play!
7. USER_DATA=`wget -qO- http://169.254.169.254/latest/user-data`
GIT_BRANCH=`echo "$USER_DATA" | jq '.gitBranch' | sed -e 's/^"//' -e 's/"$//'`
git remote add -t $GIT_BRANCH -f origin $GIT_URL
Any branch/tag
◦ Dev, INT, QA, Prod
Production robustness
◦ Not depending on repo availability
Upgrade/Downgrade?
◦ Just change the user data and reboot
9. import play.test.Helpers;
public class TestHelper extends Helpers {
public void testMethod() {
Result result =
callAction(xxx.routes.ref.XxxController.yyyMethod(),
fakeRequest().WithWhatever());
assertThat(status(result)).isEqualTo(OK);
Great for local integration/behavior testing, but
What about real clients, not running on the same machine
as the server?
◦ Different time zones, clocks
◦ Different locales and string formats
10. import play.test.Helpers;
public class TestHelper extends Helpers {
public void testMethod() {
Result result =
callApiAction(xxx.routes.ref.XxxController.yyyMethod(),
fakeRequest().WithWhatever(), relativeURL, reqParams);
assertThat(status(result)).isEqualTo(OK);
11. Play test –DTestServer.RemoteAddress=http://<host>:<port>/baseURL
import play.libs.WS.WSRequestHolder;
public Result callApiAction(HandlerRef ref, FakeRequest
request,String parameters,String methodName) {
if (!shouldTestRemote) return callAction(ref,request);
long timeoutAllowed=20000;
String contentType="application/x-www-form-urlencoded";
Response response=new
WSRequestHolder(serverUrl+methodName).setContentType(contentType
).post(parameters).get(timeoutAllowed);
return play.mvc.Results.status(response.getStatus(),
response.asByteArray());
}
12. “The R&D team you wish to have”
Senior developers
Junior developers
Students
Guy Vinograd
guy@softimize.co.il