修复代理与日志链路的可靠性问题
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package config_test
|
||||
|
||||
import (
|
||||
"math"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -50,6 +52,9 @@ func TestLoadQueueDefaults(t *testing.T) {
|
||||
if cfg.MaxBodyBytes != 1<<20 {
|
||||
t.Fatalf("MaxBodyBytes=%d want %d", cfg.MaxBodyBytes, 1<<20)
|
||||
}
|
||||
if cfg.MaxRequestBytes != 16<<20 {
|
||||
t.Fatalf("MaxRequestBytes=%d want %d", cfg.MaxRequestBytes, 16<<20)
|
||||
}
|
||||
if cfg.LogQueueSize != 256 {
|
||||
t.Fatalf("LogQueueSize=%d want 256", cfg.LogQueueSize)
|
||||
}
|
||||
@@ -242,6 +247,23 @@ func TestLoadRequiresClickHouseURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsUnsupportedUpstreamScheme(t *testing.T) {
|
||||
t.Setenv("UPSTREAM_URL", "ftp://example.com")
|
||||
t.Setenv("CLICKHOUSE_URL", "clickhouse://user:pass@localhost:9000/db")
|
||||
if _, err := config.Load(); err == nil {
|
||||
t.Fatal("Load succeeded with unsupported UPSTREAM_URL scheme")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsMaxRequestBytesOverflowBoundary(t *testing.T) {
|
||||
t.Setenv("UPSTREAM_URL", "https://example.com")
|
||||
t.Setenv("CLICKHOUSE_URL", "clickhouse://user:pass@localhost:9000/db")
|
||||
t.Setenv("MAX_REQUEST_BYTES", strconv.FormatInt(math.MaxInt64, 10))
|
||||
if _, err := config.Load(); err == nil || !strings.Contains(err.Error(), "MAX_REQUEST_BYTES") {
|
||||
t.Fatalf("Load error=%v, want MAX_REQUEST_BYTES rejection", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadValidatesClickHouseURL(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user