Skip to content

Commit

Permalink
int64 expected
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente committed Sep 13, 2024
1 parent ac2453f commit 217549e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
13 changes: 7 additions & 6 deletions diode-server/reconciler/logs_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,21 @@ func retrieveIngestionStatsSummary(ctx context.Context, client RedisClient) (*re
}

conv := convertMapInterface(res)
totalResults, ok := conv.(map[string]interface{})["total_results"].(int32)
totalRes, ok := conv.(map[string]interface{})["total_results"].(int64)
if !ok {
return nil, fmt.Errorf("failed to retrieve ingestion logs: failed to parse total_results")
}
total := int32(totalRes)
if q == int(reconcilerpb.State_NEW) {
stats.New = &totalResults
stats.New = &total
} else if q == int(reconcilerpb.State_RECONCILED) {
stats.Reconciled = &totalResults
stats.Reconciled = &total
} else if q == int(reconcilerpb.State_FAILED) {
stats.Failed = &totalResults
stats.Failed = &total
} else if q == int(reconcilerpb.State_NO_CHANGES) {
stats.NoChanges = &totalResults
stats.NoChanges = &total
} else {
stats.Total = &totalResults
stats.Total = &total
}
}
return &reconcilerpb.RetrieveIngestionLogsResponse{Logs: nil, Stats: &stats, NextPageToken: ""}, nil
Expand Down
30 changes: 14 additions & 16 deletions diode-server/reconciler/server_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,24 +776,22 @@ func TestRetrieveLogsSummary(t *testing.T) {
}{
{
name: "valid request",
expectedTotal: int32(10),
expectedTotal: int64(10),
cmdError: false,
hasError: false,
},
{
name: "query error",
expectedTotal: int32(10),
cmdError: true,
hasError: true,
errorMsg: "failed to retrieve ingestion logs: cmd error",
name: "query error",
cmdError: true,
hasError: true,
errorMsg: "failed to retrieve ingestion logs: cmd error",
},
{
name: "query error",
expectedTotal: int32(10),
cmdError: false,
execError: errors.New("exec error"),
hasError: true,
errorMsg: "failed to retrieve ingestion logs: exec error",
name: "exec error",
cmdError: false,
execError: errors.New("exec error"),
hasError: true,
errorMsg: "failed to retrieve ingestion logs: exec error",
},
{
name: "error getting total results",
Expand Down Expand Up @@ -843,7 +841,7 @@ func TestRetrieveLogsSummary(t *testing.T) {
"results": []interface{}{
map[interface{}]interface{}{},
},
"total_results": *expected.New,
"total_results": int64(*expected.New),
"warning": []interface{}{},
}))
mockPipeliner.On("Do", ctx, []interface{}{"FT.SEARCH", "ingest-entity", "@state:[1 1]", "LIMIT", 0, 0}).Return(cmdNew)
Expand All @@ -855,7 +853,7 @@ func TestRetrieveLogsSummary(t *testing.T) {
"results": []interface{}{
map[interface{}]interface{}{},
},
"total_results": *expected.Reconciled,
"total_results": int64(*expected.Reconciled),
"warning": []interface{}{},
}))
mockPipeliner.On("Do", ctx, []interface{}{"FT.SEARCH", "ingest-entity", "@state:[2 2]", "LIMIT", 0, 0}).Return(cmdReconciled)
Expand All @@ -867,7 +865,7 @@ func TestRetrieveLogsSummary(t *testing.T) {
"results": []interface{}{
map[interface{}]interface{}{},
},
"total_results": *expected.Failed,
"total_results": int64(*expected.Failed),
"warning": []interface{}{},
}))
mockPipeliner.On("Do", ctx, []interface{}{"FT.SEARCH", "ingest-entity", "@state:[3 3]", "LIMIT", 0, 0}).Return(cmdFailed)
Expand All @@ -879,7 +877,7 @@ func TestRetrieveLogsSummary(t *testing.T) {
"results": []interface{}{
map[interface{}]interface{}{},
},
"total_results": *expected.NoChanges,
"total_results": int64(*expected.NoChanges),
"warning": []interface{}{},
}))
mockPipeliner.On("Do", ctx, []interface{}{"FT.SEARCH", "ingest-entity", "@state:[4 4]", "LIMIT", 0, 0}).Return(cmdNoChanges)
Expand Down

0 comments on commit 217549e

Please sign in to comment.