Skip to content

Commit

Permalink
Remove AddEphemeralNode (#2887)
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Kim <[email protected]>
  • Loading branch information
joshua-kim authored Apr 3, 2024
1 parent d7452d3 commit d4507bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
10 changes: 5 additions & 5 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ func Eventually(condition func() bool, waitFor time.Duration, tick time.Duration
func AddEphemeralNode(network *tmpnet.Network, flags tmpnet.FlagsMap) *tmpnet.Node {
require := require.New(ginkgo.GinkgoT())

node, err := network.AddEphemeralNode(DefaultContext(), ginkgo.GinkgoWriter, flags)
require.NoError(err)
node := tmpnet.NewEphemeralNode(flags)
require.NoError(network.StartNode(DefaultContext(), ginkgo.GinkgoWriter, node))

ginkgo.DeferCleanup(func() {
tests.Outf("shutting down ephemeral node %q\n", node.NodeID)
Expand Down Expand Up @@ -199,10 +199,10 @@ func CheckBootstrapIsPossible(network *tmpnet.Network) {
ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancel()

node, err := network.AddEphemeralNode(ctx, ginkgo.GinkgoWriter, tmpnet.FlagsMap{})
// AddEphemeralNode will initiate node stop if an error is encountered during start,
node := tmpnet.NewEphemeralNode(tmpnet.FlagsMap{})
require.NoError(network.StartNode(ctx, ginkgo.GinkgoWriter, node))
// StartNode will initiate node stop if an error is encountered during start,
// so no further cleanup effort is required if an error is seen here.
require.NoError(err)

// Ensure the node is always stopped at the end of the check
defer func() {
Expand Down
10 changes: 0 additions & 10 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,6 @@ func (n *Network) Start(ctx context.Context, w io.Writer) error {
return nil
}

func (n *Network) AddEphemeralNode(ctx context.Context, w io.Writer, flags FlagsMap) (*Node, error) {
node := NewNode("")
node.Flags = flags
node.IsEphemeral = true
if err := n.StartNode(ctx, w, node); err != nil {
return nil, err
}
return node, nil
}

// Starts the provided node after configuring it for the network.
func (n *Network) StartNode(ctx context.Context, w io.Writer, node *Node) error {
if err := n.EnsureNodeConfig(node); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions tests/fixture/tmpnet/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ func NewNode(dataDir string) *Node {
}
}

// Initializes an ephemeral node using the provided config flags
func NewEphemeralNode(flags FlagsMap) *Node {
node := NewNode("")
node.Flags = flags
node.IsEphemeral = true

return node
}

// Initializes the specified number of nodes.
func NewNodes(count int) []*Node {
nodes := make([]*Node, count)
Expand Down

0 comments on commit d4507bf

Please sign in to comment.