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.
Pod tasks can be used for map tasks (flyteorg#182)
- Loading branch information
Katrina Rogan
committed
Jun 11, 2021
1 parent
632c508
commit 7c143b2
Showing
9 changed files
with
512 additions
and
58 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
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
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
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
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
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,85 @@ | ||
package k8s | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestGetTaskContainerIndex(t *testing.T) { | ||
t.Run("test container target", func(t *testing.T) { | ||
pod := &v1.Pod{ | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
{ | ||
Name: "container", | ||
}, | ||
}, | ||
}, | ||
} | ||
index, err := getTaskContainerIndex(pod) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 0, index) | ||
}) | ||
t.Run("test missing primary container annotation", func(t *testing.T) { | ||
pod := &v1.Pod{ | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
{ | ||
Name: "container", | ||
}, | ||
{ | ||
Name: "container b", | ||
}, | ||
}, | ||
}, | ||
} | ||
_, err := getTaskContainerIndex(pod) | ||
assert.EqualError(t, err, "[POD_TEMPLATE_FAILED] Expected a specified primary container key when building an array job with a K8sPod spec target") | ||
}) | ||
t.Run("test get primary container index", func(t *testing.T) { | ||
pod := &v1.Pod{ | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
{ | ||
Name: "container a", | ||
}, | ||
{ | ||
Name: "container b", | ||
}, | ||
{ | ||
Name: "container c", | ||
}, | ||
}, | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Annotations: map[string]string{ | ||
primaryContainerKey: "container c", | ||
}, | ||
}, | ||
} | ||
index, err := getTaskContainerIndex(pod) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 2, index) | ||
}) | ||
t.Run("specified primary container doesn't exist", func(t *testing.T) { | ||
pod := &v1.Pod{ | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
{ | ||
Name: "container a", | ||
}, | ||
}, | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Annotations: map[string]string{ | ||
primaryContainerKey: "container c", | ||
}, | ||
}, | ||
} | ||
_, err := getTaskContainerIndex(pod) | ||
assert.EqualError(t, err, "[POD_TEMPLATE_FAILED] Couldn't find any container matching the primary container key when building an array job with a K8sPod spec target") | ||
}) | ||
} |
Oops, something went wrong.