Skip to content

Commit

Permalink
[antithesis] Enable custom plugin dir for subnet-evm
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Aug 19, 2024
1 parent eea2b00 commit bb508a6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 27 additions & 0 deletions tests/antithesis/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit bb508a6

Please sign in to comment.