Skip to content

Commit

Permalink
Update collector test fixtures
Browse files Browse the repository at this point in the history
Update format of variableLabels in the collector test for the latest
version of prometheus/common.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Nov 24, 2023
1 parent d09fec5 commit 491ce63
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestPduToSample(t *testing.T) {
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{
`Desc{fqName: "TestMetricNameExtension", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: []} gauge:{value:5}`,
`Desc{fqName: "TestMetricNameExtension", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: {}} gauge:{value:5}`,
},
},
{
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestPduToSample(t *testing.T) {
},
},
expectedMetrics: []string{
`Desc{fqName: "TestMetricNameStatus", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: []} gauge:{value:5}`,
`Desc{fqName: "TestMetricNameStatus", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: {}} gauge:{value:5}`,
},
},
{
Expand Down Expand Up @@ -194,9 +194,9 @@ func TestPduToSample(t *testing.T) {
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{
`Desc{fqName: "TestMetricNameExtension", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: []} gauge:{value:5}`,
`Desc{fqName: "TestMetricNameMultipleRegexes", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: []} gauge:{value:999}`,
`Desc{fqName: "TestMetricNameTemplate", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: []} gauge:{value:4.42}`,
`Desc{fqName: "TestMetricNameExtension", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: {}} gauge:{value:5}`,
`Desc{fqName: "TestMetricNameMultipleRegexes", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: {}} gauge:{value:999}`,
`Desc{fqName: "TestMetricNameTemplate", help: "HelpText (regex extracted)", constLabels: {}, variableLabels: {}} gauge:{value:4.42}`,
},
},
{
Expand All @@ -213,7 +213,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} counter:{value:2}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} counter:{value:2}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -229,7 +229,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} gauge:{value:2}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} gauge:{value:2}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -246,7 +246,7 @@ func TestPduToSample(t *testing.T) {
Scale: 0.1,
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} gauge:{value:42}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} gauge:{value:42}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -263,7 +263,7 @@ func TestPduToSample(t *testing.T) {
Offset: -1.0,
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} gauge:{value:69}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} gauge:{value:69}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -281,7 +281,7 @@ func TestPduToSample(t *testing.T) {
Scale: -1.0,
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} gauge:{value:0}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} gauge:{value:0}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -296,7 +296,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"-2"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"-2"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -312,7 +312,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} gauge:{value:3}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} gauge:{value:3}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -328,7 +328,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: []} gauge:{value:3}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {}} gauge:{value:3}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -345,7 +345,7 @@ func TestPduToSample(t *testing.T) {
Indexes: []*config.Index{{Labelname: "foo", Type: "DisplayString"}},
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{foo <nil>}]} label:{name:"foo" value:"AA"} gauge:{value:3}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {foo}} label:{name:"foo" value:"AA"} gauge:{value:3}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: map[string]gosnmp.SnmpPDU{"1.41.2": gosnmp.SnmpPDU{Value: 1}},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"4.5.6.7"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"4.5.6.7"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -412,7 +412,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: map[string]gosnmp.SnmpPDU{"1.41.2": gosnmp.SnmpPDU{Value: 1}},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"4.5.6.7"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"4.5.6.7"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -427,7 +427,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: map[string]gosnmp.SnmpPDU{"1.41.2": gosnmp.SnmpPDU{Value: 2}},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"0405:0607:0809:0A0B:0C0D:0E0F:1011:1213"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"0405:0607:0809:0A0B:0C0D:0E0F:1011:1213"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -442,7 +442,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: map[string]gosnmp.SnmpPDU{"1.41.2": gosnmp.SnmpPDU{Value: 3}},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"0x0405060708"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"0x0405060708"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -457,7 +457,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: make(map[string]gosnmp.SnmpPDU),
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"0x04050607"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"0x04050607"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -472,7 +472,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
},
oidToPdu: map[string]gosnmp.SnmpPDU{"1.41.2": gosnmp.SnmpPDU{Value: 3}},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"04:05:06:07:08:09"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric", help: "Help string", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"04:05:06:07:08:09"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -487,7 +487,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
EnumValues: map[int]string{0: "foo", 1: "bar", 2: "baz"},
},
expectedMetrics: []string{`Desc{fqName: "test_metric_info", help: "Help string (EnumAsInfo)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"baz"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric_info", help: "Help string (EnumAsInfo)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"baz"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -502,7 +502,7 @@ func TestPduToSample(t *testing.T) {
Help: "Help string",
EnumValues: map[int]string{0: "foo", 1: "bar", 2: "baz"},
},
expectedMetrics: []string{`Desc{fqName: "test_metric_info", help: "Help string (EnumAsInfo)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"3"} gauge:{value:1}`},
expectedMetrics: []string{`Desc{fqName: "test_metric_info", help: "Help string (EnumAsInfo)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"3"} gauge:{value:1}`},
},
{
pdu: &gosnmp.SnmpPDU{
Expand All @@ -518,9 +518,9 @@ func TestPduToSample(t *testing.T) {
EnumValues: map[int]string{0: "foo", 1: "bar", 2: "baz"},
},
expectedMetrics: []string{
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"foo"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"bar"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"baz"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"foo"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"bar"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"baz"} gauge:{value:1}`,
},
},
{
Expand All @@ -537,10 +537,10 @@ func TestPduToSample(t *testing.T) {
EnumValues: map[int]string{0: "foo", 1: "bar", 2: "baz"},
},
expectedMetrics: []string{
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"foo"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"bar"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"baz"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"3"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"foo"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"bar"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"baz"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (EnumAsStateSet)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"3"} gauge:{value:1}`,
},
},
{
Expand All @@ -557,14 +557,14 @@ func TestPduToSample(t *testing.T) {
EnumValues: map[int]string{0: "foo", 1: "bar", 2: "baz", 8: "byte2msb", 15: "byte2lsb", 16: "byte3msb", 23: "byte3lsb", 24: "missing"},
},
expectedMetrics: []string{
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"foo"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"bar"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"baz"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"byte2msb"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"byte2lsb"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"byte3msb"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"byte3lsb"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: [{test_metric <nil>}]} label:{name:"test_metric" value:"missing"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"foo"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"bar"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"baz"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"byte2msb"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"byte2lsb"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"byte3msb"} gauge:{value:0}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"byte3lsb"} gauge:{value:1}`,
`Desc{fqName: "test_metric", help: "Help string (Bits)", constLabels: {}, variableLabels: {test_metric}} label:{name:"test_metric" value:"missing"} gauge:{value:0}`,
},
},
}
Expand Down

0 comments on commit 491ce63

Please sign in to comment.