Enable memory oversubscription (#102)

* Enable memory oversubscription

* Fix and add e2e test
This commit is contained in:
Maximilian Paß
2022-03-18 08:31:27 +01:00
committed by GitHub
parent 708ae3679e
commit a41659eed4
8 changed files with 46 additions and 14 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/openHPI/poseidon/tests/helpers"
"github.com/stretchr/testify/suite"
"net/http"
"strconv"
"strings"
"time"
)
@@ -175,6 +176,28 @@ func (s *E2ETestSuite) TestEchoEnvironment() {
}
}
func (s *E2ETestSuite) TestMemoryMaxLimit_Nomad() {
maxMemoryLimit := defaultNomadEnvironment.MemoryLimit
// The operating system is in charge to kill the process and sometimes tolerates small exceeding of the limit.
maxMemoryLimit = uint(1.1 * float64(maxMemoryLimit))
connection, err := ProvideWebSocketConnection(&s.Suite, tests.DefaultEnvironmentIDAsInteger, &dto.ExecutionRequest{
// This shell line tries to load maxMemoryLimit Bytes into the memory.
Command: "</dev/zero head -c " + strconv.Itoa(int(maxMemoryLimit)) + "MB | tail > /dev/null",
})
s.Require().NoError(err)
startMessage, err := helpers.ReceiveNextWebSocketMessage(connection)
s.Require().NoError(err)
s.Equal(dto.WebSocketMetaStart, startMessage.Type)
messages, err := helpers.ReceiveAllWebSocketMessages(connection)
s.Require().Error(err)
s.Equal(err, &websocket.CloseError{Code: websocket.CloseNormalClosure})
stdout, stderr, _ := helpers.WebSocketOutputMessages(messages)
s.Empty(stdout)
s.Contains(stderr, "Killed")
}
func (s *E2ETestSuite) TestNomadStderrFifoIsRemoved() {
runnerID, err := ProvideRunner(&dto.RunnerRequest{
ExecutionEnvironmentID: tests.DefaultEnvironmentIDAsInteger,