From aea107b95aa6d6e2c9e66a3064baac7887bc8952 Mon Sep 17 00:00:00 2001 From: Emi Gutekanst Date: Tue, 3 Dec 2024 18:53:34 -0700 Subject: [PATCH 1/2] Use the new URLs --- cmd/src/gateway_benchmark.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/src/gateway_benchmark.go b/cmd/src/gateway_benchmark.go index ef3749fb8f..d12128aa47 100644 --- a/cmd/src/gateway_benchmark.go +++ b/cmd/src/gateway_benchmark.go @@ -71,7 +71,7 @@ Examples: return fmt.Errorf("WebSocket dial(%s): %v", wsURL, err) } endpoints["ws(s): gateway"] = gatewayWebsocket - endpoints["http(s): gateway"] = fmt.Sprint(*gatewayEndpoint, "/v2") + endpoints["http(s): gateway"] = fmt.Sprint(*gatewayEndpoint, "/v2/http") } if cfg.Endpoint != "" { wsURL := strings.Replace(fmt.Sprint(cfg.Endpoint, "/.api/gateway/websocket"), "http", "ws", 1) @@ -80,7 +80,7 @@ Examples: return fmt.Errorf("WebSocket dial(%s): %v", wsURL, err) } endpoints["ws(s): sourcegraph"] = sourcegraphWebsocket - endpoints["http(s): sourcegraph"] = fmt.Sprint(*gatewayEndpoint, "/.api/gateway") + endpoints["http(s): sourcegraph"] = fmt.Sprint(*gatewayEndpoint, "/.api/gateway/http") } fmt.Printf("Starting benchmark with %d requests per endpoint...\n", *requestCount) From 5634574ba0a52063fd403a7e7668c0ff3f0cc52e Mon Sep 17 00:00:00 2001 From: David Veszelovszki Date: Wed, 4 Dec 2024 14:06:49 +0100 Subject: [PATCH 2/2] Add new CLI flag to work with local Sourcegraph --- cmd/src/gateway_benchmark.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/src/gateway_benchmark.go b/cmd/src/gateway_benchmark.go index d12128aa47..babc64a8d1 100644 --- a/cmd/src/gateway_benchmark.go +++ b/cmd/src/gateway_benchmark.go @@ -38,6 +38,7 @@ Examples: $ src gateway benchmark $ src gateway benchmark --requests 50 + $ src gateway benchmark --gateway http://localhost:9992 --sourcegraph http://localhost:3082 $ src gateway benchmark --requests 50 --csv results.csv ` @@ -47,6 +48,7 @@ Examples: requestCount = flagSet.Int("requests", 1000, "Number of requests to make per endpoint") csvOutput = flagSet.String("csv", "", "Export results to CSV file (provide filename)") gatewayEndpoint = flagSet.String("gateway", "https://cody-gateway.sourcegraph.com", "Cody Gateway endpoint") + sgEndpoint = flagSet.String("sourcegraph", "https://sourcegraph.com", "Sourcegraph endpoint") ) handler := func(args []string) error { @@ -73,14 +75,14 @@ Examples: endpoints["ws(s): gateway"] = gatewayWebsocket endpoints["http(s): gateway"] = fmt.Sprint(*gatewayEndpoint, "/v2/http") } - if cfg.Endpoint != "" { - wsURL := strings.Replace(fmt.Sprint(cfg.Endpoint, "/.api/gateway/websocket"), "http", "ws", 1) + if *sgEndpoint != "" { + wsURL := strings.Replace(fmt.Sprint(*sgEndpoint, "/.api/gateway/websocket"), "http", "ws", 1) sourcegraphWebsocket, _, err = websocket.DefaultDialer.Dial(wsURL, nil) if err != nil { return fmt.Errorf("WebSocket dial(%s): %v", wsURL, err) } endpoints["ws(s): sourcegraph"] = sourcegraphWebsocket - endpoints["http(s): sourcegraph"] = fmt.Sprint(*gatewayEndpoint, "/.api/gateway/http") + endpoints["http(s): sourcegraph"] = fmt.Sprint(*sgEndpoint, "/.api/gateway/http") } fmt.Printf("Starting benchmark with %d requests per endpoint...\n", *requestCount)