From c5a972b4d429b9f1b7c611bc6487350a00625522 Mon Sep 17 00:00:00 2001 From: Eduardo Apolinario <653394+eapolinario@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:53:47 -0700 Subject: [PATCH] Add support for gate nodes (#399) * Add support for gate nodes Signed-off-by: eduardo apolinario * Linting Signed-off-by: eduardo apolinario --------- Signed-off-by: eduardo apolinario Co-authored-by: eduardo apolinario --- flytectl/cmd/register/register_util.go | 2 + flytectl/cmd/register/register_util_test.go | 59 +++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/flytectl/cmd/register/register_util.go b/flytectl/cmd/register/register_util.go index 0f646c89b56..714e30c76b1 100644 --- a/flytectl/cmd/register/register_util.go +++ b/flytectl/cmd/register/register_util.go @@ -245,6 +245,8 @@ func hydrateNode(node *core.Node, version string, force bool) error { default: return fmt.Errorf("unknown type %T", branchNodeWrapper.BranchNode.IfElse.Default) } + case *core.Node_GateNode: + // Do nothing. default: return fmt.Errorf("unknown type %T", v) } diff --git a/flytectl/cmd/register/register_util_test.go b/flytectl/cmd/register/register_util_test.go index 6e31565cecf..97a39082d2f 100644 --- a/flytectl/cmd/register/register_util_test.go +++ b/flytectl/cmd/register/register_util_test.go @@ -35,6 +35,7 @@ import ( "github.com/stretchr/testify/mock" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/durationpb" ) type MockHTTPClient struct { @@ -501,6 +502,64 @@ func TestHydrateNode(t *testing.T) { }) } +func TestHydrateGateNode(t *testing.T) { + t.Run("Hydrate Sleep", func(t *testing.T) { + registerFilesSetup() + // Write a node that contains a GateNode + node := &core.Node{ + Target: &core.Node_GateNode{ + GateNode: &core.GateNode{ + Condition: &core.GateNode_Sleep{ + Sleep: &core.SleepCondition{ + Duration: &durationpb.Duration{ + Seconds: 10, + }, + }, + }, + }, + }, + } + err := hydrateNode(node, rconfig.DefaultFilesConfig.Version, true) + assert.Nil(t, err) + }) + + t.Run("Hydrate Signal", func(t *testing.T) { + registerFilesSetup() + // Write a node that contains a GateNode + node := &core.Node{ + Target: &core.Node_GateNode{ + GateNode: &core.GateNode{ + Condition: &core.GateNode_Signal{ + Signal: &core.SignalCondition{ + SignalId: "abc", + }, + }, + }, + }, + } + err := hydrateNode(node, rconfig.DefaultFilesConfig.Version, true) + assert.Nil(t, err) + }) + + t.Run("Hydrate Approve", func(t *testing.T) { + registerFilesSetup() + // Write a node that contains a GateNode + node := &core.Node{ + Target: &core.Node_GateNode{ + GateNode: &core.GateNode{ + Condition: &core.GateNode_Approve{ + Approve: &core.ApproveCondition{ + SignalId: "abc", + }, + }, + }, + }, + } + err := hydrateNode(node, rconfig.DefaultFilesConfig.Version, true) + assert.Nil(t, err) + }) +} + func TestHydrateTaskSpec(t *testing.T) { testScope := promutils.NewTestScope() labeled.SetMetricKeys(contextutils.AppNameKey, contextutils.ProjectKey, contextutils.DomainKey)