Use int64 for fields in bind plugin (#6063)

This commit is contained in:
Daniel Nelson 2019-07-03 16:28:11 -07:00 committed by GitHub
parent 9af39bbb7d
commit ad5d5844c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 46 deletions

View File

@ -7,7 +7,6 @@ import (
"testing"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
)
@ -127,20 +126,19 @@ func TestBindJsonStats(t *testing.T) {
}
fields := map[string]interface{}{
"block_size": 13893632,
"context_size": 3685480,
"in_use": 3064368,
"lost": 0,
"total_use": 18206566,
"block_size": int64(13893632),
"context_size": int64(3685480),
"in_use": int64(3064368),
"lost": int64(0),
"total_use": int64(18206566),
}
acc.AssertContainsTaggedFields(t, "bind_memory", fields, tags)
})
// Subtest for per-context memory stats
t.Run("memory_context", func(t *testing.T) {
assert.True(t, acc.HasIntField("bind_memory_context", "total"))
assert.True(t, acc.HasIntField("bind_memory_context", "in_use"))
assert.True(t, acc.HasInt64Field("bind_memory_context", "total"))
assert.True(t, acc.HasInt64Field("bind_memory_context", "in_use"))
})
}
@ -329,11 +327,11 @@ func TestBindXmlStatsV2(t *testing.T) {
}
fields := map[string]interface{}{
"block_size": 77070336,
"context_size": 6663840,
"in_use": 20772579,
"lost": 0,
"total_use": 81804609,
"block_size": int64(77070336),
"context_size": int64(6663840),
"in_use": int64(20772579),
"lost": int64(0),
"total_use": int64(81804609),
}
acc.AssertContainsTaggedFields(t, "bind_memory", fields, tags)
@ -341,8 +339,8 @@ func TestBindXmlStatsV2(t *testing.T) {
// Subtest for per-context memory stats
t.Run("memory_context", func(t *testing.T) {
assert.True(t, acc.HasIntField("bind_memory_context", "total"))
assert.True(t, acc.HasIntField("bind_memory_context", "in_use"))
assert.True(t, acc.HasInt64Field("bind_memory_context", "total"))
assert.True(t, acc.HasInt64Field("bind_memory_context", "in_use"))
})
}
@ -553,11 +551,11 @@ func TestBindXmlStatsV3(t *testing.T) {
}
fields := map[string]interface{}{
"block_size": 45875200,
"context_size": 10037400,
"in_use": 6000232,
"lost": 0,
"total_use": 777821909,
"block_size": int64(45875200),
"context_size": int64(10037400),
"in_use": int64(6000232),
"lost": int64(0),
"total_use": int64(777821909),
}
acc.AssertContainsTaggedFields(t, "bind_memory", fields, tags)
@ -565,8 +563,8 @@ func TestBindXmlStatsV3(t *testing.T) {
// Subtest for per-context memory stats
t.Run("memory_context", func(t *testing.T) {
assert.True(t, acc.HasIntField("bind_memory_context", "total"))
assert.True(t, acc.HasIntField("bind_memory_context", "in_use"))
assert.True(t, acc.HasInt64Field("bind_memory_context", "total"))
assert.True(t, acc.HasInt64Field("bind_memory_context", "in_use"))
})
}

View File

@ -23,16 +23,16 @@ type jsonStats struct {
}
type jsonMemory struct {
TotalUse int
InUse int
BlockSize int
ContextSize int
Lost int
TotalUse int64
InUse int64
BlockSize int64
ContextSize int64
Lost int64
Contexts []struct {
Id string
Name string
Total int
InUse int
Total int64
InUse int64
}
}

View File

@ -44,15 +44,15 @@ type v2Statistics struct {
// Omitted nodes: references, maxinuse, blocksize, pools, hiwater, lowater
Id string `xml:"id"`
Name string `xml:"name"`
Total int `xml:"total"`
InUse int `xml:"inuse"`
Total int64 `xml:"total"`
InUse int64 `xml:"inuse"`
} `xml:"contexts>context"`
Summary struct {
TotalUse int
InUse int
BlockSize int
ContextSize int
Lost int
TotalUse int64
InUse int64
BlockSize int64
ContextSize int64
Lost int64
} `xml:"summary"`
} `xml:"memory"`
}

View File

@ -27,15 +27,15 @@ type v3Memory struct {
// Omitted nodes: references, maxinuse, blocksize, pools, hiwater, lowater
Id string `xml:"id"`
Name string `xml:"name"`
Total int `xml:"total"`
InUse int `xml:"inuse"`
Total int64 `xml:"total"`
InUse int64 `xml:"inuse"`
} `xml:"contexts>context"`
Summary struct {
TotalUse int
InUse int
BlockSize int
ContextSize int
Lost int
TotalUse int64
InUse int64
BlockSize int64
ContextSize int64
Lost int64
} `xml:"summary"`
}
@ -53,7 +53,7 @@ type v3View struct {
Name string `xml:"name,attr"`
RRSets []struct {
Name string `xml:"name"`
Value int `xml:"counter"`
Value int64 `xml:"counter"`
} `xml:"rrset"`
} `xml:"cache"`
}
@ -63,7 +63,7 @@ type v3CounterGroup struct {
Type string `xml:"type,attr"`
Counters []struct {
Name string `xml:"name,attr"`
Value int `xml:",chardata"`
Value int64 `xml:",chardata"`
} `xml:"counter"`
}