Add tests and end-to-end tests for websocket execution

For unit tests, this mocks the runners Execute method with a
customizable function that operates on the request, streams and exit
channel to simulate a real execution.

End-to-end tests are moved to the tests/e2e_tests folder. The tests
folder allows us to have shared helper functions for all tests in a
separate package (tests) that is not included in the non-test build.

This also adds one second of delay before each end-to-end test case by
using the TestSetup method of suite. By slowing down test execution,
this gives Nomad time to create new allocations when a test requested a
runner. Another solution could be to increase the scale of the job to
have enough allocations for all end-to-end tests.

Co-authored-by: Maximilian Paß <maximilian.pass@student.hpi.uni-potsdam.de>
This commit is contained in:
Konrad Hanff
2021-05-20 08:51:25 +02:00
parent 3afcdeaba8
commit 242d0175a2
18 changed files with 1078 additions and 140 deletions

View File

@ -1,6 +1,6 @@
PROJECT_NAME := "poseidon"
PKG := "gitlab.hpi.de/codeocean/codemoon/$(PROJECT_NAME)"
UNIT_TESTS = $(shell go list ./... | grep -v /e2e_tests)
UNIT_TESTS = $(shell go list ./... | grep -v /e2e)
DOCKER_E2E_CONTAINER_NAME := "$(PROJECT_NAME)-e2e-tests"
DOCKER_TAG := "poseidon:latest"
@ -81,7 +81,7 @@ coverhtml: coverage ## Generate HTML coverage report
.PHONY: e2e-test
e2e-test: deps ## Run e2e tests
@go test -count=1 ./e2e_tests -v
@go test -count=1 ./tests/e2e -v
.PHONY: e2e-docker
e2e-docker: docker ## Run e2e tests against the Docker container