Add e2e tests for exec env createOrUpdate

This also adds a Nomad client to the e2e_tests that can be used to
query Nomad and validate that certain actions happened in Nomad
correctly.
This commit is contained in:
sirkrypt0
2021-05-27 10:11:43 +02:00
committed by Tobias Kantusch
parent 1be744f2d4
commit 1c4daa99a9
4 changed files with 175 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package e2e
import (
nomadApi "github.com/hashicorp/nomad/api"
"github.com/stretchr/testify/suite"
"gitlab.hpi.de/codeocean/codemoon/poseidon/config"
"gitlab.hpi.de/codeocean/codemoon/poseidon/logging"
@@ -15,7 +16,11 @@ import (
* For the e2e tests a nomad cluster must be connected and poseidon must be running.
*/
var log = logging.GetLogger("e2e")
var (
log = logging.GetLogger("e2e")
nomadClient *nomadApi.Client
nomadNamespace string
)
type E2ETestSuite struct {
suite.Suite
@@ -35,7 +40,16 @@ func TestMain(m *testing.M) {
log.Info("Test Setup")
err := config.InitConfig()
if err != nil {
log.Warn("Could not initialize configuration")
log.WithError(err).Fatal("Could not initialize configuration")
}
nomadNamespace = config.Config.Nomad.Namespace
nomadClient, err = nomadApi.NewClient(&nomadApi.Config{
Address: config.Config.NomadAPIURL().String(),
TLSConfig: &nomadApi.TLSConfig{},
Namespace: nomadNamespace,
})
if err != nil {
log.WithError(err).Fatal("Could not create Nomad client")
}
// ToDo: Add Nomad job here when it is possible to create execution environments. See #26.
log.Info("Test Run")