Parametrize e2e tests to also check AWS environments.

- Fix destroy runner after timeout.
- Add file deletion
This commit is contained in:
Maximilian Paß
2022-02-03 14:32:05 +01:00
parent 13eaa61f3b
commit 4ffbb712ed
13 changed files with 505 additions and 342 deletions

View File

@ -8,12 +8,13 @@ import (
)
type AWSEnvironment struct {
id dto.EnvironmentID
awsEndpoint string
id dto.EnvironmentID
awsEndpoint string
onDestroyRunner runner.DestroyRunnerHandler
}
func NewAWSEnvironment() *AWSEnvironment {
return &AWSEnvironment{}
func NewAWSEnvironment(onDestroyRunner runner.DestroyRunnerHandler) *AWSEnvironment {
return &AWSEnvironment{onDestroyRunner: onDestroyRunner}
}
func (a *AWSEnvironment) MarshalJSON() ([]byte, error) {
@ -86,11 +87,11 @@ func (a *AWSEnvironment) Register() error {
}
func (a *AWSEnvironment) Delete() error {
panic("implement me")
return nil
}
func (a *AWSEnvironment) Sample() (r runner.Runner, ok bool) {
workload, err := runner.NewAWSFunctionWorkload(a, nil)
workload, err := runner.NewAWSFunctionWorkload(a, a.onDestroyRunner)
if err != nil {
return nil, false
}

View File

@ -53,7 +53,7 @@ func (a *AWSEnvironmentManager) CreateOrUpdate(
}
_, ok := a.runnerManager.GetEnvironment(id)
e := NewAWSEnvironment()
e := NewAWSEnvironment(a.runnerManager.Return)
e.SetID(id)
e.SetImage(request.Image)
a.runnerManager.StoreEnvironment(e)

View File

@ -66,7 +66,7 @@ func TestAWSEnvironmentManager_Get(t *testing.T) {
})
t.Run("Returns environment when it was added before", func(t *testing.T) {
expectedEnvironment := NewAWSEnvironment()
expectedEnvironment := NewAWSEnvironment(nil)
expectedEnvironment.SetID(tests.DefaultEnvironmentIDAsInteger)
runnerManager.StoreEnvironment(expectedEnvironment)
@ -82,7 +82,7 @@ func TestAWSEnvironmentManager_List(t *testing.T) {
t.Run("returs also environments of the rest of the manager chain", func(t *testing.T) {
nextHandler := &ManagerHandlerMock{}
existingEnvironment := NewAWSEnvironment()
existingEnvironment := NewAWSEnvironment(nil)
nextHandler.On("List", mock.AnythingOfType("bool")).
Return([]runner.ExecutionEnvironment{existingEnvironment}, nil)
m.SetNextHandler(nextHandler)
@ -95,7 +95,7 @@ func TestAWSEnvironmentManager_List(t *testing.T) {
m.SetNextHandler(nil)
t.Run("Returns added environment", func(t *testing.T) {
localEnvironment := NewAWSEnvironment()
localEnvironment := NewAWSEnvironment(nil)
localEnvironment.SetID(tests.DefaultEnvironmentIDAsInteger)
runnerManager.StoreEnvironment(localEnvironment)