Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flytepropeller][flyteadmin] Compiler unknown literal type error handling #5651

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
support nodes/array/handler.go
Signed-off-by: Future-Outlier <eric901201@gmail.com>
  • Loading branch information
Future-Outlier committed Aug 30, 2024
commit 92c54b1ed45098b9085ccc1a48638bc71fd6f65c
63 changes: 63 additions & 0 deletions flytepropeller/pkg/controller/nodes/array/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package array
import (
"context"
"fmt"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/errors"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -941,6 +942,68 @@ func TestHandleArrayNodePhaseExecuting(t *testing.T) {
}
}

func TestHandle_InvalidLiteralType(t *testing.T) {
ctx := context.Background()
scope := promutils.NewTestScope()
dataStore, err := storage.NewDataStore(&storage.Config{
Type: storage.TypeMemory,
}, scope)
assert.NoError(t, err)
nodeHandler := &mocks.NodeHandler{}

// Initialize ArrayNodeHandler
arrayNodeHandler, err := createArrayNodeHandler(ctx, t, nodeHandler, dataStore, scope)
assert.NoError(t, err)

// Test cases
tests := []struct {
name string
inputLiteral *idlcore.Literal
expectedTransitionType handler.TransitionType
expectedPhase handler.EPhase
expectedErrorCode string
expectedErrorMessage string
}{
{
name: "InvalidLiteralType",
inputLiteral: &idlcore.Literal{
Value: &idlcore.Literal_Scalar{
Scalar: &idlcore.Scalar{},
},
},
expectedTransitionType: handler.TransitionTypeEphemeral,
expectedPhase: handler.EPhaseFailed,
expectedErrorCode: errors.IDLNotFoundErr,
expectedErrorMessage: "Input is an invalid type, please update all of your Flyte images to the latest version and try again.",
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// Create NodeExecutionContext
literalMap := &idlcore.LiteralMap{
Literals: map[string]*idlcore.Literal{
"invalidInput": test.inputLiteral,
},
}
arrayNodeState := &handler.ArrayNodeState{
Phase: v1alpha1.ArrayNodePhaseNone,
}
nCtx := createNodeExecutionContext(dataStore, newBufferedEventRecorder(), nil, literalMap, &arrayNodeSpec, arrayNodeState, 0, workflowMaxParallelism)

// Evaluate node
transition, err := arrayNodeHandler.Handle(ctx, nCtx)
assert.NoError(t, err)

// Validate results
assert.Equal(t, test.expectedTransitionType, transition.Type())
assert.Equal(t, test.expectedPhase, transition.Info().GetPhase())
assert.Equal(t, test.expectedErrorCode, transition.Info().GetErr().Code)
assert.Equal(t, test.expectedErrorMessage, transition.Info().GetErr().Message)
})
}
}

func TestHandleArrayNodePhaseExecutingSubNodeFailures(t *testing.T) {
ctx := context.Background()

Expand Down
Loading