Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Rammer <[email protected]>
  • Loading branch information
hamersaw committed Oct 10, 2022
1 parent 6a8ffa8 commit 6a27535
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 22 deletions.
3 changes: 3 additions & 0 deletions pkg/manager/impl/node_execution_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ func TestCreateNodeEvent(t *testing.T) {
StartedAt: occurredAtProto,
CreatedAt: occurredAtProto,
UpdatedAt: occurredAtProto,
TargetMetadata: &admin.NodeExecutionClosure_TaskNodeMetadata{
TaskNodeMetadata: &admin.TaskNodeMetadata{},
},
}
closureBytes, _ := proto.Marshal(&expectedClosure)
repository.NodeExecutionRepo().(*repositoryMocks.MockNodeExecutionRepo).SetCreateCallback(
Expand Down
69 changes: 47 additions & 22 deletions pkg/repositories/transformers/node_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,33 +188,49 @@ func TestAddTerminalState_Error(t *testing.T) {

func TestCreateNodeExecutionModel(t *testing.T) {
parentTaskExecID := uint(8)
nodeExecutionModel, err := CreateNodeExecutionModel(context.TODO(), ToNodeExecutionModelInput{
Request: &admin.NodeExecutionEventRequest{
Event: &event.NodeExecutionEvent{
Id: &core.NodeExecutionIdentifier{
NodeId: "node id",
ExecutionId: &core.WorkflowExecutionIdentifier{
Project: "project",
Domain: "domain",
Name: "name",
},
},
Phase: core.NodeExecution_RUNNING,
InputUri: "input uri",
OutputResult: &event.NodeExecutionEvent_OutputUri{
OutputUri: "output uri",
request := &admin.NodeExecutionEventRequest{
Event: &event.NodeExecutionEvent{
Id: &core.NodeExecutionIdentifier{
NodeId: "node id",
ExecutionId: &core.WorkflowExecutionIdentifier{
Project: "project",
Domain: "domain",
Name: "name",
},
OccurredAt: occurredAtProto,
ParentTaskMetadata: &event.ParentTaskExecutionMetadata{
Id: &core.TaskExecutionIdentifier{
RetryAttempt: 1,
},
Phase: core.NodeExecution_RUNNING,
InputUri: "input uri",
OutputResult: &event.NodeExecutionEvent_OutputUri{
OutputUri: "output uri",
},
OccurredAt: occurredAtProto,
TargetMetadata: &event.NodeExecutionEvent_TaskNodeMetadata{
TaskNodeMetadata: &event.TaskNodeMetadata{
CacheStatus: core.CatalogCacheStatus_CACHE_POPULATED,
CatalogKey: &core.CatalogMetadata{
DatasetId: &core.Identifier{
ResourceType: core.ResourceType_DATASET,
Name: "x",
Project: "proj",
Domain: "domain",
},
},
CheckpointUri: "last checkpoint uri",
},
},
ParentTaskMetadata: &event.ParentTaskExecutionMetadata{
Id: &core.TaskExecutionIdentifier{
RetryAttempt: 1,
},
IsParent: true,
IsDynamic: true,
EventVersion: 2,
},
IsParent: true,
IsDynamic: true,
EventVersion: 2,
},
}

nodeExecutionModel, err := CreateNodeExecutionModel(context.TODO(), ToNodeExecutionModelInput{
Request: request,
ParentTaskExecutionID: &parentTaskExecID,
})
assert.Nil(t, err)
Expand All @@ -224,6 +240,13 @@ func TestCreateNodeExecutionModel(t *testing.T) {
StartedAt: occurredAtProto,
CreatedAt: occurredAtProto,
UpdatedAt: occurredAtProto,
TargetMetadata: &admin.NodeExecutionClosure_TaskNodeMetadata{
TaskNodeMetadata: &admin.TaskNodeMetadata{
CacheStatus: request.Event.GetTaskNodeMetadata().CacheStatus,
CatalogKey: request.Event.GetTaskNodeMetadata().CatalogKey,
CheckpointUri: request.Event.GetTaskNodeMetadata().CheckpointUri,
},
},
}
var closureBytes, _ = proto.Marshal(closure)
var nodeExecutionMetadata, _ = proto.Marshal(&admin.NodeExecutionMetaData{
Expand All @@ -234,6 +257,7 @@ func TestCreateNodeExecutionModel(t *testing.T) {
EventVersion: 2,
}
internalDataBytes, _ := proto.Marshal(internalData)
cacheStatus := request.Event.GetTaskNodeMetadata().CacheStatus.String()
assert.Equal(t, &models.NodeExecution{
NodeExecutionKey: models.NodeExecutionKey{
NodeID: "node id",
Expand All @@ -251,6 +275,7 @@ func TestCreateNodeExecutionModel(t *testing.T) {
NodeExecutionUpdatedAt: &occurredAt,
NodeExecutionMetadata: nodeExecutionMetadata,
ParentTaskExecutionID: &parentTaskExecID,
CacheStatus: &cacheStatus,
InternalData: internalDataBytes,
}, nodeExecutionModel)
}
Expand Down

0 comments on commit 6a27535

Please sign in to comment.