orrsella / scala-e2e-testing

A sample project that shows how to write truly end-to-end tests in Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scala-e2e-testing

This is a sample project that shows how to write truly end-to-end tests in Scala. It accompanies a talk I gave at Scalapeno 2014 titled "True End-to-End Testing in Scala".

Project

This project uses:

  • Sbt for the build and the test harness
  • Vagrant for running the tests in
  • Ansible for deployment and automation
  • Maven repository for artifact publishing and distribution

Scala App

The app itself is a finatra-based "micro-service" (choosing finatra was an arbitrary decision, it could just as easily be another server framework/library, like Play, plain finagle, spray, etc.).

The simple example app is a notes-taking web service, which allows storing, retrieving, searching for and translating notes, and is named memento. It exposes a REST API and returns JSON.

The app is composed of two modules: core and finatra. The core contains as much of the code as possible, and includes unit and integration tests. The finatra module is the server aspect, and only contains the controller/http layer. It's modeled so we can later on easily replace the server module and use a different library/framework as our http server (or something else completely). Our end-to-end tests reside in this module.

Infrastructure/Architecture

The architecture includes:

  • Ubuntu for the operating system
  • HAProxy as a load balancer
  • Nginx as an http server in front of the finatra app server (reverse proxy)
  • Elasticsearch as the datastore

Git Repositories

The scala app and ansible playbooks are joined here in the same git repository mainly for brevity and ease-of-use. It is suggested that real projects separate them into two repositories (or more if you have more then one deployable) to allow more flexibility, but this is up to you.

Requirements

To run the tests the following should be installed on your dev machine:

Running The Tests

There are 3 testing modes:

  • test for running unit tests
  • it:test for running integration tests
  • e2e:test for running end-to-end tests

To run all tests together:

$ cd ./memento
$ sbt test-all

Running Ansible Manually

If you want to test only the ansible code, run:

$ ansible-playbook -i ansible/inventories/vagrant ansible/site.yml

About

A sample project that shows how to write truly end-to-end tests in Scala


Languages

Language:Scala 93.4%Language:Shell 6.5%Language:HTML 0.1%