Upgrading dependency to Thrift 0.12.0
This commit is contained in:
parent
3e4590dcc0
commit
356978cb42
1302 changed files with 101701 additions and 26784 deletions
17
vendor/git.apache.org/thrift.git/test/go/src/bin/stress/main.go
generated
vendored
17
vendor/git.apache.org/thrift.git/test/go/src/bin/stress/main.go
generated
vendored
|
@ -20,6 +20,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"gen/stress"
|
||||
|
@ -219,35 +220,35 @@ func client(protocolFactory thrift.TProtocolFactory) {
|
|||
|
||||
type handler struct{}
|
||||
|
||||
func (h *handler) EchoVoid() (err error) {
|
||||
func (h *handler) EchoVoid(ctx context.Context) (err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return nil
|
||||
}
|
||||
func (h *handler) EchoByte(arg int8) (r int8, err error) {
|
||||
func (h *handler) EchoByte(ctx context.Context, arg int8) (r int8, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
func (h *handler) EchoI32(arg int32) (r int32, err error) {
|
||||
func (h *handler) EchoI32(ctx context.Context, arg int32) (r int32, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
func (h *handler) EchoI64(arg int64) (r int64, err error) {
|
||||
func (h *handler) EchoI64(ctx context.Context, arg int64) (r int64, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
func (h *handler) EchoString(arg string) (r string, err error) {
|
||||
func (h *handler) EchoString(ctx context.Context, arg string) (r string, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
func (h *handler) EchoList(arg []int8) (r []int8, err error) {
|
||||
func (h *handler) EchoList(ctx context.Context, arg []int8) (r []int8, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
func (h *handler) EchoSet(arg map[int8]struct{}) (r map[int8]struct{}, err error) {
|
||||
func (h *handler) EchoSet(ctx context.Context, arg map[int8]struct{}) (r map[int8]struct{}, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
func (h *handler) EchoMap(arg map[int8]int8) (r map[int8]int8, err error) {
|
||||
func (h *handler) EchoMap(ctx context.Context, arg map[int8]int8) (r map[int8]int8, err error) {
|
||||
atomic.AddInt64(&counter, 1)
|
||||
return arg, nil
|
||||
}
|
||||
|
|
104
vendor/git.apache.org/thrift.git/test/go/src/bin/testclient/main.go
generated
vendored
104
vendor/git.apache.org/thrift.git/test/go/src/bin/testclient/main.go
generated
vendored
|
@ -21,6 +21,7 @@ package main
|
|||
|
||||
import (
|
||||
"common"
|
||||
"context"
|
||||
"flag"
|
||||
"gen/thrifttest"
|
||||
t "log"
|
||||
|
@ -34,11 +35,12 @@ var domain_socket = flag.String("domain-socket", "", "Domain Socket (e.g. /tmp/t
|
|||
var transport = flag.String("transport", "buffered", "Transport: buffered, framed, http, zlib")
|
||||
var protocol = flag.String("protocol", "binary", "Protocol: binary, compact, json")
|
||||
var ssl = flag.Bool("ssl", false, "Encrypted Transport using SSL")
|
||||
var zlib = flag.Bool("zlib", false, "Wrapped Transport using Zlib")
|
||||
var testloops = flag.Int("testloops", 1, "Number of Tests")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
client, err := common.StartClient(*host, *port, *domain_socket, *transport, *protocol, *ssl)
|
||||
client, _, err := common.StartClient(*host, *port, *domain_socket, *transport, *protocol, *ssl)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to start client: ", err)
|
||||
}
|
||||
|
@ -60,14 +62,15 @@ var xxs = &thrifttest.Xtruct{
|
|||
}
|
||||
|
||||
var xcept = &thrifttest.Xception{ErrorCode: 1001, Message: "Xception"}
|
||||
var defaultCtx = context.Background()
|
||||
|
||||
func callEverything(client *thrifttest.ThriftTestClient) {
|
||||
var err error
|
||||
if err = client.TestVoid(); err != nil {
|
||||
if err = client.TestVoid(defaultCtx); err != nil {
|
||||
t.Fatalf("Unexpected error in TestVoid() call: ", err)
|
||||
}
|
||||
|
||||
thing, err := client.TestString("thing")
|
||||
thing, err := client.TestString(defaultCtx, "thing")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestString() call: ", err)
|
||||
}
|
||||
|
@ -75,14 +78,14 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
|
||||
}
|
||||
|
||||
bl, err := client.TestBool(true)
|
||||
bl, err := client.TestBool(defaultCtx, true)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestBool() call: ", err)
|
||||
}
|
||||
if !bl {
|
||||
t.Fatalf("Unexpected TestBool() result expected true, got %f ", bl)
|
||||
}
|
||||
bl, err = client.TestBool(false)
|
||||
bl, err = client.TestBool(defaultCtx, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestBool() call: ", err)
|
||||
}
|
||||
|
@ -90,7 +93,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestBool() result expected false, got %f ", bl)
|
||||
}
|
||||
|
||||
b, err := client.TestByte(42)
|
||||
b, err := client.TestByte(defaultCtx, 42)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestByte() call: ", err)
|
||||
}
|
||||
|
@ -98,7 +101,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestByte() result expected 42, got %d ", b)
|
||||
}
|
||||
|
||||
i32, err := client.TestI32(4242)
|
||||
i32, err := client.TestI32(defaultCtx, 4242)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestI32() call: ", err)
|
||||
}
|
||||
|
@ -106,7 +109,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestI32() result expected 4242, got %d ", i32)
|
||||
}
|
||||
|
||||
i64, err := client.TestI64(424242)
|
||||
i64, err := client.TestI64(defaultCtx, 424242)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestI64() call: ", err)
|
||||
}
|
||||
|
@ -114,7 +117,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestI64() result expected 424242, got %d ", i64)
|
||||
}
|
||||
|
||||
d, err := client.TestDouble(42.42)
|
||||
d, err := client.TestDouble(defaultCtx, 42.42)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestDouble() call: ", err)
|
||||
}
|
||||
|
@ -126,19 +129,19 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
for i := 0; i < 256; i++ {
|
||||
binout[i] = byte(i)
|
||||
}
|
||||
bin, err := client.TestBinary(binout)
|
||||
bin, err := client.TestBinary(defaultCtx, binout)
|
||||
for i := 0; i < 256; i++ {
|
||||
if (binout[i] != bin[i]) {
|
||||
if binout[i] != bin[i] {
|
||||
t.Fatalf("Unexpected TestBinary() result expected %d, got %d ", binout[i], bin[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xs := thrifttest.NewXtruct()
|
||||
xs.StringThing = "thing"
|
||||
xs.ByteThing = 42
|
||||
xs.I32Thing = 4242
|
||||
xs.I64Thing = 424242
|
||||
xsret, err := client.TestStruct(xs)
|
||||
xsret, err := client.TestStruct(defaultCtx, xs)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestStruct() call: ", err)
|
||||
}
|
||||
|
@ -148,7 +151,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
|
||||
x2 := thrifttest.NewXtruct2()
|
||||
x2.StructThing = xs
|
||||
x2ret, err := client.TestNest(x2)
|
||||
x2ret, err := client.TestNest(defaultCtx, x2)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestNest() call: ", err)
|
||||
}
|
||||
|
@ -157,7 +160,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
}
|
||||
|
||||
m := map[int32]int32{1: 2, 3: 4, 5: 42}
|
||||
mret, err := client.TestMap(m)
|
||||
mret, err := client.TestMap(defaultCtx, m)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestMap() call: ", err)
|
||||
}
|
||||
|
@ -166,7 +169,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
}
|
||||
|
||||
sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
|
||||
smret, err := client.TestStringMap(sm)
|
||||
smret, err := client.TestStringMap(defaultCtx, sm)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestStringMap() call: ", err)
|
||||
}
|
||||
|
@ -174,25 +177,32 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestStringMap() result expected %#v, got %#v ", sm, smret)
|
||||
}
|
||||
|
||||
s := map[int32]struct{}{1: struct{}{}, 2: struct{}{}, 42: struct{}{}}
|
||||
sret, err := client.TestSet(s)
|
||||
s := []int32{1, 2, 42}
|
||||
sret, err := client.TestSet(defaultCtx, s)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestSet() call: ", err)
|
||||
}
|
||||
if !reflect.DeepEqual(s, sret) {
|
||||
t.Fatalf("Unexpected TestSet() result expected %#v, got %#v ", s, sret)
|
||||
// Sets can be in any order, but Go slices are ordered, so reflect.DeepEqual won't work.
|
||||
stemp := map[int32]struct{}{}
|
||||
for _, val := range s {
|
||||
stemp[val] = struct{}{}
|
||||
}
|
||||
for _, val := range sret {
|
||||
if _, ok := stemp[val]; !ok {
|
||||
t.Fatalf("Unexpected TestSet() result expected %#v, got %#v ", s, sret)
|
||||
}
|
||||
}
|
||||
|
||||
l := []int32{1, 2, 42}
|
||||
lret, err := client.TestList(l)
|
||||
lret, err := client.TestList(defaultCtx, l)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestList() call: ", err)
|
||||
}
|
||||
if !reflect.DeepEqual(l, lret) {
|
||||
t.Fatalf("Unexpected TestSet() result expected %#v, got %#v ", l, lret)
|
||||
t.Fatalf("Unexpected TestList() result expected %#v, got %#v ", l, lret)
|
||||
}
|
||||
|
||||
eret, err := client.TestEnum(thrifttest.Numberz_TWO)
|
||||
eret, err := client.TestEnum(defaultCtx, thrifttest.Numberz_TWO)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestEnum() call: ", err)
|
||||
}
|
||||
|
@ -200,7 +210,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
|
||||
}
|
||||
|
||||
tret, err := client.TestTypedef(thrifttest.UserId(42))
|
||||
tret, err := client.TestTypedef(defaultCtx, thrifttest.UserId(42))
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestTypedef() call: ", err)
|
||||
}
|
||||
|
@ -208,7 +218,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
|
||||
}
|
||||
|
||||
mapmap, err := client.TestMapMap(42)
|
||||
mapmap, err := client.TestMapMap(defaultCtx, 42)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestMapMap() call: ", err)
|
||||
}
|
||||
|
@ -217,44 +227,44 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
}
|
||||
|
||||
crazy := thrifttest.NewInsanity()
|
||||
crazy.UserMap = map[thrifttest.Numberz]thrifttest.UserId {
|
||||
thrifttest.Numberz_FIVE: 5,
|
||||
crazy.UserMap = map[thrifttest.Numberz]thrifttest.UserId{
|
||||
thrifttest.Numberz_FIVE: 5,
|
||||
thrifttest.Numberz_EIGHT: 8,
|
||||
}
|
||||
truck1 := thrifttest.NewXtruct()
|
||||
truck1.StringThing = "Goodbye4"
|
||||
truck1.ByteThing = 4;
|
||||
truck1.I32Thing = 4;
|
||||
truck1.I64Thing = 4;
|
||||
truck1.ByteThing = 4
|
||||
truck1.I32Thing = 4
|
||||
truck1.I64Thing = 4
|
||||
truck2 := thrifttest.NewXtruct()
|
||||
truck2.StringThing = "Hello2"
|
||||
truck2.ByteThing = 2;
|
||||
truck2.I32Thing = 2;
|
||||
truck2.I64Thing = 2;
|
||||
crazy.Xtructs = []*thrifttest.Xtruct {
|
||||
truck2.ByteThing = 2
|
||||
truck2.I32Thing = 2
|
||||
truck2.I64Thing = 2
|
||||
crazy.Xtructs = []*thrifttest.Xtruct{
|
||||
truck1,
|
||||
truck2,
|
||||
}
|
||||
insanity, err := client.TestInsanity(crazy)
|
||||
insanity, err := client.TestInsanity(defaultCtx, crazy)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestInsanity() call: ", err)
|
||||
}
|
||||
if !reflect.DeepEqual(crazy, insanity[1][2]) {
|
||||
t.Fatalf("Unexpected TestInsanity() first result expected %#v, got %#v ",
|
||||
crazy,
|
||||
insanity[1][2])
|
||||
crazy,
|
||||
insanity[1][2])
|
||||
}
|
||||
if !reflect.DeepEqual(crazy, insanity[1][3]) {
|
||||
t.Fatalf("Unexpected TestInsanity() second result expected %#v, got %#v ",
|
||||
crazy,
|
||||
insanity[1][3])
|
||||
crazy,
|
||||
insanity[1][3])
|
||||
}
|
||||
if len(insanity[2][6].UserMap) > 0 || len(insanity[2][6].Xtructs) > 0 {
|
||||
t.Fatalf("Unexpected TestInsanity() non-empty result got %#v ",
|
||||
insanity[2][6])
|
||||
insanity[2][6])
|
||||
}
|
||||
|
||||
xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
|
||||
xxsret, err := client.TestMulti(defaultCtx, 42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestMulti() call: ", err)
|
||||
}
|
||||
|
@ -262,7 +272,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
|
||||
}
|
||||
|
||||
err = client.TestException("Xception")
|
||||
err = client.TestException(defaultCtx, "Xception")
|
||||
if err == nil {
|
||||
t.Fatalf("Expecting exception in TestException() call")
|
||||
}
|
||||
|
@ -270,13 +280,13 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestException() result expected %#v, got %#v ", xcept, err)
|
||||
}
|
||||
|
||||
err = client.TestException("TException")
|
||||
err = client.TestException(defaultCtx, "TException")
|
||||
_, ok := err.(thrift.TApplicationException)
|
||||
if err == nil || !ok {
|
||||
t.Fatalf("Unexpected TestException() result expected ApplicationError, got %#v ", err)
|
||||
}
|
||||
|
||||
ign, err := client.TestMultiException("Xception", "ignoreme")
|
||||
ign, err := client.TestMultiException(defaultCtx, "Xception", "ignoreme")
|
||||
if ign != nil || err == nil {
|
||||
t.Fatalf("Expecting exception in TestMultiException() call")
|
||||
}
|
||||
|
@ -284,7 +294,7 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestMultiException() %#v ", err)
|
||||
}
|
||||
|
||||
ign, err = client.TestMultiException("Xception2", "ignoreme")
|
||||
ign, err = client.TestMultiException(defaultCtx, "Xception2", "ignoreme")
|
||||
if ign != nil || err == nil {
|
||||
t.Fatalf("Expecting exception in TestMultiException() call")
|
||||
}
|
||||
|
@ -294,13 +304,13 @@ func callEverything(client *thrifttest.ThriftTestClient) {
|
|||
t.Fatalf("Unexpected TestMultiException() %#v ", err)
|
||||
}
|
||||
|
||||
err = client.TestOneway(2)
|
||||
err = client.TestOneway(defaultCtx, 2)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error in TestOneway() call: ", err)
|
||||
}
|
||||
|
||||
//Make sure the connection still alive
|
||||
if err = client.TestVoid(); err != nil {
|
||||
if err = client.TestVoid(defaultCtx); err != nil {
|
||||
t.Fatalf("Unexpected error in TestVoid() call: ", err)
|
||||
}
|
||||
}
|
||||
|
|
1
vendor/git.apache.org/thrift.git/test/go/src/bin/testserver/main.go
generated
vendored
1
vendor/git.apache.org/thrift.git/test/go/src/bin/testserver/main.go
generated
vendored
|
@ -34,6 +34,7 @@ var domain_socket = flag.String("domain-socket", "", "Domain Socket (e.g. /tmp/T
|
|||
var transport = flag.String("transport", "buffered", "Transport: buffered, framed, http, zlib")
|
||||
var protocol = flag.String("protocol", "binary", "Protocol: binary, compact, json")
|
||||
var ssl = flag.Bool("ssl", false, "Encrypted Transport using SSL")
|
||||
var zlib = flag.Bool("zlib", false, "Wrapped Transport using Zlib")
|
||||
var certPath = flag.String("certPath", "keys", "Directory that contains SSL certificates")
|
||||
|
||||
func main() {
|
||||
|
|
27
vendor/git.apache.org/thrift.git/test/go/src/common/client.go
generated
vendored
27
vendor/git.apache.org/thrift.git/test/go/src/common/client.go
generated
vendored
|
@ -41,7 +41,7 @@ func StartClient(
|
|||
domain_socket string,
|
||||
transport string,
|
||||
protocol string,
|
||||
ssl bool) (client *thrifttest.ThriftTestClient, err error) {
|
||||
ssl bool) (client *thrifttest.ThriftTestClient, trans thrift.TTransport, err error) {
|
||||
|
||||
hostPort := fmt.Sprintf("%s:%d", host, port)
|
||||
|
||||
|
@ -56,12 +56,11 @@ func StartClient(
|
|||
case "binary":
|
||||
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid protocol specified %s", protocol)
|
||||
return nil, nil, fmt.Errorf("Invalid protocol specified %s", protocol)
|
||||
}
|
||||
if debugClientProtocol {
|
||||
protocolFactory = thrift.NewTDebugProtocolFactory(protocolFactory, "client:")
|
||||
}
|
||||
var trans thrift.TTransport
|
||||
if ssl {
|
||||
trans, err = thrift.NewTSSLSocket(hostPort, &tls.Config{InsecureSkipVerify: true})
|
||||
} else {
|
||||
|
@ -72,7 +71,7 @@ func StartClient(
|
|||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
switch transport {
|
||||
case "http":
|
||||
|
@ -86,29 +85,25 @@ func StartClient(
|
|||
} else {
|
||||
trans, err = thrift.NewTHttpPostClient(fmt.Sprintf("http://%s/", hostPort))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case "framed":
|
||||
trans = thrift.NewTFramedTransport(trans)
|
||||
case "buffered":
|
||||
trans = thrift.NewTBufferedTransport(trans, 8192)
|
||||
case "zlib":
|
||||
trans, err = thrift.NewTZlibTransport(trans, zlib.BestCompression)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "":
|
||||
trans = trans
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid transport specified %s", transport)
|
||||
return nil, nil, fmt.Errorf("Invalid transport specified %s", transport)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if err = trans.Open(); err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
client = thrifttest.NewThriftTestClientFactory(trans, protocolFactory)
|
||||
iprot := protocolFactory.GetProtocol(trans)
|
||||
oprot := protocolFactory.GetProtocol(trans)
|
||||
client = thrifttest.NewThriftTestClient(thrift.NewTStandardClient(iprot, oprot))
|
||||
return
|
||||
}
|
||||
|
|
188
vendor/git.apache.org/thrift.git/test/go/src/common/clientserver_test.go
generated
vendored
188
vendor/git.apache.org/thrift.git/test/go/src/common/clientserver_test.go
generated
vendored
|
@ -20,9 +20,11 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gen/thrifttest"
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
"thrift"
|
||||
|
||||
|
@ -47,10 +49,15 @@ var units = []test_unit{
|
|||
|
||||
func TestAllConnection(t *testing.T) {
|
||||
certPath = "../../../keys"
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(len(units))
|
||||
for _, unit := range units {
|
||||
t.Logf("%#v", unit)
|
||||
doUnit(t, &unit)
|
||||
go func(u test_unit) {
|
||||
defer wg.Done()
|
||||
doUnit(t, &u)
|
||||
}(unit)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func doUnit(t *testing.T, unit *test_unit) {
|
||||
|
@ -62,17 +69,17 @@ func doUnit(t *testing.T, unit *test_unit) {
|
|||
|
||||
server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
|
||||
if err = server.Listen(); err != nil {
|
||||
t.Errorf("Unable to start server", err)
|
||||
t.FailNow()
|
||||
t.Errorf("Unable to start server: %v", err)
|
||||
return
|
||||
}
|
||||
go server.AcceptLoop()
|
||||
defer server.Stop()
|
||||
client, err := StartClient(unit.host, unit.port, unit.domain_socket, unit.transport, unit.protocol, unit.ssl)
|
||||
client, trans, err := StartClient(unit.host, unit.port, unit.domain_socket, unit.transport, unit.protocol, unit.ssl)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to start client", err)
|
||||
t.FailNow()
|
||||
t.Errorf("Unable to start client: %v", err)
|
||||
return
|
||||
}
|
||||
defer client.Transport.Close()
|
||||
defer trans.Close()
|
||||
callEverythingWithMock(t, client, handler)
|
||||
}
|
||||
|
||||
|
@ -89,91 +96,92 @@ var xxs = &thrifttest.Xtruct{
|
|||
}
|
||||
|
||||
var xcept = &thrifttest.Xception{ErrorCode: 1001, Message: "some"}
|
||||
var defaultCtx = context.Background()
|
||||
|
||||
func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, handler *MockThriftTest) {
|
||||
gomock.InOrder(
|
||||
handler.EXPECT().TestVoid(),
|
||||
handler.EXPECT().TestString("thing").Return("thing", nil),
|
||||
handler.EXPECT().TestBool(true).Return(true, nil),
|
||||
handler.EXPECT().TestBool(false).Return(false, nil),
|
||||
handler.EXPECT().TestByte(int8(42)).Return(int8(42), nil),
|
||||
handler.EXPECT().TestI32(int32(4242)).Return(int32(4242), nil),
|
||||
handler.EXPECT().TestI64(int64(424242)).Return(int64(424242), nil),
|
||||
handler.EXPECT().TestVoid(gomock.Any()),
|
||||
handler.EXPECT().TestString(gomock.Any(), "thing").Return("thing", nil),
|
||||
handler.EXPECT().TestBool(gomock.Any(), true).Return(true, nil),
|
||||
handler.EXPECT().TestBool(gomock.Any(), false).Return(false, nil),
|
||||
handler.EXPECT().TestByte(gomock.Any(), int8(42)).Return(int8(42), nil),
|
||||
handler.EXPECT().TestI32(gomock.Any(), int32(4242)).Return(int32(4242), nil),
|
||||
handler.EXPECT().TestI64(gomock.Any(), int64(424242)).Return(int64(424242), nil),
|
||||
// TODO: add TestBinary()
|
||||
handler.EXPECT().TestDouble(float64(42.42)).Return(float64(42.42), nil),
|
||||
handler.EXPECT().TestStruct(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}).Return(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}, nil),
|
||||
handler.EXPECT().TestNest(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}).Return(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}, nil),
|
||||
handler.EXPECT().TestMap(map[int32]int32{1: 2, 3: 4, 5: 42}).Return(map[int32]int32{1: 2, 3: 4, 5: 42}, nil),
|
||||
handler.EXPECT().TestStringMap(map[string]string{"a": "2", "b": "blah", "some": "thing"}).Return(map[string]string{"a": "2", "b": "blah", "some": "thing"}, nil),
|
||||
handler.EXPECT().TestSet(map[int32]struct{}{1: struct{}{}, 2: struct{}{}, 42: struct{}{}}).Return(map[int32]struct{}{1: struct{}{}, 2: struct{}{}, 42: struct{}{}}, nil),
|
||||
handler.EXPECT().TestList([]int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
|
||||
handler.EXPECT().TestEnum(thrifttest.Numberz_TWO).Return(thrifttest.Numberz_TWO, nil),
|
||||
handler.EXPECT().TestTypedef(thrifttest.UserId(42)).Return(thrifttest.UserId(42), nil),
|
||||
handler.EXPECT().TestMapMap(int32(42)).Return(rmapmap, nil),
|
||||
handler.EXPECT().TestDouble(gomock.Any(), float64(42.42)).Return(float64(42.42), nil),
|
||||
handler.EXPECT().TestStruct(gomock.Any(), &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}).Return(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}, nil),
|
||||
handler.EXPECT().TestNest(gomock.Any(), &thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}).Return(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}, nil),
|
||||
handler.EXPECT().TestMap(gomock.Any(), map[int32]int32{1: 2, 3: 4, 5: 42}).Return(map[int32]int32{1: 2, 3: 4, 5: 42}, nil),
|
||||
handler.EXPECT().TestStringMap(gomock.Any(), map[string]string{"a": "2", "b": "blah", "some": "thing"}).Return(map[string]string{"a": "2", "b": "blah", "some": "thing"}, nil),
|
||||
handler.EXPECT().TestSet(gomock.Any(), []int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
|
||||
handler.EXPECT().TestList(gomock.Any(), []int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
|
||||
handler.EXPECT().TestEnum(gomock.Any(), thrifttest.Numberz_TWO).Return(thrifttest.Numberz_TWO, nil),
|
||||
handler.EXPECT().TestTypedef(gomock.Any(), thrifttest.UserId(42)).Return(thrifttest.UserId(42), nil),
|
||||
handler.EXPECT().TestMapMap(gomock.Any(), int32(42)).Return(rmapmap, nil),
|
||||
// TODO: not testing insanity
|
||||
handler.EXPECT().TestMulti(int8(42), int32(4242), int64(424242), map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24)).Return(xxs, nil),
|
||||
handler.EXPECT().TestException("some").Return(xcept),
|
||||
handler.EXPECT().TestException("TException").Return(errors.New("Just random exception")),
|
||||
handler.EXPECT().TestMultiException("Xception", "ignoreme").Return(nil, &thrifttest.Xception{ErrorCode: 1001, Message: "This is an Xception"}),
|
||||
handler.EXPECT().TestMultiException("Xception2", "ignoreme").Return(nil, &thrifttest.Xception2{ErrorCode: 2002, StructThing: &thrifttest.Xtruct{StringThing: "This is an Xception2"}}),
|
||||
handler.EXPECT().TestOneway(int32(2)).Return(nil),
|
||||
handler.EXPECT().TestVoid(),
|
||||
handler.EXPECT().TestMulti(gomock.Any(), int8(42), int32(4242), int64(424242), map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24)).Return(xxs, nil),
|
||||
handler.EXPECT().TestException(gomock.Any(), "some").Return(xcept),
|
||||
handler.EXPECT().TestException(gomock.Any(), "TException").Return(errors.New("Just random exception")),
|
||||
handler.EXPECT().TestMultiException(gomock.Any(), "Xception", "ignoreme").Return(nil, &thrifttest.Xception{ErrorCode: 1001, Message: "This is an Xception"}),
|
||||
handler.EXPECT().TestMultiException(gomock.Any(), "Xception2", "ignoreme").Return(nil, &thrifttest.Xception2{ErrorCode: 2002, StructThing: &thrifttest.Xtruct{StringThing: "This is an Xception2"}}),
|
||||
handler.EXPECT().TestOneway(gomock.Any(), int32(2)).Return(nil),
|
||||
handler.EXPECT().TestVoid(gomock.Any()),
|
||||
)
|
||||
var err error
|
||||
if err = client.TestVoid(); err != nil {
|
||||
t.Errorf("Unexpected error in TestVoid() call: ", err)
|
||||
if err = client.TestVoid(defaultCtx); err != nil {
|
||||
t.Errorf("Unexpected error in TestVoid() call: %s", err)
|
||||
}
|
||||
|
||||
thing, err := client.TestString("thing")
|
||||
thing, err := client.TestString(defaultCtx, "thing")
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestString() call: ", err)
|
||||
t.Errorf("Unexpected error in TestString() call: %s", err)
|
||||
}
|
||||
if thing != "thing" {
|
||||
t.Errorf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
|
||||
}
|
||||
|
||||
bl, err := client.TestBool(true)
|
||||
bl, err := client.TestBool(defaultCtx, true)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestBool() call: ", err)
|
||||
t.Errorf("Unexpected error in TestBool() call: %s", err)
|
||||
}
|
||||
if !bl {
|
||||
t.Errorf("Unexpected TestBool() result expected true, got %f ", bl)
|
||||
t.Errorf("Unexpected TestBool() result expected true, got %v ", bl)
|
||||
}
|
||||
bl, err = client.TestBool(false)
|
||||
bl, err = client.TestBool(defaultCtx, false)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestBool() call: ", err)
|
||||
t.Errorf("Unexpected error in TestBool() call: %s", err)
|
||||
}
|
||||
if bl {
|
||||
t.Errorf("Unexpected TestBool() result expected false, got %f ", bl)
|
||||
t.Errorf("Unexpected TestBool() result expected false, got %v ", bl)
|
||||
}
|
||||
|
||||
b, err := client.TestByte(42)
|
||||
b, err := client.TestByte(defaultCtx, 42)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestByte() call: ", err)
|
||||
t.Errorf("Unexpected error in TestByte() call: %s", err)
|
||||
}
|
||||
if b != 42 {
|
||||
t.Errorf("Unexpected TestByte() result expected 42, got %d ", b)
|
||||
}
|
||||
|
||||
i32, err := client.TestI32(4242)
|
||||
i32, err := client.TestI32(defaultCtx, 4242)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestI32() call: ", err)
|
||||
t.Errorf("Unexpected error in TestI32() call: %s", err)
|
||||
}
|
||||
if i32 != 4242 {
|
||||
t.Errorf("Unexpected TestI32() result expected 4242, got %d ", i32)
|
||||
}
|
||||
|
||||
i64, err := client.TestI64(424242)
|
||||
i64, err := client.TestI64(defaultCtx, 424242)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestI64() call: ", err)
|
||||
t.Errorf("Unexpected error in TestI64() call: %s", err)
|
||||
}
|
||||
if i64 != 424242 {
|
||||
t.Errorf("Unexpected TestI64() result expected 424242, got %d ", i64)
|
||||
}
|
||||
|
||||
d, err := client.TestDouble(42.42)
|
||||
d, err := client.TestDouble(defaultCtx, 42.42)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestDouble() call: ", err)
|
||||
t.Errorf("Unexpected error in TestDouble() call: %s", err)
|
||||
}
|
||||
if d != 42.42 {
|
||||
t.Errorf("Unexpected TestDouble() result expected 42.42, got %f ", d)
|
||||
|
@ -186,9 +194,9 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
|
|||
xs.ByteThing = 42
|
||||
xs.I32Thing = 4242
|
||||
xs.I64Thing = 424242
|
||||
xsret, err := client.TestStruct(xs)
|
||||
xsret, err := client.TestStruct(defaultCtx, xs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestStruct() call: ", err)
|
||||
t.Errorf("Unexpected error in TestStruct() call: %s", err)
|
||||
}
|
||||
if *xs != *xsret {
|
||||
t.Errorf("Unexpected TestStruct() result expected %#v, got %#v ", xs, xsret)
|
||||
|
@ -196,83 +204,90 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
|
|||
|
||||
x2 := thrifttest.NewXtruct2()
|
||||
x2.StructThing = xs
|
||||
x2ret, err := client.TestNest(x2)
|
||||
x2ret, err := client.TestNest(defaultCtx, x2)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestNest() call: ", err)
|
||||
t.Errorf("Unexpected error in TestNest() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(x2, x2ret) {
|
||||
t.Errorf("Unexpected TestNest() result expected %#v, got %#v ", x2, x2ret)
|
||||
}
|
||||
|
||||
m := map[int32]int32{1: 2, 3: 4, 5: 42}
|
||||
mret, err := client.TestMap(m)
|
||||
mret, err := client.TestMap(defaultCtx, m)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestMap() call: ", err)
|
||||
t.Errorf("Unexpected error in TestMap() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(m, mret) {
|
||||
t.Errorf("Unexpected TestMap() result expected %#v, got %#v ", m, mret)
|
||||
}
|
||||
|
||||
sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
|
||||
smret, err := client.TestStringMap(sm)
|
||||
smret, err := client.TestStringMap(defaultCtx, sm)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestStringMap() call: ", err)
|
||||
t.Errorf("Unexpected error in TestStringMap() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(sm, smret) {
|
||||
t.Errorf("Unexpected TestStringMap() result expected %#v, got %#v ", sm, smret)
|
||||
}
|
||||
|
||||
s := map[int32]struct{}{1: struct{}{}, 2: struct{}{}, 42: struct{}{}}
|
||||
sret, err := client.TestSet(s)
|
||||
s := []int32{1, 2, 42}
|
||||
sret, err := client.TestSet(defaultCtx, s)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestSet() call: ", err)
|
||||
t.Errorf("Unexpected error in TestSet() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(s, sret) {
|
||||
t.Errorf("Unexpected TestSet() result expected %#v, got %#v ", s, sret)
|
||||
// Sets can be in any order, but Go slices are ordered, so reflect.DeepEqual won't work.
|
||||
stemp := map[int32]struct{}{}
|
||||
for _, val := range s {
|
||||
stemp[val] = struct{}{}
|
||||
}
|
||||
for _, val := range sret {
|
||||
if _, ok := stemp[val]; !ok {
|
||||
t.Fatalf("Unexpected TestSet() result expected %#v, got %#v ", s, sret)
|
||||
}
|
||||
}
|
||||
|
||||
l := []int32{1, 2, 42}
|
||||
lret, err := client.TestList(l)
|
||||
lret, err := client.TestList(defaultCtx, l)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestList() call: ", err)
|
||||
t.Errorf("Unexpected error in TestList() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(l, lret) {
|
||||
t.Errorf("Unexpected TestSet() result expected %#v, got %#v ", l, lret)
|
||||
t.Errorf("Unexpected TestList() result expected %#v, got %#v ", l, lret)
|
||||
}
|
||||
|
||||
eret, err := client.TestEnum(thrifttest.Numberz_TWO)
|
||||
eret, err := client.TestEnum(defaultCtx, thrifttest.Numberz_TWO)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestEnum() call: ", err)
|
||||
t.Errorf("Unexpected error in TestEnum() call: %s", err)
|
||||
}
|
||||
if eret != thrifttest.Numberz_TWO {
|
||||
t.Errorf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
|
||||
}
|
||||
|
||||
tret, err := client.TestTypedef(thrifttest.UserId(42))
|
||||
tret, err := client.TestTypedef(defaultCtx, thrifttest.UserId(42))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestTypedef() call: ", err)
|
||||
t.Errorf("Unexpected error in TestTypedef() call: %s", err)
|
||||
}
|
||||
if tret != thrifttest.UserId(42) {
|
||||
t.Errorf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
|
||||
}
|
||||
|
||||
mapmap, err := client.TestMapMap(42)
|
||||
mapmap, err := client.TestMapMap(defaultCtx, 42)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestMapmap() call: ", err)
|
||||
t.Errorf("Unexpected error in TestMapmap() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(mapmap, rmapmap) {
|
||||
t.Errorf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
|
||||
}
|
||||
|
||||
xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
|
||||
xxsret, err := client.TestMulti(defaultCtx, 42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestMulti() call: ", err)
|
||||
t.Errorf("Unexpected error in TestMulti() call: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(xxs, xxsret) {
|
||||
t.Errorf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
|
||||
}
|
||||
|
||||
err = client.TestException("some")
|
||||
err = client.TestException(defaultCtx, "some")
|
||||
if err == nil {
|
||||
t.Errorf("Expecting exception in TestException() call")
|
||||
}
|
||||
|
@ -281,13 +296,16 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
|
|||
}
|
||||
|
||||
// TODO: connection is being closed on this
|
||||
err = client.TestException("TException")
|
||||
tex, ok := err.(thrift.TApplicationException)
|
||||
if err == nil || !ok || tex.TypeId() != thrift.INTERNAL_ERROR {
|
||||
t.Errorf("Unexpected TestException() result expected ApplicationError, got %#v ", err)
|
||||
err = client.TestException(defaultCtx, "TException")
|
||||
if err == nil {
|
||||
t.Error("expected exception got nil")
|
||||
} else if tex, ok := err.(thrift.TApplicationException); !ok {
|
||||
t.Errorf("Unexpected TestException() result expected ApplicationError, got %T ", err)
|
||||
} else if tex.TypeId() != thrift.INTERNAL_ERROR {
|
||||
t.Errorf("expected internal_error got %v", tex.TypeId())
|
||||
}
|
||||
|
||||
ign, err := client.TestMultiException("Xception", "ignoreme")
|
||||
ign, err := client.TestMultiException(defaultCtx, "Xception", "ignoreme")
|
||||
if ign != nil || err == nil {
|
||||
t.Errorf("Expecting exception in TestMultiException() call")
|
||||
}
|
||||
|
@ -295,7 +313,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
|
|||
t.Errorf("Unexpected TestMultiException() %#v ", err)
|
||||
}
|
||||
|
||||
ign, err = client.TestMultiException("Xception2", "ignoreme")
|
||||
ign, err = client.TestMultiException(defaultCtx, "Xception2", "ignoreme")
|
||||
if ign != nil || err == nil {
|
||||
t.Errorf("Expecting exception in TestMultiException() call")
|
||||
}
|
||||
|
@ -305,13 +323,13 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
|
|||
t.Errorf("Unexpected TestMultiException() %#v ", err)
|
||||
}
|
||||
|
||||
err = client.TestOneway(2)
|
||||
err = client.TestOneway(defaultCtx, 2)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error in TestOneway() call: ", err)
|
||||
t.Errorf("Unexpected error in TestOneway() call: %s", err)
|
||||
}
|
||||
|
||||
//Make sure the connection still alive
|
||||
if err = client.TestVoid(); err != nil {
|
||||
t.Errorf("Unexpected error in TestVoid() call: ", err)
|
||||
if err = client.TestVoid(defaultCtx); err != nil {
|
||||
t.Errorf("Unexpected error in TestVoid() call: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
98
vendor/git.apache.org/thrift.git/test/go/src/common/context_test.go
generated
vendored
Normal file
98
vendor/git.apache.org/thrift.git/test/go/src/common/context_test.go
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
"thrift"
|
||||
"time"
|
||||
)
|
||||
|
||||
type slowHttpHandler struct{}
|
||||
|
||||
func (slowHttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
func TestHttpContextTimeout(t *testing.T) {
|
||||
certPath = "../../../keys"
|
||||
|
||||
unit := test_unit{"127.0.0.1", 9096, "", "http", "binary", false}
|
||||
|
||||
server := &http.Server{Addr: unit.host + fmt.Sprintf(":%d", unit.port), Handler: slowHttpHandler{}}
|
||||
go server.ListenAndServe()
|
||||
|
||||
client, trans, err := StartClient(unit.host, unit.port, unit.domain_socket, unit.transport, unit.protocol, unit.ssl)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to start client: %v", err)
|
||||
return
|
||||
}
|
||||
defer trans.Close()
|
||||
|
||||
unwrapErr := func(err error) error {
|
||||
for {
|
||||
switch err.(type) {
|
||||
case thrift.TTransportException:
|
||||
err = err.(thrift.TTransportException).Err()
|
||||
case *url.Error:
|
||||
err = err.(*url.Error).Err
|
||||
case *net.OpError:
|
||||
err = err.(*net.OpError).Err
|
||||
case *os.SyscallError:
|
||||
err = err.(*os.SyscallError).Err
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serverStartupDeadline := time.Now().Add(5 * time.Second)
|
||||
for {
|
||||
ctx, _ := context.WithTimeout(context.Background(), 50*time.Millisecond)
|
||||
err = client.TestVoid(ctx)
|
||||
err = unwrapErr(err)
|
||||
if err != syscall.ECONNREFUSED || time.Now().After(serverStartupDeadline) {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("Request completed (should have timed out)")
|
||||
return
|
||||
}
|
||||
|
||||
// We've got to switch on `err.Error()` here since go1.7 doesn't properly return
|
||||
// `context.DeadlineExceeded` error and `http.errRequestCanceled` is not exported.
|
||||
// See https://github.com/golang/go/issues/17711
|
||||
switch err.Error() {
|
||||
case context.DeadlineExceeded.Error(), "net/http: request canceled":
|
||||
// Expected error
|
||||
default:
|
||||
t.Errorf("Unexpected error: %s", err)
|
||||
}
|
||||
}
|
289
vendor/git.apache.org/thrift.git/test/go/src/common/mock_handler.go
generated
vendored
289
vendor/git.apache.org/thrift.git/test/go/src/common/mock_handler.go
generated
vendored
|
@ -1,289 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Automatically generated by MockGen. DO NOT EDIT!
|
||||
// Source: gen/thrifttest (interfaces: ThriftTest)
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
thrifttest "gen/thrifttest"
|
||||
)
|
||||
|
||||
// Mock of ThriftTest interface
|
||||
type MockThriftTest struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *_MockThriftTestRecorder
|
||||
}
|
||||
|
||||
// Recorder for MockThriftTest (not exported)
|
||||
type _MockThriftTestRecorder struct {
|
||||
mock *MockThriftTest
|
||||
}
|
||||
|
||||
func NewMockThriftTest(ctrl *gomock.Controller) *MockThriftTest {
|
||||
mock := &MockThriftTest{ctrl: ctrl}
|
||||
mock.recorder = &_MockThriftTestRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) EXPECT() *_MockThriftTestRecorder {
|
||||
return _m.recorder
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestBool(_param0 bool) (bool, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestBool", _param0)
|
||||
ret0, _ := ret[0].(bool)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestBool(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBool", arg0)
|
||||
}
|
||||
|
||||
|
||||
func (_m *MockThriftTest) TestByte(_param0 int8) (int8, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestByte", _param0)
|
||||
ret0, _ := ret[0].(int8)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestByte(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestByte", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestDouble(_param0 float64) (float64, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestDouble", _param0)
|
||||
ret0, _ := ret[0].(float64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestDouble(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestDouble", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestBinary(_param0 []byte) ([]byte, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestBinary", _param0)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestBinary(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBinary", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestEnum(_param0 thrifttest.Numberz) (thrifttest.Numberz, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestEnum", _param0)
|
||||
ret0, _ := ret[0].(thrifttest.Numberz)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestEnum(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestEnum", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestException(_param0 string) error {
|
||||
ret := _m.ctrl.Call(_m, "TestException", _param0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestException(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestException", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestI32(_param0 int32) (int32, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestI32", _param0)
|
||||
ret0, _ := ret[0].(int32)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestI32(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestI32", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestI64(_param0 int64) (int64, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestI64", _param0)
|
||||
ret0, _ := ret[0].(int64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestI64(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestI64", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestInsanity(_param0 *thrifttest.Insanity) (map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestInsanity", _param0)
|
||||
ret0, _ := ret[0].(map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestInsanity(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestInsanity", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestList(_param0 []int32) ([]int32, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestList", _param0)
|
||||
ret0, _ := ret[0].([]int32)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestList(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestList", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestMap(_param0 map[int32]int32) (map[int32]int32, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestMap", _param0)
|
||||
ret0, _ := ret[0].(map[int32]int32)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestMap(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMap", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestMapMap(_param0 int32) (map[int32]map[int32]int32, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestMapMap", _param0)
|
||||
ret0, _ := ret[0].(map[int32]map[int32]int32)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestMapMap(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMapMap", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestMulti(_param0 int8, _param1 int32, _param2 int64, _param3 map[int16]string, _param4 thrifttest.Numberz, _param5 thrifttest.UserId) (*thrifttest.Xtruct, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestMulti", _param0, _param1, _param2, _param3, _param4, _param5)
|
||||
ret0, _ := ret[0].(*thrifttest.Xtruct)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestMulti(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMulti", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestMultiException(_param0 string, _param1 string) (*thrifttest.Xtruct, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestMultiException", _param0, _param1)
|
||||
ret0, _ := ret[0].(*thrifttest.Xtruct)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestMultiException(arg0, arg1 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMultiException", arg0, arg1)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestNest(_param0 *thrifttest.Xtruct2) (*thrifttest.Xtruct2, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestNest", _param0)
|
||||
ret0, _ := ret[0].(*thrifttest.Xtruct2)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestNest(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestNest", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestOneway(_param0 int32) error {
|
||||
ret := _m.ctrl.Call(_m, "TestOneway", _param0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestOneway(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestOneway", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestSet(_param0 map[int32]struct{}) (map[int32]struct{}, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestSet", _param0)
|
||||
ret0, _ := ret[0].(map[int32]struct{})
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestSet(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestSet", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestString(_param0 string) (string, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestString", _param0)
|
||||
ret0, _ := ret[0].(string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestString(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestString", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestStringMap(_param0 map[string]string) (map[string]string, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestStringMap", _param0)
|
||||
ret0, _ := ret[0].(map[string]string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestStringMap(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestStringMap", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestStruct(_param0 *thrifttest.Xtruct) (*thrifttest.Xtruct, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestStruct", _param0)
|
||||
ret0, _ := ret[0].(*thrifttest.Xtruct)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestStruct(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestStruct", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestTypedef(_param0 thrifttest.UserId) (thrifttest.UserId, error) {
|
||||
ret := _m.ctrl.Call(_m, "TestTypedef", _param0)
|
||||
ret0, _ := ret[0].(thrifttest.UserId)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestTypedef(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestTypedef", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockThriftTest) TestVoid() error {
|
||||
ret := _m.ctrl.Call(_m, "TestVoid")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
func (_mr *_MockThriftTestRecorder) TestVoid() *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestVoid")
|
||||
}
|
51
vendor/git.apache.org/thrift.git/test/go/src/common/printing_handler.go
generated
vendored
51
vendor/git.apache.org/thrift.git/test/go/src/common/printing_handler.go
generated
vendored
|
@ -20,9 +20,10 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"encoding/hex"
|
||||
. "gen/thrifttest"
|
||||
"time"
|
||||
)
|
||||
|
@ -32,7 +33,7 @@ var PrintingHandler = &printingHandler{}
|
|||
type printingHandler struct{}
|
||||
|
||||
// Prints "testVoid()" and returns nothing.
|
||||
func (p *printingHandler) TestVoid() (err error) {
|
||||
func (p *printingHandler) TestVoid(ctx context.Context) (err error) {
|
||||
fmt.Println("testVoid()")
|
||||
return nil
|
||||
}
|
||||
|
@ -43,7 +44,7 @@ func (p *printingHandler) TestVoid() (err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestString(thing string) (r string, err error) {
|
||||
func (p *printingHandler) TestString(ctx context.Context, thing string) (r string, err error) {
|
||||
fmt.Printf("testString(\"%s\")\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ func (p *printingHandler) TestString(thing string) (r string, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestBool(thing bool) (r bool, err error) {
|
||||
func (p *printingHandler) TestBool(ctx context.Context, thing bool) (r bool, err error) {
|
||||
fmt.Printf("testBool(%t)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -65,7 +66,7 @@ func (p *printingHandler) TestBool(thing bool) (r bool, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestByte(thing int8) (r int8, err error) {
|
||||
func (p *printingHandler) TestByte(ctx context.Context, thing int8) (r int8, err error) {
|
||||
fmt.Printf("testByte(%d)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ func (p *printingHandler) TestByte(thing int8) (r int8, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestI32(thing int32) (r int32, err error) {
|
||||
func (p *printingHandler) TestI32(ctx context.Context, thing int32) (r int32, err error) {
|
||||
fmt.Printf("testI32(%d)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ func (p *printingHandler) TestI32(thing int32) (r int32, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestI64(thing int64) (r int64, err error) {
|
||||
func (p *printingHandler) TestI64(ctx context.Context, thing int64) (r int64, err error) {
|
||||
fmt.Printf("testI64(%d)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ func (p *printingHandler) TestI64(thing int64) (r int64, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestDouble(thing float64) (r float64, err error) {
|
||||
func (p *printingHandler) TestDouble(ctx context.Context, thing float64) (r float64, err error) {
|
||||
fmt.Printf("testDouble(%f)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -109,7 +110,7 @@ func (p *printingHandler) TestDouble(thing float64) (r float64, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestBinary(thing []byte) (r []byte, err error) {
|
||||
func (p *printingHandler) TestBinary(ctx context.Context, thing []byte) (r []byte, err error) {
|
||||
fmt.Printf("testBinary(%s)\n", hex.EncodeToString(thing))
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ func (p *printingHandler) TestBinary(thing []byte) (r []byte, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
|
||||
func (p *printingHandler) TestStruct(ctx context.Context, thing *Xtruct) (r *Xtruct, err error) {
|
||||
fmt.Printf("testStruct({\"%s\", %d, %d, %d})\n", thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing)
|
||||
return thing, err
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ func (p *printingHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestNest(nest *Xtruct2) (r *Xtruct2, err error) {
|
||||
func (p *printingHandler) TestNest(ctx context.Context, nest *Xtruct2) (r *Xtruct2, err error) {
|
||||
thing := nest.StructThing
|
||||
fmt.Printf("testNest({%d, {\"%s\", %d, %d, %d}, %d})\n", nest.ByteThing, thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing, nest.I32Thing)
|
||||
return nest, nil
|
||||
|
@ -144,7 +145,7 @@ func (p *printingHandler) TestNest(nest *Xtruct2) (r *Xtruct2, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err error) {
|
||||
func (p *printingHandler) TestMap(ctx context.Context, thing map[int32]int32) (r map[int32]int32, err error) {
|
||||
fmt.Printf("testMap({")
|
||||
first := true
|
||||
for k, v := range thing {
|
||||
|
@ -166,7 +167,7 @@ func (p *printingHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestStringMap(thing map[string]string) (r map[string]string, err error) {
|
||||
func (p *printingHandler) TestStringMap(ctx context.Context, thing map[string]string) (r map[string]string, err error) {
|
||||
fmt.Printf("testStringMap({")
|
||||
first := true
|
||||
for k, v := range thing {
|
||||
|
@ -188,7 +189,7 @@ func (p *printingHandler) TestStringMap(thing map[string]string) (r map[string]s
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestSet(thing map[int32]struct{}) (r map[int32]struct{}, err error) {
|
||||
func (p *printingHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) {
|
||||
fmt.Printf("testSet({")
|
||||
first := true
|
||||
for k, _ := range thing {
|
||||
|
@ -210,7 +211,7 @@ func (p *printingHandler) TestSet(thing map[int32]struct{}) (r map[int32]struct{
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestList(thing []int32) (r []int32, err error) {
|
||||
func (p *printingHandler) TestList(ctx context.Context, thing []int32) (r []int32, err error) {
|
||||
fmt.Printf("testList({")
|
||||
for i, v := range thing {
|
||||
if i != 0 {
|
||||
|
@ -228,7 +229,7 @@ func (p *printingHandler) TestList(thing []int32) (r []int32, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestEnum(thing Numberz) (r Numberz, err error) {
|
||||
func (p *printingHandler) TestEnum(ctx context.Context, thing Numberz) (r Numberz, err error) {
|
||||
fmt.Printf("testEnum(%d)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -239,7 +240,7 @@ func (p *printingHandler) TestEnum(thing Numberz) (r Numberz, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Thing
|
||||
func (p *printingHandler) TestTypedef(thing UserId) (r UserId, err error) {
|
||||
func (p *printingHandler) TestTypedef(ctx context.Context, thing UserId) (r UserId, err error) {
|
||||
fmt.Printf("testTypedef(%d)\n", thing)
|
||||
return thing, nil
|
||||
}
|
||||
|
@ -251,7 +252,7 @@ func (p *printingHandler) TestTypedef(thing UserId) (r UserId, err error) {
|
|||
//
|
||||
// Parameters:
|
||||
// - Hello
|
||||
func (p *printingHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, err error) {
|
||||
func (p *printingHandler) TestMapMap(ctx context.Context, hello int32) (r map[int32]map[int32]int32, err error) {
|
||||
fmt.Printf("testMapMap(%d)\n", hello)
|
||||
|
||||
r = map[int32]map[int32]int32{
|
||||
|
@ -273,14 +274,14 @@ func (p *printingHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32,
|
|||
//
|
||||
// Parameters:
|
||||
// - Argument
|
||||
func (p *printingHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
|
||||
func (p *printingHandler) TestInsanity(ctx context.Context, argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
|
||||
fmt.Printf("testInsanity()\n")
|
||||
r = make(map[UserId]map[Numberz]*Insanity)
|
||||
r[1] = map[Numberz]*Insanity {
|
||||
r[1] = map[Numberz]*Insanity{
|
||||
2: argument,
|
||||
3: argument,
|
||||
}
|
||||
r[2] = map[Numberz]*Insanity {
|
||||
r[2] = map[Numberz]*Insanity{
|
||||
6: NewInsanity(),
|
||||
}
|
||||
return
|
||||
|
@ -303,7 +304,7 @@ func (p *printingHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Num
|
|||
// - Arg3
|
||||
// - Arg4
|
||||
// - Arg5
|
||||
func (p *printingHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
|
||||
func (p *printingHandler) TestMulti(ctx context.Context, arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
|
||||
fmt.Printf("testMulti()\n")
|
||||
r = NewXtruct()
|
||||
|
||||
|
@ -322,7 +323,7 @@ func (p *printingHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[
|
|||
//
|
||||
// Parameters:
|
||||
// - Arg
|
||||
func (p *printingHandler) TestException(arg string) (err error) {
|
||||
func (p *printingHandler) TestException(ctx context.Context, arg string) (err error) {
|
||||
fmt.Printf("testException(%s)\n", arg)
|
||||
switch arg {
|
||||
case "Xception":
|
||||
|
@ -346,7 +347,7 @@ func (p *printingHandler) TestException(arg string) (err error) {
|
|||
// Parameters:
|
||||
// - Arg0
|
||||
// - Arg1
|
||||
func (p *printingHandler) TestMultiException(arg0 string, arg1 string) (r *Xtruct, err error) {
|
||||
func (p *printingHandler) TestMultiException(ctx context.Context, arg0 string, arg1 string) (r *Xtruct, err error) {
|
||||
fmt.Printf("testMultiException(%s, %s)\n", arg0, arg1)
|
||||
switch arg0 {
|
||||
|
||||
|
@ -375,7 +376,7 @@ func (p *printingHandler) TestMultiException(arg0 string, arg1 string) (r *Xtruc
|
|||
//
|
||||
// Parameters:
|
||||
// - SecondsToSleep
|
||||
func (p *printingHandler) TestOneway(secondsToSleep int32) (err error) {
|
||||
func (p *printingHandler) TestOneway(ctx context.Context, secondsToSleep int32) (err error) {
|
||||
fmt.Printf("testOneway(%d): Sleeping...\n", secondsToSleep)
|
||||
time.Sleep(time.Second * time.Duration(secondsToSleep))
|
||||
fmt.Printf("testOneway(%d): done sleeping!\n", secondsToSleep)
|
||||
|
|
2
vendor/git.apache.org/thrift.git/test/go/src/common/simple_handler.go
generated
vendored
2
vendor/git.apache.org/thrift.git/test/go/src/common/simple_handler.go
generated
vendored
|
@ -77,7 +77,7 @@ func (p *simpleHandler) TestStringMap(thing map[string]string) (r map[string]str
|
|||
return thing, nil
|
||||
}
|
||||
|
||||
func (p *simpleHandler) TestSet(thing map[int32]struct{}) (r map[int32]struct{}, err error) {
|
||||
func (p *simpleHandler) TestSet(thing []int32) (r []int32, err error) {
|
||||
return thing, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue