diff --git a/flyteadmin/pkg/runtime/application_config_provider.go b/flyteadmin/pkg/runtime/application_config_provider.go index a16c27e694..e754858b3c 100644 --- a/flyteadmin/pkg/runtime/application_config_provider.go +++ b/flyteadmin/pkg/runtime/application_config_provider.go @@ -33,6 +33,7 @@ var flyteAdminConfig = config.MustRegisterSection(flyteAdmin, &interfaces.Applic MaxParallelism: 25, K8SServiceAccount: "", UseOffloadedWorkflowClosure: false, + ConsoleURL: "", }) var schedulerConfig = config.MustRegisterSection(scheduler, &interfaces.SchedulerConfig{ diff --git a/flyteadmin/pkg/runtime/interfaces/application_configuration.go b/flyteadmin/pkg/runtime/interfaces/application_configuration.go index 3a459209f5..092aa665b6 100644 --- a/flyteadmin/pkg/runtime/interfaces/application_configuration.go +++ b/flyteadmin/pkg/runtime/interfaces/application_configuration.go @@ -103,6 +103,9 @@ type ApplicationConfig struct { Envs map[string]string `json:"envs,omitempty"` FeatureGates FeatureGates `json:"featureGates" pflag:",Enable experimental features."` + + // A URL pointing to the flyteconsole instance used to hit this flyteadmin instance. + ConsoleURL string `json:"consoleUrl,omitempty" pflag:",A URL pointing to the flyteconsole instance used to hit this flyteadmin instance."` } func (a *ApplicationConfig) GetRoleNameKey() string { diff --git a/flyteadmin/pkg/workflowengine/impl/k8s_executor.go b/flyteadmin/pkg/workflowengine/impl/k8s_executor.go index f90051fabe..163a58cab3 100644 --- a/flyteadmin/pkg/workflowengine/impl/k8s_executor.go +++ b/flyteadmin/pkg/workflowengine/impl/k8s_executor.go @@ -55,6 +55,10 @@ func (e K8sWorkflowExecutor) Execute(ctx context.Context, data interfaces.Execut flyteWf.Tasks = nil } + if consoleURL := e.config.ApplicationConfiguration().GetTopLevelConfig().ConsoleURL; len(consoleURL) > 0 { + flyteWf.ConsoleURL = consoleURL + } + executionTargetSpec := executioncluster.ExecutionTargetSpec{ Project: data.ExecutionID.Project, Domain: data.ExecutionID.Domain, diff --git a/flyteplugins/go/tasks/pluginmachinery/core/exec_metadata.go b/flyteplugins/go/tasks/pluginmachinery/core/exec_metadata.go index 83d7dbcf12..5969d44661 100644 --- a/flyteplugins/go/tasks/pluginmachinery/core/exec_metadata.go +++ b/flyteplugins/go/tasks/pluginmachinery/core/exec_metadata.go @@ -53,4 +53,5 @@ type TaskExecutionMetadata interface { GetPlatformResources() *v1.ResourceRequirements GetInterruptibleFailureThreshold() int32 GetEnvironmentVariables() map[string]string + GetConsoleURL() string } diff --git a/flyteplugins/go/tasks/pluginmachinery/core/mocks/task_execution_metadata.go b/flyteplugins/go/tasks/pluginmachinery/core/mocks/task_execution_metadata.go index b9115f00c6..433816f89c 100644 --- a/flyteplugins/go/tasks/pluginmachinery/core/mocks/task_execution_metadata.go +++ b/flyteplugins/go/tasks/pluginmachinery/core/mocks/task_execution_metadata.go @@ -54,6 +54,38 @@ func (_m *TaskExecutionMetadata) GetAnnotations() map[string]string { return r0 } +type TaskExecutionMetadata_GetConsoleURL struct { + *mock.Call +} + +func (_m TaskExecutionMetadata_GetConsoleURL) Return(_a0 string) *TaskExecutionMetadata_GetConsoleURL { + return &TaskExecutionMetadata_GetConsoleURL{Call: _m.Call.Return(_a0)} +} + +func (_m *TaskExecutionMetadata) OnGetConsoleURL() *TaskExecutionMetadata_GetConsoleURL { + c_call := _m.On("GetConsoleURL") + return &TaskExecutionMetadata_GetConsoleURL{Call: c_call} +} + +func (_m *TaskExecutionMetadata) OnGetConsoleURLMatch(matchers ...interface{}) *TaskExecutionMetadata_GetConsoleURL { + c_call := _m.On("GetConsoleURL", matchers...) + return &TaskExecutionMetadata_GetConsoleURL{Call: c_call} +} + +// GetConsoleURL provides a mock function with given fields: +func (_m *TaskExecutionMetadata) GetConsoleURL() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + type TaskExecutionMetadata_GetEnvironmentVariables struct { *mock.Call } diff --git a/flyteplugins/go/tasks/pluginmachinery/core/template/template.go b/flyteplugins/go/tasks/pluginmachinery/core/template/template.go index 82b306ffbe..7a787c5590 100644 --- a/flyteplugins/go/tasks/pluginmachinery/core/template/template.go +++ b/flyteplugins/go/tasks/pluginmachinery/core/template/template.go @@ -64,10 +64,11 @@ func (e ErrorCollection) Error() string { // Parameters struct is used by the Templating Engine to replace the templated parameters type Parameters struct { - TaskExecMetadata core.TaskExecutionMetadata - Inputs io.InputReader - OutputPath io.OutputFilePaths - Task core.TaskTemplatePath + TaskExecMetadata core.TaskExecutionMetadata + Inputs io.InputReader + OutputPath io.OutputFilePaths + Task core.TaskTemplatePath + IncludeConsoleURL bool } // Render Evaluates templates in each command with the equivalent value from passed args. Templates are case-insensitive diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go index fdaec7256c..8ad765f72e 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper.go @@ -292,7 +292,12 @@ func AddFlyteCustomizationsToContainer(ctx context.Context, parameters template. } container.Args = modifiedArgs - container.Env, container.EnvFrom = DecorateEnvVars(ctx, container.Env, parameters.TaskExecMetadata.GetEnvironmentVariables(), parameters.TaskExecMetadata.GetTaskExecutionID()) + // The flyteconsole url is added based on the `IncludeConsoleURL` bit set via the task template + consoleURL := "" + if parameters.IncludeConsoleURL { + consoleURL = parameters.TaskExecMetadata.GetConsoleURL() + } + container.Env, container.EnvFrom = DecorateEnvVars(ctx, container.Env, parameters.TaskExecMetadata.GetEnvironmentVariables(), parameters.TaskExecMetadata.GetTaskExecutionID(), consoleURL) // retrieve platformResources and overrideResources to use when aggregating container resources platformResources := parameters.TaskExecMetadata.GetPlatformResources() diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper_test.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper_test.go index ece0f724c4..6aab57f7b3 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper_test.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/container_helper_test.go @@ -404,6 +404,7 @@ func TestToK8sContainer(t *testing.T) { "foo": "bar", }) mockTaskExecMetadata.OnGetNamespace().Return("my-namespace") + mockTaskExecMetadata.OnGetConsoleURL().Return("") tCtx := &mocks.TaskExecutionContext{} tCtx.OnTaskExecutionMetadata().Return(&mockTaskExecMetadata) @@ -447,9 +448,10 @@ func TestToK8sContainer(t *testing.T) { assert.False(t, *container.SecurityContext.AllowPrivilegeEscalation) } -func getTemplateParametersForTest(resourceRequirements, platformResources *v1.ResourceRequirements) template.Parameters { +func getTemplateParametersForTest(resourceRequirements, platformResources *v1.ResourceRequirements, includeConsoleURL bool, consoleURL string) template.Parameters { mockTaskExecMetadata := mocks.TaskExecutionMetadata{} mockTaskExecutionID := mocks.TaskExecutionID{} + mockTaskExecutionID.OnGetUniqueNodeID().Return("unique_node_id") mockTaskExecutionID.OnGetGeneratedName().Return("gen_name") mockTaskExecutionID.OnGetID().Return(core.TaskExecutionIdentifier{ TaskId: &core.Identifier{ @@ -477,6 +479,7 @@ func getTemplateParametersForTest(resourceRequirements, platformResources *v1.Re mockTaskExecMetadata.OnGetPlatformResources().Return(platformResources) mockTaskExecMetadata.OnGetEnvironmentVariables().Return(nil) mockTaskExecMetadata.OnGetNamespace().Return("my-namespace") + mockTaskExecMetadata.OnGetConsoleURL().Return(consoleURL) mockInputReader := mocks2.InputReader{} mockInputPath := storage.DataReference("s3://input/path") @@ -492,9 +495,10 @@ func getTemplateParametersForTest(resourceRequirements, platformResources *v1.Re mockOutputPath.OnGetPreviousCheckpointsPrefix().Return("/prev") return template.Parameters{ - TaskExecMetadata: &mockTaskExecMetadata, - Inputs: &mockInputReader, - OutputPath: &mockOutputPath, + TaskExecMetadata: &mockTaskExecMetadata, + Inputs: &mockInputReader, + OutputPath: &mockOutputPath, + IncludeConsoleURL: includeConsoleURL, } } @@ -506,7 +510,7 @@ func TestAddFlyteCustomizationsToContainer(t *testing.T) { Limits: v1.ResourceList{ v1.ResourceEphemeralStorage: resource.MustParse("2048Mi"), }, - }, nil) + }, nil, false, "") container := &v1.Container{ Command: []string{ "{{ .Input }}", @@ -554,7 +558,7 @@ func TestAddFlyteCustomizationsToContainer_Resources(t *testing.T) { Limits: v1.ResourceList{ v1.ResourceMemory: resource.MustParse("20"), }, - }) + }, false, "") err := AddFlyteCustomizationsToContainer(context.TODO(), templateParameters, ResourceCustomizationModeMergeExistingResources, container) assert.NoError(t, err) assert.True(t, container.Resources.Requests.Cpu().Equal(resource.MustParse("1"))) @@ -577,7 +581,7 @@ func TestAddFlyteCustomizationsToContainer_Resources(t *testing.T) { Limits: v1.ResourceList{ v1.ResourceMemory: resource.MustParse("20"), }, - }) + }, false, "") err := AddFlyteCustomizationsToContainer(context.TODO(), templateParameters, ResourceCustomizationModeMergeExistingResources, container) assert.NoError(t, err) assert.True(t, container.Resources.Requests.Cpu().Equal(resource.MustParse("1"))) @@ -612,7 +616,7 @@ func TestAddFlyteCustomizationsToContainer_Resources(t *testing.T) { v1.ResourceCPU: resource.MustParse("10"), v1.ResourceMemory: resource.MustParse("20"), }, - }) + }, false, "") err := AddFlyteCustomizationsToContainer(context.TODO(), templateParameters, ResourceCustomizationModeMergeExistingResources, container) assert.NoError(t, err) assert.True(t, container.Resources.Requests.Cpu().Equal(resource.MustParse("10"))) @@ -649,7 +653,7 @@ func TestAddFlyteCustomizationsToContainer_Resources(t *testing.T) { templateParameters := getTemplateParametersForTest(&v1.ResourceRequirements{ Requests: overrideRequests, Limits: overrideLimits, - }, &v1.ResourceRequirements{}) + }, &v1.ResourceRequirements{}, false, "") err := AddFlyteCustomizationsToContainer(context.TODO(), templateParameters, ResourceCustomizationModeMergeExistingResources, container) assert.NoError(t, err) @@ -684,7 +688,7 @@ func TestAddFlyteCustomizationsToContainer_ValidateExistingResources(t *testing. v1.ResourceCPU: resource.MustParse("10"), v1.ResourceMemory: resource.MustParse("20"), }, - }) + }, false, "") err := AddFlyteCustomizationsToContainer(context.TODO(), templateParameters, ResourceCustomizationModeEnsureExistingResourcesInRange, container) assert.NoError(t, err) diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds.go index b235725edd..f26146435a 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds.go @@ -2,8 +2,10 @@ package flytek8s import ( "context" + "fmt" "os" "strconv" + "strings" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" @@ -13,6 +15,10 @@ import ( "github.com/flyteorg/flyte/flytestdlib/contextutils" ) +const ( + flyteExecutionURL = "FLYTE_EXECUTION_URL" +) + func GetContextEnvVars(ownerCtx context.Context) []v1.EnvVar { var envVars []v1.EnvVar @@ -32,7 +38,7 @@ func GetContextEnvVars(ownerCtx context.Context) []v1.EnvVar { return envVars } -func GetExecutionEnvVars(id pluginsCore.TaskExecutionID) []v1.EnvVar { +func GetExecutionEnvVars(id pluginsCore.TaskExecutionID, consoleURL string) []v1.EnvVar { if id == nil || id.GetID().NodeExecutionId == nil || id.GetID().NodeExecutionId.ExecutionId == nil { return []v1.EnvVar{} @@ -69,6 +75,14 @@ func GetExecutionEnvVars(id pluginsCore.TaskExecutionID) []v1.EnvVar { // }, } + if len(consoleURL) > 0 { + consoleURL = strings.TrimRight(consoleURL, "/") + envVars = append(envVars, v1.EnvVar{ + Name: flyteExecutionURL, + Value: fmt.Sprintf("%s/projects/%s/domains/%s/executions/%s/nodeId/%s/nodes", consoleURL, nodeExecutionID.Project, nodeExecutionID.Domain, nodeExecutionID.Name, id.GetUniqueNodeID()), + }) + } + // Task definition Level env variables. if id.GetID().TaskId != nil { taskID := id.GetID().TaskId @@ -113,9 +127,9 @@ func GetExecutionEnvVars(id pluginsCore.TaskExecutionID) []v1.EnvVar { return envVars } -func DecorateEnvVars(ctx context.Context, envVars []v1.EnvVar, taskEnvironmentVariables map[string]string, id pluginsCore.TaskExecutionID) ([]v1.EnvVar, []v1.EnvFromSource) { +func DecorateEnvVars(ctx context.Context, envVars []v1.EnvVar, taskEnvironmentVariables map[string]string, id pluginsCore.TaskExecutionID, consoleURL string) ([]v1.EnvVar, []v1.EnvFromSource) { envVars = append(envVars, GetContextEnvVars(ctx)...) - envVars = append(envVars, GetExecutionEnvVars(id)...) + envVars = append(envVars, GetExecutionEnvVars(id, consoleURL)...) for k, v := range taskEnvironmentVariables { envVars = append(envVars, v1.EnvVar{Name: k, Value: v}) diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds_test.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds_test.go index 2093639d97..9a6f302cb9 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds_test.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/k8s_resource_adds_test.go @@ -6,6 +6,7 @@ import ( "reflect" "testing" + "github.com/golang/protobuf/proto" "github.com/stretchr/testify/assert" v12 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -18,8 +19,53 @@ import ( func TestGetExecutionEnvVars(t *testing.T) { mock := mockTaskExecutionIdentifier{} - envVars := GetExecutionEnvVars(mock) - assert.Len(t, envVars, 12) + tests := []struct { + name string + expectedEnvVars int + consoleURL string + expectedEnvVar *v12.EnvVar + }{ + { + "no-console-url", + 12, + "", + nil, + }, + { + "with-console-url", + 13, + "scheme://host/path", + &v12.EnvVar{ + Name: "FLYTE_EXECUTION_URL", + Value: "scheme://host/path/projects/proj/domains/domain/executions/name/nodeId/unique-node-id/nodes", + }, + }, + { + "with-console-url-ending-in-single-slash", + 13, + "scheme://host/path/", + &v12.EnvVar{ + Name: "FLYTE_EXECUTION_URL", + Value: "scheme://host/path/projects/proj/domains/domain/executions/name/nodeId/unique-node-id/nodes", + }, + }, + { + "with-console-url-ending-in-multiple-slashes", + 13, + "scheme://host/path////", + &v12.EnvVar{ + Name: "FLYTE_EXECUTION_URL", + Value: "scheme://host/path/projects/proj/domains/domain/executions/name/nodeId/unique-node-id/nodes", + }, + }, + } + for _, tt := range tests { + envVars := GetExecutionEnvVars(mock, tt.consoleURL) + assert.Len(t, envVars, tt.expectedEnvVars) + if tt.expectedEnvVar != nil { + assert.True(t, proto.Equal(&envVars[4], tt.expectedEnvVar)) + } + } } func TestGetTolerationsForResources(t *testing.T) { @@ -257,7 +303,7 @@ func TestDecorateEnvVars(t *testing.T) { defer os.Setenv("value", originalEnvVal) expected := append(defaultEnv, GetContextEnvVars(ctx)...) - expected = append(expected, GetExecutionEnvVars(mockTaskExecutionIdentifier{})...) + expected = append(expected, GetExecutionEnvVars(mockTaskExecutionIdentifier{}, "")...) aggregated := append(expected, v12.EnvVar{Name: "k", Value: "v"}) type args struct { @@ -270,12 +316,13 @@ func TestDecorateEnvVars(t *testing.T) { additionEnvVar map[string]string additionEnvVarFromEnv map[string]string executionEnvVar map[string]string + consoleURL string want []v12.EnvVar }{ - {"no-additional", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, emptyEnvVar, emptyEnvVar, emptyEnvVar, expected}, - {"with-additional", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, additionalEnv, emptyEnvVar, emptyEnvVar, aggregated}, - {"from-env", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, emptyEnvVar, envVarsFromEnv, emptyEnvVar, aggregated}, - {"from-execution-metadata", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, emptyEnvVar, emptyEnvVar, additionalEnv, aggregated}, + {"no-additional", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, emptyEnvVar, emptyEnvVar, emptyEnvVar, "", expected}, + {"with-additional", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, additionalEnv, emptyEnvVar, emptyEnvVar, "", aggregated}, + {"from-env", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, emptyEnvVar, envVarsFromEnv, emptyEnvVar, "", aggregated}, + {"from-execution-metadata", args{envVars: defaultEnv, id: mockTaskExecutionIdentifier{}}, emptyEnvVar, emptyEnvVar, additionalEnv, "", aggregated}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -283,7 +330,7 @@ func TestDecorateEnvVars(t *testing.T) { DefaultEnvVars: tt.additionEnvVar, DefaultEnvVarsFromEnv: tt.additionEnvVarFromEnv, })) - if got, _ := DecorateEnvVars(ctx, tt.args.envVars, tt.executionEnvVar, tt.args.id); !reflect.DeepEqual(got, tt.want) { + if got, _ := DecorateEnvVars(ctx, tt.args.envVars, tt.executionEnvVar, tt.args.id, tt.consoleURL); !reflect.DeepEqual(got, tt.want) { t.Errorf("DecorateEnvVars() = %v, want %v", got, tt.want) } }) diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper.go index e25b3a4994..036d5e80f5 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper.go @@ -316,6 +316,19 @@ func BuildRawPod(ctx context.Context, tCtx pluginsCore.TaskExecutionContext) (*v return podSpec, &objectMeta, primaryContainerName, nil } +func hasExternalLinkType(taskTemplate *core.TaskTemplate) bool { + if taskTemplate == nil { + return false + } + config := taskTemplate.GetConfig() + if config == nil { + return false + } + // The presence of any "link_type" is sufficient to guarantee that the console URL should be included. + _, exists := config["link_type"] + return exists +} + // ApplyFlytePodConfiguration updates the PodSpec and ObjectMeta with various Flyte configuration. This includes // applying default k8s configuration, applying overrides (resources etc.), injecting copilot containers, and merging with the // configuration PodTemplate (if exists). @@ -328,10 +341,11 @@ func ApplyFlytePodConfiguration(ctx context.Context, tCtx pluginsCore.TaskExecut // add flyte resource customizations to containers templateParameters := template.Parameters{ - Inputs: tCtx.InputReader(), - OutputPath: tCtx.OutputWriter(), - Task: tCtx.TaskReader(), - TaskExecMetadata: tCtx.TaskExecutionMetadata(), + Inputs: tCtx.InputReader(), + OutputPath: tCtx.OutputWriter(), + Task: tCtx.TaskReader(), + TaskExecMetadata: tCtx.TaskExecutionMetadata(), + IncludeConsoleURL: hasExternalLinkType(taskTemplate), } resourceRequests := make([]v1.ResourceRequirements, 0, len(podSpec.Containers)) diff --git a/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper_test.go b/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper_test.go index 7869ed400f..7010247ee5 100644 --- a/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper_test.go +++ b/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper_test.go @@ -57,6 +57,7 @@ func dummyTaskExecutionMetadata(resources *v1.ResourceRequirements, extendedReso taskExecutionMetadata.On("IsInterruptible").Return(true) taskExecutionMetadata.OnGetPlatformResources().Return(&v1.ResourceRequirements{}) taskExecutionMetadata.OnGetEnvironmentVariables().Return(nil) + taskExecutionMetadata.OnGetConsoleURL().Return("") return taskExecutionMetadata } @@ -2117,3 +2118,71 @@ func TestMergePodSpecs(t *testing.T) { assert.Equal(t, podSpec.Containers[1].Name, defaultContainer.Name) assert.Equal(t, defaultContainerTemplate.TerminationMessagePath, defaultContainer.TerminationMessagePath) } + +func TestAddFlyteCustomizationsToContainer_SetConsoleUrl(t *testing.T) { + tests := []struct { + name string + includeConsoleURL bool + consoleURL string + expectedEnvVar *v1.EnvVar + }{ + { + name: "do not include console url and console url is not set", + includeConsoleURL: false, + consoleURL: "", + expectedEnvVar: nil, + }, + { + name: "include console url but console url is not set", + includeConsoleURL: false, + consoleURL: "", + expectedEnvVar: nil, + }, + { + name: "do not include console url but console url is set", + includeConsoleURL: false, + consoleURL: "gopher://flyte:65535/console", + expectedEnvVar: nil, + }, + { + name: "include console url and console url is set", + includeConsoleURL: true, + consoleURL: "gopher://flyte:65535/console", + expectedEnvVar: &v1.EnvVar{ + Name: flyteExecutionURL, + Value: "gopher://flyte:65535/console/projects/p2/domains/d2/executions/n2/nodeId/unique_node_id/nodes", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + container := &v1.Container{ + Command: []string{ + "{{ .Input }}", + }, + Args: []string{ + "{{ .OutputPrefix }}", + }, + } + templateParameters := getTemplateParametersForTest(&v1.ResourceRequirements{}, &v1.ResourceRequirements{}, tt.includeConsoleURL, tt.consoleURL) + err := AddFlyteCustomizationsToContainer(context.TODO(), templateParameters, ResourceCustomizationModeAssignResources, container) + assert.NoError(t, err) + if tt.expectedEnvVar == nil { + // Confirm that there is no env var FLYTE_EXECUTION_URL set + for _, envVar := range container.Env { + assert.NotEqual(t, "FLYTE_EXECUTION_URL", envVar.Name) + } + } + if tt.expectedEnvVar != nil { + // Assert that the env var FLYTE_EXECUTION_URL is set if its value is non-nil + for _, envVar := range container.Env { + if envVar.Name == tt.expectedEnvVar.Name { + assert.Equal(t, tt.expectedEnvVar.Value, envVar.Value) + return + } + } + t.Fail() + } + }) + } +} diff --git a/flyteplugins/go/tasks/plugins/array/awsbatch/transformer.go b/flyteplugins/go/tasks/plugins/array/awsbatch/transformer.go index 68dc88c883..50445d31b0 100644 --- a/flyteplugins/go/tasks/plugins/array/awsbatch/transformer.go +++ b/flyteplugins/go/tasks/plugins/array/awsbatch/transformer.go @@ -138,7 +138,7 @@ func UpdateBatchInputForArray(_ context.Context, batchInput *batch.SubmitJobInpu func getEnvVarsForTask(ctx context.Context, execID pluginCore.TaskExecutionID, containerEnvVars []*core.KeyValuePair, defaultEnvVars map[string]string) []v1.EnvVar { - envVars, _ := flytek8s.DecorateEnvVars(ctx, flytek8s.ToK8sEnvVar(containerEnvVars), nil, execID) + envVars, _ := flytek8s.DecorateEnvVars(ctx, flytek8s.ToK8sEnvVar(containerEnvVars), nil, execID, "") m := make(map[string]string, len(envVars)) for _, envVar := range envVars { m[envVar.Name] = envVar.Value diff --git a/flyteplugins/go/tasks/plugins/array/k8s/management_test.go b/flyteplugins/go/tasks/plugins/array/k8s/management_test.go index c5d52efda7..7100fbc34c 100644 --- a/flyteplugins/go/tasks/plugins/array/k8s/management_test.go +++ b/flyteplugins/go/tasks/plugins/array/k8s/management_test.go @@ -116,6 +116,7 @@ func getMockTaskExecutionContext(ctx context.Context, parallelism int) *mocks.Ta tMeta.OnGetPlatformResources().Return(&v1.ResourceRequirements{}) tMeta.OnGetInterruptibleFailureThreshold().Return(2) tMeta.OnGetEnvironmentVariables().Return(nil) + tMeta.OnGetConsoleURL().Return("") ow := &mocks2.OutputWriter{} ow.OnGetOutputPrefixPath().Return("/prefix/") diff --git a/flyteplugins/go/tasks/plugins/k8s/dask/dask_test.go b/flyteplugins/go/tasks/plugins/k8s/dask/dask_test.go index 86ca034e7b..616312ca12 100644 --- a/flyteplugins/go/tasks/plugins/k8s/dask/dask_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/dask/dask_test.go @@ -191,6 +191,7 @@ func dummyDaskTaskContext(taskTemplate *core.TaskTemplate, resources *v1.Resourc taskExecutionMetadata.OnGetEnvironmentVariables().Return(nil) taskExecutionMetadata.OnGetK8sServiceAccount().Return(defaultServiceAccountName) taskExecutionMetadata.OnGetNamespace().Return(defaultNamespace) + taskExecutionMetadata.OnGetConsoleURL().Return("") overrides := &mocks.TaskOverrides{} overrides.OnGetResources().Return(resources) overrides.OnGetExtendedResources().Return(extendedResources) diff --git a/flyteplugins/go/tasks/plugins/k8s/kfoperators/mpi/mpi_test.go b/flyteplugins/go/tasks/plugins/k8s/kfoperators/mpi/mpi_test.go index 900091f78a..02224ec8a7 100644 --- a/flyteplugins/go/tasks/plugins/k8s/kfoperators/mpi/mpi_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/kfoperators/mpi/mpi_test.go @@ -169,6 +169,7 @@ func dummyMPITaskContext(taskTemplate *core.TaskTemplate, resources *corev1.Reso taskExecutionMetadata.OnGetK8sServiceAccount().Return(serviceAccount) taskExecutionMetadata.OnGetPlatformResources().Return(&corev1.ResourceRequirements{}) taskExecutionMetadata.OnGetEnvironmentVariables().Return(nil) + taskExecutionMetadata.OnGetConsoleURL().Return("") taskCtx.OnTaskExecutionMetadata().Return(taskExecutionMetadata) return taskCtx } diff --git a/flyteplugins/go/tasks/plugins/k8s/kfoperators/pytorch/pytorch_test.go b/flyteplugins/go/tasks/plugins/k8s/kfoperators/pytorch/pytorch_test.go index f40f80e1f7..70fcdcdc5c 100644 --- a/flyteplugins/go/tasks/plugins/k8s/kfoperators/pytorch/pytorch_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/kfoperators/pytorch/pytorch_test.go @@ -175,6 +175,7 @@ func dummyPytorchTaskContext(taskTemplate *core.TaskTemplate, resources *corev1. taskExecutionMetadata.OnGetK8sServiceAccount().Return(serviceAccount) taskExecutionMetadata.OnGetPlatformResources().Return(&corev1.ResourceRequirements{}) taskExecutionMetadata.OnGetEnvironmentVariables().Return(nil) + taskExecutionMetadata.OnGetConsoleURL().Return("") taskCtx.OnTaskExecutionMetadata().Return(taskExecutionMetadata) return taskCtx } diff --git a/flyteplugins/go/tasks/plugins/k8s/kfoperators/tensorflow/tensorflow_test.go b/flyteplugins/go/tasks/plugins/k8s/kfoperators/tensorflow/tensorflow_test.go index a85ce8f875..0cf0f34fd2 100644 --- a/flyteplugins/go/tasks/plugins/k8s/kfoperators/tensorflow/tensorflow_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/kfoperators/tensorflow/tensorflow_test.go @@ -170,6 +170,7 @@ func dummyTensorFlowTaskContext(taskTemplate *core.TaskTemplate, resources *core taskExecutionMetadata.OnGetK8sServiceAccount().Return(serviceAccount) taskExecutionMetadata.OnGetPlatformResources().Return(&corev1.ResourceRequirements{}) taskExecutionMetadata.OnGetEnvironmentVariables().Return(nil) + taskExecutionMetadata.OnGetConsoleURL().Return("") taskCtx.OnTaskExecutionMetadata().Return(taskExecutionMetadata) return taskCtx } diff --git a/flyteplugins/go/tasks/plugins/k8s/pod/container_test.go b/flyteplugins/go/tasks/plugins/k8s/pod/container_test.go index 9c098bd708..5d89e2f0ec 100644 --- a/flyteplugins/go/tasks/plugins/k8s/pod/container_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/pod/container_test.go @@ -122,6 +122,7 @@ func dummyContainerTaskMetadata(resources *v1.ResourceRequirements, extendedReso taskMetadata.On("GetOverrides").Return(to) taskMetadata.On("IsInterruptible").Return(true) taskMetadata.On("GetEnvironmentVariables").Return(nil) + taskMetadata.OnGetConsoleURL().Return("") return taskMetadata } diff --git a/flyteplugins/go/tasks/plugins/k8s/pod/sidecar_test.go b/flyteplugins/go/tasks/plugins/k8s/pod/sidecar_test.go index 06166d15fb..e6b8b0478b 100644 --- a/flyteplugins/go/tasks/plugins/k8s/pod/sidecar_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/pod/sidecar_test.go @@ -93,6 +93,7 @@ func dummySidecarTaskMetadata(resources *v1.ResourceRequirements, extendedResour to.On("GetContainerImage").Return("") taskMetadata.On("GetOverrides").Return(to) taskMetadata.On("GetEnvironmentVariables").Return(nil) + taskMetadata.On("GetConsoleURL").Return("") return taskMetadata } diff --git a/flyteplugins/go/tasks/plugins/k8s/ray/ray_test.go b/flyteplugins/go/tasks/plugins/k8s/ray/ray_test.go index cb69e883c2..28f4749625 100644 --- a/flyteplugins/go/tasks/plugins/k8s/ray/ray_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/ray/ray_test.go @@ -159,6 +159,7 @@ func dummyRayTaskContext(taskTemplate *core.TaskTemplate, resources *corev1.Reso RunAs: &core.Identity{K8SServiceAccount: serviceAccount}, }) taskExecutionMetadata.OnGetEnvironmentVariables().Return(nil) + taskExecutionMetadata.OnGetConsoleURL().Return("") taskCtx.OnTaskExecutionMetadata().Return(taskExecutionMetadata) return taskCtx } diff --git a/flyteplugins/go/tasks/plugins/k8s/spark/spark_test.go b/flyteplugins/go/tasks/plugins/k8s/spark/spark_test.go index 561901226a..2b481834db 100644 --- a/flyteplugins/go/tasks/plugins/k8s/spark/spark_test.go +++ b/flyteplugins/go/tasks/plugins/k8s/spark/spark_test.go @@ -405,6 +405,7 @@ func dummySparkTaskContext(taskTemplate *core.TaskTemplate, interruptible bool) taskExecutionMetadata.On("GetPlatformResources").Return(nil) taskExecutionMetadata.On("GetOverrides").Return(overrides) taskExecutionMetadata.On("GetK8sServiceAccount").Return("new-val") + taskExecutionMetadata.On("GetConsoleURL").Return("") taskCtx.On("TaskExecutionMetadata").Return(taskExecutionMetadata) return taskCtx } diff --git a/flyteplugins/tests/end_to_end.go b/flyteplugins/tests/end_to_end.go index 732241953d..b045deae13 100644 --- a/flyteplugins/tests/end_to_end.go +++ b/flyteplugins/tests/end_to_end.go @@ -171,6 +171,7 @@ func RunPluginEndToEndTest(t *testing.T, executor pluginCore.Plugin, template *i tMeta.OnGetPlatformResources().Return(&v1.ResourceRequirements{}) tMeta.OnGetInterruptibleFailureThreshold().Return(2) tMeta.OnGetEnvironmentVariables().Return(nil) + tMeta.OnGetConsoleURL().Return("") catClient := &catalogMocks.Client{} catData := sync.Map{} diff --git a/flytepropeller/cmd/kubectl-flyte/cmd/printers/workflow.go b/flytepropeller/cmd/kubectl-flyte/cmd/printers/workflow.go index ff881c938e..24d750661e 100644 --- a/flytepropeller/cmd/kubectl-flyte/cmd/printers/workflow.go +++ b/flytepropeller/cmd/kubectl-flyte/cmd/printers/workflow.go @@ -47,6 +47,8 @@ func (w *ContextualWorkflow) GetExecutionConfig() v1alpha1.ExecutionConfig { return v1alpha1.ExecutionConfig{} } +func (w *ContextualWorkflow) GetConsoleURL() string { return "" } + type WorkflowPrinter struct { } diff --git a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/iface.go b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/iface.go index f92cca4a5a..ef402d724d 100644 --- a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/iface.go +++ b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/iface.go @@ -511,6 +511,7 @@ type Meta interface { GetEventVersion() EventVersion GetDefinitionVersion() WorkflowDefinitionVersion GetRawOutputDataConfig() RawOutputDataConfig + GetConsoleURL() string } type TaskDetailsGetter interface { diff --git a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/ExecutableWorkflow.go b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/ExecutableWorkflow.go index b417e2f892..093a93ac2d 100644 --- a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/ExecutableWorkflow.go +++ b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/ExecutableWorkflow.go @@ -163,6 +163,38 @@ func (_m *ExecutableWorkflow) GetConnections() *v1alpha1.Connections { return r0 } +type ExecutableWorkflow_GetConsoleURL struct { + *mock.Call +} + +func (_m ExecutableWorkflow_GetConsoleURL) Return(_a0 string) *ExecutableWorkflow_GetConsoleURL { + return &ExecutableWorkflow_GetConsoleURL{Call: _m.Call.Return(_a0)} +} + +func (_m *ExecutableWorkflow) OnGetConsoleURL() *ExecutableWorkflow_GetConsoleURL { + c_call := _m.On("GetConsoleURL") + return &ExecutableWorkflow_GetConsoleURL{Call: c_call} +} + +func (_m *ExecutableWorkflow) OnGetConsoleURLMatch(matchers ...interface{}) *ExecutableWorkflow_GetConsoleURL { + c_call := _m.On("GetConsoleURL", matchers...) + return &ExecutableWorkflow_GetConsoleURL{Call: c_call} +} + +// GetConsoleURL provides a mock function with given fields: +func (_m *ExecutableWorkflow) GetConsoleURL() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + type ExecutableWorkflow_GetCreationTimestamp struct { *mock.Call } diff --git a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/Meta.go b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/Meta.go index e99227b099..4e098aab2f 100644 --- a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/Meta.go +++ b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/Meta.go @@ -52,6 +52,38 @@ func (_m *Meta) GetAnnotations() map[string]string { return r0 } +type Meta_GetConsoleURL struct { + *mock.Call +} + +func (_m Meta_GetConsoleURL) Return(_a0 string) *Meta_GetConsoleURL { + return &Meta_GetConsoleURL{Call: _m.Call.Return(_a0)} +} + +func (_m *Meta) OnGetConsoleURL() *Meta_GetConsoleURL { + c_call := _m.On("GetConsoleURL") + return &Meta_GetConsoleURL{Call: c_call} +} + +func (_m *Meta) OnGetConsoleURLMatch(matchers ...interface{}) *Meta_GetConsoleURL { + c_call := _m.On("GetConsoleURL", matchers...) + return &Meta_GetConsoleURL{Call: c_call} +} + +// GetConsoleURL provides a mock function with given fields: +func (_m *Meta) GetConsoleURL() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + type Meta_GetCreationTimestamp struct { *mock.Call } diff --git a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/MetaExtended.go b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/MetaExtended.go index 50e478b6d4..95915088da 100644 --- a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/MetaExtended.go +++ b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks/MetaExtended.go @@ -86,6 +86,38 @@ func (_m *MetaExtended) GetAnnotations() map[string]string { return r0 } +type MetaExtended_GetConsoleURL struct { + *mock.Call +} + +func (_m MetaExtended_GetConsoleURL) Return(_a0 string) *MetaExtended_GetConsoleURL { + return &MetaExtended_GetConsoleURL{Call: _m.Call.Return(_a0)} +} + +func (_m *MetaExtended) OnGetConsoleURL() *MetaExtended_GetConsoleURL { + c_call := _m.On("GetConsoleURL") + return &MetaExtended_GetConsoleURL{Call: c_call} +} + +func (_m *MetaExtended) OnGetConsoleURLMatch(matchers ...interface{}) *MetaExtended_GetConsoleURL { + c_call := _m.On("GetConsoleURL", matchers...) + return &MetaExtended_GetConsoleURL{Call: c_call} +} + +// GetConsoleURL provides a mock function with given fields: +func (_m *MetaExtended) GetConsoleURL() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + type MetaExtended_GetCreationTimestamp struct { *mock.Call } diff --git a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/workflow.go b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/workflow.go index 225a49ac3f..1d45dc6578 100644 --- a/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/workflow.go +++ b/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/workflow.go @@ -77,6 +77,9 @@ type FlyteWorkflow struct { // portions of the CRD to an external data store to reduce CRD size. If this exists, FlytePropeller must retrieve // and parse the static data prior to processing. WorkflowClosureReference DataReference `json:"workflowClosureReference,omitempty"` + + // Flyteconsole url + ConsoleURL string `json:"consoleUrl,omitempty"` } func (in *FlyteWorkflow) GetSecurityContext() core.SecurityContext { @@ -102,6 +105,8 @@ func (in *FlyteWorkflow) GetExecutionConfig() ExecutionConfig { return in.ExecutionConfig } +func (in *FlyteWorkflow) GetConsoleURL() string { return in.ConsoleURL } + type WorkflowMeta struct { EventVersion EventVersion `json:"eventVersion,omitempty"` } diff --git a/flytepropeller/pkg/controller/executors/execution_context.go b/flytepropeller/pkg/controller/executors/execution_context.go index 84799a0400..07b5a6c450 100644 --- a/flytepropeller/pkg/controller/executors/execution_context.go +++ b/flytepropeller/pkg/controller/executors/execution_context.go @@ -4,7 +4,7 @@ import ( "github.com/flyteorg/flyte/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" ) -// go:generate mockery -case=underscore +//go:generate mockery-v2 --case=underscore --with-expecter --name ExecutionContext --output=mocks type TaskDetailsGetter interface { GetTask(id v1alpha1.TaskID) (v1alpha1.ExecutableTask, error) diff --git a/flytepropeller/pkg/controller/executors/mocks/execution_context.go b/flytepropeller/pkg/controller/executors/mocks/execution_context.go index cf9f4bcb49..cbcd501525 100644 --- a/flytepropeller/pkg/controller/executors/mocks/execution_context.go +++ b/flytepropeller/pkg/controller/executors/mocks/execution_context.go @@ -1,4 +1,4 @@ -// Code generated by mockery v1.0.1. DO NOT EDIT. +// Code generated by mockery v2.40.3. DO NOT EDIT. package mocks @@ -20,28 +20,22 @@ type ExecutionContext struct { mock.Mock } -type ExecutionContext_CurrentNodeExecutionCount struct { - *mock.Call -} - -func (_m ExecutionContext_CurrentNodeExecutionCount) Return(_a0 uint32) *ExecutionContext_CurrentNodeExecutionCount { - return &ExecutionContext_CurrentNodeExecutionCount{Call: _m.Call.Return(_a0)} -} - -func (_m *ExecutionContext) OnCurrentNodeExecutionCount() *ExecutionContext_CurrentNodeExecutionCount { - c_call := _m.On("CurrentNodeExecutionCount") - return &ExecutionContext_CurrentNodeExecutionCount{Call: c_call} +type ExecutionContext_Expecter struct { + mock *mock.Mock } -func (_m *ExecutionContext) OnCurrentNodeExecutionCountMatch(matchers ...interface{}) *ExecutionContext_CurrentNodeExecutionCount { - c_call := _m.On("CurrentNodeExecutionCount", matchers...) - return &ExecutionContext_CurrentNodeExecutionCount{Call: c_call} +func (_m *ExecutionContext) EXPECT() *ExecutionContext_Expecter { + return &ExecutionContext_Expecter{mock: &_m.Mock} } // CurrentNodeExecutionCount provides a mock function with given fields: func (_m *ExecutionContext) CurrentNodeExecutionCount() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CurrentNodeExecutionCount") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -52,28 +46,41 @@ func (_m *ExecutionContext) CurrentNodeExecutionCount() uint32 { return r0 } -type ExecutionContext_CurrentParallelism struct { +// ExecutionContext_CurrentNodeExecutionCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentNodeExecutionCount' +type ExecutionContext_CurrentNodeExecutionCount_Call struct { *mock.Call } -func (_m ExecutionContext_CurrentParallelism) Return(_a0 uint32) *ExecutionContext_CurrentParallelism { - return &ExecutionContext_CurrentParallelism{Call: _m.Call.Return(_a0)} +// CurrentNodeExecutionCount is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) CurrentNodeExecutionCount() *ExecutionContext_CurrentNodeExecutionCount_Call { + return &ExecutionContext_CurrentNodeExecutionCount_Call{Call: _e.mock.On("CurrentNodeExecutionCount")} } -func (_m *ExecutionContext) OnCurrentParallelism() *ExecutionContext_CurrentParallelism { - c_call := _m.On("CurrentParallelism") - return &ExecutionContext_CurrentParallelism{Call: c_call} +func (_c *ExecutionContext_CurrentNodeExecutionCount_Call) Run(run func()) *ExecutionContext_CurrentNodeExecutionCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnCurrentParallelismMatch(matchers ...interface{}) *ExecutionContext_CurrentParallelism { - c_call := _m.On("CurrentParallelism", matchers...) - return &ExecutionContext_CurrentParallelism{Call: c_call} +func (_c *ExecutionContext_CurrentNodeExecutionCount_Call) Return(_a0 uint32) *ExecutionContext_CurrentNodeExecutionCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_CurrentNodeExecutionCount_Call) RunAndReturn(run func() uint32) *ExecutionContext_CurrentNodeExecutionCount_Call { + _c.Call.Return(run) + return _c } // CurrentParallelism provides a mock function with given fields: func (_m *ExecutionContext) CurrentParallelism() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CurrentParallelism") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -84,28 +91,41 @@ func (_m *ExecutionContext) CurrentParallelism() uint32 { return r0 } -type ExecutionContext_CurrentTaskExecutionCount struct { +// ExecutionContext_CurrentParallelism_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentParallelism' +type ExecutionContext_CurrentParallelism_Call struct { *mock.Call } -func (_m ExecutionContext_CurrentTaskExecutionCount) Return(_a0 uint32) *ExecutionContext_CurrentTaskExecutionCount { - return &ExecutionContext_CurrentTaskExecutionCount{Call: _m.Call.Return(_a0)} +// CurrentParallelism is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) CurrentParallelism() *ExecutionContext_CurrentParallelism_Call { + return &ExecutionContext_CurrentParallelism_Call{Call: _e.mock.On("CurrentParallelism")} +} + +func (_c *ExecutionContext_CurrentParallelism_Call) Run(run func()) *ExecutionContext_CurrentParallelism_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnCurrentTaskExecutionCount() *ExecutionContext_CurrentTaskExecutionCount { - c_call := _m.On("CurrentTaskExecutionCount") - return &ExecutionContext_CurrentTaskExecutionCount{Call: c_call} +func (_c *ExecutionContext_CurrentParallelism_Call) Return(_a0 uint32) *ExecutionContext_CurrentParallelism_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnCurrentTaskExecutionCountMatch(matchers ...interface{}) *ExecutionContext_CurrentTaskExecutionCount { - c_call := _m.On("CurrentTaskExecutionCount", matchers...) - return &ExecutionContext_CurrentTaskExecutionCount{Call: c_call} +func (_c *ExecutionContext_CurrentParallelism_Call) RunAndReturn(run func() uint32) *ExecutionContext_CurrentParallelism_Call { + _c.Call.Return(run) + return _c } // CurrentTaskExecutionCount provides a mock function with given fields: func (_m *ExecutionContext) CurrentTaskExecutionCount() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CurrentTaskExecutionCount") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -116,28 +136,41 @@ func (_m *ExecutionContext) CurrentTaskExecutionCount() uint32 { return r0 } -type ExecutionContext_FindSubWorkflow struct { +// ExecutionContext_CurrentTaskExecutionCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentTaskExecutionCount' +type ExecutionContext_CurrentTaskExecutionCount_Call struct { *mock.Call } -func (_m ExecutionContext_FindSubWorkflow) Return(_a0 v1alpha1.ExecutableSubWorkflow) *ExecutionContext_FindSubWorkflow { - return &ExecutionContext_FindSubWorkflow{Call: _m.Call.Return(_a0)} +// CurrentTaskExecutionCount is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) CurrentTaskExecutionCount() *ExecutionContext_CurrentTaskExecutionCount_Call { + return &ExecutionContext_CurrentTaskExecutionCount_Call{Call: _e.mock.On("CurrentTaskExecutionCount")} } -func (_m *ExecutionContext) OnFindSubWorkflow(subID string) *ExecutionContext_FindSubWorkflow { - c_call := _m.On("FindSubWorkflow", subID) - return &ExecutionContext_FindSubWorkflow{Call: c_call} +func (_c *ExecutionContext_CurrentTaskExecutionCount_Call) Run(run func()) *ExecutionContext_CurrentTaskExecutionCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnFindSubWorkflowMatch(matchers ...interface{}) *ExecutionContext_FindSubWorkflow { - c_call := _m.On("FindSubWorkflow", matchers...) - return &ExecutionContext_FindSubWorkflow{Call: c_call} +func (_c *ExecutionContext_CurrentTaskExecutionCount_Call) Return(_a0 uint32) *ExecutionContext_CurrentTaskExecutionCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_CurrentTaskExecutionCount_Call) RunAndReturn(run func() uint32) *ExecutionContext_CurrentTaskExecutionCount_Call { + _c.Call.Return(run) + return _c } // FindSubWorkflow provides a mock function with given fields: subID func (_m *ExecutionContext) FindSubWorkflow(subID string) v1alpha1.ExecutableSubWorkflow { ret := _m.Called(subID) + if len(ret) == 0 { + panic("no return value specified for FindSubWorkflow") + } + var r0 v1alpha1.ExecutableSubWorkflow if rf, ok := ret.Get(0).(func(string) v1alpha1.ExecutableSubWorkflow); ok { r0 = rf(subID) @@ -150,28 +183,42 @@ func (_m *ExecutionContext) FindSubWorkflow(subID string) v1alpha1.ExecutableSub return r0 } -type ExecutionContext_GetAnnotations struct { +// ExecutionContext_FindSubWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindSubWorkflow' +type ExecutionContext_FindSubWorkflow_Call struct { *mock.Call } -func (_m ExecutionContext_GetAnnotations) Return(_a0 map[string]string) *ExecutionContext_GetAnnotations { - return &ExecutionContext_GetAnnotations{Call: _m.Call.Return(_a0)} +// FindSubWorkflow is a helper method to define mock.On call +// - subID string +func (_e *ExecutionContext_Expecter) FindSubWorkflow(subID interface{}) *ExecutionContext_FindSubWorkflow_Call { + return &ExecutionContext_FindSubWorkflow_Call{Call: _e.mock.On("FindSubWorkflow", subID)} } -func (_m *ExecutionContext) OnGetAnnotations() *ExecutionContext_GetAnnotations { - c_call := _m.On("GetAnnotations") - return &ExecutionContext_GetAnnotations{Call: c_call} +func (_c *ExecutionContext_FindSubWorkflow_Call) Run(run func(subID string)) *ExecutionContext_FindSubWorkflow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c } -func (_m *ExecutionContext) OnGetAnnotationsMatch(matchers ...interface{}) *ExecutionContext_GetAnnotations { - c_call := _m.On("GetAnnotations", matchers...) - return &ExecutionContext_GetAnnotations{Call: c_call} +func (_c *ExecutionContext_FindSubWorkflow_Call) Return(_a0 v1alpha1.ExecutableSubWorkflow) *ExecutionContext_FindSubWorkflow_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_FindSubWorkflow_Call) RunAndReturn(run func(string) v1alpha1.ExecutableSubWorkflow) *ExecutionContext_FindSubWorkflow_Call { + _c.Call.Return(run) + return _c } // GetAnnotations provides a mock function with given fields: func (_m *ExecutionContext) GetAnnotations() map[string]string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAnnotations") + } + var r0 map[string]string if rf, ok := ret.Get(0).(func() map[string]string); ok { r0 = rf() @@ -184,28 +231,86 @@ func (_m *ExecutionContext) GetAnnotations() map[string]string { return r0 } -type ExecutionContext_GetCreationTimestamp struct { +// ExecutionContext_GetAnnotations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAnnotations' +type ExecutionContext_GetAnnotations_Call struct { *mock.Call } -func (_m ExecutionContext_GetCreationTimestamp) Return(_a0 v1.Time) *ExecutionContext_GetCreationTimestamp { - return &ExecutionContext_GetCreationTimestamp{Call: _m.Call.Return(_a0)} +// GetAnnotations is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetAnnotations() *ExecutionContext_GetAnnotations_Call { + return &ExecutionContext_GetAnnotations_Call{Call: _e.mock.On("GetAnnotations")} +} + +func (_c *ExecutionContext_GetAnnotations_Call) Run(run func()) *ExecutionContext_GetAnnotations_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetCreationTimestamp() *ExecutionContext_GetCreationTimestamp { - c_call := _m.On("GetCreationTimestamp") - return &ExecutionContext_GetCreationTimestamp{Call: c_call} +func (_c *ExecutionContext_GetAnnotations_Call) Return(_a0 map[string]string) *ExecutionContext_GetAnnotations_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetCreationTimestampMatch(matchers ...interface{}) *ExecutionContext_GetCreationTimestamp { - c_call := _m.On("GetCreationTimestamp", matchers...) - return &ExecutionContext_GetCreationTimestamp{Call: c_call} +func (_c *ExecutionContext_GetAnnotations_Call) RunAndReturn(run func() map[string]string) *ExecutionContext_GetAnnotations_Call { + _c.Call.Return(run) + return _c +} + +// GetConsoleURL provides a mock function with given fields: +func (_m *ExecutionContext) GetConsoleURL() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetConsoleURL") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// ExecutionContext_GetConsoleURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConsoleURL' +type ExecutionContext_GetConsoleURL_Call struct { + *mock.Call +} + +// GetConsoleURL is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetConsoleURL() *ExecutionContext_GetConsoleURL_Call { + return &ExecutionContext_GetConsoleURL_Call{Call: _e.mock.On("GetConsoleURL")} +} + +func (_c *ExecutionContext_GetConsoleURL_Call) Run(run func()) *ExecutionContext_GetConsoleURL_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ExecutionContext_GetConsoleURL_Call) Return(_a0 string) *ExecutionContext_GetConsoleURL_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetConsoleURL_Call) RunAndReturn(run func() string) *ExecutionContext_GetConsoleURL_Call { + _c.Call.Return(run) + return _c } // GetCreationTimestamp provides a mock function with given fields: func (_m *ExecutionContext) GetCreationTimestamp() v1.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCreationTimestamp") + } + var r0 v1.Time if rf, ok := ret.Get(0).(func() v1.Time); ok { r0 = rf() @@ -216,28 +321,41 @@ func (_m *ExecutionContext) GetCreationTimestamp() v1.Time { return r0 } -type ExecutionContext_GetDefinitionVersion struct { +// ExecutionContext_GetCreationTimestamp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCreationTimestamp' +type ExecutionContext_GetCreationTimestamp_Call struct { *mock.Call } -func (_m ExecutionContext_GetDefinitionVersion) Return(_a0 v1alpha1.WorkflowDefinitionVersion) *ExecutionContext_GetDefinitionVersion { - return &ExecutionContext_GetDefinitionVersion{Call: _m.Call.Return(_a0)} +// GetCreationTimestamp is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetCreationTimestamp() *ExecutionContext_GetCreationTimestamp_Call { + return &ExecutionContext_GetCreationTimestamp_Call{Call: _e.mock.On("GetCreationTimestamp")} } -func (_m *ExecutionContext) OnGetDefinitionVersion() *ExecutionContext_GetDefinitionVersion { - c_call := _m.On("GetDefinitionVersion") - return &ExecutionContext_GetDefinitionVersion{Call: c_call} +func (_c *ExecutionContext_GetCreationTimestamp_Call) Run(run func()) *ExecutionContext_GetCreationTimestamp_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetDefinitionVersionMatch(matchers ...interface{}) *ExecutionContext_GetDefinitionVersion { - c_call := _m.On("GetDefinitionVersion", matchers...) - return &ExecutionContext_GetDefinitionVersion{Call: c_call} +func (_c *ExecutionContext_GetCreationTimestamp_Call) Return(_a0 v1.Time) *ExecutionContext_GetCreationTimestamp_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetCreationTimestamp_Call) RunAndReturn(run func() v1.Time) *ExecutionContext_GetCreationTimestamp_Call { + _c.Call.Return(run) + return _c } // GetDefinitionVersion provides a mock function with given fields: func (_m *ExecutionContext) GetDefinitionVersion() v1alpha1.WorkflowDefinitionVersion { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefinitionVersion") + } + var r0 v1alpha1.WorkflowDefinitionVersion if rf, ok := ret.Get(0).(func() v1alpha1.WorkflowDefinitionVersion); ok { r0 = rf() @@ -248,28 +366,41 @@ func (_m *ExecutionContext) GetDefinitionVersion() v1alpha1.WorkflowDefinitionVe return r0 } -type ExecutionContext_GetEventVersion struct { +// ExecutionContext_GetDefinitionVersion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDefinitionVersion' +type ExecutionContext_GetDefinitionVersion_Call struct { *mock.Call } -func (_m ExecutionContext_GetEventVersion) Return(_a0 v1alpha1.EventVersion) *ExecutionContext_GetEventVersion { - return &ExecutionContext_GetEventVersion{Call: _m.Call.Return(_a0)} +// GetDefinitionVersion is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetDefinitionVersion() *ExecutionContext_GetDefinitionVersion_Call { + return &ExecutionContext_GetDefinitionVersion_Call{Call: _e.mock.On("GetDefinitionVersion")} } -func (_m *ExecutionContext) OnGetEventVersion() *ExecutionContext_GetEventVersion { - c_call := _m.On("GetEventVersion") - return &ExecutionContext_GetEventVersion{Call: c_call} +func (_c *ExecutionContext_GetDefinitionVersion_Call) Run(run func()) *ExecutionContext_GetDefinitionVersion_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetEventVersionMatch(matchers ...interface{}) *ExecutionContext_GetEventVersion { - c_call := _m.On("GetEventVersion", matchers...) - return &ExecutionContext_GetEventVersion{Call: c_call} +func (_c *ExecutionContext_GetDefinitionVersion_Call) Return(_a0 v1alpha1.WorkflowDefinitionVersion) *ExecutionContext_GetDefinitionVersion_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetDefinitionVersion_Call) RunAndReturn(run func() v1alpha1.WorkflowDefinitionVersion) *ExecutionContext_GetDefinitionVersion_Call { + _c.Call.Return(run) + return _c } // GetEventVersion provides a mock function with given fields: func (_m *ExecutionContext) GetEventVersion() v1alpha1.EventVersion { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetEventVersion") + } + var r0 v1alpha1.EventVersion if rf, ok := ret.Get(0).(func() v1alpha1.EventVersion); ok { r0 = rf() @@ -280,28 +411,41 @@ func (_m *ExecutionContext) GetEventVersion() v1alpha1.EventVersion { return r0 } -type ExecutionContext_GetExecutionConfig struct { +// ExecutionContext_GetEventVersion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetEventVersion' +type ExecutionContext_GetEventVersion_Call struct { *mock.Call } -func (_m ExecutionContext_GetExecutionConfig) Return(_a0 v1alpha1.ExecutionConfig) *ExecutionContext_GetExecutionConfig { - return &ExecutionContext_GetExecutionConfig{Call: _m.Call.Return(_a0)} +// GetEventVersion is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetEventVersion() *ExecutionContext_GetEventVersion_Call { + return &ExecutionContext_GetEventVersion_Call{Call: _e.mock.On("GetEventVersion")} +} + +func (_c *ExecutionContext_GetEventVersion_Call) Run(run func()) *ExecutionContext_GetEventVersion_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetExecutionConfig() *ExecutionContext_GetExecutionConfig { - c_call := _m.On("GetExecutionConfig") - return &ExecutionContext_GetExecutionConfig{Call: c_call} +func (_c *ExecutionContext_GetEventVersion_Call) Return(_a0 v1alpha1.EventVersion) *ExecutionContext_GetEventVersion_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetExecutionConfigMatch(matchers ...interface{}) *ExecutionContext_GetExecutionConfig { - c_call := _m.On("GetExecutionConfig", matchers...) - return &ExecutionContext_GetExecutionConfig{Call: c_call} +func (_c *ExecutionContext_GetEventVersion_Call) RunAndReturn(run func() v1alpha1.EventVersion) *ExecutionContext_GetEventVersion_Call { + _c.Call.Return(run) + return _c } // GetExecutionConfig provides a mock function with given fields: func (_m *ExecutionContext) GetExecutionConfig() v1alpha1.ExecutionConfig { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetExecutionConfig") + } + var r0 v1alpha1.ExecutionConfig if rf, ok := ret.Get(0).(func() v1alpha1.ExecutionConfig); ok { r0 = rf() @@ -312,28 +456,41 @@ func (_m *ExecutionContext) GetExecutionConfig() v1alpha1.ExecutionConfig { return r0 } -type ExecutionContext_GetExecutionID struct { +// ExecutionContext_GetExecutionConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetExecutionConfig' +type ExecutionContext_GetExecutionConfig_Call struct { *mock.Call } -func (_m ExecutionContext_GetExecutionID) Return(_a0 v1alpha1.WorkflowExecutionIdentifier) *ExecutionContext_GetExecutionID { - return &ExecutionContext_GetExecutionID{Call: _m.Call.Return(_a0)} +// GetExecutionConfig is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetExecutionConfig() *ExecutionContext_GetExecutionConfig_Call { + return &ExecutionContext_GetExecutionConfig_Call{Call: _e.mock.On("GetExecutionConfig")} +} + +func (_c *ExecutionContext_GetExecutionConfig_Call) Run(run func()) *ExecutionContext_GetExecutionConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetExecutionID() *ExecutionContext_GetExecutionID { - c_call := _m.On("GetExecutionID") - return &ExecutionContext_GetExecutionID{Call: c_call} +func (_c *ExecutionContext_GetExecutionConfig_Call) Return(_a0 v1alpha1.ExecutionConfig) *ExecutionContext_GetExecutionConfig_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetExecutionIDMatch(matchers ...interface{}) *ExecutionContext_GetExecutionID { - c_call := _m.On("GetExecutionID", matchers...) - return &ExecutionContext_GetExecutionID{Call: c_call} +func (_c *ExecutionContext_GetExecutionConfig_Call) RunAndReturn(run func() v1alpha1.ExecutionConfig) *ExecutionContext_GetExecutionConfig_Call { + _c.Call.Return(run) + return _c } // GetExecutionID provides a mock function with given fields: func (_m *ExecutionContext) GetExecutionID() v1alpha1.WorkflowExecutionIdentifier { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetExecutionID") + } + var r0 v1alpha1.WorkflowExecutionIdentifier if rf, ok := ret.Get(0).(func() v1alpha1.WorkflowExecutionIdentifier); ok { r0 = rf() @@ -344,28 +501,41 @@ func (_m *ExecutionContext) GetExecutionID() v1alpha1.WorkflowExecutionIdentifie return r0 } -type ExecutionContext_GetID struct { +// ExecutionContext_GetExecutionID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetExecutionID' +type ExecutionContext_GetExecutionID_Call struct { *mock.Call } -func (_m ExecutionContext_GetID) Return(_a0 string) *ExecutionContext_GetID { - return &ExecutionContext_GetID{Call: _m.Call.Return(_a0)} +// GetExecutionID is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetExecutionID() *ExecutionContext_GetExecutionID_Call { + return &ExecutionContext_GetExecutionID_Call{Call: _e.mock.On("GetExecutionID")} } -func (_m *ExecutionContext) OnGetID() *ExecutionContext_GetID { - c_call := _m.On("GetID") - return &ExecutionContext_GetID{Call: c_call} +func (_c *ExecutionContext_GetExecutionID_Call) Run(run func()) *ExecutionContext_GetExecutionID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetIDMatch(matchers ...interface{}) *ExecutionContext_GetID { - c_call := _m.On("GetID", matchers...) - return &ExecutionContext_GetID{Call: c_call} +func (_c *ExecutionContext_GetExecutionID_Call) Return(_a0 v1alpha1.WorkflowExecutionIdentifier) *ExecutionContext_GetExecutionID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetExecutionID_Call) RunAndReturn(run func() v1alpha1.WorkflowExecutionIdentifier) *ExecutionContext_GetExecutionID_Call { + _c.Call.Return(run) + return _c } // GetID provides a mock function with given fields: func (_m *ExecutionContext) GetID() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetID") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -376,28 +546,41 @@ func (_m *ExecutionContext) GetID() string { return r0 } -type ExecutionContext_GetK8sWorkflowID struct { +// ExecutionContext_GetID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetID' +type ExecutionContext_GetID_Call struct { *mock.Call } -func (_m ExecutionContext_GetK8sWorkflowID) Return(_a0 types.NamespacedName) *ExecutionContext_GetK8sWorkflowID { - return &ExecutionContext_GetK8sWorkflowID{Call: _m.Call.Return(_a0)} +// GetID is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetID() *ExecutionContext_GetID_Call { + return &ExecutionContext_GetID_Call{Call: _e.mock.On("GetID")} +} + +func (_c *ExecutionContext_GetID_Call) Run(run func()) *ExecutionContext_GetID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetK8sWorkflowID() *ExecutionContext_GetK8sWorkflowID { - c_call := _m.On("GetK8sWorkflowID") - return &ExecutionContext_GetK8sWorkflowID{Call: c_call} +func (_c *ExecutionContext_GetID_Call) Return(_a0 string) *ExecutionContext_GetID_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetK8sWorkflowIDMatch(matchers ...interface{}) *ExecutionContext_GetK8sWorkflowID { - c_call := _m.On("GetK8sWorkflowID", matchers...) - return &ExecutionContext_GetK8sWorkflowID{Call: c_call} +func (_c *ExecutionContext_GetID_Call) RunAndReturn(run func() string) *ExecutionContext_GetID_Call { + _c.Call.Return(run) + return _c } // GetK8sWorkflowID provides a mock function with given fields: func (_m *ExecutionContext) GetK8sWorkflowID() types.NamespacedName { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetK8sWorkflowID") + } + var r0 types.NamespacedName if rf, ok := ret.Get(0).(func() types.NamespacedName); ok { r0 = rf() @@ -408,28 +591,41 @@ func (_m *ExecutionContext) GetK8sWorkflowID() types.NamespacedName { return r0 } -type ExecutionContext_GetLabels struct { +// ExecutionContext_GetK8sWorkflowID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetK8sWorkflowID' +type ExecutionContext_GetK8sWorkflowID_Call struct { *mock.Call } -func (_m ExecutionContext_GetLabels) Return(_a0 map[string]string) *ExecutionContext_GetLabels { - return &ExecutionContext_GetLabels{Call: _m.Call.Return(_a0)} +// GetK8sWorkflowID is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetK8sWorkflowID() *ExecutionContext_GetK8sWorkflowID_Call { + return &ExecutionContext_GetK8sWorkflowID_Call{Call: _e.mock.On("GetK8sWorkflowID")} +} + +func (_c *ExecutionContext_GetK8sWorkflowID_Call) Run(run func()) *ExecutionContext_GetK8sWorkflowID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetLabels() *ExecutionContext_GetLabels { - c_call := _m.On("GetLabels") - return &ExecutionContext_GetLabels{Call: c_call} +func (_c *ExecutionContext_GetK8sWorkflowID_Call) Return(_a0 types.NamespacedName) *ExecutionContext_GetK8sWorkflowID_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetLabelsMatch(matchers ...interface{}) *ExecutionContext_GetLabels { - c_call := _m.On("GetLabels", matchers...) - return &ExecutionContext_GetLabels{Call: c_call} +func (_c *ExecutionContext_GetK8sWorkflowID_Call) RunAndReturn(run func() types.NamespacedName) *ExecutionContext_GetK8sWorkflowID_Call { + _c.Call.Return(run) + return _c } // GetLabels provides a mock function with given fields: func (_m *ExecutionContext) GetLabels() map[string]string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLabels") + } + var r0 map[string]string if rf, ok := ret.Get(0).(func() map[string]string); ok { r0 = rf() @@ -442,28 +638,41 @@ func (_m *ExecutionContext) GetLabels() map[string]string { return r0 } -type ExecutionContext_GetName struct { +// ExecutionContext_GetLabels_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLabels' +type ExecutionContext_GetLabels_Call struct { *mock.Call } -func (_m ExecutionContext_GetName) Return(_a0 string) *ExecutionContext_GetName { - return &ExecutionContext_GetName{Call: _m.Call.Return(_a0)} +// GetLabels is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetLabels() *ExecutionContext_GetLabels_Call { + return &ExecutionContext_GetLabels_Call{Call: _e.mock.On("GetLabels")} } -func (_m *ExecutionContext) OnGetName() *ExecutionContext_GetName { - c_call := _m.On("GetName") - return &ExecutionContext_GetName{Call: c_call} +func (_c *ExecutionContext_GetLabels_Call) Run(run func()) *ExecutionContext_GetLabels_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetNameMatch(matchers ...interface{}) *ExecutionContext_GetName { - c_call := _m.On("GetName", matchers...) - return &ExecutionContext_GetName{Call: c_call} +func (_c *ExecutionContext_GetLabels_Call) Return(_a0 map[string]string) *ExecutionContext_GetLabels_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetLabels_Call) RunAndReturn(run func() map[string]string) *ExecutionContext_GetLabels_Call { + _c.Call.Return(run) + return _c } // GetName provides a mock function with given fields: func (_m *ExecutionContext) GetName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -474,28 +683,41 @@ func (_m *ExecutionContext) GetName() string { return r0 } -type ExecutionContext_GetNamespace struct { +// ExecutionContext_GetName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetName' +type ExecutionContext_GetName_Call struct { *mock.Call } -func (_m ExecutionContext_GetNamespace) Return(_a0 string) *ExecutionContext_GetNamespace { - return &ExecutionContext_GetNamespace{Call: _m.Call.Return(_a0)} +// GetName is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetName() *ExecutionContext_GetName_Call { + return &ExecutionContext_GetName_Call{Call: _e.mock.On("GetName")} } -func (_m *ExecutionContext) OnGetNamespace() *ExecutionContext_GetNamespace { - c_call := _m.On("GetNamespace") - return &ExecutionContext_GetNamespace{Call: c_call} +func (_c *ExecutionContext_GetName_Call) Run(run func()) *ExecutionContext_GetName_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetNamespaceMatch(matchers ...interface{}) *ExecutionContext_GetNamespace { - c_call := _m.On("GetNamespace", matchers...) - return &ExecutionContext_GetNamespace{Call: c_call} +func (_c *ExecutionContext_GetName_Call) Return(_a0 string) *ExecutionContext_GetName_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetName_Call) RunAndReturn(run func() string) *ExecutionContext_GetName_Call { + _c.Call.Return(run) + return _c } // GetNamespace provides a mock function with given fields: func (_m *ExecutionContext) GetNamespace() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNamespace") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -506,28 +728,41 @@ func (_m *ExecutionContext) GetNamespace() string { return r0 } -type ExecutionContext_GetOnFailurePolicy struct { +// ExecutionContext_GetNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNamespace' +type ExecutionContext_GetNamespace_Call struct { *mock.Call } -func (_m ExecutionContext_GetOnFailurePolicy) Return(_a0 v1alpha1.WorkflowOnFailurePolicy) *ExecutionContext_GetOnFailurePolicy { - return &ExecutionContext_GetOnFailurePolicy{Call: _m.Call.Return(_a0)} +// GetNamespace is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetNamespace() *ExecutionContext_GetNamespace_Call { + return &ExecutionContext_GetNamespace_Call{Call: _e.mock.On("GetNamespace")} +} + +func (_c *ExecutionContext_GetNamespace_Call) Run(run func()) *ExecutionContext_GetNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetOnFailurePolicy() *ExecutionContext_GetOnFailurePolicy { - c_call := _m.On("GetOnFailurePolicy") - return &ExecutionContext_GetOnFailurePolicy{Call: c_call} +func (_c *ExecutionContext_GetNamespace_Call) Return(_a0 string) *ExecutionContext_GetNamespace_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetOnFailurePolicyMatch(matchers ...interface{}) *ExecutionContext_GetOnFailurePolicy { - c_call := _m.On("GetOnFailurePolicy", matchers...) - return &ExecutionContext_GetOnFailurePolicy{Call: c_call} +func (_c *ExecutionContext_GetNamespace_Call) RunAndReturn(run func() string) *ExecutionContext_GetNamespace_Call { + _c.Call.Return(run) + return _c } // GetOnFailurePolicy provides a mock function with given fields: func (_m *ExecutionContext) GetOnFailurePolicy() v1alpha1.WorkflowOnFailurePolicy { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetOnFailurePolicy") + } + var r0 v1alpha1.WorkflowOnFailurePolicy if rf, ok := ret.Get(0).(func() v1alpha1.WorkflowOnFailurePolicy); ok { r0 = rf() @@ -538,28 +773,41 @@ func (_m *ExecutionContext) GetOnFailurePolicy() v1alpha1.WorkflowOnFailurePolic return r0 } -type ExecutionContext_GetOwnerReference struct { +// ExecutionContext_GetOnFailurePolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOnFailurePolicy' +type ExecutionContext_GetOnFailurePolicy_Call struct { *mock.Call } -func (_m ExecutionContext_GetOwnerReference) Return(_a0 v1.OwnerReference) *ExecutionContext_GetOwnerReference { - return &ExecutionContext_GetOwnerReference{Call: _m.Call.Return(_a0)} +// GetOnFailurePolicy is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetOnFailurePolicy() *ExecutionContext_GetOnFailurePolicy_Call { + return &ExecutionContext_GetOnFailurePolicy_Call{Call: _e.mock.On("GetOnFailurePolicy")} +} + +func (_c *ExecutionContext_GetOnFailurePolicy_Call) Run(run func()) *ExecutionContext_GetOnFailurePolicy_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetOwnerReference() *ExecutionContext_GetOwnerReference { - c_call := _m.On("GetOwnerReference") - return &ExecutionContext_GetOwnerReference{Call: c_call} +func (_c *ExecutionContext_GetOnFailurePolicy_Call) Return(_a0 v1alpha1.WorkflowOnFailurePolicy) *ExecutionContext_GetOnFailurePolicy_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetOwnerReferenceMatch(matchers ...interface{}) *ExecutionContext_GetOwnerReference { - c_call := _m.On("GetOwnerReference", matchers...) - return &ExecutionContext_GetOwnerReference{Call: c_call} +func (_c *ExecutionContext_GetOnFailurePolicy_Call) RunAndReturn(run func() v1alpha1.WorkflowOnFailurePolicy) *ExecutionContext_GetOnFailurePolicy_Call { + _c.Call.Return(run) + return _c } // GetOwnerReference provides a mock function with given fields: func (_m *ExecutionContext) GetOwnerReference() v1.OwnerReference { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetOwnerReference") + } + var r0 v1.OwnerReference if rf, ok := ret.Get(0).(func() v1.OwnerReference); ok { r0 = rf() @@ -570,28 +818,41 @@ func (_m *ExecutionContext) GetOwnerReference() v1.OwnerReference { return r0 } -type ExecutionContext_GetParentInfo struct { +// ExecutionContext_GetOwnerReference_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOwnerReference' +type ExecutionContext_GetOwnerReference_Call struct { *mock.Call } -func (_m ExecutionContext_GetParentInfo) Return(_a0 executors.ImmutableParentInfo) *ExecutionContext_GetParentInfo { - return &ExecutionContext_GetParentInfo{Call: _m.Call.Return(_a0)} +// GetOwnerReference is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetOwnerReference() *ExecutionContext_GetOwnerReference_Call { + return &ExecutionContext_GetOwnerReference_Call{Call: _e.mock.On("GetOwnerReference")} } -func (_m *ExecutionContext) OnGetParentInfo() *ExecutionContext_GetParentInfo { - c_call := _m.On("GetParentInfo") - return &ExecutionContext_GetParentInfo{Call: c_call} +func (_c *ExecutionContext_GetOwnerReference_Call) Run(run func()) *ExecutionContext_GetOwnerReference_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetParentInfoMatch(matchers ...interface{}) *ExecutionContext_GetParentInfo { - c_call := _m.On("GetParentInfo", matchers...) - return &ExecutionContext_GetParentInfo{Call: c_call} +func (_c *ExecutionContext_GetOwnerReference_Call) Return(_a0 v1.OwnerReference) *ExecutionContext_GetOwnerReference_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetOwnerReference_Call) RunAndReturn(run func() v1.OwnerReference) *ExecutionContext_GetOwnerReference_Call { + _c.Call.Return(run) + return _c } // GetParentInfo provides a mock function with given fields: func (_m *ExecutionContext) GetParentInfo() executors.ImmutableParentInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetParentInfo") + } + var r0 executors.ImmutableParentInfo if rf, ok := ret.Get(0).(func() executors.ImmutableParentInfo); ok { r0 = rf() @@ -604,28 +865,41 @@ func (_m *ExecutionContext) GetParentInfo() executors.ImmutableParentInfo { return r0 } -type ExecutionContext_GetRawOutputDataConfig struct { +// ExecutionContext_GetParentInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetParentInfo' +type ExecutionContext_GetParentInfo_Call struct { *mock.Call } -func (_m ExecutionContext_GetRawOutputDataConfig) Return(_a0 v1alpha1.RawOutputDataConfig) *ExecutionContext_GetRawOutputDataConfig { - return &ExecutionContext_GetRawOutputDataConfig{Call: _m.Call.Return(_a0)} +// GetParentInfo is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetParentInfo() *ExecutionContext_GetParentInfo_Call { + return &ExecutionContext_GetParentInfo_Call{Call: _e.mock.On("GetParentInfo")} +} + +func (_c *ExecutionContext_GetParentInfo_Call) Run(run func()) *ExecutionContext_GetParentInfo_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetRawOutputDataConfig() *ExecutionContext_GetRawOutputDataConfig { - c_call := _m.On("GetRawOutputDataConfig") - return &ExecutionContext_GetRawOutputDataConfig{Call: c_call} +func (_c *ExecutionContext_GetParentInfo_Call) Return(_a0 executors.ImmutableParentInfo) *ExecutionContext_GetParentInfo_Call { + _c.Call.Return(_a0) + return _c } -func (_m *ExecutionContext) OnGetRawOutputDataConfigMatch(matchers ...interface{}) *ExecutionContext_GetRawOutputDataConfig { - c_call := _m.On("GetRawOutputDataConfig", matchers...) - return &ExecutionContext_GetRawOutputDataConfig{Call: c_call} +func (_c *ExecutionContext_GetParentInfo_Call) RunAndReturn(run func() executors.ImmutableParentInfo) *ExecutionContext_GetParentInfo_Call { + _c.Call.Return(run) + return _c } // GetRawOutputDataConfig provides a mock function with given fields: func (_m *ExecutionContext) GetRawOutputDataConfig() v1alpha1.RawOutputDataConfig { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRawOutputDataConfig") + } + var r0 v1alpha1.RawOutputDataConfig if rf, ok := ret.Get(0).(func() v1alpha1.RawOutputDataConfig); ok { r0 = rf() @@ -636,28 +910,41 @@ func (_m *ExecutionContext) GetRawOutputDataConfig() v1alpha1.RawOutputDataConfi return r0 } -type ExecutionContext_GetSecurityContext struct { +// ExecutionContext_GetRawOutputDataConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRawOutputDataConfig' +type ExecutionContext_GetRawOutputDataConfig_Call struct { *mock.Call } -func (_m ExecutionContext_GetSecurityContext) Return(_a0 core.SecurityContext) *ExecutionContext_GetSecurityContext { - return &ExecutionContext_GetSecurityContext{Call: _m.Call.Return(_a0)} +// GetRawOutputDataConfig is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetRawOutputDataConfig() *ExecutionContext_GetRawOutputDataConfig_Call { + return &ExecutionContext_GetRawOutputDataConfig_Call{Call: _e.mock.On("GetRawOutputDataConfig")} } -func (_m *ExecutionContext) OnGetSecurityContext() *ExecutionContext_GetSecurityContext { - c_call := _m.On("GetSecurityContext") - return &ExecutionContext_GetSecurityContext{Call: c_call} +func (_c *ExecutionContext_GetRawOutputDataConfig_Call) Run(run func()) *ExecutionContext_GetRawOutputDataConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetSecurityContextMatch(matchers ...interface{}) *ExecutionContext_GetSecurityContext { - c_call := _m.On("GetSecurityContext", matchers...) - return &ExecutionContext_GetSecurityContext{Call: c_call} +func (_c *ExecutionContext_GetRawOutputDataConfig_Call) Return(_a0 v1alpha1.RawOutputDataConfig) *ExecutionContext_GetRawOutputDataConfig_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetRawOutputDataConfig_Call) RunAndReturn(run func() v1alpha1.RawOutputDataConfig) *ExecutionContext_GetRawOutputDataConfig_Call { + _c.Call.Return(run) + return _c } // GetSecurityContext provides a mock function with given fields: func (_m *ExecutionContext) GetSecurityContext() core.SecurityContext { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSecurityContext") + } + var r0 core.SecurityContext if rf, ok := ret.Get(0).(func() core.SecurityContext); ok { r0 = rf() @@ -668,28 +955,41 @@ func (_m *ExecutionContext) GetSecurityContext() core.SecurityContext { return r0 } -type ExecutionContext_GetServiceAccountName struct { +// ExecutionContext_GetSecurityContext_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSecurityContext' +type ExecutionContext_GetSecurityContext_Call struct { *mock.Call } -func (_m ExecutionContext_GetServiceAccountName) Return(_a0 string) *ExecutionContext_GetServiceAccountName { - return &ExecutionContext_GetServiceAccountName{Call: _m.Call.Return(_a0)} +// GetSecurityContext is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetSecurityContext() *ExecutionContext_GetSecurityContext_Call { + return &ExecutionContext_GetSecurityContext_Call{Call: _e.mock.On("GetSecurityContext")} } -func (_m *ExecutionContext) OnGetServiceAccountName() *ExecutionContext_GetServiceAccountName { - c_call := _m.On("GetServiceAccountName") - return &ExecutionContext_GetServiceAccountName{Call: c_call} +func (_c *ExecutionContext_GetSecurityContext_Call) Run(run func()) *ExecutionContext_GetSecurityContext_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetServiceAccountNameMatch(matchers ...interface{}) *ExecutionContext_GetServiceAccountName { - c_call := _m.On("GetServiceAccountName", matchers...) - return &ExecutionContext_GetServiceAccountName{Call: c_call} +func (_c *ExecutionContext_GetSecurityContext_Call) Return(_a0 core.SecurityContext) *ExecutionContext_GetSecurityContext_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetSecurityContext_Call) RunAndReturn(run func() core.SecurityContext) *ExecutionContext_GetSecurityContext_Call { + _c.Call.Return(run) + return _c } // GetServiceAccountName provides a mock function with given fields: func (_m *ExecutionContext) GetServiceAccountName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetServiceAccountName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -700,29 +1000,46 @@ func (_m *ExecutionContext) GetServiceAccountName() string { return r0 } -type ExecutionContext_GetTask struct { +// ExecutionContext_GetServiceAccountName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetServiceAccountName' +type ExecutionContext_GetServiceAccountName_Call struct { *mock.Call } -func (_m ExecutionContext_GetTask) Return(_a0 v1alpha1.ExecutableTask, _a1 error) *ExecutionContext_GetTask { - return &ExecutionContext_GetTask{Call: _m.Call.Return(_a0, _a1)} +// GetServiceAccountName is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) GetServiceAccountName() *ExecutionContext_GetServiceAccountName_Call { + return &ExecutionContext_GetServiceAccountName_Call{Call: _e.mock.On("GetServiceAccountName")} } -func (_m *ExecutionContext) OnGetTask(id string) *ExecutionContext_GetTask { - c_call := _m.On("GetTask", id) - return &ExecutionContext_GetTask{Call: c_call} +func (_c *ExecutionContext_GetServiceAccountName_Call) Run(run func()) *ExecutionContext_GetServiceAccountName_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnGetTaskMatch(matchers ...interface{}) *ExecutionContext_GetTask { - c_call := _m.On("GetTask", matchers...) - return &ExecutionContext_GetTask{Call: c_call} +func (_c *ExecutionContext_GetServiceAccountName_Call) Return(_a0 string) *ExecutionContext_GetServiceAccountName_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_GetServiceAccountName_Call) RunAndReturn(run func() string) *ExecutionContext_GetServiceAccountName_Call { + _c.Call.Return(run) + return _c } // GetTask provides a mock function with given fields: id func (_m *ExecutionContext) GetTask(id string) (v1alpha1.ExecutableTask, error) { ret := _m.Called(id) + if len(ret) == 0 { + panic("no return value specified for GetTask") + } + var r0 v1alpha1.ExecutableTask + var r1 error + if rf, ok := ret.Get(0).(func(string) (v1alpha1.ExecutableTask, error)); ok { + return rf(id) + } if rf, ok := ret.Get(0).(func(string) v1alpha1.ExecutableTask); ok { r0 = rf(id) } else { @@ -731,7 +1048,6 @@ func (_m *ExecutionContext) GetTask(id string) (v1alpha1.ExecutableTask, error) } } - var r1 error if rf, ok := ret.Get(1).(func(string) error); ok { r1 = rf(id) } else { @@ -741,28 +1057,42 @@ func (_m *ExecutionContext) GetTask(id string) (v1alpha1.ExecutableTask, error) return r0, r1 } -type ExecutionContext_IncrementNodeExecutionCount struct { +// ExecutionContext_GetTask_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTask' +type ExecutionContext_GetTask_Call struct { *mock.Call } -func (_m ExecutionContext_IncrementNodeExecutionCount) Return(_a0 uint32) *ExecutionContext_IncrementNodeExecutionCount { - return &ExecutionContext_IncrementNodeExecutionCount{Call: _m.Call.Return(_a0)} +// GetTask is a helper method to define mock.On call +// - id string +func (_e *ExecutionContext_Expecter) GetTask(id interface{}) *ExecutionContext_GetTask_Call { + return &ExecutionContext_GetTask_Call{Call: _e.mock.On("GetTask", id)} +} + +func (_c *ExecutionContext_GetTask_Call) Run(run func(id string)) *ExecutionContext_GetTask_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c } -func (_m *ExecutionContext) OnIncrementNodeExecutionCount() *ExecutionContext_IncrementNodeExecutionCount { - c_call := _m.On("IncrementNodeExecutionCount") - return &ExecutionContext_IncrementNodeExecutionCount{Call: c_call} +func (_c *ExecutionContext_GetTask_Call) Return(_a0 v1alpha1.ExecutableTask, _a1 error) *ExecutionContext_GetTask_Call { + _c.Call.Return(_a0, _a1) + return _c } -func (_m *ExecutionContext) OnIncrementNodeExecutionCountMatch(matchers ...interface{}) *ExecutionContext_IncrementNodeExecutionCount { - c_call := _m.On("IncrementNodeExecutionCount", matchers...) - return &ExecutionContext_IncrementNodeExecutionCount{Call: c_call} +func (_c *ExecutionContext_GetTask_Call) RunAndReturn(run func(string) (v1alpha1.ExecutableTask, error)) *ExecutionContext_GetTask_Call { + _c.Call.Return(run) + return _c } // IncrementNodeExecutionCount provides a mock function with given fields: func (_m *ExecutionContext) IncrementNodeExecutionCount() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IncrementNodeExecutionCount") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -773,28 +1103,41 @@ func (_m *ExecutionContext) IncrementNodeExecutionCount() uint32 { return r0 } -type ExecutionContext_IncrementParallelism struct { +// ExecutionContext_IncrementNodeExecutionCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IncrementNodeExecutionCount' +type ExecutionContext_IncrementNodeExecutionCount_Call struct { *mock.Call } -func (_m ExecutionContext_IncrementParallelism) Return(_a0 uint32) *ExecutionContext_IncrementParallelism { - return &ExecutionContext_IncrementParallelism{Call: _m.Call.Return(_a0)} +// IncrementNodeExecutionCount is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) IncrementNodeExecutionCount() *ExecutionContext_IncrementNodeExecutionCount_Call { + return &ExecutionContext_IncrementNodeExecutionCount_Call{Call: _e.mock.On("IncrementNodeExecutionCount")} } -func (_m *ExecutionContext) OnIncrementParallelism() *ExecutionContext_IncrementParallelism { - c_call := _m.On("IncrementParallelism") - return &ExecutionContext_IncrementParallelism{Call: c_call} +func (_c *ExecutionContext_IncrementNodeExecutionCount_Call) Run(run func()) *ExecutionContext_IncrementNodeExecutionCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnIncrementParallelismMatch(matchers ...interface{}) *ExecutionContext_IncrementParallelism { - c_call := _m.On("IncrementParallelism", matchers...) - return &ExecutionContext_IncrementParallelism{Call: c_call} +func (_c *ExecutionContext_IncrementNodeExecutionCount_Call) Return(_a0 uint32) *ExecutionContext_IncrementNodeExecutionCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_IncrementNodeExecutionCount_Call) RunAndReturn(run func() uint32) *ExecutionContext_IncrementNodeExecutionCount_Call { + _c.Call.Return(run) + return _c } // IncrementParallelism provides a mock function with given fields: func (_m *ExecutionContext) IncrementParallelism() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IncrementParallelism") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -805,28 +1148,41 @@ func (_m *ExecutionContext) IncrementParallelism() uint32 { return r0 } -type ExecutionContext_IncrementTaskExecutionCount struct { +// ExecutionContext_IncrementParallelism_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IncrementParallelism' +type ExecutionContext_IncrementParallelism_Call struct { *mock.Call } -func (_m ExecutionContext_IncrementTaskExecutionCount) Return(_a0 uint32) *ExecutionContext_IncrementTaskExecutionCount { - return &ExecutionContext_IncrementTaskExecutionCount{Call: _m.Call.Return(_a0)} +// IncrementParallelism is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) IncrementParallelism() *ExecutionContext_IncrementParallelism_Call { + return &ExecutionContext_IncrementParallelism_Call{Call: _e.mock.On("IncrementParallelism")} } -func (_m *ExecutionContext) OnIncrementTaskExecutionCount() *ExecutionContext_IncrementTaskExecutionCount { - c_call := _m.On("IncrementTaskExecutionCount") - return &ExecutionContext_IncrementTaskExecutionCount{Call: c_call} +func (_c *ExecutionContext_IncrementParallelism_Call) Run(run func()) *ExecutionContext_IncrementParallelism_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnIncrementTaskExecutionCountMatch(matchers ...interface{}) *ExecutionContext_IncrementTaskExecutionCount { - c_call := _m.On("IncrementTaskExecutionCount", matchers...) - return &ExecutionContext_IncrementTaskExecutionCount{Call: c_call} +func (_c *ExecutionContext_IncrementParallelism_Call) Return(_a0 uint32) *ExecutionContext_IncrementParallelism_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_IncrementParallelism_Call) RunAndReturn(run func() uint32) *ExecutionContext_IncrementParallelism_Call { + _c.Call.Return(run) + return _c } // IncrementTaskExecutionCount provides a mock function with given fields: func (_m *ExecutionContext) IncrementTaskExecutionCount() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IncrementTaskExecutionCount") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -837,28 +1193,41 @@ func (_m *ExecutionContext) IncrementTaskExecutionCount() uint32 { return r0 } -type ExecutionContext_IsInterruptible struct { +// ExecutionContext_IncrementTaskExecutionCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IncrementTaskExecutionCount' +type ExecutionContext_IncrementTaskExecutionCount_Call struct { *mock.Call } -func (_m ExecutionContext_IsInterruptible) Return(_a0 bool) *ExecutionContext_IsInterruptible { - return &ExecutionContext_IsInterruptible{Call: _m.Call.Return(_a0)} +// IncrementTaskExecutionCount is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) IncrementTaskExecutionCount() *ExecutionContext_IncrementTaskExecutionCount_Call { + return &ExecutionContext_IncrementTaskExecutionCount_Call{Call: _e.mock.On("IncrementTaskExecutionCount")} } -func (_m *ExecutionContext) OnIsInterruptible() *ExecutionContext_IsInterruptible { - c_call := _m.On("IsInterruptible") - return &ExecutionContext_IsInterruptible{Call: c_call} +func (_c *ExecutionContext_IncrementTaskExecutionCount_Call) Run(run func()) *ExecutionContext_IncrementTaskExecutionCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c } -func (_m *ExecutionContext) OnIsInterruptibleMatch(matchers ...interface{}) *ExecutionContext_IsInterruptible { - c_call := _m.On("IsInterruptible", matchers...) - return &ExecutionContext_IsInterruptible{Call: c_call} +func (_c *ExecutionContext_IncrementTaskExecutionCount_Call) Return(_a0 uint32) *ExecutionContext_IncrementTaskExecutionCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_IncrementTaskExecutionCount_Call) RunAndReturn(run func() uint32) *ExecutionContext_IncrementTaskExecutionCount_Call { + _c.Call.Return(run) + return _c } // IsInterruptible provides a mock function with given fields: func (_m *ExecutionContext) IsInterruptible() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInterruptible") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -868,3 +1237,44 @@ func (_m *ExecutionContext) IsInterruptible() bool { return r0 } + +// ExecutionContext_IsInterruptible_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInterruptible' +type ExecutionContext_IsInterruptible_Call struct { + *mock.Call +} + +// IsInterruptible is a helper method to define mock.On call +func (_e *ExecutionContext_Expecter) IsInterruptible() *ExecutionContext_IsInterruptible_Call { + return &ExecutionContext_IsInterruptible_Call{Call: _e.mock.On("IsInterruptible")} +} + +func (_c *ExecutionContext_IsInterruptible_Call) Run(run func()) *ExecutionContext_IsInterruptible_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ExecutionContext_IsInterruptible_Call) Return(_a0 bool) *ExecutionContext_IsInterruptible_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ExecutionContext_IsInterruptible_Call) RunAndReturn(run func() bool) *ExecutionContext_IsInterruptible_Call { + _c.Call.Return(run) + return _c +} + +// NewExecutionContext creates a new instance of ExecutionContext. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewExecutionContext(t interface { + mock.TestingT + Cleanup(func()) +}) *ExecutionContext { + mock := &ExecutionContext{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/flytepropeller/pkg/controller/nodes/array/handler_test.go b/flytepropeller/pkg/controller/nodes/array/handler_test.go index ba0815fee6..e906318975 100644 --- a/flytepropeller/pkg/controller/nodes/array/handler_test.go +++ b/flytepropeller/pkg/controller/nodes/array/handler_test.go @@ -91,11 +91,11 @@ func createNodeExecutionContext(dataStore *storage.DataStore, eventRecorder inte // ExecutionContext executionContext := &execmocks.ExecutionContext{} - executionContext.OnGetEventVersion().Return(1) - executionContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{ + executionContext.EXPECT().GetEventVersion().Return(1) + executionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{ MaxParallelism: maxParallelism, }) - executionContext.OnGetExecutionID().Return( + executionContext.EXPECT().GetExecutionID().Return( v1alpha1.ExecutionID{ WorkflowExecutionIdentifier: &idlcore.WorkflowExecutionIdentifier{ Project: "project", @@ -103,15 +103,15 @@ func createNodeExecutionContext(dataStore *storage.DataStore, eventRecorder inte Name: "name", }, }) - executionContext.OnGetLabels().Return(nil) - executionContext.OnGetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{}) - executionContext.OnIsInterruptible().Return(false) - executionContext.OnGetParentInfo().Return(nil) + executionContext.EXPECT().GetLabels().Return(nil) + executionContext.EXPECT().GetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{}) + executionContext.EXPECT().IsInterruptible().Return(false) + executionContext.EXPECT().GetParentInfo().Return(nil) outputVariableMap := make(map[string]*idlcore.Variable) for _, outputVariable := range outputVariables { outputVariableMap[outputVariable] = &idlcore.Variable{} } - executionContext.OnGetTaskMatch(taskRef).Return( + executionContext.EXPECT().GetTask(taskRef).Return( &v1alpha1.TaskSpec{ TaskTemplate: &idlcore.TaskTemplate{ Interface: &idlcore.TypedInterface{ @@ -123,12 +123,12 @@ func createNodeExecutionContext(dataStore *storage.DataStore, eventRecorder inte }, nil, ) - executionContext.OnCurrentParallelism().Return(currentParallelism) + executionContext.EXPECT().CurrentParallelism().Return(currentParallelism) executionContext.On("IncrementParallelism").Run(func(args mock.Arguments) {}).Return(currentParallelism) - executionContext.OnIncrementNodeExecutionCount().Return(1) - executionContext.OnIncrementTaskExecutionCount().Return(1) - executionContext.OnCurrentNodeExecutionCount().Return(1) - executionContext.OnCurrentTaskExecutionCount().Return(1) + executionContext.EXPECT().IncrementNodeExecutionCount().Return(1) + executionContext.EXPECT().IncrementTaskExecutionCount().Return(1) + executionContext.EXPECT().CurrentNodeExecutionCount().Return(1) + executionContext.EXPECT().CurrentTaskExecutionCount().Return(1) nCtx.OnExecutionContext().Return(executionContext) // EventsRecorder diff --git a/flytepropeller/pkg/controller/nodes/branch/handler_test.go b/flytepropeller/pkg/controller/nodes/branch/handler_test.go index dfe0338fc1..b26dd004c4 100644 --- a/flytepropeller/pkg/controller/nodes/branch/handler_test.go +++ b/flytepropeller/pkg/controller/nodes/branch/handler_test.go @@ -181,7 +181,7 @@ func TestBranchHandler_RecurseDownstream(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetParentInfo().Return(parentInfo{}) + eCtx.EXPECT().GetParentInfo().Return(parentInfo{}) mockNodeLookup := &execMocks.NodeLookup{} if len(test.upstreamNodeID) > 0 { @@ -305,7 +305,7 @@ func TestBranchHandler_AbortNode(t *testing.T) { mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("err")) eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetParentInfo().Return(nil) + eCtx.EXPECT().GetParentInfo().Return(nil) nCtx, _ := createNodeContext(v1alpha1.BranchNodeError, nil, n, nil, nil, eCtx) branch := New(mockNodeExecutor, eventConfig, promutils.NewTestScope()) err := branch.Abort(ctx, nCtx, "") @@ -317,7 +317,7 @@ func TestBranchHandler_AbortNode(t *testing.T) { mockNodeLookup := &execMocks.NodeLookup{} mockNodeLookup.OnToNodeMatch(mock.Anything).Return(nil, nil) eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetParentInfo().Return(parentInfo{}) + eCtx.EXPECT().GetParentInfo().Return(parentInfo{}) nCtx, s := createNodeContext(v1alpha1.BranchNodeSuccess, &n1, n, nil, mockNodeLookup, eCtx) newParentInfo, _ := common.CreateParentInfo(parentInfo{}, nCtx.NodeID(), nCtx.CurrentAttempt()) expectedExecContext := executors.NewExecutionContextWithParentInfo(nCtx.ExecutionContext(), newParentInfo) @@ -378,7 +378,7 @@ func TestBranchHandler_HandleNode(t *testing.T) { n.OnGetBranchNode().Return(nil) n.OnGetID().Return("n1") eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetParentInfo().Return(nil) + eCtx.EXPECT().GetParentInfo().Return(nil) nCtx, _ := createNodeContext(v1alpha1.BranchNodeSuccess, &childNodeID, n, inputs, nil, eCtx) s, err := branch.Handle(ctx, nCtx) diff --git a/flytepropeller/pkg/controller/nodes/cache_test.go b/flytepropeller/pkg/controller/nodes/cache_test.go index 1f2c615af2..05d6ecfeaa 100644 --- a/flytepropeller/pkg/controller/nodes/cache_test.go +++ b/flytepropeller/pkg/controller/nodes/cache_test.go @@ -61,8 +61,8 @@ func setupCacheableNodeExecutionContext(dataStore *storage.DataStore, taskTempla mockParentInfo.OnGetUniqueIDMatch().Return(uniqueID) mockExecutionContext := &executorsmocks.ExecutionContext{} - mockExecutionContext.OnGetParentInfoMatch(mock.Anything).Return(mockParentInfo) - mockExecutionContext.OnGetExecutionConfigMatch().Return(v1alpha1.ExecutionConfig{}) + mockExecutionContext.EXPECT().GetParentInfo().Return(mockParentInfo) + mockExecutionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) mockNodeExecutionMetadata := &interfacesmocks.NodeExecutionMetadata{} mockNodeExecutionMetadata.OnGetOwnerID().Return( @@ -75,6 +75,7 @@ func setupCacheableNodeExecutionContext(dataStore *storage.DataStore, taskTempla NodeId: nodeID, }, ) + mockNodeExecutionMetadata.OnGetConsoleURL().Return("") var taskReader interfaces.TaskReader if taskTemplate != nil { diff --git a/flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow_test.go b/flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow_test.go index 389ea0439b..526f41977a 100644 --- a/flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow_test.go +++ b/flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow_test.go @@ -193,8 +193,8 @@ func Test_dynamicNodeHandler_buildContextualDynamicWorkflow_withLaunchPlans(t *t immutableParentInfo := mocks4.ImmutableParentInfo{} immutableParentInfo.OnGetUniqueID().Return("c1") immutableParentInfo.OnCurrentAttempt().Return(uint32(2)) - execContext.OnGetParentInfo().Return(&immutableParentInfo) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) + execContext.EXPECT().GetParentInfo().Return(&immutableParentInfo) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) nCtx.OnExecutionContext().Return(execContext) dCtx, err := d.buildContextualDynamicWorkflow(ctx, nCtx) @@ -262,8 +262,8 @@ func Test_dynamicNodeHandler_buildContextualDynamicWorkflow_withLaunchPlans(t *t } execContext := &mocks4.ExecutionContext{} - execContext.OnGetParentInfo().Return(nil) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) + execContext.EXPECT().GetParentInfo().Return(nil) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) nCtx.OnExecutionContext().Return(execContext) dCtx, err := d.buildContextualDynamicWorkflow(ctx, nCtx) @@ -330,8 +330,8 @@ func Test_dynamicNodeHandler_buildContextualDynamicWorkflow_withLaunchPlans(t *t metrics: newMetrics(promutils.NewTestScope()), } execContext := &mocks4.ExecutionContext{} - execContext.OnGetParentInfo().Return(nil) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) + execContext.EXPECT().GetParentInfo().Return(nil) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) nCtx.OnExecutionContext().Return(execContext) _, err = d.buildContextualDynamicWorkflow(ctx, nCtx) @@ -417,8 +417,8 @@ func Test_dynamicNodeHandler_buildContextualDynamicWorkflow_withLaunchPlans(t *t immutableParentInfo := mocks4.ImmutableParentInfo{} immutableParentInfo.OnGetUniqueID().Return("c1") immutableParentInfo.OnCurrentAttempt().Return(uint32(2)) - execContext.OnGetParentInfo().Return(&immutableParentInfo) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) + execContext.EXPECT().GetParentInfo().Return(&immutableParentInfo) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) nCtx.OnExecutionContext().Return(execContext) dCtx, err := d.buildContextualDynamicWorkflow(ctx, nCtx) @@ -471,8 +471,8 @@ func Test_dynamicNodeHandler_buildContextualDynamicWorkflow_withLaunchPlans(t *t immutableParentInfo := mocks4.ImmutableParentInfo{} immutableParentInfo.OnGetUniqueID().Return("c1") immutableParentInfo.OnCurrentAttempt().Return(uint32(2)) - execContext.OnGetParentInfo().Return(&immutableParentInfo) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) + execContext.EXPECT().GetParentInfo().Return(&immutableParentInfo) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) nCtx.OnExecutionContext().Return(execContext) _, err := d.buildContextualDynamicWorkflow(ctx, nCtx) @@ -560,9 +560,9 @@ func Test_dynamicNodeHandler_buildContextualDynamicWorkflow_withLaunchPlans(t *t immutableParentInfo := mocks4.ImmutableParentInfo{} immutableParentInfo.OnGetUniqueID().Return("c1") immutableParentInfo.OnCurrentAttempt().Return(uint32(2)) - execContext.OnGetParentInfo().Return(&immutableParentInfo) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) - execContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{ + execContext.EXPECT().GetParentInfo().Return(&immutableParentInfo) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) + execContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{ RecoveryExecution: v1alpha1.WorkflowExecutionIdentifier{}, }) nCtx.OnExecutionContext().Return(execContext) diff --git a/flytepropeller/pkg/controller/nodes/dynamic/handler_test.go b/flytepropeller/pkg/controller/nodes/dynamic/handler_test.go index bab7b48f1b..16acd4b699 100644 --- a/flytepropeller/pkg/controller/nodes/dynamic/handler_test.go +++ b/flytepropeller/pkg/controller/nodes/dynamic/handler_test.go @@ -576,12 +576,12 @@ func Test_dynamicNodeHandler_Handle_SubTaskV1(t *testing.T) { assert.NoError(t, nCtx.DataStore().WriteProtobuf(context.TODO(), endF, storage.Options{}, &core.LiteralMap{})) } execContext := executorMocks.ExecutionContext{} - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) immutableParentInfo := executorMocks.ImmutableParentInfo{} immutableParentInfo.OnGetUniqueID().Return("c1") immutableParentInfo.OnCurrentAttempt().Return(uint32(2)) - execContext.OnGetParentInfo().Return(&immutableParentInfo) - execContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + execContext.EXPECT().GetParentInfo().Return(&immutableParentInfo) + execContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) nCtx.OnExecutionContext().Return(&execContext) d := New(h, n, mockLPLauncher, eventConfig, promutils.NewTestScope()) got, err := d.Handle(context.TODO(), nCtx) @@ -766,9 +766,9 @@ func Test_dynamicNodeHandler_Handle_SubTask(t *testing.T) { assert.NoError(t, nCtx.DataStore().WriteProtobuf(context.TODO(), endF, storage.Options{}, &core.LiteralMap{})) } execContext := executorMocks.ExecutionContext{} - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) - execContext.OnGetParentInfo().Return(nil) - execContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) + execContext.EXPECT().GetParentInfo().Return(nil) + execContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) nCtx.OnExecutionContext().Return(&execContext) d := New(h, n, mockLPLauncher, eventConfig, promutils.NewTestScope()) got, err := d.Handle(context.TODO(), nCtx) @@ -913,8 +913,8 @@ func TestDynamicNodeTaskNodeHandler_Finalize(t *testing.T) { nCtx.OnEnqueueOwnerFunc().Return(func() error { return nil }) nCtx.OnDataStore().Return(dataStore) execContext := executorMocks.ExecutionContext{} - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) - execContext.OnGetParentInfo().Return(nil) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) + execContext.EXPECT().GetParentInfo().Return(nil) nCtx.OnExecutionContext().Return(&execContext) endNodeStatus := &flyteMocks.ExecutableNodeStatus{} diff --git a/flytepropeller/pkg/controller/nodes/executor_test.go b/flytepropeller/pkg/controller/nodes/executor_test.go index 227f3e5f1b..194458d2b8 100644 --- a/flytepropeller/pkg/controller/nodes/executor_test.go +++ b/flytepropeller/pkg/controller/nodes/executor_test.go @@ -1299,18 +1299,20 @@ func TestNodeExecutor_RecursiveNodeHandler_BranchNode(t *testing.T) { tid := "tid" eCtx := &mocks4.ExecutionContext{} - eCtx.OnGetTask(tid).Return(tk, nil) - eCtx.OnIsInterruptible().Return(true) - eCtx.OnGetExecutionID().Return(v1alpha1.WorkflowExecutionIdentifier{WorkflowExecutionIdentifier: &core.WorkflowExecutionIdentifier{}}) - eCtx.OnGetLabels().Return(nil) - eCtx.OnGetEventVersion().Return(v1alpha1.EventVersion0) - eCtx.OnGetParentInfo().Return(nil) - eCtx.OnGetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{ + eCtx.EXPECT().GetTask(tid).Return(tk, nil) + + eCtx.EXPECT().IsInterruptible().Return(true) + eCtx.EXPECT().GetExecutionID().Return(v1alpha1.WorkflowExecutionIdentifier{WorkflowExecutionIdentifier: &core.WorkflowExecutionIdentifier{}}) + eCtx.EXPECT().GetLabels().Return(nil) + eCtx.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) + eCtx.EXPECT().GetParentInfo().Return(nil) + eCtx.EXPECT().GetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{ RawOutputDataConfig: &admin.RawOutputDataConfig{OutputLocationPrefix: ""}, }) - eCtx.OnIncrementParallelism().Return(0) - eCtx.OnCurrentParallelism().Return(0) - eCtx.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + eCtx.EXPECT().IncrementParallelism().Return(0) + eCtx.EXPECT().CurrentParallelism().Return(0) + eCtx.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + eCtx.EXPECT().GetConsoleURL().Return("") branchTakenNodeID := "branchTakenNode" branchTakenNode := &mocks.ExecutableNode{} @@ -1674,12 +1676,12 @@ func TestNodeExecutor_AbortHandler(t *testing.T) { dag.OnFromNode(id).Return(make([]string, 0), nil) execContext := mocks4.ExecutionContext{} - execContext.OnIsInterruptible().Return(false) + execContext.EXPECT().IsInterruptible().Return(false) r := v1alpha1.RawOutputDataConfig{} - execContext.OnGetRawOutputDataConfig().Return(r) - execContext.OnGetExecutionID().Return(v1alpha1.WorkflowExecutionIdentifier{}) - execContext.OnGetLabels().Return(nil) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) + execContext.EXPECT().GetRawOutputDataConfig().Return(r) + execContext.EXPECT().GetExecutionID().Return(v1alpha1.WorkflowExecutionIdentifier{}) + execContext.EXPECT().GetLabels().Return(nil) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) assert.NoError(t, nExec.AbortHandler(ctx, &execContext, &dag, nl, n, "aborting")) }) @@ -2040,12 +2042,12 @@ func TestRecover(t *testing.T) { } execContext := &mocks4.ExecutionContext{} - execContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{ + execContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{ RecoveryExecution: v1alpha1.WorkflowExecutionIdentifier{ WorkflowExecutionIdentifier: recoveryID, }, }) - execContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) + execContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) nm := &nodemocks.NodeExecutionMetadata{} nm.OnGetNodeExecutionID().Return(&core.NodeExecutionIdentifier{ @@ -2477,10 +2479,10 @@ func TestIsMaxParallelismAchieved(t *testing.T) { // Creates an execution context for the test createExecContext := func(maxParallelism, currentParallelism uint32) executors.ExecutionContext { m := &mocks4.ExecutionContext{} - m.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{ + m.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{ MaxParallelism: maxParallelism, }) - m.OnCurrentParallelism().Return(currentParallelism) + m.EXPECT().CurrentParallelism().Return(currentParallelism) return m } diff --git a/flytepropeller/pkg/controller/nodes/gate/handler_test.go b/flytepropeller/pkg/controller/nodes/gate/handler_test.go index 488cb58a07..d988e8cb74 100644 --- a/flytepropeller/pkg/controller/nodes/gate/handler_test.go +++ b/flytepropeller/pkg/controller/nodes/gate/handler_test.go @@ -106,7 +106,7 @@ func createNodeExecutionContext(gateNode *v1alpha1.GateNodeSpec) *nodeMocks.Node dataStore, _ := storage.NewDataStore(&storage.Config{Type: storage.TypeMemory}, promutils.NewTestScope()) eCtx := &executormocks.ExecutionContext{} - eCtx.OnGetExecutionID().Return(wfExecID) + eCtx.EXPECT().GetExecutionID().Return(wfExecID) nCtx := &nodeMocks.NodeExecutionContext{} nCtx.OnNodeExecutionMetadata().Return(nm) diff --git a/flytepropeller/pkg/controller/nodes/interfaces/mocks/node_execution_metadata.go b/flytepropeller/pkg/controller/nodes/interfaces/mocks/node_execution_metadata.go index c78bdfb557..26b41cc94b 100644 --- a/flytepropeller/pkg/controller/nodes/interfaces/mocks/node_execution_metadata.go +++ b/flytepropeller/pkg/controller/nodes/interfaces/mocks/node_execution_metadata.go @@ -51,6 +51,38 @@ func (_m *NodeExecutionMetadata) GetAnnotations() map[string]string { return r0 } +type NodeExecutionMetadata_GetConsoleURL struct { + *mock.Call +} + +func (_m NodeExecutionMetadata_GetConsoleURL) Return(_a0 string) *NodeExecutionMetadata_GetConsoleURL { + return &NodeExecutionMetadata_GetConsoleURL{Call: _m.Call.Return(_a0)} +} + +func (_m *NodeExecutionMetadata) OnGetConsoleURL() *NodeExecutionMetadata_GetConsoleURL { + c_call := _m.On("GetConsoleURL") + return &NodeExecutionMetadata_GetConsoleURL{Call: c_call} +} + +func (_m *NodeExecutionMetadata) OnGetConsoleURLMatch(matchers ...interface{}) *NodeExecutionMetadata_GetConsoleURL { + c_call := _m.On("GetConsoleURL", matchers...) + return &NodeExecutionMetadata_GetConsoleURL{Call: c_call} +} + +// GetConsoleURL provides a mock function with given fields: +func (_m *NodeExecutionMetadata) GetConsoleURL() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + type NodeExecutionMetadata_GetInterruptibleFailureThreshold struct { *mock.Call } diff --git a/flytepropeller/pkg/controller/nodes/interfaces/node_exec_context.go b/flytepropeller/pkg/controller/nodes/interfaces/node_exec_context.go index b6a33a4e35..1ea60f89b0 100644 --- a/flytepropeller/pkg/controller/nodes/interfaces/node_exec_context.go +++ b/flytepropeller/pkg/controller/nodes/interfaces/node_exec_context.go @@ -39,6 +39,7 @@ type NodeExecutionMetadata interface { GetSecurityContext() core.SecurityContext IsInterruptible() bool GetInterruptibleFailureThreshold() int32 + GetConsoleURL() string } type NodeExecutionContext interface { diff --git a/flytepropeller/pkg/controller/nodes/resolve_test.go b/flytepropeller/pkg/controller/nodes/resolve_test.go index 19a8be1e7d..10b9e4e45d 100644 --- a/flytepropeller/pkg/controller/nodes/resolve_test.go +++ b/flytepropeller/pkg/controller/nodes/resolve_test.go @@ -172,6 +172,8 @@ func (d *dummyBaseWorkflow) GetExecutionConfig() v1alpha1.ExecutionConfig { return v1alpha1.ExecutionConfig{} } +func (d *dummyBaseWorkflow) GetConsoleURL() string { return "" } + func createDummyBaseWorkflow(dataStore *storage.DataStore) *dummyBaseWorkflow { return &dummyBaseWorkflow{ ID: "w1", diff --git a/flytepropeller/pkg/controller/nodes/subworkflow/handler_test.go b/flytepropeller/pkg/controller/nodes/subworkflow/handler_test.go index c47c39cde8..cd67b96466 100644 --- a/flytepropeller/pkg/controller/nodes/subworkflow/handler_test.go +++ b/flytepropeller/pkg/controller/nodes/subworkflow/handler_test.go @@ -112,16 +112,16 @@ func createNodeContextWithVersion(phase v1alpha1.WorkflowNodePhase, n v1alpha1.E nCtx.OnNodeStateWriter().Return(state) ex := &execMocks.ExecutionContext{} - ex.OnGetEventVersion().Return(version) - ex.OnGetParentInfo().Return(nil) - ex.OnGetName().Return("name") - ex.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) - ex.OnIncrementParallelism().Return(1) - ex.OnGetSecurityContext().Return(core.SecurityContext{}) - ex.OnGetAnnotations().Return(nil) - ex.OnGetLabels().Return(nil) - ex.OnGetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{}) - ex.OnGetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + ex.EXPECT().GetEventVersion().Return(version) + ex.EXPECT().GetParentInfo().Return(nil) + ex.EXPECT().GetName().Return("name") + ex.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + ex.EXPECT().IncrementParallelism().Return(1) + ex.EXPECT().GetSecurityContext().Return(core.SecurityContext{}) + ex.EXPECT().GetAnnotations().Return(nil) + ex.EXPECT().GetLabels().Return(nil) + ex.EXPECT().GetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{}) + ex.EXPECT().GetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) nCtx.OnExecutionContext().Return(ex) @@ -329,9 +329,9 @@ func TestWorkflowNodeHandler_AbortNode(t *testing.T) { ).Return(nil) eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + eCtx.EXPECT().GetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + eCtx.EXPECT().GetName().Return("test") nCtx.OnExecutionContext().Return(eCtx) - eCtx.OnGetName().Return("test") err := h.Abort(ctx, nCtx, "test") assert.NoError(t, err) }) @@ -351,9 +351,9 @@ func TestWorkflowNodeHandler_AbortNode(t *testing.T) { ).Return(nil) eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + eCtx.EXPECT().GetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + eCtx.EXPECT().GetName().Return("test") nCtx.OnExecutionContext().Return(eCtx) - eCtx.OnGetName().Return("test") err := h.Abort(ctx, nCtx, "test") assert.NoError(t, err) }) @@ -372,9 +372,9 @@ func TestWorkflowNodeHandler_AbortNode(t *testing.T) { nCtx := createNodeContext(v1alpha1.WorkflowNodePhaseExecuting, mockNode, mockNodeStatus) eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + eCtx.EXPECT().GetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + eCtx.EXPECT().GetName().Return("test") nCtx.OnExecutionContext().Return(eCtx) - eCtx.OnGetName().Return("test") err := h.Abort(ctx, nCtx, "test") assert.Error(t, err) diff --git a/flytepropeller/pkg/controller/nodes/subworkflow/launchplan_test.go b/flytepropeller/pkg/controller/nodes/subworkflow/launchplan_test.go index 2e042d72a4..96acf46d78 100644 --- a/flytepropeller/pkg/controller/nodes/subworkflow/launchplan_test.go +++ b/flytepropeller/pkg/controller/nodes/subworkflow/launchplan_test.go @@ -245,19 +245,19 @@ func TestSubWorkflowHandler_StartLaunchPlan(t *testing.T) { nCtx.OnNodeExecutionMetadata().Return(nm) ectx := &execMocks.ExecutionContext{} - ectx.OnGetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) - ectx.OnGetEventVersion().Return(1) - ectx.OnGetParentInfo().Return(nil) - ectx.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{ + ectx.EXPECT().GetDefinitionVersion().Return(v1alpha1.WorkflowDefinitionVersion1) + ectx.EXPECT().GetEventVersion().Return(1) + ectx.EXPECT().GetParentInfo().Return(nil) + ectx.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{ RecoveryExecution: v1alpha1.WorkflowExecutionIdentifier{ WorkflowExecutionIdentifier: recoveredExecID, }, }) - ectx.OnIncrementParallelism().Return(1) - ectx.OnGetSecurityContext().Return(core.SecurityContext{}) - ectx.OnGetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{}) - ectx.OnGetLabels().Return(nil) - ectx.OnGetAnnotations().Return(nil) + ectx.EXPECT().IncrementParallelism().Return(1) + ectx.EXPECT().GetSecurityContext().Return(core.SecurityContext{}) + ectx.EXPECT().GetRawOutputDataConfig().Return(v1alpha1.RawOutputDataConfig{}) + ectx.EXPECT().GetLabels().Return(nil) + ectx.EXPECT().GetAnnotations().Return(nil) nCtx.OnExecutionContext().Return(ectx) nCtx.OnCurrentAttempt().Return(uint32(1)) @@ -671,7 +671,7 @@ func TestLaunchPlanHandler_HandleAbort(t *testing.T) { } nCtx := createNodeContext(v1alpha1.WorkflowNodePhaseExecuting, mockNode, mockNodeStatus) eCtx := &execMocks.ExecutionContext{} - eCtx.OnGetName().Return("name") + eCtx.EXPECT().GetName().Return("name") nCtx.OnExecutionContext().Return(eCtx) err := h.HandleAbort(ctx, nCtx, "some reason") assert.NoError(t, err) diff --git a/flytepropeller/pkg/controller/nodes/subworkflow/subworkflow_test.go b/flytepropeller/pkg/controller/nodes/subworkflow/subworkflow_test.go index dc00efacdc..02de593463 100644 --- a/flytepropeller/pkg/controller/nodes/subworkflow/subworkflow_test.go +++ b/flytepropeller/pkg/controller/nodes/subworkflow/subworkflow_test.go @@ -30,7 +30,7 @@ func TestGetSubWorkflow(t *testing.T) { ectx := &execMocks.ExecutionContext{} swf := &coreMocks.ExecutableSubWorkflow{} - ectx.OnFindSubWorkflow("x").Return(swf) + ectx.EXPECT().FindSubWorkflow("x").Return(swf) nCtx := &mocks.NodeExecutionContext{} nCtx.OnNode().Return(node) @@ -60,7 +60,7 @@ func TestGetSubWorkflow(t *testing.T) { swf := &coreMocks.ExecutableSubWorkflow{} swf.OnGetOnFailureNode().Return(failureNode) - ectx.OnFindSubWorkflow("x").Return(swf) + ectx.EXPECT().FindSubWorkflow("x").Return(swf) nCtx := &mocks.NodeExecutionContext{} nCtx.OnNode().Return(node) @@ -82,7 +82,7 @@ func TestGetSubWorkflow(t *testing.T) { ectx := &execMocks.ExecutionContext{} - ectx.OnFindSubWorkflow("x").Return(nil) + ectx.EXPECT().FindSubWorkflow("x").Return(nil) nCtx := &mocks.NodeExecutionContext{} nCtx.OnNode().Return(node) @@ -107,7 +107,7 @@ func Test_subworkflowHandler_HandleAbort(t *testing.T) { swf := &coreMocks.ExecutableSubWorkflow{} ectx := &execMocks.ExecutionContext{} - ectx.OnFindSubWorkflow("x").Return(swf) + ectx.EXPECT().FindSubWorkflow("x").Return(swf) ns := &coreMocks.ExecutableNodeStatus{} nCtx := &mocks.NodeExecutionContext{} @@ -138,8 +138,8 @@ func Test_subworkflowHandler_HandleAbort(t *testing.T) { swf.OnStartNode().Return(&coreMocks.ExecutableNode{}) ectx := &execMocks.ExecutionContext{} - ectx.OnFindSubWorkflow("x").Return(swf) - ectx.OnGetParentInfo().Return(nil) + ectx.EXPECT().FindSubWorkflow("x").Return(swf) + ectx.EXPECT().GetParentInfo().Return(nil) ns := &coreMocks.ExecutableNodeStatus{} nCtx := &mocks.NodeExecutionContext{} @@ -172,8 +172,8 @@ func Test_subworkflowHandler_HandleAbort(t *testing.T) { swf.OnStartNode().Return(&coreMocks.ExecutableNode{}) ectx := &execMocks.ExecutionContext{} - ectx.OnFindSubWorkflow("x").Return(swf) - ectx.OnGetParentInfo().Return(nil) + ectx.EXPECT().FindSubWorkflow("x").Return(swf) + ectx.EXPECT().GetParentInfo().Return(nil) ns := &coreMocks.ExecutableNodeStatus{} nCtx := &mocks.NodeExecutionContext{} diff --git a/flytepropeller/pkg/controller/nodes/task/handler_test.go b/flytepropeller/pkg/controller/nodes/task/handler_test.go index f0e177838f..27e377236f 100644 --- a/flytepropeller/pkg/controller/nodes/task/handler_test.go +++ b/flytepropeller/pkg/controller/nodes/task/handler_test.go @@ -499,11 +499,11 @@ func Test_task_Handle_NoCatalog(t *testing.T) { nCtx.OnOutputShardSelector().Return(ioutils.NewConstantShardSelector([]string{"x"})) executionContext := &mocks.ExecutionContext{} - executionContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) - executionContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) - executionContext.OnGetParentInfo().Return(nil) + executionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + executionContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) + executionContext.EXPECT().GetParentInfo().Return(nil) if allowIncrementParallelism { - executionContext.OnIncrementParallelism().Return(1) + executionContext.EXPECT().IncrementParallelism().Return(1) } nCtx.OnExecutionContext().Return(executionContext) @@ -811,9 +811,9 @@ func Test_task_Abort(t *testing.T) { nCtx.OnEventsRecorder().Return(ev) executionContext := &mocks.ExecutionContext{} - executionContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) - executionContext.OnGetParentInfo().Return(nil) - executionContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) + executionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + executionContext.EXPECT().GetParentInfo().Return(nil) + executionContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) nCtx.OnExecutionContext().Return(executionContext) nCtx.OnRawOutputPrefix().Return("s3://sandbox/") @@ -972,9 +972,9 @@ func Test_task_Abort_v1(t *testing.T) { nCtx.OnEventsRecorder().Return(ev) executionContext := &mocks.ExecutionContext{} - executionContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) - executionContext.OnGetParentInfo().Return(nil) - executionContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) + executionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + executionContext.EXPECT().GetParentInfo().Return(nil) + executionContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) nCtx.OnExecutionContext().Return(executionContext) nCtx.OnRawOutputPrefix().Return("s3://sandbox/") @@ -1153,9 +1153,9 @@ func Test_task_Finalize(t *testing.T) { nCtx.OnEnqueueOwnerFunc().Return(nil) executionContext := &mocks.ExecutionContext{} - executionContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) - executionContext.OnGetParentInfo().Return(nil) - executionContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) + executionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + executionContext.EXPECT().GetParentInfo().Return(nil) + executionContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) nCtx.OnExecutionContext().Return(executionContext) nCtx.OnRawOutputPrefix().Return("s3://sandbox/") diff --git a/flytepropeller/pkg/controller/nodes/task/taskexec_context_test.go b/flytepropeller/pkg/controller/nodes/task/taskexec_context_test.go index e798f82a04..5f5f3d68c5 100644 --- a/flytepropeller/pkg/controller/nodes/task/taskexec_context_test.go +++ b/flytepropeller/pkg/controller/nodes/task/taskexec_context_test.go @@ -93,9 +93,9 @@ func dummyNodeExecutionContext(t *testing.T, parentInfo executors.ImmutableParen nCtx.OnEnqueueOwnerFunc().Return(nil) executionContext := &mocks2.ExecutionContext{} - executionContext.OnGetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) - executionContext.OnGetParentInfo().Return(parentInfo) - executionContext.OnGetEventVersion().Return(eventVersion) + executionContext.EXPECT().GetExecutionConfig().Return(v1alpha1.ExecutionConfig{}) + executionContext.EXPECT().GetParentInfo().Return(parentInfo) + executionContext.EXPECT().GetEventVersion().Return(eventVersion) nCtx.OnExecutionContext().Return(executionContext) ds, err := storage.NewDataStore( diff --git a/flytepropeller/pkg/controller/nodes/task/transformer_test.go b/flytepropeller/pkg/controller/nodes/task/transformer_test.go index db89dda3e6..0fdab91907 100644 --- a/flytepropeller/pkg/controller/nodes/task/transformer_test.go +++ b/flytepropeller/pkg/controller/nodes/task/transformer_test.go @@ -60,8 +60,8 @@ func TestToTaskExecutionEvent(t *testing.T) { nodeExecutionMetadata.OnIsInterruptible().Return(true) mockExecContext := &mocks2.ExecutionContext{} - mockExecContext.OnGetEventVersion().Return(v1alpha1.EventVersion0) - mockExecContext.OnGetParentInfo().Return(nil) + mockExecContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion0) + mockExecContext.EXPECT().GetParentInfo().Return(nil) tID := &pluginMocks.TaskExecutionID{} generatedName := "generated_name" @@ -252,11 +252,11 @@ func TestToTaskExecutionEventWithParent(t *testing.T) { nodeExecutionMetadata.OnIsInterruptible().Return(true) mockExecContext := &mocks2.ExecutionContext{} - mockExecContext.OnGetEventVersion().Return(v1alpha1.EventVersion1) + mockExecContext.EXPECT().GetEventVersion().Return(v1alpha1.EventVersion1) mockParentInfo := &mocks2.ImmutableParentInfo{} mockParentInfo.OnGetUniqueID().Return("np1") mockParentInfo.OnCurrentAttempt().Return(uint32(2)) - mockExecContext.OnGetParentInfo().Return(mockParentInfo) + mockExecContext.EXPECT().GetParentInfo().Return(mockParentInfo) tID := &pluginMocks.TaskExecutionID{} generatedName := "generated_name"