Skip to content

Commit

Permalink
test(linters): Enable testifylint: blank-import, float-compare, negat…
Browse files Browse the repository at this point in the history
…ive-positive, nil-compare and useless-assert
  • Loading branch information
zak-pawel committed Jun 25, 2024
1 parent e561156 commit a3bceb7
Show file tree
Hide file tree
Showing 34 changed files with 102 additions and 96 deletions.
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,22 @@ linters-settings:
# len, negative-positive, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert
# ).
enable:
- blank-import
- bool-compare
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- float-compare
- len
- negative-positive
- nil-compare
- require-error
- suite-dont-use-pkg
- suite-extra-assert-call
- suite-thelper
- useless-assert

run:
# Timeout for analysis, e.g. 30s, 5m.
Expand Down
2 changes: 1 addition & 1 deletion agent/accumulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAddFields(t *testing.T) {
actual, ok := testm.GetField("usage")

require.True(t, ok)
require.Equal(t, float64(99), actual)
require.InDelta(t, float64(99), actual, 0.001)

actual, ok = testm.GetTag("foo")
require.True(t, ok)
Expand Down
2 changes: 1 addition & 1 deletion metric/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestAddFieldOverwrites(t *testing.T) {

value, ok := m.GetField("value")
require.True(t, ok)
require.Equal(t, 42.0, value)
require.InDelta(t, 42.0, value, 0.001)
}

func TestAddFieldChangesType(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/ceph/ceph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ func TestParseOsdDump(t *testing.T) {
dump, err := c.parseDump(osdPerfDump)
require.NoError(t, err)
require.InEpsilon(t, 552132.109360000, dump["filestore"]["commitcycle_interval.sum"], epsilon)
require.Equal(t, float64(0), dump["mutex-FileJournal::finisher_lock"]["wait.avgcount"])
require.InDelta(t, float64(0), dump["mutex-FileJournal::finisher_lock"]["wait.avgcount"], 0.001)
}

func TestParseMdsDump(t *testing.T) {
c := &Ceph{Log: testutil.Logger{}}
dump, err := c.parseDump(mdsPerfDump)
require.NoError(t, err)
require.InEpsilon(t, 2408386.600934982, dump["mds"]["reply_latency.sum"], epsilon)
require.Equal(t, float64(0), dump["throttle-write_buf_throttle"]["wait.avgcount"])
require.InDelta(t, float64(0), dump["throttle-write_buf_throttle"]["wait.avgcount"], 0.001)
}

func TestParseRgwDump(t *testing.T) {
c := &Ceph{Log: testutil.Logger{}}
dump, err := c.parseDump(rgwPerfDump)
require.NoError(t, err)
require.InEpsilon(t, 0.002219876, dump["rgw"]["get_initial_lat.sum"], epsilon)
require.Equal(t, float64(0), dump["rgw"]["put_initial_lat.avgcount"])
require.InDelta(t, float64(0), dump["rgw"]["put_initial_lat.avgcount"], 0.001)
}

func TestDecodeStatus(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/cloud_pubsub/cloud_pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ func TestRunErrorInSubscriber(t *testing.T) {
func validateTestInfluxMetric(t *testing.T, m *testutil.Metric) {
require.Equal(t, "cpu_load_short", m.Measurement)
require.Equal(t, "server01", m.Tags["host"])
require.Equal(t, 23422.0, m.Fields["value"])
require.InDelta(t, 23422.0, m.Fields["value"], 0.001)
require.Equal(t, int64(1422568543702900257), m.Time.UnixNano())
}
4 changes: 2 additions & 2 deletions plugins/inputs/ctrlx_datalayer/ctrlx_datalayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestCtrlXMetricsField(t *testing.T) {
require.NoError(t, acc.GatherError(s.Start))
require.Eventually(t, func() bool {
if v, found := acc.FloatField(measurement, fieldName); found {
require.Equal(t, 43.0, v)
require.InDelta(t, 43.0, v, 0.001)
return true
}
return false
Expand All @@ -226,7 +226,7 @@ func TestCtrlXMetricsMulti(t *testing.T) {
require.NoError(t, acc.GatherError(s.Start))
require.Eventually(t, func() bool {
if v, found := acc.FloatField(measurement, fieldName); found {
require.Equal(t, 44.0, v)
require.InDelta(t, 44.0, v, 0.001)
return true
}
return false
Expand Down
50 changes: 25 additions & 25 deletions plugins/inputs/fluentd/fluentd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,41 +200,41 @@ func Test_Gather(t *testing.T) {
require.Equal(t, expectedOutput[0].PluginID, acc.Metrics[0].Tags["plugin_id"])
require.Equal(t, expectedOutput[0].PluginType, acc.Metrics[0].Tags["plugin_type"])
require.Equal(t, expectedOutput[0].PluginCategory, acc.Metrics[0].Tags["plugin_category"])
require.Equal(t, *expectedOutput[0].RetryCount, acc.Metrics[0].Fields["retry_count"])
require.InDelta(t, *expectedOutput[0].RetryCount, acc.Metrics[0].Fields["retry_count"], 0.001)

require.Equal(t, expectedOutput[1].PluginID, acc.Metrics[1].Tags["plugin_id"])
require.Equal(t, expectedOutput[1].PluginType, acc.Metrics[1].Tags["plugin_type"])
require.Equal(t, expectedOutput[1].PluginCategory, acc.Metrics[1].Tags["plugin_category"])
require.Equal(t, *expectedOutput[1].RetryCount, acc.Metrics[1].Fields["retry_count"])
require.Equal(t, *expectedOutput[1].BufferQueueLength, acc.Metrics[1].Fields["buffer_queue_length"])
require.Equal(t, *expectedOutput[1].BufferTotalQueuedSize, acc.Metrics[1].Fields["buffer_total_queued_size"])
require.InDelta(t, *expectedOutput[1].RetryCount, acc.Metrics[1].Fields["retry_count"], 0.001)
require.InDelta(t, *expectedOutput[1].BufferQueueLength, acc.Metrics[1].Fields["buffer_queue_length"], 0.001)
require.InDelta(t, *expectedOutput[1].BufferTotalQueuedSize, acc.Metrics[1].Fields["buffer_total_queued_size"], 0.001)

require.Equal(t, expectedOutput[2].PluginID, acc.Metrics[2].Tags["plugin_id"])
require.Equal(t, expectedOutput[2].PluginType, acc.Metrics[2].Tags["plugin_type"])
require.Equal(t, expectedOutput[2].PluginCategory, acc.Metrics[2].Tags["plugin_category"])
require.Equal(t, *expectedOutput[2].RetryCount, acc.Metrics[2].Fields["retry_count"])
require.Equal(t, *expectedOutput[2].BufferQueueLength, acc.Metrics[2].Fields["buffer_queue_length"])
require.Equal(t, *expectedOutput[2].BufferTotalQueuedSize, acc.Metrics[2].Fields["buffer_total_queued_size"])
require.Equal(t, *expectedOutput[2].EmitRecords, acc.Metrics[2].Fields["emit_records"])
require.Equal(t, *expectedOutput[2].EmitSize, acc.Metrics[2].Fields["emit_size"])
require.Equal(t, *expectedOutput[2].EmitCount, acc.Metrics[2].Fields["emit_count"])
require.Equal(t, *expectedOutput[2].RollbackCount, acc.Metrics[2].Fields["rollback_count"])
require.Equal(t, *expectedOutput[2].SlowFlushCount, acc.Metrics[2].Fields["slow_flush_count"])
require.Equal(t, *expectedOutput[2].WriteCount, acc.Metrics[2].Fields["write_count"])
require.Equal(t, *expectedOutput[2].FlushTimeCount, acc.Metrics[2].Fields["flush_time_count"])
require.Equal(t, *expectedOutput[2].BufferStageLength, acc.Metrics[2].Fields["buffer_stage_length"])
require.Equal(t, *expectedOutput[2].BufferStageByteSize, acc.Metrics[2].Fields["buffer_stage_byte_size"])
require.Equal(t, *expectedOutput[2].BufferQueueByteSize, acc.Metrics[2].Fields["buffer_queue_byte_size"])
require.Equal(t, *expectedOutput[2].AvailBufferSpaceRatios, acc.Metrics[2].Fields["buffer_available_buffer_space_ratios"])
require.InDelta(t, *expectedOutput[2].RetryCount, acc.Metrics[2].Fields["retry_count"], 0.001)
require.InDelta(t, *expectedOutput[2].BufferQueueLength, acc.Metrics[2].Fields["buffer_queue_length"], 0.001)
require.InDelta(t, *expectedOutput[2].BufferTotalQueuedSize, acc.Metrics[2].Fields["buffer_total_queued_size"], 0.001)
require.InDelta(t, *expectedOutput[2].EmitRecords, acc.Metrics[2].Fields["emit_records"], 0.001)
require.InDelta(t, *expectedOutput[2].EmitSize, acc.Metrics[2].Fields["emit_size"], 0.001)
require.InDelta(t, *expectedOutput[2].EmitCount, acc.Metrics[2].Fields["emit_count"], 0.001)
require.InDelta(t, *expectedOutput[2].RollbackCount, acc.Metrics[2].Fields["rollback_count"], 0.001)
require.InDelta(t, *expectedOutput[2].SlowFlushCount, acc.Metrics[2].Fields["slow_flush_count"], 0.001)
require.InDelta(t, *expectedOutput[2].WriteCount, acc.Metrics[2].Fields["write_count"], 0.001)
require.InDelta(t, *expectedOutput[2].FlushTimeCount, acc.Metrics[2].Fields["flush_time_count"], 0.001)
require.InDelta(t, *expectedOutput[2].BufferStageLength, acc.Metrics[2].Fields["buffer_stage_length"], 0.001)
require.InDelta(t, *expectedOutput[2].BufferStageByteSize, acc.Metrics[2].Fields["buffer_stage_byte_size"], 0.001)
require.InDelta(t, *expectedOutput[2].BufferQueueByteSize, acc.Metrics[2].Fields["buffer_queue_byte_size"], 0.001)
require.InDelta(t, *expectedOutput[2].AvailBufferSpaceRatios, acc.Metrics[2].Fields["buffer_available_buffer_space_ratios"], 0.001)

require.Equal(t, expectedOutput[3].PluginID, acc.Metrics[3].Tags["plugin_id"])
require.Equal(t, expectedOutput[3].PluginType, acc.Metrics[3].Tags["plugin_type"])
require.Equal(t, expectedOutput[3].PluginCategory, acc.Metrics[3].Tags["plugin_category"])
require.Equal(t, *expectedOutput[3].RetryCount, acc.Metrics[3].Fields["retry_count"])
require.Equal(t, *expectedOutput[3].BufferQueueLength, acc.Metrics[3].Fields["buffer_queue_length"])
require.Equal(t, *expectedOutput[3].BufferTotalQueuedSize, acc.Metrics[3].Fields["buffer_total_queued_size"])
require.Equal(t, *expectedOutput[3].EmitRecords, acc.Metrics[3].Fields["emit_records"])
require.Equal(t, *expectedOutput[3].RollbackCount, acc.Metrics[3].Fields["rollback_count"])
require.Equal(t, *expectedOutput[3].SlowFlushCount, acc.Metrics[3].Fields["slow_flush_count"])
require.Equal(t, *expectedOutput[3].AvailBufferSpaceRatios, acc.Metrics[3].Fields["buffer_available_buffer_space_ratios"])
require.InDelta(t, *expectedOutput[3].RetryCount, acc.Metrics[3].Fields["retry_count"], 0.001)
require.InDelta(t, *expectedOutput[3].BufferQueueLength, acc.Metrics[3].Fields["buffer_queue_length"], 0.001)
require.InDelta(t, *expectedOutput[3].BufferTotalQueuedSize, acc.Metrics[3].Fields["buffer_total_queued_size"], 0.001)
require.InDelta(t, *expectedOutput[3].EmitRecords, acc.Metrics[3].Fields["emit_records"], 0.001)
require.InDelta(t, *expectedOutput[3].RollbackCount, acc.Metrics[3].Fields["rollback_count"], 0.001)
require.InDelta(t, *expectedOutput[3].SlowFlushCount, acc.Metrics[3].Fields["slow_flush_count"], 0.001)
require.InDelta(t, *expectedOutput[3].AvailBufferSpaceRatios, acc.Metrics[3].Fields["buffer_available_buffer_space_ratios"], 0.001)
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func TestRunGatherOneItem(t *testing.T) {
require.Equal(t, "cpu", metric.Measurement)
require.Equal(t, "us-east-1", metric.Tags["tags_datacenter"])
require.Equal(t, "localhost", metric.Tags["tags_host"])
require.Equal(t, 10.0, metric.Fields["fields_cosine"])
require.Equal(t, -1.0975806427415925e-12, metric.Fields["fields_sine"])
require.InDelta(t, 10.0, metric.Fields["fields_cosine"], 0.001)
require.InDelta(t, -1.0975806427415925e-12, metric.Fields["fields_sine"], 0.001)
}

func TestRunGatherOneIteration(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestHTTPWithJSONFormat(t *testing.T) {
var metric = acc.Metrics[0]
require.Equal(t, metric.Measurement, metricName)
require.Len(t, acc.Metrics[0].Fields, 1)
require.Equal(t, 1.2, acc.Metrics[0].Fields["a"])
require.InDelta(t, 1.2, acc.Metrics[0].Fields["a"], 0.001)
require.Equal(t, acc.Metrics[0].Tags["url"], address)
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/http_response/http_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func checkFields(t *testing.T, fields map[string]interface{}, acc *testutil.Accu
case float64:
value, ok := acc.FloatField("http_response", key)
require.True(t, ok)
require.Equal(t, field, value)
require.InDelta(t, field, value, 0.001)
case string:
value, ok := acc.StringField("http_response", key)
require.True(t, ok)
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/intel_dlb/intel_dlb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func TestDLB_gatherSecondDeviceIndex(t *testing.T) {
mockConn.On("Close").Return(nil).Once()

_, err := dlb.gatherSecondDeviceIndex(0, dlb.EventdevCommands[0])
require.Equal(t, nil, dlb.connection)
require.Nil(t, dlb.connection)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to parse json")
dlb.SocketPath = pathToSocket
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/intel_powerstat/intel_powerstat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4948,8 +4948,8 @@ func TestGetUncoreFreqInitialLimits(t *testing.T) {
initMin, initMax, err := getUncoreFreqInitialLimits(mFetcher, packageID, dieID)

require.NoError(t, err)
require.Equal(t, initMinExp, initMin)
require.Equal(t, initMaxExp, initMax)
require.InDelta(t, initMinExp, initMin, 0.001)
require.InDelta(t, initMaxExp, initMax, 0.001)
mFetcher.AssertExpectations(t)
})
}
Expand Down
24 changes: 12 additions & 12 deletions plugins/inputs/intel_rdt/publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func TestParseCoresMeasurement(t *testing.T) {
require.NoError(t, err)
require.Equal(t, expectedCores, result.cores)
require.Equal(t, expectedTimestamp, result.time)
require.Equal(t, result.values[0], metricsValues["IPC"])
require.Equal(t, result.values[1], metricsValues["LLC_Misses"])
require.Equal(t, result.values[2], metricsValues["LLC"])
require.Equal(t, result.values[3], metricsValues["MBL"])
require.Equal(t, result.values[4], metricsValues["MBR"])
require.Equal(t, result.values[5], metricsValues["MBT"])
require.InDelta(t, result.values[0], metricsValues["IPC"], 0.001)
require.InDelta(t, result.values[1], metricsValues["LLC_Misses"], 0.001)
require.InDelta(t, result.values[2], metricsValues["LLC"], 0.001)
require.InDelta(t, result.values[3], metricsValues["MBL"], 0.001)
require.InDelta(t, result.values[4], metricsValues["MBR"], 0.001)
require.InDelta(t, result.values[5], metricsValues["MBT"], 0.001)
})
t.Run("not valid measurement string", func(t *testing.T) {
measurement := "not, valid, measurement"
Expand Down Expand Up @@ -131,12 +131,12 @@ func TestParseProcessesMeasurement(t *testing.T) {
require.Equal(t, processName, result.process)
require.Equal(t, expectedCores, result.cores)
require.Equal(t, expectedTimestamp, result.time)
require.Equal(t, result.values[0], metricsValues["IPC"])
require.Equal(t, result.values[1], metricsValues["LLC_Misses"])
require.Equal(t, result.values[2], metricsValues["LLC"])
require.Equal(t, result.values[3], metricsValues["MBL"])
require.Equal(t, result.values[4], metricsValues["MBR"])
require.Equal(t, result.values[5], metricsValues["MBT"])
require.InDelta(t, result.values[0], metricsValues["IPC"], 0.001)
require.InDelta(t, result.values[1], metricsValues["LLC_Misses"], 0.001)
require.InDelta(t, result.values[2], metricsValues["LLC"], 0.001)
require.InDelta(t, result.values[3], metricsValues["MBL"], 0.001)
require.InDelta(t, result.values[4], metricsValues["MBR"], 0.001)
require.InDelta(t, result.values[5], metricsValues["MBT"], 0.001)
})

invalidTimestamp := "2020-20-20-31"
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestGather(t *testing.T) {
for k, v := range metric.Fields {
switch k {
case "abc":
require.Equal(t, 50.0, v)
require.InDelta(t, 50.0, v, 0.001)
case "constant_string":
require.Equal(t, testConstantString.Value, v)
case "constant_float":
Expand All @@ -88,9 +88,9 @@ func TestGather(t *testing.T) {
require.GreaterOrEqual(t, 6.0, v)
require.LessOrEqual(t, 1.0, v)
case "sine":
require.Equal(t, 2.0, v)
require.InDelta(t, 2.0, v, 0.001)
case "step":
require.Equal(t, 0.0, v)
require.InDelta(t, 0.0, v, 0.001)
default:
require.Failf(t, "unexpected field %q", k)
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/netflow/type_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestDecodeFloat64(t *testing.T) {
require.NoError(t, err)
out, ok := v.(float64)
require.True(t, ok)
require.Equal(t, float64(3.14159265359), out)
require.InDelta(t, float64(3.14159265359), out, 0.001)
}

func TestDecodeBool(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/pgbouncer/pgbouncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestPgBouncerGeneratesMetricsIntegration(t *testing.T) {
metricsCounted++
}

require.Greater(t, metricsCounted, 0)
require.Positive(t, metricsCounted)
require.Equal(t, len(intMetricsPgBouncer)+len(intMetricsPgBouncerPools), metricsCounted)
}

Expand Down Expand Up @@ -210,6 +210,6 @@ func TestPgBouncerGeneratesMetricsIntegrationShowCommands(t *testing.T) {
metricsCounted++
}

require.Greater(t, metricsCounted, 0)
require.Positive(t, metricsCounted)
require.Equal(t, len(intMetricsPgBouncerPools)+len(intMetricsPgBouncerLists)+len(intMetricsPgBouncerDatabases), metricsCounted)
}
6 changes: 3 additions & 3 deletions plugins/inputs/ping/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,11 @@ func TestPingGatherNative(t *testing.T) {
require.True(t, acc.HasPoint("ping", map[string]string{"url": "localhost"}, "packets_transmitted", 5))
require.True(t, acc.HasPoint("ping", map[string]string{"url": "localhost"}, "packets_received", 5))
require.True(t, acc.HasField("ping", "percentile50_ms"))
require.Equal(t, float64(3), acc.Metrics[0].Fields["percentile50_ms"])
require.InDelta(t, float64(3), acc.Metrics[0].Fields["percentile50_ms"], 0.001)
require.True(t, acc.HasField("ping", "percentile95_ms"))
require.Equal(t, float64(4.799999), acc.Metrics[0].Fields["percentile95_ms"])
require.InDelta(t, float64(4.799999), acc.Metrics[0].Fields["percentile95_ms"], 0.001)
require.True(t, acc.HasField("ping", "percentile99_ms"))
require.Equal(t, float64(4.96), acc.Metrics[0].Fields["percentile99_ms"])
require.InDelta(t, float64(4.96), acc.Metrics[0].Fields["percentile99_ms"], 0.001)
require.True(t, acc.HasField("ping", "percent_packet_loss"))
require.True(t, acc.HasField("ping", "minimum_response_ms"))
require.True(t, acc.HasField("ping", "average_response_ms"))
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/postgresql/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestPostgresqlGeneratesMetricsIntegration(t *testing.T) {
metricsCounted++
}

require.Greater(t, metricsCounted, 0)
require.Positive(t, metricsCounted)
require.Equal(t, len(floatMetrics)+len(intMetrics)+len(int32Metrics)+len(stringMetrics), metricsCounted)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestPostgresqlGeneratesMetricsIntegration(t *testing.T) {
metricsCounted++
}

require.Greater(t, metricsCounted, 0)
require.Positive(t, metricsCounted)
require.Equal(t, len(floatMetrics)+len(intMetrics)+len(int32Metrics)+len(stringMetrics), metricsCounted)
}

Expand All @@ -136,7 +136,7 @@ func TestPostgresqlQueryOutputTestsIntegration(t *testing.T) {
"SELECT 10.0::float AS myvalue": func(acc *testutil.Accumulator) {
v, found := acc.FloatField(measurement, "myvalue")
require.True(t, found)
require.Equal(t, 10.0, v)
require.InDelta(t, 10.0, v, 0.001)
},
"SELECT 10.0 AS myvalue": func(acc *testutil.Accumulator) {
v, found := acc.StringField(measurement, "myvalue")
Expand Down
3 changes: 2 additions & 1 deletion plugins/inputs/statsd/statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,8 @@ func TestParse_MeasurementsWithMultipleValues(t *testing.T) {
// which adds up to 12 individual datapoints to be cached
require.EqualValuesf(t, 12, cachedtiming.fields[defaultFieldName].n, "Expected 12 additions, got %d", cachedtiming.fields[defaultFieldName].n)

require.EqualValuesf(t, 1, cachedtiming.fields[defaultFieldName].upper, "Expected max input to be 1, got %f", cachedtiming.fields[defaultFieldName].upper)
require.InDeltaf(t, 1, cachedtiming.fields[defaultFieldName].upper, 0.001,
"Expected max input to be 1, got %f", cachedtiming.fields[defaultFieldName].upper)

// test if sSingle and sMultiple did compute the same stats for valid.multiple.duplicate
require.NoError(t, testValidateSet("valid_multiple_duplicate", 2, sSingle.sets))
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/vsphere/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func testAlignUniform(t *testing.T, n int) {
require.Len(t, newInfo, n/3, "Aligned infos have wrong size")
require.Len(t, newValues, n/3, "Aligned values have wrong size")
for _, v := range newValues {
require.Equal(t, 1.0, v, "Aligned value should be 1")
require.InDelta(t, 1.0, v, 0.001, "Aligned value should be 1")
}
}

Expand All @@ -204,7 +204,7 @@ func TestAlignMetrics(t *testing.T) {
require.Len(t, newInfo, n/3, "Aligned infos have wrong size")
require.Len(t, newValues, n/3, "Aligned values have wrong size")
for _, v := range newValues {
require.Equal(t, 2.0, v, "Aligned value should be 2")
require.InDelta(t, 2.0, v, 0.001, "Aligned value should be 2")
}
}

Expand Down
Loading

0 comments on commit a3bceb7

Please sign in to comment.