Skip to content

Commit

Permalink
Add tests in flytepropeller/pkg /controller/executors from 72.3% to…
Browse files Browse the repository at this point in the history
… 87.3% coverage (#4276)

* add to 87.3% coverage

Signed-off-by: Future Outlier <[email protected]>

* update to the latest pr: update k8s dependencies

Signed-off-by: Future Outlier <[email protected]>

---------

Signed-off-by: Future Outlier <[email protected]>
Co-authored-by: Future Outlier <[email protected]>
  • Loading branch information
Future-Outlier and Future Outlier authored Oct 30, 2023
1 parent 4e34214 commit ac4ec7d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
29 changes: 29 additions & 0 deletions flytepropeller/pkg/controller/executors/execution_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,32 @@ func TestExecutionContext(t *testing.T) {
assert.Equal(t, typed.TaskDetailsGetter, taskGetter)
assert.Equal(t, typed.GetParentInfo(), immutableParentInfo2)
}

func TestParentExecutionInfo_GetUniqueID(t *testing.T) {
expectedID := "testID"
parentInfo := NewParentInfo(expectedID, 1)
assert.Equal(t, expectedID, parentInfo.GetUniqueID())
}

func TestParentExecutionInfo_CurrentAttempt(t *testing.T) {
expectedAttempt := uint32(123465)
parentInfo := NewParentInfo("testID", expectedAttempt)
assert.Equal(t, expectedAttempt, parentInfo.CurrentAttempt())
}

func TestControlFlow_ControlFlowParallelism(t *testing.T) {
cFlow := InitializeControlFlow().(*controlFlow)
assert.Equal(t, uint32(0), cFlow.CurrentParallelism())
cFlow.IncrementParallelism()
assert.Equal(t, uint32(1), cFlow.CurrentParallelism())
cFlow.IncrementParallelism()
assert.Equal(t, uint32(2), cFlow.CurrentParallelism())
}

func TestNewParentInfo(t *testing.T) {
expectedID := "testID"
expectedAttempt := uint32(123465)
parentInfo := NewParentInfo(expectedID, expectedAttempt).(*parentExecutionInfo)
assert.Equal(t, expectedID, parentInfo.uniqueID)
assert.Equal(t, expectedAttempt, parentInfo.currentAttempts)
}
15 changes: 15 additions & 0 deletions flytepropeller/pkg/controller/executors/node_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,18 @@ func TestNewTestNodeLookup(t *testing.T) {
assert.False(t, ok)
assert.NotEqual(t, ns, nl.GetNodeExecutionStatus(context.TODO(), "n"))
}

func TestToNodeAndFromNode(t *testing.T) {
n := &mocks.ExecutableNode{}
ns := &mocks.ExecutableNodeStatus{}
nl := NewTestNodeLookup(map[string]v1alpha1.ExecutableNode{"n1": n}, map[string]v1alpha1.ExecutableNodeStatus{"n1": ns})

nodeIds, err := nl.ToNode("n1")
assert.Nil(t, nodeIds)
assert.Nil(t, err)

nodeIds, err = nl.FromNode("n1")
assert.Nil(t, nodeIds)
assert.Nil(t, err)

}

0 comments on commit ac4ec7d

Please sign in to comment.