fix trace test

pull/209/head
Tony 6 years ago
parent ce5990b96f
commit ca2a0228a8
  1. 10
      pkg/net/trace/context_test.go
  2. 30
      pkg/net/trace/dapper_test.go
  3. 4
      pkg/net/trace/span_test.go

@ -6,10 +6,10 @@ import (
func TestSpanContext(t *testing.T) {
pctx := &spanContext{
parentID: genID(),
spanID: genID(),
traceID: genID(),
flags: flagSampled,
ParentID: genID(),
SpanID: genID(),
TraceID: genID(),
Flags: flagSampled,
}
if !pctx.isSampled() {
t.Error("expect sampled")
@ -20,7 +20,7 @@ func TestSpanContext(t *testing.T) {
if err != nil {
t.Error(err)
}
if pctx2.parentID != pctx.parentID || pctx2.spanID != pctx.spanID || pctx2.traceID != pctx.traceID || pctx2.flags != pctx.flags {
if pctx2.ParentID != pctx.ParentID || pctx2.SpanID != pctx.SpanID || pctx2.TraceID != pctx.TraceID || pctx2.Flags != pctx.Flags {
t.Errorf("wrong spancontext get %+v -> %+v", pctx, pctx2)
}
}

@ -40,12 +40,12 @@ func TestDapperPropagation(t *testing.T) {
sp1.Finish(nil)
assert.Len(t, report.sps, 3)
assert.Equal(t, report.sps[2].context.parentID, uint64(0))
assert.Equal(t, report.sps[0].context.traceID, report.sps[1].context.traceID)
assert.Equal(t, report.sps[2].context.traceID, report.sps[1].context.traceID)
assert.Equal(t, report.sps[2].context.ParentID, uint64(0))
assert.Equal(t, report.sps[0].context.TraceID, report.sps[1].context.TraceID)
assert.Equal(t, report.sps[2].context.TraceID, report.sps[1].context.TraceID)
assert.Equal(t, report.sps[1].context.parentID, report.sps[2].context.spanID)
assert.Equal(t, report.sps[0].context.parentID, report.sps[1].context.spanID)
assert.Equal(t, report.sps[1].context.ParentID, report.sps[2].context.SpanID)
assert.Equal(t, report.sps[0].context.ParentID, report.sps[1].context.SpanID)
})
t.Run("test gRPC progagation", func(t *testing.T) {
report := &mockReport{}
@ -64,12 +64,12 @@ func TestDapperPropagation(t *testing.T) {
sp1.Finish(nil)
assert.Len(t, report.sps, 3)
assert.Equal(t, report.sps[2].context.parentID, uint64(0))
assert.Equal(t, report.sps[0].context.traceID, report.sps[1].context.traceID)
assert.Equal(t, report.sps[2].context.traceID, report.sps[1].context.traceID)
assert.Equal(t, report.sps[2].context.ParentID, uint64(0))
assert.Equal(t, report.sps[0].context.TraceID, report.sps[1].context.TraceID)
assert.Equal(t, report.sps[2].context.TraceID, report.sps[1].context.TraceID)
assert.Equal(t, report.sps[1].context.parentID, report.sps[2].context.spanID)
assert.Equal(t, report.sps[0].context.parentID, report.sps[1].context.spanID)
assert.Equal(t, report.sps[1].context.ParentID, report.sps[2].context.SpanID)
assert.Equal(t, report.sps[0].context.ParentID, report.sps[1].context.SpanID)
})
t.Run("test normal", func(t *testing.T) {
report := &mockReport{}
@ -94,12 +94,12 @@ func TestDapperPropagation(t *testing.T) {
sp1.Finish(nil)
assert.Len(t, report.sps, 3)
assert.Equal(t, report.sps[2].context.parentID, uint64(0))
assert.Equal(t, report.sps[0].context.traceID, report.sps[1].context.traceID)
assert.Equal(t, report.sps[2].context.traceID, report.sps[1].context.traceID)
assert.Equal(t, report.sps[2].context.ParentID, uint64(0))
assert.Equal(t, report.sps[0].context.TraceID, report.sps[1].context.TraceID)
assert.Equal(t, report.sps[2].context.TraceID, report.sps[1].context.TraceID)
assert.Equal(t, report.sps[1].context.parentID, report.sps[2].context.spanID)
assert.Equal(t, report.sps[0].context.parentID, report.sps[1].context.spanID)
assert.Equal(t, report.sps[1].context.ParentID, report.sps[2].context.SpanID)
assert.Equal(t, report.sps[0].context.ParentID, report.sps[1].context.SpanID)
})
}

@ -20,8 +20,8 @@ func TestSpan(t *testing.T) {
t.Run("test fork", func(t *testing.T) {
sp1 := t1.New("testfork").(*Span)
sp2 := sp1.Fork("xxx", "opt_2").(*Span)
assert.Equal(t, sp1.context.traceID, sp2.context.traceID)
assert.Equal(t, sp1.context.spanID, sp2.context.parentID)
assert.Equal(t, sp1.context.TraceID, sp2.context.TraceID)
assert.Equal(t, sp1.context.SpanID, sp2.context.ParentID)
t.Run("test max fork", func(t *testing.T) {
sp3 := sp2.Fork("xx", "xxx")
for i := 0; i < 100; i++ {

Loading…
Cancel
Save