Skip to content

Commit

Permalink
Tweaks to stress test
Browse files Browse the repository at this point in the history
Summary:
1. Use unix sockets, rather than tcp. For some reason using TCP results in a lot of noise coming in (logs spamming) - I have an unconfirmed theory that devservers come with some sort of system that continuously probes open TCP ports. This system tries connecting to frequently used ports (such as our TCP port during stress test). No such issue with unix sockets.
2. Add a dial timeout to make sure the test never hangs.
3. Add log statements to make errors more visible.

Reviewed By: mahmednabil109

Differential Revision: D68249101

fbshipit-source-id: 368efe901cc30f46cb1900766242072402010ba8
  • Loading branch information
echistyakov authored and facebook-github-bot committed Jan 16, 2025
1 parent 13da71c commit 0720c72
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions thrift/lib/go/thrift/stress/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ func TestServerStress(t *testing.T) {
runStressTest(t, thrift.TransportIDHeader)
})
// t.Run("UpgradeToRocket", func(t *testing.T) {
// runStressTest(t, TransportIDUpgradeToRocket)
// runStressTest(t, thrift.TransportIDUpgradeToRocket)
// })
// t.Run("Rocket", func(t *testing.T) {
// runStressTest(t, TransportIDRocket)
// runStressTest(t, thrift.TransportIDRocket)
// })
}

func runStressTest(t *testing.T, serverTransport thrift.TransportID) {
listener, err := net.Listen("tcp", "[::]:0")
listener, err := net.Listen("unix", fmt.Sprintf("/tmp/thrift_go_stress_server_test_%d.sock", os.Getpid()))
if err != nil {
t.Fatalf("could not create listener: %s", err)
}
Expand Down Expand Up @@ -91,18 +91,22 @@ func runStressTest(t *testing.T, serverTransport thrift.TransportID) {
conn, err := thrift.NewClient(
clientTransportOption,
thrift.WithDialer(func() (net.Conn, error) {
return net.Dial("tcp", addr.String())
return net.DialTimeout("unix", addr.String(), 5*time.Second)
}),
thrift.WithIoTimeout(5*time.Second),
)
if err != nil {
return fmt.Errorf("failed to create client: %v", err)
errRes := fmt.Errorf("failed to create client: %v", err)
t.Log(errRes.Error())
return errRes
}
client := dummy.NewDummyClient(conn)
defer client.Close()
result, err := client.Echo("hello")
if err != nil {
return fmt.Errorf("failed to make RPC: %v", err)
errRes := fmt.Errorf("failed to make RPC: %v", err)
t.Log(errRes.Error())
return errRes
}
if result != "hello" {
return fmt.Errorf("unexpected RPC result: %s", result)
Expand Down

0 comments on commit 0720c72

Please sign in to comment.