clean up tests
This commit is contained in:
parent
9785d3c2c6
commit
5c8666d1af
|
|
@ -235,10 +235,6 @@ func testRFC5426(t *testing.T, protocol string, address string, bestEffort bool)
|
|||
require.NoError(t, receiver.Start(acc))
|
||||
defer receiver.Stop()
|
||||
|
||||
// Clear
|
||||
acc.ClearMetrics()
|
||||
acc.Errors = make([]error, 0)
|
||||
|
||||
// Connect
|
||||
conn, err := net.Dial(protocol, address)
|
||||
require.NotNil(t, conn)
|
||||
|
|
|
|||
|
|
@ -51,10 +51,11 @@ func TestExternalProcessorWorks(t *testing.T) {
|
|||
}
|
||||
|
||||
acc.Wait(1)
|
||||
m := acc.GetTelegrafMetrics()[0]
|
||||
|
||||
require.NoError(t, e.Stop())
|
||||
|
||||
metrics = acc.GetTelegrafMetrics()
|
||||
m := metrics[0]
|
||||
|
||||
expected := testutil.MustMetric("test",
|
||||
map[string]string{
|
||||
"city": "Toronto",
|
||||
|
|
@ -70,8 +71,6 @@ func TestExternalProcessorWorks(t *testing.T) {
|
|||
metricTime := m.Time().UnixNano()
|
||||
|
||||
// read the other 9 and make sure they're ordered properly
|
||||
acc.Wait(9)
|
||||
metrics = acc.GetTelegrafMetrics()
|
||||
for i := 0; i < 9; i++ {
|
||||
m = metrics[i+1]
|
||||
require.EqualValues(t, metricTime+1, m.Time().UnixNano())
|
||||
|
|
|
|||
|
|
@ -55,8 +55,6 @@ func (a *Accumulator) NMetrics() uint64 {
|
|||
}
|
||||
|
||||
func (a *Accumulator) GetTelegrafMetrics() []telegraf.Metric {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
metrics := []telegraf.Metric{}
|
||||
for _, m := range a.Metrics {
|
||||
metrics = append(metrics, FromTestMetric(m))
|
||||
|
|
@ -253,8 +251,6 @@ func (a *Accumulator) SetDebug(debug bool) {
|
|||
|
||||
// Get gets the specified measurement point from the accumulator
|
||||
func (a *Accumulator) Get(measurement string) (*Metric, bool) {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
for _, p := range a.Metrics {
|
||||
if p.Measurement == measurement {
|
||||
return p, true
|
||||
|
|
@ -265,8 +261,6 @@ func (a *Accumulator) Get(measurement string) (*Metric, bool) {
|
|||
}
|
||||
|
||||
func (a *Accumulator) HasTag(measurement string, key string) bool {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
for _, p := range a.Metrics {
|
||||
if p.Measurement == measurement {
|
||||
_, ok := p.Tags[key]
|
||||
|
|
@ -277,8 +271,6 @@ func (a *Accumulator) HasTag(measurement string, key string) bool {
|
|||
}
|
||||
|
||||
func (a *Accumulator) TagSetValue(measurement string, key string) string {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
for _, p := range a.Metrics {
|
||||
if p.Measurement == measurement {
|
||||
v, ok := p.Tags[key]
|
||||
|
|
@ -291,8 +283,6 @@ func (a *Accumulator) TagSetValue(measurement string, key string) string {
|
|||
}
|
||||
|
||||
func (a *Accumulator) TagValue(measurement string, key string) string {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
for _, p := range a.Metrics {
|
||||
if p.Measurement == measurement {
|
||||
v, ok := p.Tags[key]
|
||||
|
|
|
|||
Loading…
Reference in New Issue