Ejemplo n.º 1
0
func main() {
	tracer, _ := jaeger.NewTracer("crossdock", jaeger.NewConstSampler(true), jaeger.NewNullReporter())
	opentracing.InitGlobalTracer(tracer)

	server.Start()
	client.Start()
}
Ejemplo n.º 2
0
func TestCrossdock(t *testing.T) {
	tracer, closer := jaeger.NewTracer("crossdock", jaeger.NewConstSampler(true), jaeger.NewNullReporter())
	defer closer.Close()
	opentracing.InitGlobalTracer(tracer)

	server.Start()
	defer server.Stop()
	go client.Start()

	crossdock.Wait(t, clientURL, 10)

	type params map[string]string
	type axes map[string][]string

	defaultParams := params{"server": "127.0.0.1"}

	behaviors := []struct {
		name   string
		params params
		axes   axes
	}{
		{
			name: "oneway",
			axes: axes{
				"encoding": []string{"raw", "json", "thrift"},
			},
		},
		{
			name: "raw",

			axes: axes{"transport": []string{"http", "tchannel"}},
		},
		{
			name: "json",
			axes: axes{"transport": []string{"http", "tchannel"}},
		},
		{
			name: "thrift",
			axes: axes{"transport": []string{"http", "tchannel"}},
		},
		{
			name: "errors_httpclient",
		},
		{
			name: "errors_tchclient",
		},
		{
			name: "headers",
			axes: axes{
				"transport": []string{"http", "tchannel"},
				"encoding":  []string{"raw", "json", "thrift"},
			},
		},
		{
			name: "tchclient",
			axes: axes{
				"encoding": []string{"raw", "json", "thrift"},
			},
		},
		{
			name: "tchserver",
			axes: axes{
				"encoding": []string{"raw", "json", "thrift"},
			},
		},
		{
			name: "httpserver",
			params: params{
				"httpserver": "127.0.0.1",
			},
		},
		{
			name: "thriftgauntlet",
			axes: axes{
				"transport": []string{"http", "tchannel"},
			},
		},
		{
			name: "timeout",
			axes: axes{
				"transport": []string{"http", "tchannel"},
			},
		},
		{
			name: "ctxpropagation",
			axes: axes{
				"transport": []string{"http", "tchannel"},
			},
			params: params{
				"ctxserver": "127.0.0.1",
				"ctxclient": "127.0.0.1",
			},
		},
		{
			name: "apachethrift",
			params: params{
				"apachethriftserver": "127.0.0.1",
				"apachethriftclient": "127.0.0.1",
			},
		},
	}

	for _, bb := range behaviors {

		args := url.Values{}
		for k, v := range defaultParams {
			args.Set(k, v)
		}
		for k, v := range bb.params {
			args.Set(k, v)
		}

		if len(bb.axes) == 0 {
			crossdock.Call(t, clientURL, bb.name, args)
			continue
		}

		for _, entry := range crossdock.Combinations(bb.axes) {
			entryArgs := url.Values{}
			for k := range args {
				entryArgs.Set(k, args.Get(k))
			}
			for k, v := range entry {
				entryArgs.Set(k, v)
			}

			crossdock.Call(t, clientURL, bb.name, entryArgs)
		}
	}
}