Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
asuresh4 committed Sep 25, 2020
1 parent 7ab593e commit 6f4027d
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,19 @@ func TestScrapeMetrics(t *testing.T) {
assertFileSystemUsageMetricValid(t, metrics.At(1), fileSystemINodesUsageDescriptor, test.expectedDeviceDataPoints*2)
}

assertFileSystemUsageCommonMetricLabels(t, metrics)
internal.AssertSameTimeStampForAllMetrics(t, metrics)
})
}
}

func assertFileSystemUsageMetricValid(t *testing.T, metric pdata.Metric, descriptor pdata.Metric, expectedDeviceDataPoints int) {
internal.AssertDescriptorEqual(t, descriptor, metric)
for i := 0; i < metric.IntSum().DataPoints().Len(); i++ {
for _, label := range []string{deviceLabelName, filesystemTypeLabelName, mountModeLabelName, mountPointLabelName} {
internal.AssertIntSumMetricLabelExists(t, metric, i, label)
}
}

if expectedDeviceDataPoints > 0 {
assert.Equal(t, expectedDeviceDataPoints, metric.IntSum().DataPoints().Len())
} else {
Expand All @@ -144,16 +149,6 @@ func assertFileSystemUsageMetricValid(t *testing.T, metric pdata.Metric, descrip
internal.AssertIntSumMetricLabelHasValue(t, metric, 1, stateLabelName, freeLabelValue)
}

func assertFileSystemUsageCommonMetricLabels(t *testing.T, metrics pdata.MetricSlice) {
for i := 0; i < metrics.Len(); i++ {
for j := 0; j < metrics.At(i).IntSum().DataPoints().Len(); j++ {
for _, label := range []string{deviceLabelName, filesystemTypeLabelName, mountModeLabelName, mountPointLabelName} {
internal.AssertIntSumMetricLabelExists(t, metrics.At(i), j, label)
}
}
}
}

func assertFileSystemUsageMetricHasUnixSpecificStateLabels(t *testing.T, metric pdata.Metric) {
internal.AssertIntSumMetricLabelHasValue(t, metric, 2, stateLabelName, reservedLabelValue)
}
Expand Down

0 comments on commit 6f4027d

Please sign in to comment.