forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass task-name and node-id in pod labels (flyteorg#87)
* Pass task-name and node-id in pod labels * changing receiver name
- Loading branch information
1 parent
1bd3181
commit 12dca2b
Showing
2 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
flytepropeller/pkg/controller/nodes/node_exec_context_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package nodes | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks" | ||
"github.com/lyft/flytestdlib/promutils" | ||
"github.com/lyft/flytestdlib/storage" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type TaskReader struct{} | ||
|
||
func (t TaskReader) Read(ctx context.Context) (*core.TaskTemplate, error) { return nil, nil } | ||
func (t TaskReader) GetTaskType() v1alpha1.TaskType { return "" } | ||
func (t TaskReader) GetTaskID() *core.Identifier { | ||
return &core.Identifier{Project: "p", Domain: "d", Name: "task-name"} | ||
} | ||
|
||
func Test_NodeContext(t *testing.T) { | ||
ns := mocks.ExecutableNodeStatus{} | ||
ns.On("GetDataDir").Return(storage.DataReference("data-dir")) | ||
ns.On("GetPhase").Return(v1alpha1.NodePhaseNotYetStarted) | ||
|
||
childDatadir := v1alpha1.DataReference("test") | ||
dataStore, _ := storage.NewDataStore(&storage.Config{Type: storage.TypeMemory}, promutils.NewTestScope()) | ||
w1 := &v1alpha1.FlyteWorkflow{ | ||
Status: v1alpha1.WorkflowStatus{ | ||
NodeStatus: map[v1alpha1.NodeID]*v1alpha1.NodeStatus{ | ||
"childNodeID": { | ||
DataDir: childDatadir, | ||
}, | ||
}, | ||
}, | ||
DataReferenceConstructor: dataStore, | ||
} | ||
|
||
taskID := "taskID" | ||
n := &v1alpha1.NodeSpec{ | ||
ID: "id", | ||
TaskRef: &taskID, | ||
Kind: v1alpha1.NodeKindTask, | ||
} | ||
s, _ := storage.NewDataStore(&storage.Config{Type: storage.TypeMemory}, promutils.NewTestScope()) | ||
nCtx := newNodeExecContext(context.TODO(), s, w1, n, nil, nil, 0, nil, TaskReader{}, nil, nil) | ||
assert.Equal(t, nCtx.NodeExecutionMetadata().GetLabels()["node-id"], "id") | ||
assert.Equal(t, nCtx.NodeExecutionMetadata().GetLabels()["task-name"], "task-name") | ||
} |