Skip to content

Commit

Permalink
Use int64 for fields in bind plugin (influxdata#6063)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and idohalevi committed Sep 23, 2020
1 parent 38deb23 commit 270cc4e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 46 deletions.
44 changes: 21 additions & 23 deletions plugins/inputs/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"

"github.com/influxdata/telegraf/testutil"

"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -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"))
})
}

Expand Down Expand Up @@ -329,20 +327,20 @@ 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)
})

// 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"))
})
}

Expand Down Expand Up @@ -553,20 +551,20 @@ 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)
})

// 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"))
})
}

Expand Down
14 changes: 7 additions & 7 deletions plugins/inputs/bind/json_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
14 changes: 7 additions & 7 deletions plugins/inputs/bind/xml_stats_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
18 changes: 9 additions & 9 deletions plugins/inputs/bind/xml_stats_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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"`
}
Expand All @@ -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"`
}

Expand Down

0 comments on commit 270cc4e

Please sign in to comment.