-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrew Putilov <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,802 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2020 The Jaeger Authors. | ||
// | ||
// Licensed 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 grpc | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
) | ||
|
||
// ArchiveWriter implements spanstore.Writer | ||
type ArchiveWriter struct { | ||
impl shared.ArchiveWriter | ||
} | ||
|
||
// WriteSpan saves the span | ||
func (w *ArchiveWriter) WriteSpan(span *model.Span) error { | ||
return w.impl.WriteArchiveSpan(span) | ||
} | ||
|
||
// ArchiveReader implements spanstore.Reader | ||
type ArchiveReader struct { | ||
impl shared.ArchiveReader | ||
} | ||
|
||
// GetTrace takes a traceID and returns a Trace associated with that traceID | ||
func (r *ArchiveReader) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { | ||
return r.impl.GetArchiveTrace(ctx, traceID) | ||
} | ||
|
||
// GetServices is not used by archive storage | ||
func (r *ArchiveReader) GetServices(ctx context.Context) ([]string, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// GetOperations is not used by archive storage | ||
func (r *ArchiveReader) GetOperations(ctx context.Context, query spanstore.OperationQueryParameters) ([]spanstore.Operation, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// FindTraces is not used by archive storage | ||
func (r *ArchiveReader) FindTraces(ctx context.Context, query *spanstore.TraceQueryParameters) ([]*model.Trace, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// FindTraceIDs is not used by archive storage | ||
func (r *ArchiveReader) FindTraceIDs(ctx context.Context, query *spanstore.TraceQueryParameters) ([]model.TraceID, error) { | ||
panic("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (c) 2020 The Jaeger Authors. | ||
// | ||
// Licensed 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 grpc | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared/mocks" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
) | ||
|
||
var ( | ||
mockTraceID = model.NewTraceID(0, 123456) | ||
mockSpan = &model.Span{ | ||
TraceID: mockTraceID, | ||
SpanID: model.NewSpanID(1), | ||
Process: &model.Process{}, | ||
} | ||
) | ||
|
||
func TestArchiveWriter_WriteSpan(t *testing.T) { | ||
archiveWriter := new(mocks.ArchiveWriter) | ||
archiveWriter.On("WriteArchiveSpan", mockSpan).Return(nil) | ||
writer := &ArchiveWriter{impl: archiveWriter} | ||
|
||
err := writer.WriteSpan(mockSpan) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func TestArchiveReader_GetTrace(t *testing.T) { | ||
expected := &model.Trace{ | ||
Spans: []*model.Span{ | ||
mockSpan, | ||
}, | ||
} | ||
archiveReader := new(mocks.ArchiveReader) | ||
archiveReader.On("GetArchiveTrace", mock.Anything, mockTraceID).Return(expected, nil) | ||
reader := &ArchiveReader{impl: archiveReader} | ||
|
||
trace, err := reader.GetTrace(context.Background(), mockTraceID) | ||
assert.NoError(t, err) | ||
assert.Equal(t, expected, trace) | ||
} | ||
|
||
func TestArchiveReader_FindTraceIDs(t *testing.T) { | ||
assert.Panics(t, func() { | ||
reader := ArchiveReader{impl: &mocks.ArchiveReader{}} | ||
_, _ = reader.FindTraceIDs(context.Background(), nil) | ||
}) | ||
} | ||
|
||
func TestArchiveReader_FindTraces(t *testing.T) { | ||
assert.Panics(t, func() { | ||
reader := ArchiveReader{impl: &mocks.ArchiveReader{}} | ||
_, _ = reader.FindTraces(context.Background(), nil) | ||
}) | ||
} | ||
|
||
func TestArchiveReader_GetOperations(t *testing.T) { | ||
assert.Panics(t, func() { | ||
reader := ArchiveReader{impl: &mocks.ArchiveReader{}} | ||
_, _ = reader.GetOperations(context.Background(), spanstore.OperationQueryParameters{}) | ||
}) | ||
} | ||
|
||
func TestArchiveReader_GetServices(t *testing.T) { | ||
assert.Panics(t, func() { | ||
reader := ArchiveReader{impl: &mocks.ArchiveReader{}} | ||
_, _ = reader.GetServices(context.Background()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.