Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Running E2E Tests

tenczar edited this page Nov 21, 2018 · 8 revisions

Dispatch E2E Testing

This guide will walk you through how to run the Dispatch E2E tests in your local development environment. This guide assumes you have already cloned the Dispatch source and prepared your environment to compile and run the Dispatch Solo server and Dispatch CLI. See ... for more details.

Prerequisites

The E2E tests require Bats (Bash Automated Testing System) and jq, a command line json parser to run. You will need to install these utilities before continuing.

For MacOS

You can fulfill these requirements on Mac with Homebrew

Run the following commands from your terminal to install the prerequisites using Homebrew

$ brew install bats-core
==> Downloading https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz
######################################################################## 100.0%
==> ./install.sh /usr/local/Cellar/bats-core/1.1.0
🍺  /usr/local/Cellar/bats-core/1.1.0: 13 files, 55.1KB, built in 4 seconds
$ brew install jq
==> Downloading https://homebrew.bintray.com/bottles/jq-1.6.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring jq-1.6.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/jq/1.6: 18 files, 1MB

If you do not use Homebrew and wish not to, you can find links to the full installation documentation for these prerequisites below.

For Linux

You can install Bats from source following the instructions here.

To install jq in Linux run the appropriate command for your distribution in your terminal.

Debian/Ubuntu

$ sudo apt-get install jq

Fedora

$ sudo dnf install jq

OpenSUSE

$ sudo zypper install jq

Links to the official installation documentation can be found below.

Full Instructions

Full installation instructions for Bats can be found here, and full instructions for jq can be found here

Preparing the Environment

To run the E2E tests you will need to make note of several parameters passed to the server API Gateway HTTP Port and API Gateway HTTPS Port. You will also need the organization set in the config.json for the dispatchcli.

Set Environment Variables

Set API Gateway HTTP/HTTPS Host URL

export API_GATEWAY_HTTP_HOST="http://localhost:8081"
export API_GATEWAY_HTTPS_HOST="https://locahost:8444"
export DISPATCH_ORGANIZATION="dispatch"
export INSTALL_DISPATCH=0
export DOCKER_REGISTRY=dispatchframework

if you are not running Dispatch solo with valid certificates you can still pass the e2e tests by setting the API_GATEWAY_HTTPS_HOST environment variable to point to the same URL as the API_GATEWAY_HTTP_HOST environment variable.

The DISPATCH_ORGANIZATION environment variable must match the organization field in the config.json being used your dispatch-cli. This config.json is typically found at $HOME/.dispatch/config.json.

Build Dispatch

From the Dispatch root directory run the make target for your platform

For MacOS

$ make darwin

For Linux

$ make linux

The output will look similar to this:

GOOS=darwin go build -ldflags "-X github.com/vmware/dispatch/pkg/version.version=v0.2.0-alpha-28-g01653429-dirty -X github.com/vmware/dispatch/pkg/version.buildDate=2018-11-09T13:20:15Z -X github.com/vmware/dispatch/pkg/version.commit=016534295e7d553dd16c21599201d2125e5dc1e7" -o bin/dispatch-server-darwin ./cmd/dispatch-server
GOOS=darwin go build -ldflags "-X github.com/vmware/dispatch/pkg/version.version=v0.2.0-alpha-28-g01653429-dirty -X github.com/vmware/dispatch/pkg/version.buildDate=2018-11-09T13:20:15Z -X github.com/vmware/dispatch/pkg/version.commit=016534295e7d553dd16c21599201d2125e5dc1e7 -X github.com/vmware/dispatch/pkg/dispatchcli/cmd.imagesB64=H4sIAA/65VsAA42RSxKDIBBE95yCC2g+7limsskmuxwAZVREBwMaK7cP+fg3ljuK6Z5X060kCkZP3MKl4AkQ5AUwilpAZr3QfROhIwXmZnJGhbQlr6I0Nk7VaKN2AyHb+3v/cCQ5x6R2q9otxPM8ohYx5bNKNQYbOEPlFxQMQL/pGkk3YGwKeb4FNhYv8DrBCjLjD74B1snmmPdoAJgXRMKWeZ3Vtuxrk5oYR0WYGitZwBlKQAEYSbCMUFpwlDHYilED99o97D9Gn84UM2lh2f85e+Lsw3wBpVEiqLECAAA=" -o bin/dispatch-darwin ./cmd/dispatch

At this point the Dispatch CLI binary is available at bin/dispatch-darwin for Mac or bin/dispatch-linux for Linux. To run the tests you will want the cli binary in your PATH. We recommend adding a symlink from /usr/local/bin to the binary in the dispatch/bin directory. For example on Mac run the following command:

$ ln -s $PWD/bin/dispatch-darwin /usr/local/bin/dispatch

Running Test Suites

Then you can run all of the e2e tests in the tests directory using

$ e2e/scripts/run-e2e.sh e2e/tests

You can run individual test suites by specifying the bats file directly, e.g.

$ e2e/scripts/run-e2e.sh e2e/tests/apis.bats

This will run the API gateway test suite

Available Test Suires

  1. images.bats (tests base-image and image CRUD)
  2. functions.bats (tests function CRUD and execution)
  3. apis.bats (tests API gateway CRUD and function wiring)
  4. secrets.bats (tests secrets CRUD and availability in functions)
  5. events.bats (tests event driver CRUD)
  6. services.bats (All skipped for Dispatch solo)
  7. login.bats (All skipped for Dispatch solo)
  8. organizations.bats (All skipped for Dispatch solo)
  9. clean.bats (cleans up the test environment, removes all created resources)