Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed Mar 24, 2021
1 parent 946db0c commit c4dd139
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controller/nodes/task/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ func (t Handler) Handle(ctx context.Context, nCtx handler.NodeExecutionContext)
ExecContext: nCtx.ExecutionContext(),
TaskType: ttype,
PluginID: p.GetID(),
ResourcePoolInfo: tCtx.rm.GetResourcePoolInfo(),
})
if err != nil {
logger.Errorf(ctx, "failed to convert plugin transition to TaskExecutionEvent. Error: %s", err.Error())
Expand Down
22 changes: 22 additions & 0 deletions pkg/controller/nodes/task/resourcemanager/resourcemanager_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package resourcemanager

import (
"context"
"testing"

"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/event"
core2 "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/core"
rmConfig "github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/resourcemanager/config"
"github.com/flyteorg/flytestdlib/promutils"
"github.com/stretchr/testify/assert"

"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
)

Expand Down Expand Up @@ -53,3 +60,18 @@ func TestToken_prepend(t *testing.T) {
})
}
}

func TestTaskResourceManager(t *testing.T) {
rmBuilder, _ := GetResourceManagerBuilderByType(context.TODO(), rmConfig.TypeNoop, promutils.NewTestScope())
rm, _ := rmBuilder.BuildResourceManager(context.TODO())
taskResourceManager := GetTaskResourceManager(rm, "namespace", &core.TaskExecutionIdentifier{})
_, err := taskResourceManager.AllocateResource(context.TODO(), "namespace", "allocation token", core2.ResourceConstraintsSpec{})
assert.NoError(t, err)
resourcePoolInfo := taskResourceManager.GetResourcePoolInfo()
assert.EqualValues(t, []*event.ResourcePoolInfo{
{
Namespace: "namespace",
AllocationToken: "allocation token",
},
}, resourcePoolInfo)
}

0 comments on commit c4dd139

Please sign in to comment.