|
|
|
@ -1004,145 +1004,6 @@ func TestCoordinationWithReceiver(t *testing.T) {
|
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "The receiver gets an update when a target group is gone", |
|
|
|
|
providers: map[string]Discoverer{ |
|
|
|
|
"mock1": newMockDiscoveryProvider( |
|
|
|
|
update{ |
|
|
|
|
targetGroups: []targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
update{ |
|
|
|
|
interval: 2 * updateDelay, |
|
|
|
|
targetGroups: []targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
expected: []expect{ |
|
|
|
|
{ |
|
|
|
|
tgs: map[string][]*targetgroup.Group{ |
|
|
|
|
"mock1": []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
tgs: map[string][]*targetgroup.Group{ |
|
|
|
|
"mock1": []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "The receiver gets merged updates", |
|
|
|
|
providers: map[string]Discoverer{ |
|
|
|
|
"mock1": newMockDiscoveryProvider( |
|
|
|
|
// This update should never be seen by the receiver because
|
|
|
|
|
// it is overwritten by the next one.
|
|
|
|
|
update{ |
|
|
|
|
targetGroups: []targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "0"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
update{ |
|
|
|
|
targetGroups: []targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
expected: []expect{ |
|
|
|
|
{ |
|
|
|
|
tgs: map[string][]*targetgroup.Group{ |
|
|
|
|
"mock1": []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "Discovery with multiple providers", |
|
|
|
|
providers: map[string]Discoverer{ |
|
|
|
|
"mock1": newMockDiscoveryProvider( |
|
|
|
|
// This update is available in the first receive.
|
|
|
|
|
update{ |
|
|
|
|
targetGroups: []targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
"mock2": newMockDiscoveryProvider( |
|
|
|
|
// This update should only arrive after the receiver has read from the channel once.
|
|
|
|
|
update{ |
|
|
|
|
interval: 2 * updateDelay, |
|
|
|
|
targetGroups: []targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg2", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}), |
|
|
|
|
}, |
|
|
|
|
expected: []expect{ |
|
|
|
|
{ |
|
|
|
|
tgs: map[string][]*targetgroup.Group{ |
|
|
|
|
"mock1": []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
delay: 1 * updateDelay, |
|
|
|
|
tgs: map[string][]*targetgroup.Group{ |
|
|
|
|
"mock1": []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg1", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
"mock2": []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Source: "tg2", |
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, tc := range testCases { |
|
|
|
|