Skip to content

feat: add oneway-pingpong test #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions thriftrpc/normalcall/normalcall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cloudwego/kitex-tests/thriftrpc"
"github.com/cloudwego/kitex/client"
"github.com/cloudwego/kitex/client/callopt"
"github.com/cloudwego/kitex/pkg/connpool"
"github.com/cloudwego/kitex/pkg/kerrors"
"github.com/cloudwego/kitex/transport"
)
Expand Down Expand Up @@ -136,6 +137,18 @@ func TestVisitOneway(t *testing.T) {
test.Assert(t, atomic.LoadInt32(&thriftrpc.CheckNum) == int32(3))
}

func TestOnewayPingPongByTurns(t *testing.T) {
cli := getKitexClient(transport.TTHeaderFramed, client.WithLongConnection(connpool.IdleConfig{MaxIdlePerAddress: 10, MaxIdleGlobal: 1000, MaxIdleTimeout: time.Second * 3}))
ctx, stReq := thriftrpc.CreateSTRequest(context.Background())
stReq.MockCost = &(&struct{ x string }{x: "300ms"}).x
err := cli.VisitOneway(ctx, stReq)
test.Assert(t, err == nil, err)

ctx, stReq = thriftrpc.CreateSTRequest(context.Background())
_, err = cli.TestSTReq(ctx, stReq, callopt.WithRPCTimeout(time.Millisecond*300))
test.Assert(t, err == nil, err)
}

func TestRPCTimeoutPriority(t *testing.T) {
cli := getKitexClient(transport.TTHeaderFramed, client.WithRPCTimeout(500*time.Millisecond))
ctx, stReq := thriftrpc.CreateSTRequest(context.Background())
Expand Down
7 changes: 7 additions & 0 deletions thriftrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ var CheckNum int32

func (*STServiceHandler) VisitOneway(ctx context.Context, req *stability.STRequest) (err error) {
atomic.AddInt32(&CheckNum, 1)
if req.MockCost != nil {
if mockSleep, err := time.ParseDuration(*req.MockCost); err != nil {
return err
} else {
time.Sleep(mockSleep)
}
}
return nil
}

Expand Down