Skip to content

Commit

Permalink
Add support for gate nodes (flyteorg#399)
Browse files Browse the repository at this point in the history
* Add support for gate nodes

Signed-off-by: eduardo apolinario <[email protected]>

* Linting

Signed-off-by: eduardo apolinario <[email protected]>

---------

Signed-off-by: eduardo apolinario <[email protected]>
Co-authored-by: eduardo apolinario <[email protected]>
  • Loading branch information
2 people authored and robert-ulbrich-mercedes-benz committed Jul 2, 2024
1 parent 8202101 commit 60d2ffe
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flytectl/cmd/register/register_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
59 changes: 59 additions & 0 deletions flytectl/cmd/register/register_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 60d2ffe

Please sign in to comment.