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
add tests for signal_validator
Signed-off-by: Future-Outlier <eric901201@gmail.com>
  • Loading branch information
Future-Outlier committed Aug 30, 2024
commit 426716050e1ebbd7ecaa3bdc338669e7281f128b
52 changes: 52 additions & 0 deletions flyteadmin/pkg/manager/impl/validation/signal_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,56 @@ func TestValidateSignalUpdateRequest(t *testing.T) {
utils.AssertEqualWithSanitizedRegex(t,
"requested signal value [scalar:{ primitive:{ boolean:false } } ] is not castable to existing signal type [[8 1]]", ValidateSignalSetRequest(ctx, repo, request).Error())
})

t.Run("UnknownIDLType", func(t *testing.T) {
ctx := context.TODO()

// Define an unsupported literal type with a simple type of 1000
unsupportedLiteralType := &core.LiteralType{
Type: &core.LiteralType_Simple{
Simple: 1000, // Using 1000 as an unsupported type
},
}
unsupportedLiteralTypeBytes, _ := proto.Marshal(unsupportedLiteralType)

// Mock the repository to return a signal with this unsupported type
repo := repositoryMocks.NewMockRepository()
repo.SignalRepo().(*repositoryMocks.SignalRepoInterface).
OnGetMatch(mock.Anything, mock.Anything).Return(
models.Signal{
Type: unsupportedLiteralTypeBytes, // Set the unsupported type
},
nil,
)

// Set up the unsupported literal that will trigger the nil valueType condition
unsupportedLiteral := &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{},
},
}

request := admin.SignalSetRequest{
Id: &core.SignalIdentifier{
ExecutionId: &core.WorkflowExecutionIdentifier{
Project: "project",
Domain: "domain",
Name: "name",
},
SignalId: "signal",
},
Value: unsupportedLiteral, // This will lead to valueType being nil
}

// Invoke the function and check for the expected error
err := ValidateSignalSetRequest(ctx, repo, request)
assert.NotNil(t, err)

// Expected error message
expectedErrorMsg := "Invalid signal value for 'scalar:{}'.\n" +
"Expected type: simple:1000, but received: <nil>.\n" +
"Suggested solution: Ensure all Flyte images are updated to the latest version and try again."
assert.Equal(t, expectedErrorMsg, err.Error())

})
}
Loading