mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
commit
c44cd7e166
|
@ -195,7 +195,7 @@ func TestSendAlerts(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
in: []*rules.Alert{
|
||||
&rules.Alert{
|
||||
{
|
||||
Labels: []labels.Label{{Name: "l1", Value: "v1"}},
|
||||
Annotations: []labels.Label{{Name: "a2", Value: "v2"}},
|
||||
ActiveAt: time.Unix(1, 0),
|
||||
|
@ -204,7 +204,7 @@ func TestSendAlerts(t *testing.T) {
|
|||
},
|
||||
},
|
||||
exp: []*notifier.Alert{
|
||||
¬ifier.Alert{
|
||||
{
|
||||
Labels: []labels.Label{{Name: "l1", Value: "v1"}},
|
||||
Annotations: []labels.Label{{Name: "a2", Value: "v2"}},
|
||||
StartsAt: time.Unix(2, 0),
|
||||
|
@ -215,7 +215,7 @@ func TestSendAlerts(t *testing.T) {
|
|||
},
|
||||
{
|
||||
in: []*rules.Alert{
|
||||
&rules.Alert{
|
||||
{
|
||||
Labels: []labels.Label{{Name: "l1", Value: "v1"}},
|
||||
Annotations: []labels.Label{{Name: "a2", Value: "v2"}},
|
||||
ActiveAt: time.Unix(1, 0),
|
||||
|
@ -224,7 +224,7 @@ func TestSendAlerts(t *testing.T) {
|
|||
},
|
||||
},
|
||||
exp: []*notifier.Alert{
|
||||
¬ifier.Alert{
|
||||
{
|
||||
Labels: []labels.Label{{Name: "l1", Value: "v1"}},
|
||||
Annotations: []labels.Label{{Name: "a2", Value: "v2"}},
|
||||
StartsAt: time.Unix(2, 0),
|
||||
|
|
|
@ -418,7 +418,7 @@ func (m *Manager) registerProviders(cfg sd_config.ServiceDiscoveryConfig, setNam
|
|||
// It can happen because the combined set of SD configurations is empty
|
||||
// or because we fail to instantiate all the SD configurations.
|
||||
add(setName, func() (Discoverer, error) {
|
||||
return &StaticProvider{TargetGroups: []*targetgroup.Group{&targetgroup.Group{}}}, nil
|
||||
return &StaticProvider{TargetGroups: []*targetgroup.Group{{}}}, nil
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -988,7 +988,7 @@ func TestCoordinationWithReceiver(t *testing.T) {
|
|||
expected: []expect{
|
||||
{
|
||||
tgs: map[string][]*targetgroup.Group{
|
||||
"once1": []*targetgroup.Group{
|
||||
"once1": {
|
||||
{
|
||||
Source: "tg1",
|
||||
Targets: []model.LabelSet{{"__instance__": "1"}},
|
||||
|
@ -998,13 +998,13 @@ func TestCoordinationWithReceiver(t *testing.T) {
|
|||
},
|
||||
{
|
||||
tgs: map[string][]*targetgroup.Group{
|
||||
"once1": []*targetgroup.Group{
|
||||
"once1": {
|
||||
{
|
||||
Source: "tg1",
|
||||
Targets: []model.LabelSet{{"__instance__": "1"}},
|
||||
},
|
||||
},
|
||||
"mock1": []*targetgroup.Group{
|
||||
"mock1": {
|
||||
{
|
||||
Source: "tg2",
|
||||
Targets: []model.LabelSet{{"__instance__": "2"}},
|
||||
|
@ -1041,7 +1041,7 @@ func TestCoordinationWithReceiver(t *testing.T) {
|
|||
{
|
||||
delay: 2 * updateDelay,
|
||||
tgs: map[string][]*targetgroup.Group{
|
||||
"mock1": []*targetgroup.Group{
|
||||
"mock1": {
|
||||
{
|
||||
Source: "tg1",
|
||||
Targets: []model.LabelSet{{"__instance__": "1"}},
|
||||
|
@ -1052,7 +1052,7 @@ func TestCoordinationWithReceiver(t *testing.T) {
|
|||
{
|
||||
delay: 4 * updateDelay,
|
||||
tgs: map[string][]*targetgroup.Group{
|
||||
"mock1": []*targetgroup.Group{
|
||||
"mock1": {
|
||||
{
|
||||
Source: "tg1",
|
||||
Targets: []model.LabelSet{{"__instance__": "1"}},
|
||||
|
|
|
@ -69,7 +69,7 @@ func TestOpenstackSDInstanceRefresh(t *testing.T) {
|
|||
testutil.Equals(t, 4, len(tg.Targets))
|
||||
|
||||
for i, lbls := range []model.LabelSet{
|
||||
model.LabelSet{
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.32:0"),
|
||||
"__meta_openstack_instance_flavor": model.LabelValue("1"),
|
||||
"__meta_openstack_instance_id": model.LabelValue("ef079b0c-e610-4dfb-b1aa-b49f07ac48e5"),
|
||||
|
@ -79,7 +79,7 @@ func TestOpenstackSDInstanceRefresh(t *testing.T) {
|
|||
"__meta_openstack_public_ip": model.LabelValue("10.10.10.2"),
|
||||
"__meta_openstack_address_pool": model.LabelValue("private"),
|
||||
},
|
||||
model.LabelSet{
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.31:0"),
|
||||
"__meta_openstack_instance_flavor": model.LabelValue("1"),
|
||||
"__meta_openstack_instance_id": model.LabelValue("9e5476bd-a4ec-4653-93d6-72c93aa682ba"),
|
||||
|
@ -88,7 +88,7 @@ func TestOpenstackSDInstanceRefresh(t *testing.T) {
|
|||
"__meta_openstack_private_ip": model.LabelValue("10.0.0.31"),
|
||||
"__meta_openstack_address_pool": model.LabelValue("private"),
|
||||
},
|
||||
model.LabelSet{
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.33:0"),
|
||||
"__meta_openstack_instance_flavor": model.LabelValue("4"),
|
||||
"__meta_openstack_instance_id": model.LabelValue("9e5476bd-a4ec-4653-93d6-72c93aa682bb"),
|
||||
|
@ -98,7 +98,7 @@ func TestOpenstackSDInstanceRefresh(t *testing.T) {
|
|||
"__meta_openstack_address_pool": model.LabelValue("private"),
|
||||
"__meta_openstack_tag_env": model.LabelValue("prod"),
|
||||
},
|
||||
model.LabelSet{
|
||||
{
|
||||
"__address__": model.LabelValue("10.0.0.34:0"),
|
||||
"__meta_openstack_instance_flavor": model.LabelValue("4"),
|
||||
"__meta_openstack_instance_id": model.LabelValue("9e5476bd-a4ec-4653-93d6-72c93aa682bb"),
|
||||
|
|
|
@ -41,10 +41,10 @@ func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
|||
metric1 1+1x10
|
||||
`,
|
||||
testCases: []testCase{
|
||||
testCase{
|
||||
{
|
||||
ts: time.Unix(40, 0),
|
||||
series: []Series{
|
||||
Series{
|
||||
{
|
||||
Metric: labels.FromStrings("__name__", "metric1"),
|
||||
Points: []Point{
|
||||
{0, 1}, {10000, 2}, {20000, 3}, {30000, 4}, {40000, 5},
|
||||
|
@ -52,10 +52,10 @@ func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
testCase{
|
||||
{
|
||||
ts: time.Unix(10, 0),
|
||||
series: []Series{
|
||||
Series{
|
||||
{
|
||||
Metric: labels.FromStrings("__name__", "metric1"),
|
||||
Points: []Point{
|
||||
{0, 1}, {10000, 2}, {20000, 3}, {30000, 4}, {40000, 5},
|
||||
|
@ -63,10 +63,10 @@ func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
testCase{
|
||||
{
|
||||
ts: time.Unix(60, 0),
|
||||
series: []Series{
|
||||
Series{
|
||||
{
|
||||
Metric: labels.FromStrings("__name__", "metric1"),
|
||||
Points: []Point{
|
||||
{0, 1}, {10000, 2}, {20000, 3}, {30000, 4}, {40000, 5}, {50000, 6}, {60000, 7},
|
||||
|
@ -83,16 +83,16 @@ func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
|||
metric2 1+1x100
|
||||
`,
|
||||
testCases: []testCase{
|
||||
testCase{ // Adds all samples of metric1.
|
||||
{ // Adds all samples of metric1.
|
||||
ts: time.Unix(70, 0),
|
||||
series: []Series{
|
||||
Series{
|
||||
{
|
||||
Metric: labels.FromStrings("__name__", "metric1"),
|
||||
Points: []Point{
|
||||
{0, 1}, {10000, 1}, {20000, 1}, {30000, 1}, {40000, 1}, {50000, 1},
|
||||
},
|
||||
},
|
||||
Series{
|
||||
{
|
||||
Metric: labels.FromStrings("__name__", "metric2"),
|
||||
Points: []Point{
|
||||
{0, 1}, {10000, 2}, {20000, 3}, {30000, 4}, {40000, 5}, {50000, 6}, {60000, 7}, {70000, 8},
|
||||
|
@ -100,7 +100,7 @@ func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
testCase{ // This tests fix for https://github.com/prometheus/prometheus/issues/5064.
|
||||
{ // This tests fix for https://github.com/prometheus/prometheus/issues/5064.
|
||||
ts: time.Unix(300, 0),
|
||||
checkOnlyError: true,
|
||||
},
|
||||
|
|
|
@ -66,7 +66,7 @@ func TestAlertingRuleLabelsUpdate(t *testing.T) {
|
|||
)
|
||||
|
||||
results := []promql.Vector{
|
||||
promql.Vector{
|
||||
{
|
||||
{
|
||||
Metric: labels.FromStrings(
|
||||
"__name__", "ALERTS",
|
||||
|
@ -79,7 +79,7 @@ func TestAlertingRuleLabelsUpdate(t *testing.T) {
|
|||
Point: promql.Point{V: 1},
|
||||
},
|
||||
},
|
||||
promql.Vector{
|
||||
{
|
||||
{
|
||||
Metric: labels.FromStrings(
|
||||
"__name__", "ALERTS",
|
||||
|
@ -92,7 +92,7 @@ func TestAlertingRuleLabelsUpdate(t *testing.T) {
|
|||
Point: promql.Point{V: 1},
|
||||
},
|
||||
},
|
||||
promql.Vector{
|
||||
{
|
||||
{
|
||||
Metric: labels.FromStrings(
|
||||
"__name__", "ALERTS",
|
||||
|
@ -105,7 +105,7 @@ func TestAlertingRuleLabelsUpdate(t *testing.T) {
|
|||
Point: promql.Point{V: 1},
|
||||
},
|
||||
},
|
||||
promql.Vector{
|
||||
{
|
||||
{
|
||||
Metric: labels.FromStrings(
|
||||
"__name__", "ALERTS",
|
||||
|
|
|
@ -552,7 +552,7 @@ func TestStaleness(t *testing.T) {
|
|||
metricSample[2].V = 42 // reflect.DeepEqual cannot handle NaN.
|
||||
|
||||
want := map[string][]promql.Point{
|
||||
metric: []promql.Point{{0, 2}, {1000, 3}, {2000, 42}},
|
||||
metric: {{0, 2}, {1000, 3}, {2000, 42}},
|
||||
}
|
||||
|
||||
testutil.Equals(t, want, samples)
|
||||
|
@ -588,11 +588,11 @@ func TestCopyState(t *testing.T) {
|
|||
NewRecordingRule("rule3", nil, nil),
|
||||
},
|
||||
seriesInPreviousEval: []map[string]labels.Labels{
|
||||
map[string]labels.Labels{"a": nil},
|
||||
map[string]labels.Labels{"r1": nil},
|
||||
map[string]labels.Labels{"r2": nil},
|
||||
map[string]labels.Labels{"r3a": nil},
|
||||
map[string]labels.Labels{"r3b": nil},
|
||||
{"a": nil},
|
||||
{"r1": nil},
|
||||
{"r2": nil},
|
||||
{"r3a": nil},
|
||||
{"r3b": nil},
|
||||
},
|
||||
evaluationDuration: time.Second,
|
||||
}
|
||||
|
@ -611,11 +611,11 @@ func TestCopyState(t *testing.T) {
|
|||
newGroup.CopyState(oldGroup)
|
||||
|
||||
want := []map[string]labels.Labels{
|
||||
map[string]labels.Labels{"r3a": nil},
|
||||
map[string]labels.Labels{"r3b": nil},
|
||||
{"r3a": nil},
|
||||
{"r3b": nil},
|
||||
nil,
|
||||
map[string]labels.Labels{"a": nil},
|
||||
map[string]labels.Labels{"r1": nil},
|
||||
{"a": nil},
|
||||
{"r1": nil},
|
||||
nil,
|
||||
}
|
||||
testutil.Equals(t, want, newGroup.seriesInPreviousEval)
|
||||
|
|
|
@ -275,7 +275,7 @@ func TestManagerTargetsUpdates(t *testing.T) {
|
|||
for x := 0; x < 10; x++ {
|
||||
|
||||
tgSent[strconv.Itoa(x)] = []*targetgroup.Group{
|
||||
&targetgroup.Group{
|
||||
{
|
||||
Source: strconv.Itoa(x),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ func TestDroppedTargetsList(t *testing.T) {
|
|||
tgs = []*targetgroup.Group{
|
||||
{
|
||||
Targets: []model.LabelSet{
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.1:9090"},
|
||||
{model.AddressLabel: "127.0.0.1:9090"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -352,16 +352,16 @@ func TestScrapePoolRaces(t *testing.T) {
|
|||
}
|
||||
sp := newScrapePool(newConfig(), &nopAppendable{}, nil)
|
||||
tgts := []*targetgroup.Group{
|
||||
&targetgroup.Group{
|
||||
{
|
||||
Targets: []model.LabelSet{
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.1:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.2:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.3:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.4:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.5:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.6:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.7:9090"},
|
||||
model.LabelSet{model.AddressLabel: "127.0.0.8:9090"},
|
||||
{model.AddressLabel: "127.0.0.1:9090"},
|
||||
{model.AddressLabel: "127.0.0.2:9090"},
|
||||
{model.AddressLabel: "127.0.0.3:9090"},
|
||||
{model.AddressLabel: "127.0.0.4:9090"},
|
||||
{model.AddressLabel: "127.0.0.5:9090"},
|
||||
{model.AddressLabel: "127.0.0.6:9090"},
|
||||
{model.AddressLabel: "127.0.0.7:9090"},
|
||||
{model.AddressLabel: "127.0.0.8:9090"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -101,11 +101,11 @@ func TestValidateLabelsAndMetricName(t *testing.T) {
|
|||
func TestConcreteSeriesSet(t *testing.T) {
|
||||
series1 := &concreteSeries{
|
||||
labels: labels.FromStrings("foo", "bar"),
|
||||
samples: []prompb.Sample{prompb.Sample{Value: 1, Timestamp: 2}},
|
||||
samples: []prompb.Sample{{Value: 1, Timestamp: 2}},
|
||||
}
|
||||
series2 := &concreteSeries{
|
||||
labels: labels.FromStrings("foo", "baz"),
|
||||
samples: []prompb.Sample{prompb.Sample{Value: 3, Timestamp: 4}},
|
||||
samples: []prompb.Sample{{Value: 3, Timestamp: 4}},
|
||||
}
|
||||
c := &concreteSeriesSet{
|
||||
series: []storage.Series{series1, series2},
|
||||
|
|
|
@ -1053,7 +1053,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: snapshotAPI,
|
||||
values: map[string][]string{"skip_head": []string{"true"}},
|
||||
values: map[string][]string{"skip_head": {"true"}},
|
||||
|
||||
errType: errorNone,
|
||||
},
|
||||
|
@ -1061,7 +1061,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: snapshotAPI,
|
||||
values: map[string][]string{"skip_head": []string{"xxx"}},
|
||||
values: map[string][]string{"skip_head": {"xxx"}},
|
||||
|
||||
errType: errorBadData,
|
||||
},
|
||||
|
@ -1127,7 +1127,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: deleteAPI,
|
||||
values: map[string][]string{"match[]": []string{"123"}},
|
||||
values: map[string][]string{"match[]": {"123"}},
|
||||
|
||||
errType: errorBadData,
|
||||
},
|
||||
|
@ -1135,7 +1135,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: deleteAPI,
|
||||
values: map[string][]string{"match[]": []string{"up"}, "start": []string{"xxx"}},
|
||||
values: map[string][]string{"match[]": {"up"}, "start": {"xxx"}},
|
||||
|
||||
errType: errorBadData,
|
||||
},
|
||||
|
@ -1143,7 +1143,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: deleteAPI,
|
||||
values: map[string][]string{"match[]": []string{"up"}, "end": []string{"xxx"}},
|
||||
values: map[string][]string{"match[]": {"up"}, "end": {"xxx"}},
|
||||
|
||||
errType: errorBadData,
|
||||
},
|
||||
|
@ -1151,7 +1151,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: deleteAPI,
|
||||
values: map[string][]string{"match[]": []string{"up"}},
|
||||
values: map[string][]string{"match[]": {"up"}},
|
||||
|
||||
errType: errorNone,
|
||||
},
|
||||
|
@ -1159,7 +1159,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdb,
|
||||
enableAdmin: true,
|
||||
endpoint: deleteAPI,
|
||||
values: map[string][]string{"match[]": []string{"up{job!=\"foo\"}", "{job=~\"bar.+\"}", "up{instance!~\"fred.+\"}"}},
|
||||
values: map[string][]string{"match[]": {"up{job!=\"foo\"}", "{job=~\"bar.+\"}", "up{instance!~\"fred.+\"}"}},
|
||||
|
||||
errType: errorNone,
|
||||
},
|
||||
|
@ -1167,7 +1167,7 @@ func TestAdminEndpoints(t *testing.T) {
|
|||
db: tsdbWithError,
|
||||
enableAdmin: true,
|
||||
endpoint: deleteAPI,
|
||||
values: map[string][]string{"match[]": []string{"up"}},
|
||||
values: map[string][]string{"match[]": {"up"}},
|
||||
|
||||
errType: errorInternal,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue