-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple changes to improve UX of the test command: 1. Add `charon test all` that runs all 5 test commands 2. Shorten the ENRs and MEV relays URLs hashes when outputting results 3. Sort the targets of the tests (so that it's easier to follow consecutive re-ran tests) Also do some refactoring of the functions. category: feature ticket: none
- Loading branch information
1 parent
88ebdbd
commit 683918a
Showing
10 changed files
with
958 additions
and
888 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright © 2022-2024 Obol Labs Inc. Licensed under the terms of a Business Source License 1.1 | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/obolnetwork/charon/app/errors" | ||
) | ||
|
||
type testAllConfig struct { | ||
testConfig | ||
Peers testPeersConfig | ||
Beacon testBeaconConfig | ||
Validator testValidatorConfig | ||
MEV testMEVConfig | ||
Performance testPerformanceConfig | ||
} | ||
|
||
func newTestAllCmd(runFunc func(context.Context, io.Writer, testAllConfig) error) *cobra.Command { | ||
var config testAllConfig | ||
|
||
cmd := &cobra.Command{ | ||
Use: "all", | ||
Short: "Run tests towards peer nodes, beacon nodes, validator client, MEV relays, own hardware and internet connectivity.", | ||
Long: `Run tests towards peer nodes, beacon nodes, validator client, MEV relays, own hardware and internet connectivity. Verify that Charon can efficiently do its duties on the tested setup.`, | ||
Args: cobra.NoArgs, | ||
PreRunE: func(cmd *cobra.Command, _ []string) error { | ||
return mustOutputToFileOnQuiet(cmd) | ||
}, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
return runFunc(cmd.Context(), cmd.OutOrStdout(), config) | ||
}, | ||
} | ||
|
||
bindTestFlags(cmd, &config.testConfig) | ||
|
||
bindTestPeersFlags(cmd, &config.Peers, "peers-") | ||
bindTestBeaconFlags(cmd, &config.Beacon, "beacon-") | ||
bindTestValidatorFlags(cmd, &config.Validator, "validator-") | ||
bindTestMEVFlags(cmd, &config.MEV, "mev-") | ||
bindTestPerformanceFlags(cmd, &config.Performance, "performance-") | ||
|
||
bindP2PFlags(cmd, &config.Peers.P2P) | ||
bindDataDirFlag(cmd.Flags(), &config.Peers.DataDir) | ||
bindTestLogFlags(cmd.Flags(), &config.Peers.Log) | ||
|
||
wrapPreRunE(cmd, func(cmd *cobra.Command, _ []string) error { | ||
testCasesPresent := cmd.Flags().Lookup("test-cases").Changed | ||
|
||
if testCasesPresent { | ||
//nolint:revive // we use our own version of the errors package | ||
return errors.New("test-cases cannot be specified when explicitly running all test cases.") | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
return cmd | ||
} | ||
|
||
func runTestAll(ctx context.Context, w io.Writer, cfg testAllConfig) (err error) { | ||
cfg.Beacon.testConfig = cfg.testConfig | ||
err = runTestBeacon(ctx, w, cfg.Beacon) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfg.Validator.testConfig = cfg.testConfig | ||
err = runTestValidator(ctx, w, cfg.Validator) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfg.MEV.testConfig = cfg.testConfig | ||
err = runTestMEV(ctx, w, cfg.MEV) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfg.Performance.testConfig = cfg.testConfig | ||
err = runTestPerformance(ctx, w, cfg.Performance) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfg.Peers.testConfig = cfg.testConfig | ||
err = runTestPeers(ctx, w, cfg.Peers) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.