Restore existing jobs and fix rebase (7c99eff3) issues
This commit is contained in:
@@ -3,8 +3,13 @@ package e2e
|
||||
import (
|
||||
nomadApi "github.com/hashicorp/nomad/api"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/api"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/config"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/logging"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/tests"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -51,8 +56,35 @@ func TestMain(m *testing.M) {
|
||||
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")
|
||||
createDefaultEnvironment()
|
||||
|
||||
// wait for environment to become ready
|
||||
<-time.After(10 * time.Second)
|
||||
|
||||
code := m.Run()
|
||||
cleanupJobsForEnvironment(&testing.T{}, "0")
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func createDefaultEnvironment() {
|
||||
path := helpers.BuildURL(api.BasePath, api.EnvironmentsPath, tests.DefaultEnvironmentIDAsString)
|
||||
|
||||
request := dto.ExecutionEnvironmentRequest{
|
||||
PrewarmingPoolSize: 10,
|
||||
CPULimit: 100,
|
||||
MemoryLimit: 100,
|
||||
Image: "drp.codemoon.xopic.de/openhpi/co_execenv_python:3.8",
|
||||
NetworkAccess: false,
|
||||
ExposedPorts: nil,
|
||||
}
|
||||
|
||||
resp, err := helpers.HttpPutJSON(path, request)
|
||||
if err != nil || resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusNoContent {
|
||||
log.Fatal("Couldn't create default environment for e2e tests")
|
||||
}
|
||||
err = resp.Body.Close()
|
||||
if err != nil {
|
||||
log.Fatal("Failed closing body")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user