Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type LoadConfig struct {
Scenarios []Scenario `json:"scenarios,omitempty"`
MockDeploy bool `json:"mockDeploy,omitempty"`
Settings *Settings `json:"settings,omitempty"`
// Path to write a JSON report of the load test.
ReportPath string `json:"reportPath,omitempty"`
}

// Duration wraps time.Duration to provide JSON unmarshaling support
Expand Down
5 changes: 5 additions & 0 deletions config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Settings struct {
TrackUserLatency bool `json:"trackUserLatency"`
Prewarm bool `json:"prewarm"`
RampUp bool `json:"rampUp"`
ReportPath string `json:"reportPath"`
}

// DefaultSettings returns the default configuration values
Expand All @@ -37,6 +38,7 @@ func DefaultSettings() Settings {
TrackUserLatency: false,
Prewarm: false,
RampUp: false,
ReportPath: "",
}
}

Expand All @@ -55,6 +57,7 @@ func InitializeViper(cmd *cobra.Command) error {
"trackUserLatency": "track-user-latency",
"workers": "workers",
"rampUp": "ramp-up",
"reportPath": "report-path",
}

for viperKey, flagName := range flagBindings {
Expand All @@ -76,6 +79,7 @@ func InitializeViper(cmd *cobra.Command) error {
viper.SetDefault("trackUserLatency", defaults.TrackUserLatency)
viper.SetDefault("workers", defaults.Workers)
viper.SetDefault("rampUp", defaults.RampUp)
viper.SetDefault("reportPath", defaults.ReportPath)
return nil
}

Expand Down Expand Up @@ -107,5 +111,6 @@ func ResolveSettings() Settings {
TrackUserLatency: viper.GetBool("trackUserLatency"),
Prewarm: viper.GetBool("prewarm"),
RampUp: viper.GetBool("rampUp"),
ReportPath: viper.GetString("reportPath"),
}
}
2 changes: 2 additions & 0 deletions config/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func TestArgumentPrecedence(t *testing.T) {
cmd.Flags().Bool("track-user-latency", false, "Track user latency")
cmd.Flags().Int("buffer-size", 0, "Buffer size")
cmd.Flags().Bool("ramp-up", false, "Ramp up loadtest")
cmd.Flags().String("report-path", "", "Report path")

// Parse CLI args
if len(tt.cliArgs) > 0 {
Expand Down Expand Up @@ -130,6 +131,7 @@ func TestDefaultSettings(t *testing.T) {
TrackUserLatency: false,
Prewarm: false,
RampUp: false,
ReportPath: "",
}

if defaults != expected {
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func init() {
rootCmd.Flags().IntP("nodes", "n", 0, "Number of nodes/endpoints to use (0 = use all)")
rootCmd.Flags().String("metricsListenAddr", "0.0.0.0:9090", "The ip:port on which to export prometheus metrics.")
rootCmd.Flags().Bool("ramp-up", false, "Ramp up loadtest")
rootCmd.Flags().String("report-path", "", "Path to save the report")

// Initialize Viper with proper error handling
if err := config.InitializeViper(rootCmd); err != nil {
Expand Down Expand Up @@ -148,7 +149,7 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {

// Create statistics collector and logger
collector := stats.NewCollector()
logger := stats.NewLogger(collector, settings.StatsInterval.ToDuration(), settings.Debug)
logger := stats.NewLogger(collector, settings.StatsInterval.ToDuration(), settings.ReportPath, settings.Debug)
var ramper *sender.Ramper

err = service.Run(ctx, func(ctx context.Context, s service.Scope) error {
Expand Down
30 changes: 30 additions & 0 deletions profiles/autobake_evm_transfer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"chainId": 713714,
"seiChainId": "sei-autobake",
"endpoints": [
"https://evm-rpc.sei-autobake.seinetwork.io"
],
"accounts": {
"count": 5000,
"newAccountRate": 0.0
},
"scenarios": [
{
"name": "EVMTransfer",
"weight": 1
}
],
"settings": {
"workers": 500,
"tps": 0,
"statsInterval": "5s",
"bufferSize": 1000,
"dryRun": false,
"debug": false,
"trackReceipts": false,
"trackBlocks": false,
"trackUserLatency": false,
"prewarm": false,
"reportPath": "/home/ubuntu/evm_transfer_report.txt"
}
}
5 changes: 1 addition & 4 deletions stats/block_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"log"
"sort"
"strings"
"time"

"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -57,9 +56,7 @@ func NewBlockCollector(seiChainID string) *BlockCollector {

// Start begins block subscription and data collection
func (bc *BlockCollector) Run(ctx context.Context, firstEndpoint string) error {
// Convert HTTP endpoint to WebSocket endpoint (8545 -> 8546)
wsEndpoint := strings.Replace(firstEndpoint, ":8545", ":8546", 1)
wsEndpoint = strings.Replace(wsEndpoint, "http://", "ws://", 1)
wsEndpoint := utils.GetWSEndpoint(firstEndpoint)
return service.Run(ctx, func(ctx context.Context, s service.Scope) error {
// Connect to WebSocket endpoint
client, err := ethclient.Dial(wsEndpoint)
Expand Down
Loading
Loading