mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
lib/storage: add a test for Storage.SearchMetricNames
This commit is contained in:
parent
467ed68a37
commit
ac7460abdd
@ -769,7 +769,7 @@ func testStorageRegisterMetricNames(s *Storage) error {
|
|||||||
}
|
}
|
||||||
now := timestampFromTime(time.Now())
|
now := timestampFromTime(time.Now())
|
||||||
for j := 0; j < metricsPerAdd; j++ {
|
for j := 0; j < metricsPerAdd; j++ {
|
||||||
mn.MetricGroup = []byte(fmt.Sprintf("metric_%d", rand.Intn(100)))
|
mn.MetricGroup = []byte(fmt.Sprintf("metric_%d", j))
|
||||||
metricNameRaw := mn.marshalRaw(nil)
|
metricNameRaw := mn.marshalRaw(nil)
|
||||||
|
|
||||||
mr := MetricRow{
|
mr := MetricRow{
|
||||||
@ -844,6 +844,29 @@ func testStorageRegisterMetricNames(s *Storage) error {
|
|||||||
return fmt.Errorf("unexpected tag values returned from SearchTagValuesOnTimeRange;\ngot\n%q\nwant\n%q", addIDs, addIDsExpected)
|
return fmt.Errorf("unexpected tag values returned from SearchTagValuesOnTimeRange;\ngot\n%q\nwant\n%q", addIDs, addIDsExpected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify that SearchMetricNames returns correct result.
|
||||||
|
tfs := NewTagFilters(accountID, projectID)
|
||||||
|
if err := tfs.Add([]byte("add_id"), []byte("0"), false, false); err != nil {
|
||||||
|
return fmt.Errorf("unexpected error in TagFilters.Add: %w", err)
|
||||||
|
}
|
||||||
|
mns, err := s.SearchMetricNames(accountID, projectID, []*TagFilters{tfs}, tr, metricsPerAdd*addsCount*100+100, noDeadline)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error in SearchMetricNames: %w", err)
|
||||||
|
}
|
||||||
|
if len(mns) < metricsPerAdd {
|
||||||
|
return fmt.Errorf("unexpected number of metricNames returned from SearchMetricNames; got %d; want at least %d", len(mns), int(metricsPerAdd))
|
||||||
|
}
|
||||||
|
for i, mn := range mns {
|
||||||
|
addID := mn.GetTagValue("add_id")
|
||||||
|
if string(addID) != "0" {
|
||||||
|
return fmt.Errorf("unexpected addID for metricName #%d; got %q; want %q", i, addID, "0")
|
||||||
|
}
|
||||||
|
job := mn.GetTagValue("job")
|
||||||
|
if string(job) != "webservice" {
|
||||||
|
return fmt.Errorf("unexpected job for metricName #%d; got %q; want %q", i, job, "webservice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user