Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Adding tests for operator v1 api #165

Merged
merged 2 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ cd ${GO_DIR}

echo "Running smoke test"
SENDRECV_TEST_IMAGE_TAG="pytorch-dist-sendrecv-test:v1.0"
go run ./test/e2e/v1beta1/cleanpolicy_all.go --namespace=${NAMESPACE} --image=${REGISTRY}/${SENDRECV_TEST_IMAGE_TAG} --name=sendrecvjob-cleanall
go run ./test/e2e/v1/cleanpolicy_all.go --namespace=${NAMESPACE} --image=${REGISTRY}/${SENDRECV_TEST_IMAGE_TAG} --name=sendrecvjob-cleanall

echo "Running mnist test"
MNIST_TEST_IMAGE_TAG="pytorch-dist-mnist-test:v1.0"
go run ./test/e2e/v1beta1/cleanpolicy_all.go --namespace=${NAMESPACE} --image=${REGISTRY}/${MNIST_TEST_IMAGE_TAG} --name=mnistjob-cleanall
go run ./test/e2e/v1/cleanpolicy_all.go --namespace=${NAMESPACE} --image=${REGISTRY}/${MNIST_TEST_IMAGE_TAG} --name=mnistjob-cleanall

Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ cd ${GO_DIR}

echo "Running smoke test"
SENDRECV_TEST_IMAGE_TAG="pytorch-dist-sendrecv-test:v1.0"
go run ./test/e2e/v1beta1/defaults.go --namespace=${NAMESPACE} --image=${REGISTRY}/${SENDRECV_TEST_IMAGE_TAG} --name=sendrecvjob-cleannone
go run ./test/e2e/v1/defaults.go --namespace=${NAMESPACE} --image=${REGISTRY}/${SENDRECV_TEST_IMAGE_TAG} --name=sendrecvjob-cleannone

echo "Running mnist test"
MNIST_TEST_IMAGE_TAG="pytorch-dist-mnist-test:v1.0"
go run ./test/e2e/v1beta1/defaults.go --namespace=${NAMESPACE} --image=${REGISTRY}/${MNIST_TEST_IMAGE_TAG} --name=mnistjob-cleannone
go run ./test/e2e/v1/defaults.go --namespace=${NAMESPACE} --image=${REGISTRY}/${MNIST_TEST_IMAGE_TAG} --name=mnistjob-cleannone

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"time"

"github.com/gogo/protobuf/proto"
v1beta1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1beta1"
pyv1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1"
torchjobclient "github.com/kubeflow/pytorch-operator/pkg/client/clientset/versioned"
"github.com/kubeflow/pytorch-operator/pkg/util"
common "github.com/kubeflow/tf-operator/pkg/apis/common/v1beta1"
common "github.com/kubeflow/tf-operator/pkg/apis/common/v1"
log "github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -33,10 +33,10 @@ var (
image = flag.String("image", "", "The Test image to run")
)

func getReplicaSpec(worker int32) map[v1beta1.PyTorchReplicaType]*common.ReplicaSpec {
spec := make(map[v1beta1.PyTorchReplicaType]*common.ReplicaSpec)
spec[v1beta1.PyTorchReplicaTypeMaster] = replicaSpec(1)
spec[v1beta1.PyTorchReplicaTypeWorker] = replicaSpec(worker)
func getReplicaSpec(worker int32) map[pyv1.PyTorchReplicaType]*common.ReplicaSpec {
spec := make(map[pyv1.PyTorchReplicaType]*common.ReplicaSpec)
spec[pyv1.PyTorchReplicaTypeMaster] = replicaSpec(1)
spec[pyv1.PyTorchReplicaTypeWorker] = replicaSpec(worker)
return spec

}
Expand Down Expand Up @@ -104,26 +104,26 @@ func run() (string, error) {
return "", err
}

original := &v1beta1.PyTorchJob{
original := &pyv1.PyTorchJob{
ObjectMeta: metav1.ObjectMeta{
Name: *name,
},
Spec: v1beta1.PyTorchJobSpec{
Spec: pyv1.PyTorchJobSpec{
PyTorchReplicaSpecs: getReplicaSpec(3),
},
}
policy := common.CleanPodPolicyAll
original.Spec.CleanPodPolicy = &policy
// Create PyTorchJob
_, err = torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Create(original)
_, err = torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Create(original)
if err != nil {
log.Errorf("Creating the job failed; %v", err)
return *name, err
}
log.Info("Job created: \n%v", util.Pformat(original))
var torchJob *v1beta1.PyTorchJob
var torchJob *pyv1.PyTorchJob
for endTime := time.Now().Add(*timeout); time.Now().Before(endTime); {
torchJob, err = torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
torchJob, err = torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
if err != nil {
log.Errorf("There was a problem getting PyTorchJob: %v; error %v", *name, err)
return *name, err
Expand All @@ -146,7 +146,7 @@ func run() (string, error) {
}

l := map[string]string{
"group-name": v1beta1.GroupName,
"group-name": pyv1.GroupName,
"pytorch-job-name": strings.Replace(*name, "/", "-", -1),
}

Expand Down Expand Up @@ -175,13 +175,13 @@ func run() (string, error) {
return *name, fmt.Errorf("Not all pods are successfully deleted for PyTorchJob %v.", *name)
}
// Delete the job and make sure all subresources are properly garbage collected.
if err := torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Delete(*name, &metav1.DeleteOptions{}); err != nil {
if err := torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Delete(*name, &metav1.DeleteOptions{}); err != nil {
log.Fatalf("Failed to delete PyTorchJob %v; error %v", *name, err)
}

deleted = false
for endTime := time.Now().Add(*timeout); time.Now().Before(endTime); {
_, err = torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
_, err = torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
if k8s_errors.IsNotFound(err) {
deleted = true
break
Expand Down
26 changes: 13 additions & 13 deletions test/e2e/v1beta1/defaults.go → test/e2e/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"time"

"github.com/gogo/protobuf/proto"
v1beta1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1beta1"
pyv1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1"
torchjobclient "github.com/kubeflow/pytorch-operator/pkg/client/clientset/versioned"
"github.com/kubeflow/pytorch-operator/pkg/util"
common "github.com/kubeflow/tf-operator/pkg/apis/common/v1beta1"
common "github.com/kubeflow/tf-operator/pkg/apis/common/v1"
"github.com/kubeflow/tf-operator/pkg/common/jobcontroller"
log "github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
Expand All @@ -35,10 +35,10 @@ var (
image = flag.String("image", "", "The Test image to run")
)

func getReplicaSpec(worker int32) map[v1beta1.PyTorchReplicaType]*common.ReplicaSpec {
spec := make(map[v1beta1.PyTorchReplicaType]*common.ReplicaSpec)
spec[v1beta1.PyTorchReplicaTypeMaster] = replicaSpec(1)
spec[v1beta1.PyTorchReplicaTypeWorker] = replicaSpec(worker)
func getReplicaSpec(worker int32) map[pyv1.PyTorchReplicaType]*common.ReplicaSpec {
spec := make(map[pyv1.PyTorchReplicaType]*common.ReplicaSpec)
spec[pyv1.PyTorchReplicaTypeMaster] = replicaSpec(1)
spec[pyv1.PyTorchReplicaTypeWorker] = replicaSpec(worker)
return spec

}
Expand Down Expand Up @@ -106,24 +106,24 @@ func run() (string, error) {
return "", err
}

original := &v1beta1.PyTorchJob{
original := &pyv1.PyTorchJob{
ObjectMeta: metav1.ObjectMeta{
Name: *name,
},
Spec: v1beta1.PyTorchJobSpec{
Spec: pyv1.PyTorchJobSpec{
PyTorchReplicaSpecs: getReplicaSpec(3),
},
}
// Create PyTorchJob
_, err = torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Create(original)
_, err = torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Create(original)
if err != nil {
log.Errorf("Creating the job failed; %v", err)
return *name, err
}
log.Info("Job created: \n%v", util.Pformat(original))
var torchJob *v1beta1.PyTorchJob
var torchJob *pyv1.PyTorchJob
for endTime := time.Now().Add(*timeout); time.Now().Before(endTime); {
torchJob, err = torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
torchJob, err = torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
if err != nil {
log.Errorf("There was a problem getting PyTorchJob: %v; error %v", *name, err)
return *name, err
Expand Down Expand Up @@ -159,13 +159,13 @@ func run() (string, error) {
}

// Delete the job and make sure all subresources are properly garbage collected.
if err := torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Delete(*name, &metav1.DeleteOptions{}); err != nil {
if err := torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Delete(*name, &metav1.DeleteOptions{}); err != nil {
log.Fatalf("Failed to delete PyTorchJob %v; error %v", *name, err)
}

deleted := false
for endTime := time.Now().Add(*timeout); time.Now().Before(endTime); {
_, err = torchJobClient.KubeflowV1beta1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
_, err = torchJobClient.KubeflowV1().PyTorchJobs(*namespace).Get(*name, metav1.GetOptions{})
if k8s_errors.IsNotFound(err) {
deleted = true
break
Expand Down
20 changes: 10 additions & 10 deletions test/workflows/components/workflows.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@
],
[
{
name: "run-v1beta1-defaults",
template: "run-v1beta1-defaults",
name: "run-v1-defaults",
template: "run-v1-defaults",
},
{
name: "run-v1beta1-cleanpodpolicy-all",
template: "run-v1beta1-cleanpodpolicy-all",
name: "run-v1-cleanpodpolicy-all",
template: "run-v1-cleanpodpolicy-all",
},
],
[
Expand Down Expand Up @@ -287,12 +287,12 @@
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("setup-kubeflow", testWorkerImage, [
"scripts/setup-kubeflow.sh",
]), // setup kubeflow
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("run-v1beta1-defaults", testWorkerImage, [
"scripts/v1beta1/run-defaults.sh",
]), // run v1beta1 default tests
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("run-v1beta1-cleanpodpolicy-all", testWorkerImage, [
"scripts/v1beta1/run-cleanpodpolicy-all.sh",
]), // run v1beta1 cleanpodpolicy tests
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("run-v1-defaults", testWorkerImage, [
"scripts/v1/run-defaults.sh",
]), // run v1 default tests
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("run-v1-cleanpodpolicy-all", testWorkerImage, [
"scripts/v1/run-cleanpodpolicy-all.sh",
]), // run v1 cleanpodpolicy tests
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("run-v1beta2-defaults", testWorkerImage, [
"scripts/v1beta2/run-defaults.sh",
]), // run v1beta2 default tests
Expand Down