mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-17 05:59:42 +02:00
Add context parameter to TCP/UDP stream health checks and client constructors for proper cancellation and deadline propagation. Switch from encoding/json to sonic for faster JSON unmarshaling. Standardize HTTP client timeouts to 5 seconds across agent pool and health check.
27 lines
612 B
Go
27 lines
612 B
Go
package stream_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/yusing/godoxy/agent/pkg/agent/stream"
|
|
)
|
|
|
|
func TestTCPHealthCheck(t *testing.T) {
|
|
certs := genTestCerts(t)
|
|
|
|
srv := startTCPServer(t, certs)
|
|
|
|
err := stream.TCPHealthCheck(t.Context(), srv.Addr.String(), certs.CaCert, certs.ClientCert)
|
|
require.NoError(t, err, "health check")
|
|
}
|
|
|
|
func TestUDPHealthCheck(t *testing.T) {
|
|
certs := genTestCerts(t)
|
|
|
|
srv := startUDPServer(t, certs)
|
|
|
|
err := stream.UDPHealthCheck(t.Context(), srv.Addr.String(), certs.CaCert, certs.ClientCert)
|
|
require.NoError(t, err, "health check")
|
|
}
|