Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwanthgoli committed Mar 29, 2024
1 parent 24cd3ec commit 13f257b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
36 changes: 23 additions & 13 deletions pkg/logqlmodel/stats/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestResult(t *testing.T) {
stats.AddCacheRequest(IndexCache, 4)
stats.AddCacheRequest(ResultCache, 1)
stats.SetQueryReferencedStructuredMetadata()
stats.AddPipelineWrapperFilterdLines(1)

fakeIngesterQuery(ctx)
fakeIngesterQuery(ctx)
Expand All @@ -39,6 +40,7 @@ func TestResult(t *testing.T) {
TotalLinesSent: 60,
TotalReached: 2,
Store: Store{
PipelineWrapperFilteredLines: 2,
Chunk: Chunk{
HeadChunkBytes: 10,
HeadChunkLines: 20,
Expand All @@ -51,10 +53,11 @@ func TestResult(t *testing.T) {
},
Querier: Querier{
Store: Store{
TotalChunksRef: 50,
TotalChunksDownloaded: 60,
ChunksDownloadTime: time.Second.Nanoseconds(),
QueryReferencedStructured: true,
TotalChunksRef: 50,
TotalChunksDownloaded: 60,
ChunksDownloadTime: time.Second.Nanoseconds(),
QueryReferencedStructured: true,
PipelineWrapperFilteredLines: 1,
Chunk: Chunk{
HeadChunkBytes: 10,
HeadChunkLines: 20,
Expand Down Expand Up @@ -148,6 +151,7 @@ func fakeIngesterQuery(ctx context.Context) {
TotalBatches: 25,
TotalLinesSent: 30,
Store: Store{
PipelineWrapperFilteredLines: 1,
Chunk: Chunk{
HeadChunkBytes: 5,
HeadChunkLines: 10,
Expand All @@ -173,6 +177,7 @@ func TestResult_Merge(t *testing.T) {
TotalLinesSent: 60,
TotalReached: 2,
Store: Store{
PipelineWrapperFilteredLines: 4,
Chunk: Chunk{
HeadChunkBytes: 10,
HeadChunkLines: 20,
Expand All @@ -185,10 +190,11 @@ func TestResult_Merge(t *testing.T) {
},
Querier: Querier{
Store: Store{
TotalChunksRef: 50,
TotalChunksDownloaded: 60,
ChunksDownloadTime: time.Second.Nanoseconds(),
QueryReferencedStructured: true,
TotalChunksRef: 50,
TotalChunksDownloaded: 60,
ChunksDownloadTime: time.Second.Nanoseconds(),
QueryReferencedStructured: true,
PipelineWrapperFilteredLines: 2,
Chunk: Chunk{
HeadChunkBytes: 10,
HeadChunkLines: 20,
Expand Down Expand Up @@ -235,6 +241,7 @@ func TestResult_Merge(t *testing.T) {
TotalBatches: 2 * 50,
TotalLinesSent: 2 * 60,
Store: Store{
PipelineWrapperFilteredLines: 8,
Chunk: Chunk{
HeadChunkBytes: 2 * 10,
HeadChunkLines: 2 * 20,
Expand All @@ -248,10 +255,11 @@ func TestResult_Merge(t *testing.T) {
},
Querier: Querier{
Store: Store{
TotalChunksRef: 2 * 50,
TotalChunksDownloaded: 2 * 60,
ChunksDownloadTime: 2 * time.Second.Nanoseconds(),
QueryReferencedStructured: true,
TotalChunksRef: 2 * 50,
TotalChunksDownloaded: 2 * 60,
ChunksDownloadTime: 2 * time.Second.Nanoseconds(),
QueryReferencedStructured: true,
PipelineWrapperFilteredLines: 4,
Chunk: Chunk{
HeadChunkBytes: 2 * 10,
HeadChunkLines: 2 * 20,
Expand Down Expand Up @@ -306,13 +314,15 @@ func TestIngester(t *testing.T) {
statsCtx.AddDuplicates(10)
statsCtx.AddHeadChunkBytes(200)
statsCtx.SetQueryReferencedStructuredMetadata()
statsCtx.AddPipelineWrapperFilterdLines(1)
require.Equal(t, Ingester{
TotalReached: 1,
TotalChunksMatched: 100,
TotalBatches: 25,
TotalLinesSent: 30,
Store: Store{
QueryReferencedStructured: true,
QueryReferencedStructured: true,
PipelineWrapperFilteredLines: 1,
Chunk: Chunk{
HeadChunkBytes: 200,
CompressedBytes: 100,
Expand Down
20 changes: 12 additions & 8 deletions pkg/querier/queryrange/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,8 @@ var (
"totalChunksRef": 0,
"totalChunksDownloaded": 0,
"chunkRefsFetchTime": 0,
"queryReferencedStructuredMetadata": false
"queryReferencedStructuredMetadata": false,
"pipelineWrapperFilteredLines": 2
},
"totalBatches": 6,
"totalChunksMatched": 7,
Expand All @@ -1590,7 +1591,8 @@ var (
"totalChunksRef": 17,
"totalChunksDownloaded": 18,
"chunkRefsFetchTime": 19,
"queryReferencedStructuredMetadata": true
"queryReferencedStructuredMetadata": true,
"pipelineWrapperFilteredLines": 4
}
},
"index": {
Expand Down Expand Up @@ -2023,17 +2025,19 @@ var (
PostFilterLines: 0,
TotalDuplicates: 19,
},
ChunksDownloadTime: 16,
CongestionControlLatency: 0,
TotalChunksRef: 17,
TotalChunksDownloaded: 18,
ChunkRefsFetchTime: 19,
QueryReferencedStructured: true,
ChunksDownloadTime: 16,
CongestionControlLatency: 0,
TotalChunksRef: 17,
TotalChunksDownloaded: 18,
ChunkRefsFetchTime: 19,
QueryReferencedStructured: true,
PipelineWrapperFilteredLines: 4,
},
},

Ingester: stats.Ingester{
Store: stats.Store{
PipelineWrapperFilteredLines: 2,
Chunk: stats.Chunk{
CompressedBytes: 1,
DecompressedBytes: 2,
Expand Down
2 changes: 2 additions & 0 deletions pkg/querier/queryrange/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var emptyStats = `"stats": {
"totalChunksDownloaded": 0,
"chunkRefsFetchTime": 0,
"queryReferencedStructuredMetadata": false,
"pipelineWrapperFilteredLines": 0,
"chunk" :{
"compressedBytes": 0,
"decompressedBytes": 0,
Expand All @@ -50,6 +51,7 @@ var emptyStats = `"stats": {
"totalChunksDownloaded": 0,
"chunkRefsFetchTime": 0,
"queryReferencedStructuredMetadata": false,
"pipelineWrapperFilteredLines": 0,
"chunk" :{
"compressedBytes": 0,
"decompressedBytes": 0,
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/marshal/legacy/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var queryTests = []struct {
"totalChunksDownloaded": 0,
"chunkRefsFetchTime": 0,
"queryReferencedStructuredMetadata": false,
"pipelineWrapperFilteredLines": 0,
"chunk" :{
"compressedBytes": 0,
"decompressedBytes": 0,
Expand All @@ -93,6 +94,7 @@ var queryTests = []struct {
"totalChunksDownloaded": 0,
"chunkRefsFetchTime": 0,
"queryReferencedStructuredMetadata": false,
"pipelineWrapperFilteredLines": 0,
"chunk" :{
"compressedBytes": 0,
"decompressedBytes": 0,
Expand Down

0 comments on commit 13f257b

Please sign in to comment.