(t *testing.T)
| 1471 | } |
| 1472 | |
| 1473 | func TestHelpStringFix(t *testing.T) { |
| 1474 | dms := NewDiskMetricStore("", 100*time.Millisecond, prometheus.DefaultGatherer, logger) |
| 1475 | |
| 1476 | ts1 := time.Now() |
| 1477 | errCh := make(chan error, 1) |
| 1478 | dms.SubmitWriteRequest(WriteRequest{ |
| 1479 | Labels: map[string]string{ |
| 1480 | "job": "job1", |
| 1481 | }, |
| 1482 | Timestamp: ts1, |
| 1483 | MetricFamilies: map[string]*dto.MetricFamily{ |
| 1484 | "go_goroutines": mfgg, |
| 1485 | "mf_help": mfh1, |
| 1486 | }, |
| 1487 | }) |
| 1488 | dms.SubmitWriteRequest(WriteRequest{ |
| 1489 | Labels: map[string]string{ |
| 1490 | "job": "job2", |
| 1491 | }, |
| 1492 | Timestamp: ts1, |
| 1493 | MetricFamilies: map[string]*dto.MetricFamily{ |
| 1494 | "mf_help": mfh2, |
| 1495 | }, |
| 1496 | Done: errCh, |
| 1497 | }) |
| 1498 | for err := range errCh { |
| 1499 | t.Fatal("Unexpected error:", err) |
| 1500 | } |
| 1501 | |
| 1502 | // Either we have settled on the mfh1 help string or the mfh2 help string. |
| 1503 | gotMFs := dms.GetMetricFamilies() |
| 1504 | if len(gotMFs) != 4 { |
| 1505 | t.Fatalf("expected 4 metric families, got %d", len(gotMFs)) |
| 1506 | } |
| 1507 | gotMFsAsStrings := make([]string, len(gotMFs)) |
| 1508 | for i, mf := range gotMFs { |
| 1509 | sort.Sort(metricSorter(mf.GetMetric())) |
| 1510 | gotMFsAsStrings[i] = mf.String() |
| 1511 | } |
| 1512 | sort.Strings(gotMFsAsStrings) |
| 1513 | gotGG := gotMFsAsStrings[0] |
| 1514 | got12 := gotMFsAsStrings[1] |
| 1515 | expectedGG := mfggFixed.String() |
| 1516 | expected12 := mfh12.String() |
| 1517 | expected21 := mfh21.String() |
| 1518 | |
| 1519 | if gotGG != expectedGG { |
| 1520 | t.Errorf( |
| 1521 | "help strings weren't properly adjusted, got '%s', expected '%s'", |
| 1522 | gotGG, expectedGG, |
| 1523 | ) |
| 1524 | } |
| 1525 | if got12 != expected12 && got12 != expected21 { |
| 1526 | t.Errorf( |
| 1527 | "help strings weren't properly adjusted, got '%s' which is neither '%s' nor '%s'", |
| 1528 | got12, expected12, expected21, |
| 1529 | ) |
| 1530 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…