Skip to content

Commit

Permalink
Fix spark tests
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Graetz <[email protected]>
  • Loading branch information
fg91 committed Apr 17, 2024
1 parent 9428cf6 commit d4b547d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions flyteplugins/go/tasks/plugins/k8s/spark/spark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package spark
import (
"context"
"os"
"reflect"
"strconv"
"testing"

Expand Down Expand Up @@ -118,9 +119,14 @@ func TestGetEventInfo(t *testing.T) {
assert.Equal(t, expectedLinks, generatedLinks)

info, err = getEventInfoForSpark(taskCtx, dummySparkApplication(sj.SubmittedState))
generatedLinks = make([]string, 0, len(info.Logs))
for _, l := range info.Logs {
generatedLinks = append(generatedLinks, l.Uri)
}
assert.NoError(t, err)
assert.Len(t, info.Logs, 1)
assert.Equal(t, "https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logStream:group=/kubernetes/flyte;prefix=var.log.containers.spark-app-name;streamFilter=typeLogStreamPrefix", info.Logs[0].Uri)
assert.Len(t, info.Logs, 5)
assert.Equal(t, expectedLinks[:5], generatedLinks) // No Spark Driver UI for Submitted state
assert.True(t, info.Logs[4].ShowWhilePending) // All User Logs should be shown while pending

assert.NoError(t, setSparkConfig(&Config{
SparkHistoryServerURL: "spark-history.flyte",
Expand Down Expand Up @@ -406,6 +412,19 @@ func dummySparkTaskContext(taskTemplate *core.TaskTemplate, interruptible bool)
taskExecutionMetadata.On("GetOverrides").Return(overrides)
taskExecutionMetadata.On("GetK8sServiceAccount").Return("new-val")
taskCtx.On("TaskExecutionMetadata").Return(taskExecutionMetadata)

inputState := k8s.PluginState{}
pluginStateReaderMock := mocks.PluginStateReader{}
pluginStateReaderMock.On("Get", mock.AnythingOfType(reflect.TypeOf(&inputState).String())).Return(
func(v interface{}) uint8 {
*(v.(*k8s.PluginState)) = inputState
return 0
},
func(v interface{}) error {
return nil
})

taskCtx.OnPluginStateReader().Return(&pluginStateReaderMock)
return taskCtx
}

Expand Down

0 comments on commit d4b547d

Please sign in to comment.