Skip to content

Commit

Permalink
Add more integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
  • Loading branch information
rubenvp8510 committed Dec 14, 2023
1 parent d9b6af3 commit 39f270a
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions integration/e2e/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,44 @@ func TestSearchTagValuesV2(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
callSearchTagValuesAndAssert(t, tempo, tc.tagName, tc.query, tc.expected)
callSearchTagValuesAndAssert(t, tempo, tc.tagName, tc.query, tc.expected, 0, 0)
})
}

// Wait to block flushed to backend
time.Sleep(5)

// Assert no more on the ingester
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
callSearchTagValuesAndAssert(t, tempo, tc.tagName, tc.query, searchTagValuesResponse{}, 0, 0)
})
}

// Assert tags on storage backend
now := time.Now()
startOfDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
endOfDay := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999999999, now.Location())

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
callSearchTagValuesAndAssert(t, tempo, tc.tagName, tc.query, searchTagValuesResponse{}, startOfDay.Unix(), endOfDay.Unix())
})
}

}

func callSearchTagValuesAndAssert(t *testing.T, svc *e2e.HTTPService, tagName, query string, expected searchTagValuesResponse) {
func callSearchTagValuesAndAssert(t *testing.T, svc *e2e.HTTPService, tagName, query string, expected searchTagValuesResponse, start, end int64) {
urlPath := fmt.Sprintf(`/api/v2/search/tag/%s/values?q=%s`, tagName, url.QueryEscape(query))

if start != 0 {
urlPath = fmt.Sprintf("%s&start=0", urlPath)
}

if end != 0 {
urlPath = fmt.Sprintf("%s&end=0", urlPath)
}

// search for tag values
req, err := http.NewRequest(http.MethodGet, "http://"+svc.Endpoint(3200)+urlPath, nil)
require.NoError(t, err)
Expand Down

0 comments on commit 39f270a

Please sign in to comment.