chore: Fix linter findings for `revive:enforce-slice-style` in `plugins/inputs/[k-o]*` (#16071)
This commit is contained in:
parent
c8a30655cb
commit
0a6e51d1d6
|
|
@ -418,7 +418,6 @@ func TestConsumerGroupHandlerHandle(t *testing.T) {
|
|||
Topic: "telegraf",
|
||||
Value: []byte("12345"),
|
||||
},
|
||||
expected: []telegraf.Metric{},
|
||||
expectedHandleError: "message exceeds max_message_len (actual 5, max 4)",
|
||||
},
|
||||
{
|
||||
|
|
@ -427,7 +426,6 @@ func TestConsumerGroupHandlerHandle(t *testing.T) {
|
|||
Topic: "telegraf",
|
||||
Value: []byte("not an integer"),
|
||||
},
|
||||
expected: []telegraf.Metric{},
|
||||
expectedHandleError: "strconv.Atoi: parsing \"integer\": invalid syntax",
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -208,7 +208,6 @@ func TestKSMDisabledNoKSMTags(t *testing.T) {
|
|||
statFile: "testdata/stat_file_full",
|
||||
entropyStatFile: "testdata/entropy_stat_file_full",
|
||||
ksmStatsDir: "testdata/this_file_does_not_exist",
|
||||
ConfigCollect: []string{},
|
||||
}
|
||||
|
||||
acc := testutil.Accumulator{}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import (
|
|||
|
||||
func TestDaemonSet(t *testing.T) {
|
||||
cli := &client{}
|
||||
selectInclude := []string{}
|
||||
selectExclude := []string{}
|
||||
now := time.Now()
|
||||
now = time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 1, 36, 0, now.Location())
|
||||
tests := []struct {
|
||||
|
|
@ -102,9 +100,7 @@ func TestDaemonSet(t *testing.T) {
|
|||
|
||||
for _, v := range tests {
|
||||
ks := &KubernetesInventory{
|
||||
client: cli,
|
||||
SelectorInclude: selectInclude,
|
||||
SelectorExclude: selectExclude,
|
||||
client: cli,
|
||||
}
|
||||
require.NoError(t, ks.createSelectorFilters())
|
||||
acc := new(testutil.Accumulator)
|
||||
|
|
@ -193,8 +189,6 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
"selector_select2": "s2",
|
||||
|
|
@ -207,7 +201,6 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"select1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -218,7 +211,6 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"select2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -231,7 +223,6 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"*1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -242,7 +233,6 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -254,7 +244,6 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ import (
|
|||
|
||||
func TestDeployment(t *testing.T) {
|
||||
cli := &client{}
|
||||
selectInclude := []string{}
|
||||
selectExclude := []string{}
|
||||
now := time.Now()
|
||||
now = time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 1, 36, 0, now.Location())
|
||||
|
||||
|
|
@ -107,9 +105,7 @@ func TestDeployment(t *testing.T) {
|
|||
|
||||
for _, v := range tests {
|
||||
ks := &KubernetesInventory{
|
||||
client: cli,
|
||||
SelectorInclude: selectInclude,
|
||||
SelectorExclude: selectExclude,
|
||||
client: cli,
|
||||
}
|
||||
require.NoError(t, ks.createSelectorFilters())
|
||||
acc := new(testutil.Accumulator)
|
||||
|
|
@ -209,8 +205,6 @@ func TestDeploymentSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
"selector_select2": "s2",
|
||||
|
|
@ -223,7 +217,6 @@ func TestDeploymentSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"select1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -234,7 +227,6 @@ func TestDeploymentSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"select2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -247,7 +239,6 @@ func TestDeploymentSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"*1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -258,7 +249,6 @@ func TestDeploymentSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -270,7 +260,6 @@ func TestDeploymentSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ func init() {
|
|||
return &KubernetesInventory{
|
||||
ResponseTimeout: config.Duration(time.Second * 5),
|
||||
Namespace: "default",
|
||||
SelectorInclude: []string{},
|
||||
SelectorInclude: make([]string, 0),
|
||||
SelectorExclude: []string{"*"},
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import (
|
|||
|
||||
func TestPersistentVolumeClaim(t *testing.T) {
|
||||
cli := &client{}
|
||||
selectInclude := []string{}
|
||||
selectExclude := []string{}
|
||||
now := time.Now()
|
||||
now = time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 1, 36, 0, now.Location())
|
||||
|
||||
|
|
@ -190,9 +188,7 @@ func TestPersistentVolumeClaim(t *testing.T) {
|
|||
|
||||
for _, v := range tests {
|
||||
ks := &KubernetesInventory{
|
||||
client: cli,
|
||||
SelectorInclude: selectInclude,
|
||||
SelectorExclude: selectExclude,
|
||||
client: cli,
|
||||
}
|
||||
require.NoError(t, ks.createSelectorFilters())
|
||||
acc := new(testutil.Accumulator)
|
||||
|
|
@ -277,8 +273,6 @@ func TestPersistentVolumeClaimSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
"selector_select2": "s2",
|
||||
|
|
@ -291,7 +285,6 @@ func TestPersistentVolumeClaimSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"select1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -302,7 +295,6 @@ func TestPersistentVolumeClaimSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"select2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -315,7 +307,6 @@ func TestPersistentVolumeClaimSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"*1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -326,7 +317,6 @@ func TestPersistentVolumeClaimSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -338,7 +328,6 @@ func TestPersistentVolumeClaimSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ import (
|
|||
|
||||
func TestPod(t *testing.T) {
|
||||
cli := &client{}
|
||||
selectInclude := []string{}
|
||||
selectExclude := []string{}
|
||||
now := time.Now()
|
||||
started := time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-1, 1, 36, 0, now.Location())
|
||||
created := time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-2, 1, 0, 0, now.Location())
|
||||
|
|
@ -441,9 +439,7 @@ func TestPod(t *testing.T) {
|
|||
}
|
||||
for _, v := range tests {
|
||||
ks := &KubernetesInventory{
|
||||
client: cli,
|
||||
SelectorInclude: selectInclude,
|
||||
SelectorExclude: selectExclude,
|
||||
client: cli,
|
||||
}
|
||||
require.NoError(t, ks.createSelectorFilters())
|
||||
acc := new(testutil.Accumulator)
|
||||
|
|
@ -607,8 +603,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"node_selector_select1": "s1",
|
||||
"node_selector_select2": "s2",
|
||||
|
|
@ -621,7 +615,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"select1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"node_selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -632,7 +625,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"select2"},
|
||||
expected: map[string]string{
|
||||
"node_selector_select1": "s1",
|
||||
|
|
@ -645,7 +637,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"*1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"node_selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -656,7 +647,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"node_selector_select1": "s1",
|
||||
|
|
@ -668,7 +658,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"node_selector_select1": "s1",
|
||||
|
|
@ -705,8 +694,6 @@ func TestPodSelectorFilter(t *testing.T) {
|
|||
|
||||
func TestPodPendingContainers(t *testing.T) {
|
||||
cli := &client{}
|
||||
selectInclude := []string{}
|
||||
selectExclude := []string{}
|
||||
now := time.Now()
|
||||
started := time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-1, 1, 36, 0, now.Location())
|
||||
created := time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-2, 1, 36, 0, now.Location())
|
||||
|
|
@ -808,7 +795,6 @@ func TestPodPendingContainers(t *testing.T) {
|
|||
LastTransitionTime: metav1.Time{Time: cond1},
|
||||
},
|
||||
},
|
||||
ContainerStatuses: []corev1.ContainerStatus{},
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
OwnerReferences: []metav1.OwnerReference{
|
||||
|
|
@ -988,9 +974,7 @@ func TestPodPendingContainers(t *testing.T) {
|
|||
}
|
||||
for _, v := range tests {
|
||||
ks := &KubernetesInventory{
|
||||
client: cli,
|
||||
SelectorInclude: selectInclude,
|
||||
SelectorExclude: selectExclude,
|
||||
client: cli,
|
||||
}
|
||||
require.NoError(t, ks.createSelectorFilters())
|
||||
acc := new(testutil.Accumulator)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ func TestResourceQuota(t *testing.T) {
|
|||
"/resourcequotas/": corev1.ResourceQuotaList{},
|
||||
},
|
||||
},
|
||||
output: []telegraf.Metric{},
|
||||
hasError: false,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -191,8 +191,6 @@ func TestServiceSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
"selector_select2": "s2",
|
||||
|
|
@ -205,7 +203,6 @@ func TestServiceSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"select1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -216,7 +213,6 @@ func TestServiceSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"select2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -229,7 +225,6 @@ func TestServiceSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"*1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -240,7 +235,6 @@ func TestServiceSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -252,7 +246,6 @@ func TestServiceSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import (
|
|||
|
||||
func TestStatefulSet(t *testing.T) {
|
||||
cli := &client{}
|
||||
selectInclude := []string{}
|
||||
selectExclude := []string{}
|
||||
now := time.Now()
|
||||
now = time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 1, 36, 0, now.Location())
|
||||
tests := []struct {
|
||||
|
|
@ -204,9 +202,7 @@ func TestStatefulSet(t *testing.T) {
|
|||
|
||||
for _, v := range tests {
|
||||
ks := &KubernetesInventory{
|
||||
client: cli,
|
||||
SelectorInclude: selectInclude,
|
||||
SelectorExclude: selectExclude,
|
||||
client: cli,
|
||||
}
|
||||
require.NoError(t, ks.createSelectorFilters())
|
||||
acc := &testutil.Accumulator{}
|
||||
|
|
@ -292,8 +288,6 @@ func TestStatefulSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
"selector_select2": "s2",
|
||||
|
|
@ -306,7 +300,6 @@ func TestStatefulSetSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"select1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -317,7 +310,6 @@ func TestStatefulSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"select2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -330,7 +322,6 @@ func TestStatefulSetSelectorFilter(t *testing.T) {
|
|||
},
|
||||
hasError: false,
|
||||
include: []string{"*1"},
|
||||
exclude: []string{},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
},
|
||||
|
|
@ -341,7 +332,6 @@ func TestStatefulSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
@ -353,7 +343,6 @@ func TestStatefulSetSelectorFilter(t *testing.T) {
|
|||
responseMap: responseMap,
|
||||
},
|
||||
hasError: false,
|
||||
include: []string{},
|
||||
exclude: []string{"*2"},
|
||||
expected: map[string]string{
|
||||
"selector_select1": "s1",
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ type Kubernetes struct {
|
|||
func init() {
|
||||
inputs.Add("kubernetes", func() telegraf.Input {
|
||||
return &Kubernetes{
|
||||
LabelInclude: []string{},
|
||||
LabelExclude: []string{"*"},
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ func TestMockResult(t *testing.T) {
|
|||
Attributes: []*ldap.EntryAttribute{{Name: "monitorCounter", Values: []string{"1"}}},
|
||||
},
|
||||
},
|
||||
Referrals: []string{},
|
||||
Controls: []ldap.Control{},
|
||||
}
|
||||
|
||||
// Setup the plugin
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func TestLibvirt_Gather(t *testing.T) {
|
|||
StatisticsGroups: []string{"state"},
|
||||
}
|
||||
mockLibvirtUtils.On("EnsureConnected", mock.Anything).Return(nil).Once().
|
||||
On("GatherAllDomains", mock.Anything).Return([]golibvirt.Domain{}, nil).Once()
|
||||
On("GatherAllDomains", mock.Anything).Return(nil, nil).Once()
|
||||
|
||||
err := l.Gather(&acc)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -207,11 +207,9 @@ func TestLibvirt_GatherMetrics(t *testing.T) {
|
|||
var acc testutil.Accumulator
|
||||
mockLibvirtUtils := MockLibvirtUtils{}
|
||||
l := Libvirt{
|
||||
utils: &mockLibvirtUtils,
|
||||
Log: testutil.Logger{},
|
||||
StatisticsGroups: []string{},
|
||||
Domains: test.excludeDomains,
|
||||
AdditionalStatistics: []string{},
|
||||
utils: &mockLibvirtUtils,
|
||||
Log: testutil.Logger{},
|
||||
Domains: test.excludeDomains,
|
||||
}
|
||||
|
||||
mockLibvirtUtils.On("EnsureConnected", mock.Anything).Return(nil).Once().
|
||||
|
|
@ -223,7 +221,7 @@ func TestLibvirt_GatherMetrics(t *testing.T) {
|
|||
l.metricNumber = domainStatsVCPU
|
||||
mockLibvirtUtils.On("GatherNumberOfPCPUs").Return(4, nil).Once().
|
||||
On("GatherVcpuMapping", domains[0], mock.Anything, mock.Anything).Return(test.vcpuMapping, nil).Once().
|
||||
On("GatherVcpuMapping", domains[1], mock.Anything, mock.Anything).Return([]vcpuAffinity{}, nil).Once()
|
||||
On("GatherVcpuMapping", domains[1], mock.Anything, mock.Anything).Return(nil, nil).Once()
|
||||
}
|
||||
|
||||
err := l.Gather(&acc)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func (l *utilsImpl) GatherAllDomains() (domains []golibvirt.Domain, err error) {
|
|||
func (l *utilsImpl) GatherStatsForDomains(domains []golibvirt.Domain, metricNumber uint32) ([]golibvirt.DomainStatsRecord, error) {
|
||||
if metricNumber == 0 {
|
||||
// do not need to do expensive call if no stats were set to gather
|
||||
return []golibvirt.DomainStatsRecord{}, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
allDomainStatesFlag := golibvirt.ConnectGetAllDomainsStatsRunning + golibvirt.ConnectGetAllDomainsStatsPaused +
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ func (m *Mesos) createHTTPClient() (*http.Client, error) {
|
|||
|
||||
// metricsDiff() returns set names for removal
|
||||
func metricsDiff(role Role, w []string) []string {
|
||||
b := []string{}
|
||||
b := make([]string, 0, len(allMetrics[role]))
|
||||
s := make(map[string]bool)
|
||||
|
||||
if len(w) == 0 {
|
||||
|
|
@ -269,8 +269,8 @@ func (m *Mesos) getMetrics(role Role, group string) []string {
|
|||
// framework_offers and allocator metrics have unpredictable names, so they can't be listed here.
|
||||
// These empty groups are included to prevent the "unknown metrics group" info log below.
|
||||
// filterMetrics() filters these metrics by looking for names with the corresponding prefix.
|
||||
metrics["framework_offers"] = []string{}
|
||||
metrics["allocator"] = []string{}
|
||||
metrics["framework_offers"] = make([]string, 0)
|
||||
metrics["allocator"] = make([]string, 0)
|
||||
|
||||
metrics["tasks"] = []string{
|
||||
"master/tasks_error",
|
||||
|
|
@ -432,8 +432,8 @@ func (m *Mesos) getMetrics(role Role, group string) []string {
|
|||
ret, ok := metrics[group]
|
||||
|
||||
if !ok {
|
||||
m.Log.Infof("unknown role %q metrics group: %s", role, group)
|
||||
return []string{}
|
||||
m.Log.Infof("Unknown role %q metrics group: %s", role, group)
|
||||
return nil
|
||||
}
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -373,9 +373,8 @@ func TestMesosSlave(t *testing.T) {
|
|||
var acc testutil.Accumulator
|
||||
|
||||
m := Mesos{
|
||||
Log: testutil.Logger{},
|
||||
Masters: []string{},
|
||||
Slaves: []string{slaveTestServer.Listener.Addr().String()},
|
||||
Log: testutil.Logger{},
|
||||
Slaves: []string{slaveTestServer.Listener.Addr().String()},
|
||||
// SlaveTasks: true,
|
||||
Timeout: 10,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ func (c *client) Scores(player string) ([]Score, error) {
|
|||
func parsePlayers(input string) []string {
|
||||
parts := strings.SplitAfterN(input, ":", 2)
|
||||
if len(parts) != 2 {
|
||||
return []string{}
|
||||
return nil
|
||||
}
|
||||
|
||||
names := strings.Split(parts[1], ",")
|
||||
|
|
@ -135,7 +135,7 @@ type Score struct {
|
|||
|
||||
func parseScores(input string) []Score {
|
||||
if strings.Contains(input, "has no scores") {
|
||||
return []Score{}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Detect Minecraft <= 1.12
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ func TestClient_Player(t *testing.T) {
|
|||
commands: map[string]string{
|
||||
"scoreboard players list": "There are no tracked players on the scoreboard",
|
||||
},
|
||||
expected: []string{},
|
||||
},
|
||||
{
|
||||
name: "minecraft 1.12 single player",
|
||||
|
|
@ -75,7 +74,6 @@ func TestClient_Player(t *testing.T) {
|
|||
commands: map[string]string{
|
||||
"scoreboard players list": "There are no tracked entities",
|
||||
},
|
||||
expected: []string{},
|
||||
},
|
||||
{
|
||||
name: "minecraft 1.13 single player",
|
||||
|
|
@ -120,7 +118,6 @@ func TestClient_Scores(t *testing.T) {
|
|||
commands: map[string]string{
|
||||
"scoreboard players list Etho": "Player Etho has no scores recorded",
|
||||
},
|
||||
expected: []Score{},
|
||||
},
|
||||
{
|
||||
name: "minecraft 1.12 player with one score",
|
||||
|
|
@ -150,7 +147,6 @@ func TestClient_Scores(t *testing.T) {
|
|||
commands: map[string]string{
|
||||
"scoreboard players list Etho": "Etho has no scores to show",
|
||||
},
|
||||
expected: []Score{},
|
||||
},
|
||||
{
|
||||
name: "minecraft 1.13 player with one score",
|
||||
|
|
|
|||
|
|
@ -43,10 +43,9 @@ func TestGather(t *testing.T) {
|
|||
return nil
|
||||
},
|
||||
PlayersF: func() ([]string, error) {
|
||||
return []string{}, nil
|
||||
return nil, nil
|
||||
},
|
||||
},
|
||||
metrics: []telegraf.Metric{},
|
||||
},
|
||||
{
|
||||
name: "one player without scores",
|
||||
|
|
@ -60,13 +59,12 @@ func TestGather(t *testing.T) {
|
|||
ScoresF: func(player string) ([]Score, error) {
|
||||
switch player {
|
||||
case "Etho":
|
||||
return []Score{}, nil
|
||||
return nil, nil
|
||||
default:
|
||||
panic("unknown player")
|
||||
}
|
||||
},
|
||||
},
|
||||
metrics: []telegraf.Metric{},
|
||||
},
|
||||
{
|
||||
name: "one player with scores",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ type Configuration interface {
|
|||
|
||||
func removeDuplicates(elements []uint16) []uint16 {
|
||||
encountered := make(map[uint16]bool, len(elements))
|
||||
result := []uint16{}
|
||||
result := make([]uint16, 0, len(elements))
|
||||
|
||||
for _, addr := range elements {
|
||||
if !encountered[addr] {
|
||||
|
|
|
|||
|
|
@ -947,7 +947,7 @@ func TestRegisterReadMultipleCoilWithHole(t *testing.T) {
|
|||
defer handler.Close()
|
||||
client := mb.NewClient(handler)
|
||||
|
||||
fcs := []fieldDefinition{}
|
||||
fcs := make([]fieldDefinition, 0, 26)
|
||||
expectedFields := make(map[string]interface{})
|
||||
writeValue := uint16(0)
|
||||
readValue := uint16(0)
|
||||
|
|
@ -1032,7 +1032,7 @@ func TestRegisterReadMultipleCoilLimit(t *testing.T) {
|
|||
defer handler.Close()
|
||||
client := mb.NewClient(handler)
|
||||
|
||||
fcs := []fieldDefinition{}
|
||||
fcs := make([]fieldDefinition, 0, 4000)
|
||||
expectedFields := make(map[string]interface{})
|
||||
writeValue := uint16(0)
|
||||
readValue := uint16(0)
|
||||
|
|
@ -1091,7 +1091,7 @@ func TestRegisterReadMultipleHoldingRegisterWithHole(t *testing.T) {
|
|||
defer handler.Close()
|
||||
client := mb.NewClient(handler)
|
||||
|
||||
fcs := []fieldDefinition{}
|
||||
fcs := make([]fieldDefinition, 0, 20)
|
||||
expectedFields := make(map[string]interface{})
|
||||
for i := 0; i < 10; i++ {
|
||||
fc := fieldDefinition{
|
||||
|
|
@ -1165,7 +1165,7 @@ func TestRegisterReadMultipleHoldingRegisterLimit(t *testing.T) {
|
|||
defer handler.Close()
|
||||
client := mb.NewClient(handler)
|
||||
|
||||
fcs := []fieldDefinition{}
|
||||
fcs := make([]fieldDefinition, 0, 401)
|
||||
expectedFields := make(map[string]interface{})
|
||||
for i := 0; i <= 400; i++ {
|
||||
fc := fieldDefinition{}
|
||||
|
|
|
|||
|
|
@ -231,12 +231,7 @@ func (c *ConfigurationPerRequest) Process() (map[byte]requestSet, error) {
|
|||
// Make sure we have a set to work with
|
||||
set, found := result[def.SlaveID]
|
||||
if !found {
|
||||
set = requestSet{
|
||||
coil: []request{},
|
||||
discrete: []request{},
|
||||
holding: []request{},
|
||||
input: []request{},
|
||||
}
|
||||
set = requestSet{}
|
||||
}
|
||||
|
||||
params := groupingParams{
|
||||
|
|
|
|||
|
|
@ -1731,7 +1731,6 @@ func TestRequestFail(t *testing.T) {
|
|||
SlaveID: 1,
|
||||
ByteOrder: "AB",
|
||||
RegisterType: "coil",
|
||||
Fields: []requestFieldDefinition{},
|
||||
},
|
||||
},
|
||||
errormsg: "configuration invalid: unknown byte-order \"AB\"",
|
||||
|
|
@ -1794,7 +1793,6 @@ func TestRequestFail(t *testing.T) {
|
|||
SlaveID: 1,
|
||||
ByteOrder: "AB",
|
||||
RegisterType: "discrete",
|
||||
Fields: []requestFieldDefinition{},
|
||||
},
|
||||
},
|
||||
errormsg: "configuration invalid: unknown byte-order \"AB\"",
|
||||
|
|
@ -1857,7 +1855,6 @@ func TestRequestFail(t *testing.T) {
|
|||
SlaveID: 1,
|
||||
ByteOrder: "AB",
|
||||
RegisterType: "holding",
|
||||
Fields: []requestFieldDefinition{},
|
||||
},
|
||||
},
|
||||
errormsg: "configuration invalid: unknown byte-order \"AB\"",
|
||||
|
|
@ -1969,7 +1966,6 @@ func TestRequestFail(t *testing.T) {
|
|||
SlaveID: 1,
|
||||
ByteOrder: "AB",
|
||||
RegisterType: "input",
|
||||
Fields: []requestFieldDefinition{},
|
||||
},
|
||||
},
|
||||
errormsg: "configuration invalid: unknown byte-order \"AB\"",
|
||||
|
|
@ -2326,7 +2322,7 @@ func TestRequestMultipleSlavesOneFail(t *testing.T) {
|
|||
|
||||
if tcpframe.Device == 2 {
|
||||
// Simulate device 2 being unavailable
|
||||
return []byte{}, &mbserver.GatewayTargetDeviceFailedtoRespond
|
||||
return nil, &mbserver.GatewayTargetDeviceFailedtoRespond
|
||||
}
|
||||
return []byte{0x02, 0x00, 0x42}, &mbserver.Success
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ func splitMaxBatchSize(g request, maxBatchSize uint16) []request {
|
|||
idx := 0
|
||||
for start := g.address; start < g.address+g.length; {
|
||||
current := request{
|
||||
fields: []field{},
|
||||
address: start,
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +237,6 @@ func groupFieldsToRequests(fields []field, params groupingParams) []request {
|
|||
groups = append(groups, current)
|
||||
}
|
||||
current = request{
|
||||
fields: []field{},
|
||||
address: f.address,
|
||||
length: f.length,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ func NewMongodbData(statLine *statLine, tags map[string]string) *MongodbData {
|
|||
StatLine: statLine,
|
||||
Tags: tags,
|
||||
Fields: make(map[string]interface{}),
|
||||
DbData: []DbData{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ func TestGather(t *testing.T) {
|
|||
servers: []string{"http://abc", "https://def"},
|
||||
},
|
||||
{
|
||||
name: "Good case, 0 servers",
|
||||
servers: []string{},
|
||||
name: "Good case, 0 servers",
|
||||
},
|
||||
{
|
||||
name: "Good case nil",
|
||||
|
|
|
|||
|
|
@ -269,7 +269,6 @@ func TestDecodeIPv4Options(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "none",
|
||||
bits: []int{},
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
|
|
@ -323,12 +322,10 @@ func TestDecodeTCPFlags(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "none",
|
||||
bits: []int{},
|
||||
expected: "........",
|
||||
},
|
||||
{
|
||||
name: "none IPFIX",
|
||||
bits: []int{},
|
||||
expected: "................",
|
||||
ipfix: true,
|
||||
},
|
||||
|
|
@ -423,7 +420,6 @@ func TestDecodeFragmentFlags(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "none",
|
||||
bits: []int{},
|
||||
expected: "........",
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ func TestReadClientIntegrationAdditionalFields(t *testing.T) {
|
|||
"The operation succeeded. StatusGood (0x0)",
|
||||
"The operation succeeded. StatusGood (0x0)",
|
||||
}
|
||||
expectedopcmetrics := []telegraf.Metric{}
|
||||
expectedopcmetrics := make([]telegraf.Metric, 0, len(testopctags))
|
||||
for i, x := range testopctags {
|
||||
now := time.Now()
|
||||
tags := map[string]string{
|
||||
|
|
@ -233,8 +233,7 @@ func TestReadClientIntegrationAdditionalFields(t *testing.T) {
|
|||
|
||||
require.NoError(t, client.Connect())
|
||||
|
||||
actualopcmetrics := []telegraf.Metric{}
|
||||
|
||||
actualopcmetrics := make([]telegraf.Metric, 0, len(client.LastReceivedData))
|
||||
for i := range client.LastReceivedData {
|
||||
actualopcmetrics = append(actualopcmetrics, client.MetricForNode(i))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ func TestSubscribeClientIntegrationAdditionalFields(t *testing.T) {
|
|||
"The operation succeeded. StatusGood (0x0)",
|
||||
"The operation succeeded. StatusGood (0x0)",
|
||||
}
|
||||
expectedopcmetrics := []telegraf.Metric{}
|
||||
expectedopcmetrics := make([]telegraf.Metric, 0, len(testopctags))
|
||||
for i, x := range testopctags {
|
||||
now := time.Now()
|
||||
tags := map[string]string{
|
||||
|
|
|
|||
|
|
@ -152,10 +152,6 @@ func (o *SubscribeClient) Stop(ctx context.Context) <-chan struct{} {
|
|||
return closing
|
||||
}
|
||||
|
||||
func (o *SubscribeClient) CurrentValues() ([]telegraf.Metric, error) {
|
||||
return []telegraf.Metric{}, nil
|
||||
}
|
||||
|
||||
func (o *SubscribeClient) StartStreamValues(ctx context.Context) (<-chan telegraf.Metric, error) {
|
||||
err := o.Connect()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ func TestOpenldapMockResult(t *testing.T) {
|
|||
Attributes: []*ldap.EntryAttribute{{Name: "monitorCounter", Values: []string{"1"}}},
|
||||
},
|
||||
},
|
||||
Referrals: []string{},
|
||||
Controls: []ldap.Control{},
|
||||
}
|
||||
|
||||
o := &Openldap{
|
||||
|
|
|
|||
|
|
@ -242,7 +242,6 @@ func testData() []osAggregationQueryTest {
|
|||
FilterQuery: "response: 200",
|
||||
DateField: "@timestamp",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{},
|
||||
},
|
||||
expectedMetrics: []telegraf.Metric{
|
||||
|
|
@ -264,7 +263,6 @@ func testData() []osAggregationQueryTest {
|
|||
MetricFunction: "max",
|
||||
DateField: "@timestamp",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{"size": "long"},
|
||||
},
|
||||
expectedMetrics: []telegraf.Metric{
|
||||
|
|
@ -286,7 +284,6 @@ func testData() []osAggregationQueryTest {
|
|||
MetricFunction: "average",
|
||||
DateField: "@timestamp",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{"size": "long"},
|
||||
},
|
||||
wantInitErr: true,
|
||||
|
|
@ -299,7 +296,6 @@ func testData() []osAggregationQueryTest {
|
|||
MetricFields: []string{"none"},
|
||||
DateField: "@timestamp",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{},
|
||||
},
|
||||
wantQueryResErr: true,
|
||||
|
|
@ -312,7 +308,6 @@ func testData() []osAggregationQueryTest {
|
|||
MeasurementName: "measurement11",
|
||||
DateField: "@timestamp",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{},
|
||||
},
|
||||
wantQueryResErr: true,
|
||||
|
|
@ -326,7 +321,6 @@ func testData() []osAggregationQueryTest {
|
|||
MetricFunction: "avg",
|
||||
DateField: "@notatimestamp",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{"size": "long"},
|
||||
},
|
||||
expectedMetrics: []telegraf.Metric{
|
||||
|
|
@ -360,7 +354,6 @@ func testData() []osAggregationQueryTest {
|
|||
DateField: "@timestamp",
|
||||
DateFieldFormat: "yyyy",
|
||||
QueryPeriod: queryPeriod,
|
||||
Tags: []string{},
|
||||
mapMetricFields: map[string]string{},
|
||||
},
|
||||
wantQueryResErr: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue