Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
Signed-off-by: Antonino Fugazzotto <[email protected]>
  • Loading branch information
afugazzotto committed Jun 11, 2024
1 parent 0edab78 commit 316e3e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 25 deletions.
1 change: 1 addition & 0 deletions internal/controller/isbservicerollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (r *ISBServiceRolloutReconciler) reconcile(ctx context.Context, isbServiceR

// TODO: instead of doing this, modify the ApplyCRSpec below to be similar to what is done on the PipelineRollout controller code
if rolloutChildOp == RolloutChildNone {
numaLogger.Debug("InterStepBufferService spec is unchanged. No updates will be performed")
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions internal/controller/pipelinerollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ func (r *PipelineRolloutReconciler) reconcile(
if err != nil {
return false, err
}
} else {
numaLogger.Debug("Pipeline spec is unchanged. No updates will be performed")
}

pipelineRollout.Status.MarkRunning()
Expand Down
64 changes: 39 additions & 25 deletions internal/controller/pipelinerollout_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand All @@ -37,6 +38,8 @@ import (
"github.com/numaproj/numaplane/internal/kubernetes"
"github.com/numaproj/numaplane/internal/util"
apiv1 "github.com/numaproj/numaplane/pkg/apis/numaplane/v1alpha1"

ctrl "sigs.k8s.io/controller-runtime"
)

var _ = Describe("PipelineRollout Controller", func() {
Expand Down Expand Up @@ -314,8 +317,19 @@ var _ = Describe("PipelineRollout Controller", func() {
})

func Test_makeChildResourceFromRolloutAndUpdateSpecHash_PipelineRollout(t *testing.T) {
scheme := runtime.NewScheme()
err := corev1.AddToScheme(scheme)
assert.NoError(t, err)
err = numaflowv1.AddToScheme(scheme)
assert.NoError(t, err)
err = apiv1.AddToScheme(scheme)
assert.NoError(t, err)

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{Scheme: scheme})
assert.NoError(t, err)

ctx := context.Background()
restConfig := &rest.Config{}
restConfig := mgr.GetConfig()

pipelineRollout := &apiv1.PipelineRollout{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -338,30 +352,30 @@ func Test_makeChildResourceFromRolloutAndUpdateSpecHash_PipelineRollout(t *testi
assert.Equal(t, operation, RolloutChildNew)
}

func Test_makeChildResourceFromRolloutAndUpdateSpecHash_ISBServiceRollout(t *testing.T) {
ctx := context.Background()
restConfig := &rest.Config{}

isbService := &apiv1.ISBServiceRollout{
ObjectMeta: metav1.ObjectMeta{
Name: "isbs-test",
Namespace: "default",
},
Spec: apiv1.ISBServiceRolloutSpec{
InterStepBufferService: runtime.RawExtension{Raw: []byte(`{"key":"value"}`)},
},
}

obj, operation, err := makeChildResourceFromRolloutAndUpdateSpecHash(ctx, restConfig, isbService)

require.NoError(t, err)
assert.Equal(t, "InterStepBufferService", obj.Kind)
assert.Equal(t, "numaflow.numaproj.io/v1alpha1", obj.APIVersion)
assert.Equal(t, isbService.Name, obj.Name)
assert.Equal(t, isbService.Namespace, obj.Namespace)
assert.Equal(t, []metav1.OwnerReference{*metav1.NewControllerRef(isbService, apiv1.ISBServiceRolloutGroupVersionKind)}, obj.OwnerReferences)
assert.Equal(t, operation, RolloutChildNew)
}
// func Test_makeChildResourceFromRolloutAndUpdateSpecHash_ISBServiceRollout(t *testing.T) {
// ctx := context.Background()
// restConfig := &rest.Config{}

// isbService := &apiv1.ISBServiceRollout{
// ObjectMeta: metav1.ObjectMeta{
// Name: "isbs-test",
// Namespace: "default",
// },
// Spec: apiv1.ISBServiceRolloutSpec{
// InterStepBufferService: runtime.RawExtension{Raw: []byte(`{"key":"value"}`)},
// },
// }

// obj, operation, err := makeChildResourceFromRolloutAndUpdateSpecHash(ctx, restConfig, isbService)

// require.NoError(t, err)
// assert.Equal(t, "InterStepBufferService", obj.Kind)
// assert.Equal(t, "numaflow.numaproj.io/v1alpha1", obj.APIVersion)
// assert.Equal(t, isbService.Name, obj.Name)
// assert.Equal(t, isbService.Namespace, obj.Namespace)
// assert.Equal(t, []metav1.OwnerReference{*metav1.NewControllerRef(isbService, apiv1.ISBServiceRolloutGroupVersionKind)}, obj.OwnerReferences)
// assert.Equal(t, operation, RolloutChildNew)
// }

func Test_makeChildResourceFromRolloutAndUpdateSpecHash_InvalidType(t *testing.T) {
ctx := context.Background()
Expand Down

0 comments on commit 316e3e3

Please sign in to comment.