From bb508a69e07842a7646d2541cc7b273dfc0fc29f Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Fri, 16 Aug 2024 02:08:40 -0700 Subject: [PATCH] [antithesis] Enable custom plugin dir for subnet-evm --- tests/antithesis/compose.go | 27 +++++++++++++++++++++++++++ tests/fixture/tmpnet/network.go | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/antithesis/compose.go b/tests/antithesis/compose.go index f11ac0288ea..53f4d5ee22e 100644 --- a/tests/antithesis/compose.go +++ b/tests/antithesis/compose.go @@ -61,9 +61,27 @@ func GenerateComposeConfig(network *tmpnet.Network, baseImageName string) error return fmt.Errorf("failed to get bootstrap volume path: %w", err) } + // Save the plugin dir for use with compose configuration and remove it from flags so pluginDir can + // be used for the db-initialization bootstrap. + // + // TODO(marun) Separate bootstrap configuration from runtime configuration to avoid having to do this + pluginDirForCompose, err := network.GetPluginDir() + if err != nil { + return fmt.Errorf("failed to get plugin dir: %w", err) + } + delete(network.DefaultFlags, config.PluginDirKey) + if err := initBootstrapDB(network, avalancheGoPath, pluginDir, bootstrapVolumePath); err != nil { return fmt.Errorf("failed to initialize db volumes: %w", err) } + + if len(pluginDirForCompose) > 0 { + // Restore the plugin dir + network.DefaultFlags[config.PluginDirKey] = pluginDirForCompose + } else { + // Ensure the plugin dir is not provided so that the default is used + delete(network.DefaultFlags, config.PluginDirKey) + } } nodeImageName := fmt.Sprintf("%s-node:%s", baseImageName, imageTag) @@ -160,6 +178,15 @@ func newComposeProject(network *tmpnet.Network, nodeImageName string, workloadIm config.StakingSignerKeyContentKey: signerKey, } + // Set a non-default plugin dir if provided + pluginDir, err := network.GetPluginDir() + if err != nil { + return nil, err + } + if len(pluginDir) > 0 { + env[config.PluginDirKey] = pluginDir + } + // Apply configuration appropriate to a test network for k, v := range tmpnet.DefaultTestFlags() { switch value := v.(type) { diff --git a/tests/fixture/tmpnet/network.go b/tests/fixture/tmpnet/network.go index 68b4a7173e0..bed6db06fa2 100644 --- a/tests/fixture/tmpnet/network.go +++ b/tests/fixture/tmpnet/network.go @@ -289,7 +289,7 @@ func (n *Network) Create(rootDir string) error { n.Dir = canonicalDir // Ensure the existence of the plugin directory or nodes won't be able to start. - pluginDir, err := n.getPluginDir() + pluginDir, err := n.GetPluginDir() if err != nil { return err } @@ -463,7 +463,7 @@ func (n *Network) Bootstrap(ctx context.Context, w io.Writer) error { func (n *Network) StartNode(ctx context.Context, w io.Writer, node *Node) error { // This check is duplicative for a network that is starting, but ensures // that individual node start/restart won't fail due to missing binaries. - pluginDir, err := n.getPluginDir() + pluginDir, err := n.GetPluginDir() if err != nil { return err } @@ -877,7 +877,7 @@ func (n *Network) GetNetworkID() uint32 { return n.NetworkID } -func (n *Network) getPluginDir() (string, error) { +func (n *Network) GetPluginDir() (string, error) { return n.DefaultFlags.GetStringVal(config.PluginDirKey) }