Files
poseidon/tests/e2e/e2e_test.go
Konrad Hanff 242d0175a2 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>
2021-05-31 12:32:51 +02:00

45 lines
958 B
Go

package e2e
import (
"github.com/stretchr/testify/suite"
"gitlab.hpi.de/codeocean/codemoon/poseidon/config"
"gitlab.hpi.de/codeocean/codemoon/poseidon/logging"
"os"
"testing"
"time"
)
/*
* # E2E Tests
*
* For the e2e tests a nomad cluster must be connected and poseidon must be running.
*/
var log = logging.GetLogger("e2e")
type E2ETestSuite struct {
suite.Suite
}
func (suite *E2ETestSuite) SetupTest() {
// Waiting one second before each test allows Nomad to rescale after tests requested runners.
<-time.After(time.Second)
}
func TestE2ETestSuite(t *testing.T) {
suite.Run(t, new(E2ETestSuite))
}
// Overwrite TestMain for custom setup.
func TestMain(m *testing.M) {
log.Info("Test Setup")
err := config.InitConfig()
if err != nil {
log.Warn("Could not initialize configuration")
}
// ToDo: Add Nomad job here when it is possible to create execution environments. See #26.
log.Info("Test Run")
code := m.Run()
os.Exit(code)
}