Skip to content

Commit 7ec4aea

Browse files
committed
fix: ci grid proxy binary flags to handle test
Signed-off-by: nabil salah <[email protected]>
1 parent 2d552fc commit 7ec4aea

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

.github/workflows/grid-proxy-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
pushd tools/db
5353
go run . --seed 13 --postgres-host localhost --postgres-db tfgrid-graphql --postgres-password postgres --postgres-user postgres --reset
5454
popd
55-
go run cmds/proxy_server/main.go -no-cert -no-indexer --address :8080 --log-level debug --postgres-host localhost --postgres-db tfgrid-graphql --postgres-password postgres --postgres-user postgres --mnemonics "$MNEMONICS" &
55+
go run cmds/proxy_server/main.go --rate-limit-rps 1000 -no-cert -no-indexer --address :8080 --log-level debug --postgres-host localhost --postgres-db tfgrid-graphql --postgres-password postgres --postgres-user postgres --mnemonics "$MNEMONICS" &
5656
sleep 10
5757
pushd tests/queries
5858
go test -v --seed 13 -no-modify --postgres-host localhost --postgres-db tfgrid-graphql --postgres-password postgres --postgres-user postgres --endpoint http://localhost:8080

grid-proxy/internal/explorer/mw/ratelimiter.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ func (rlm *RateLimiterMiddleware) RateLimitAction(action Action) Action {
4444
// RateLimitProxyAction wraps a ProxyAction with rate limiting
4545
func (rlm *RateLimiterMiddleware) RateLimitProxyAction(action ProxyAction) ProxyAction {
4646
return func(r *http.Request) (*http.Response, Response) {
47-
// Get client IP
4847
clientIP := ratelimiter.GetClientIP(r)
49-
50-
// Check rate limit
5148
if !rlm.limiter.Allow(clientIP) {
5249
log.Warn().
5350
Str("ip", clientIP).
@@ -58,7 +55,6 @@ func (rlm *RateLimiterMiddleware) RateLimitProxyAction(action ProxyAction) Proxy
5855
return nil, rlm.TooManyRequests(fmt.Errorf("rate limit exceeded for IP: %s", clientIP), clientIP)
5956
}
6057

61-
// Rate limit passed, execute the original action
6258
return action(r)
6359
}
6460
}

grid-proxy/internal/explorer/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,6 @@ func Setup(router *mux.Router, gitCommit string, cl DBClient, relayClient rmb.Cl
638638
idxIntervals: idxIntervals,
639639
}
640640

641-
// Create rate limiter middleware if rate limiting is enabled
642641
var rateLimiter *mw.RateLimiterMiddleware
643642
if rateLimitRPS > 0 {
644643
rateLimiter = mw.NewRateLimiterMiddleware(rateLimitRPS)

grid-proxy/tools/ratelimiter/sliding_window_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ func TestGetClientIP(t *testing.T) {
5757
}
5858

5959
func TestSlidingWindowRateLimiter(t *testing.T) {
60-
limiter := NewSlidingWindowRateLimiter(2) // 2 requests per second
60+
limiter := NewSlidingWindowRateLimiter(2)
6161

62-
// Test that we can make 2 requests immediately
6362
if !limiter.Allow("192.168.1.1") {
6463
t.Error("First request should be allowed")
6564
}
6665
if !limiter.Allow("192.168.1.1") {
6766
t.Error("Second request should be allowed")
6867
}
6968

70-
// Third request should be blocked
7169
if limiter.Allow("192.168.1.1") {
7270
t.Error("Third request should be blocked")
7371
}
@@ -78,7 +76,7 @@ func TestSlidingWindowRateLimiter(t *testing.T) {
7876
}
7977

8078
// After waiting, requests should be allowed again
81-
time.Sleep(1100 * time.Millisecond) // Wait for window to slide
79+
time.Sleep(1100 * time.Millisecond)
8280
if !limiter.Allow("192.168.1.1") {
8381
t.Error("Request should be allowed after window slide")
8482
}
@@ -104,7 +102,7 @@ func TestSlidingWindowRateLimiterStats(t *testing.T) {
104102
}
105103

106104
func TestGetCurrentRequestCountAndRateLimit(t *testing.T) {
107-
limiter := NewSlidingWindowRateLimiter(5) // 5 requests per second
105+
limiter := NewSlidingWindowRateLimiter(5)
108106

109107
// Test rate limit getter
110108
if limiter.GetRateLimit() != 5 {

0 commit comments

Comments
 (0)