Skip to content

Commit

Permalink
chore: add test validating higher ranking for special resource attribs
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-k-singh committed Sep 25, 2024
1 parent 7f66dc2 commit c9e86ca
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion pkg/query-service/tests/integration/filter_suggestions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,44 @@ func TestLogsFilterSuggestionsWithExistingFilter(t *testing.T) {
func TestResourceAttribsRankedHigherInLogsFilterSuggestions(t *testing.T) {
require := require.New(t)

require.Equal(1, 2)
testAttribKeys := []v3.AttributeKey{}

tags := []string{"user_id", "user_email"}
for _, k := range tags {
testAttribKeys = append(testAttribKeys, v3.AttributeKey{
Key: k,
Type: v3.AttributeKeyTypeTag,
DataType: v3.AttributeKeyDataTypeArrayString,
IsColumn: false,
})
}

topResourceAttribs := []string{"service", "env"}
otherResourceAttribs := []string{"container_name", "container_id"}

for _, k := range append(otherResourceAttribs, topResourceAttribs...) {
testAttribKeys = append(testAttribKeys, v3.AttributeKey{
Key: k,
Type: v3.AttributeKeyTypeResource,
DataType: v3.AttributeKeyDataTypeArrayString,
IsColumn: false,
})
}

tb := NewFilterSuggestionsTestBed(t)
tb.mockAttribKeysQueryResponse(testAttribKeys)

suggestionsQueryParams := map[string]string{}
suggestionsResp := tb.GetQBFilterSuggestionsForLogs(suggestionsQueryParams)
suggestedKeys := []string{}
for _, k := range suggestionsResp.AttributeKeys {
suggestedKeys = append(suggestedKeys, k.Key)
}

expectedSuggestionKeys := append(topResourceAttribs, otherResourceAttribs...)
expectedSuggestionKeys = append(expectedSuggestionKeys, tags...)

require.Equal(expectedSuggestionKeys, suggestedKeys[:len(expectedSuggestionKeys)])
}

// Mocks response for CH queries made by reader.GetLogAttributeKeys
Expand Down

0 comments on commit c9e86ca

Please sign in to comment.