summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYuxuan 'fishy' Wang <yuxuan.wang@reddit.com>2021-08-09 14:27:48 -0700
committerYuxuan 'fishy' Wang <fishywang@gmail.com>2021-08-11 11:08:49 -0700
commitfb539ae41297c369439bea6edf39186f92f408dc (patch)
tree83abd3dfce84e463439d605438976d9115daadb1 /test
parent82a9c67405602ff053146a8df6bd566d90a9bf03 (diff)
downloadthrift-fb539ae41297c369439bea6edf39186f92f408dc.tar.gz
THRIFT-5453: Defer DNS from NewTSocketConf to TSocket.Open
Client: go We used to do DNS lookups in NewTSocketConf, without any timeout checks. Stop doing that and do DNS lookups in TSocket.Open instead, which already checks for ConnectTimeout set in TConfiguration. Also remove the error return from NewTSocketConf.
Diffstat (limited to 'test')
-rw-r--r--test/go/genmock.sh2
-rw-r--r--test/go/src/bin/stress/main.go28
-rw-r--r--test/go/src/common/client.go10
3 files changed, 20 insertions, 20 deletions
diff --git a/test/go/genmock.sh b/test/go/genmock.sh
index bccfdf351..27cd0c43e 100644
--- a/test/go/genmock.sh
+++ b/test/go/genmock.sh
@@ -9,4 +9,4 @@ GO111MODULE=on go install -mod=mod github.com/golang/mock/mockgen
`go env GOPATH`/bin/mockgen -build_flags "-mod=mod" -destination=src/common/mock_handler.go -package=common github.com/apache/thrift/test/go/src/gen/thrifttest ThriftTest
-rm -Rf $GOPATH
+chmod a+w -R $GOPATH && rm -Rf $GOPATH
diff --git a/test/go/src/bin/stress/main.go b/test/go/src/bin/stress/main.go
index 3ff0a3969..9f3267654 100644
--- a/test/go/src/bin/stress/main.go
+++ b/test/go/src/bin/stress/main.go
@@ -158,13 +158,11 @@ func main() {
}
func client(protocolFactory thrift.TProtocolFactory) {
- trans, err := thrift.NewTSocket(hostPort)
- if err != nil {
- log.Fatalf("Unable to create server socket: %s", err)
- }
+ ctx := context.Background()
+ trans := thrift.NewTSocketConf(hostPort, nil)
btrans := thrift.NewTBufferedTransport(trans, 2048)
client := stress.NewServiceClientFactory(btrans, protocolFactory)
- err = trans.Open()
+ err := trans.Open()
if err != nil {
log.Fatalf("Unable to open connection: %s", err)
}
@@ -173,45 +171,45 @@ func client(protocolFactory thrift.TProtocolFactory) {
switch callType {
case echoVoid:
for i := 0; i < *loop; i++ {
- client.EchoVoid()
+ client.EchoVoid(ctx)
atomic.AddInt64(&clicounter, 1)
}
case echoByte:
for i := 0; i < *loop; i++ {
- client.EchoByte(42)
+ client.EchoByte(ctx, 42)
atomic.AddInt64(&clicounter, 1)
}
case echoI32:
for i := 0; i < *loop; i++ {
- client.EchoI32(4242)
+ client.EchoI32(ctx, 4242)
atomic.AddInt64(&clicounter, 1)
}
case echoI64:
for i := 0; i < *loop; i++ {
- client.EchoI64(424242)
+ client.EchoI64(ctx, 424242)
atomic.AddInt64(&clicounter, 1)
}
case echoString:
for i := 0; i < *loop; i++ {
- client.EchoString("TestString")
+ client.EchoString(ctx, "TestString")
atomic.AddInt64(&clicounter, 1)
}
case echiList:
l := []int8{-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}
for i := 0; i < *loop; i++ {
- client.EchoList(l)
+ client.EchoList(ctx, l)
atomic.AddInt64(&clicounter, 1)
}
case echoSet:
- s := map[int8]struct{}{-10: {}, -9: {}, -8: {}, -7: {}, -6: {}, -5: {}, -4: {}, -3: {}, -2: {}, -1: {}, 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, 8: {}}
+ s := []int8{-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}
for i := 0; i < *loop; i++ {
- client.EchoSet(s)
+ client.EchoSet(ctx, s)
atomic.AddInt64(&clicounter, 1)
}
case echoMap:
m := map[int8]int8{-10: 10, -9: 9, -8: 8, -7: 7, -6: 6, -5: 5, -4: 4, -3: 3, -2: 2, -1: 1, 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8}
for i := 0; i < *loop; i++ {
- client.EchoMap(m)
+ client.EchoMap(ctx, m)
atomic.AddInt64(&clicounter, 1)
}
}
@@ -245,7 +243,7 @@ func (h *handler) EchoList(ctx context.Context, arg []int8) (r []int8, err error
atomic.AddInt64(&counter, 1)
return arg, nil
}
-func (h *handler) EchoSet(ctx context.Context, arg map[int8]struct{}) (r map[int8]struct{}, err error) {
+func (h *handler) EchoSet(ctx context.Context, arg []int8) (r []int8, err error) {
atomic.AddInt64(&counter, 1)
return arg, nil
}
diff --git a/test/go/src/common/client.go b/test/go/src/common/client.go
index 15973d82c..201503538 100644
--- a/test/go/src/common/client.go
+++ b/test/go/src/common/client.go
@@ -62,15 +62,17 @@ func StartClient(
return nil, nil, fmt.Errorf("Invalid protocol specified %s", protocol)
}
if debugClientProtocol {
- protocolFactory = thrift.NewTDebugProtocolFactory(protocolFactory, "client:")
+ protocolFactory = thrift.NewTDebugProtocolFactoryWithLogger(protocolFactory, "client:", thrift.StdLogger(nil))
}
if ssl {
- trans, err = thrift.NewTSSLSocket(hostPort, &tls.Config{InsecureSkipVerify: true})
+ trans, err = thrift.NewTSSLSocketConf(hostPort, &thrift.TConfiguration{
+ TLSConfig: &tls.Config{InsecureSkipVerify: true},
+ })
} else {
if domain_socket != "" {
- trans, err = thrift.NewTSocket(domain_socket)
+ trans = thrift.NewTSocketConf(domain_socket, nil)
} else {
- trans, err = thrift.NewTSocket(hostPort)
+ trans = thrift.NewTSocketConf(hostPort, nil)
}
}
if err != nil {