2016-11-22 11:48:30 +00:00
|
|
|
// Copyright 2016 The Prometheus Authors
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package discovery
|
|
|
|
|
|
|
|
import (
|
2017-10-25 04:21:42 +00:00
|
|
|
"context"
|
2017-11-29 22:52:38 +00:00
|
|
|
"fmt"
|
2018-09-01 07:51:31 +00:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2017-11-12 02:39:08 +00:00
|
|
|
"reflect"
|
2018-01-04 21:41:54 +00:00
|
|
|
"sort"
|
2017-11-29 22:52:38 +00:00
|
|
|
"strconv"
|
2016-11-22 11:48:30 +00:00
|
|
|
"testing"
|
2017-11-06 17:33:52 +00:00
|
|
|
"time"
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2018-09-05 11:32:47 +00:00
|
|
|
"github.com/go-kit/kit/log"
|
2017-11-12 02:39:08 +00:00
|
|
|
"github.com/prometheus/common/model"
|
2016-11-22 11:48:30 +00:00
|
|
|
"github.com/prometheus/prometheus/config"
|
2017-12-30 17:47:18 +00:00
|
|
|
sd_config "github.com/prometheus/prometheus/discovery/config"
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
"github.com/prometheus/prometheus/discovery/targetgroup"
|
|
|
|
"gopkg.in/yaml.v2"
|
2016-11-22 11:48:30 +00:00
|
|
|
)
|
|
|
|
|
2018-01-27 12:03:06 +00:00
|
|
|
// TestTargetUpdatesOrder checks that the target updates are received in the expected order.
|
|
|
|
func TestTargetUpdatesOrder(t *testing.T) {
|
2017-11-29 22:52:38 +00:00
|
|
|
|
2018-09-01 07:51:31 +00:00
|
|
|
// The order by which the updates are send is determined by the interval passed to the mock discovery adapter
|
2017-11-29 22:52:38 +00:00
|
|
|
// Final targets array is ordered alphabetically by the name of the discoverer.
|
|
|
|
// For example discoverer "A" with targets "t2,t3" and discoverer "B" with targets "t1,t2" will result in "t2,t3,t1,t2" after the merge.
|
2017-11-12 02:39:08 +00:00
|
|
|
testCases := []struct {
|
2017-11-29 22:52:38 +00:00
|
|
|
title string
|
|
|
|
updates map[string][]update
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets [][]*targetgroup.Group
|
2017-11-12 02:39:08 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
title: "Single TP no updates",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
expectedTargets: nil,
|
2017-11-06 17:33:52 +00:00
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
|
|
|
title: "Multips TPs no updates",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {},
|
|
|
|
"tp2": {},
|
|
|
|
"tp3": {},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
expectedTargets: nil,
|
2017-11-06 17:33:52 +00:00
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
|
|
|
title: "Single TP empty initials",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{},
|
2017-11-12 02:39:08 +00:00
|
|
|
interval: 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{},
|
|
|
|
},
|
2017-11-06 17:33:52 +00:00
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
|
|
|
title: "Multiple TPs empty initials",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{},
|
2017-11-12 02:39:08 +00:00
|
|
|
interval: 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"tp2": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 200,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"tp3": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{},
|
2017-11-12 02:39:08 +00:00
|
|
|
interval: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{},
|
2017-11-12 02:39:08 +00:00
|
|
|
{},
|
|
|
|
{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Single TP initials only",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-12-01 12:59:24 +00:00
|
|
|
{
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-12-01 12:59:24 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-12-01 12:59:24 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Multiple TPs initials only",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-12-01 12:59:24 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"tp2": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-12-01 12:59:24 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-12-01 12:59:24 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-12-01 12:59:24 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
}, {
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-12-01 12:59:24 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Single TP initials followed by empty updates",
|
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 0,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tp1_group1",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp1_group2",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2018-01-04 21:41:54 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
Source: "tp1_group1",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp1_group2",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-11-29 22:52:38 +00:00
|
|
|
title: "Single TP initials and new groups",
|
2017-11-12 02:39:08 +00:00
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 0,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
|
|
|
},
|
2018-01-04 21:41:54 +00:00
|
|
|
{
|
|
|
|
Source: "tp1_group3",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
},
|
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
2018-01-04 21:41:54 +00:00
|
|
|
{
|
|
|
|
Source: "tp1_group3",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-11-29 22:52:38 +00:00
|
|
|
title: "Multiple TPs initials and new groups",
|
2017-11-12 02:39:08 +00:00
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group3",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group4",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 500,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"tp2": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "5"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "6"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 100,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group3",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "7"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group4",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "8"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "5"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "6"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "5"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp2_group2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "6"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp2_group3",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "7"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group4",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "8"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp1_group2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp1_group3",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group4",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "5"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp2_group2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "6"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp2_group3",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "7"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group4",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "8"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-11-06 17:33:52 +00:00
|
|
|
},
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
title: "One TP initials arrive after other TP updates.",
|
2017-11-12 02:39:08 +00:00
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 150,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
"tp2": {
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "5"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "6"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 200,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "7"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "8"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 100,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
},
|
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "5"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "6"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "7"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp2_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "8"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
title: "Single TP empty update in between",
|
2017-11-12 02:39:08 +00:00
|
|
|
updates: map[string][]update{
|
|
|
|
"tp1": {
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 30,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tp1_group1",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp1_group2",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interval: 10,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
interval: 300,
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
2017-11-29 22:52:38 +00:00
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
expectedTargets: [][]*targetgroup.Group{
|
2017-11-29 22:52:38 +00:00
|
|
|
{
|
2017-11-12 02:39:08 +00:00
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group1",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tp1_group2",
|
|
|
|
Targets: []model.LabelSet{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Source: "tp1_group1",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "3"}},
|
|
|
|
},
|
|
|
|
{
|
2018-01-04 21:41:54 +00:00
|
|
|
Source: "tp1_group2",
|
2017-11-29 22:52:38 +00:00
|
|
|
Targets: []model.LabelSet{{"__instance__": "4"}},
|
2017-11-12 02:39:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-09-05 13:44:52 +00:00
|
|
|
for i, tc := range testCases {
|
|
|
|
tc := tc
|
|
|
|
t.Run(tc.title, func(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
discoveryManager := NewManager(ctx, log.NewNopLogger())
|
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
|
|
|
|
var totalUpdatesCount int
|
|
|
|
|
|
|
|
provUpdates := make(chan []*targetgroup.Group)
|
|
|
|
for _, up := range tc.updates {
|
|
|
|
go newMockDiscoveryProvider(up).Run(ctx, provUpdates)
|
|
|
|
if len(up) > 0 {
|
|
|
|
totalUpdatesCount = totalUpdatesCount + len(up)
|
|
|
|
}
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
2017-11-12 02:39:08 +00:00
|
|
|
|
2018-09-05 13:44:52 +00:00
|
|
|
Loop:
|
|
|
|
for x := 0; x < totalUpdatesCount; x++ {
|
|
|
|
select {
|
|
|
|
case <-time.After(10 * time.Second):
|
|
|
|
t.Errorf("%d: no update arrived within the timeout limit", x)
|
|
|
|
break Loop
|
|
|
|
case tgs := <-provUpdates:
|
|
|
|
discoveryManager.updateGroup(poolKey{setName: strconv.Itoa(i), provider: tc.title}, tgs)
|
|
|
|
for _, got := range discoveryManager.allGroups() {
|
|
|
|
assertEqualGroups(t, got, tc.expectedTargets[x], func(got, expected string) string {
|
|
|
|
return fmt.Sprintf("%d: \ntargets mismatch \ngot: %v \nexpected: %v",
|
|
|
|
x,
|
|
|
|
got,
|
|
|
|
expected)
|
|
|
|
})
|
2017-11-29 22:52:38 +00:00
|
|
|
}
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-05 13:44:52 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func assertEqualGroups(t *testing.T, got, expected []*targetgroup.Group, msg func(got, expected string) string) {
|
|
|
|
t.Helper()
|
|
|
|
format := func(groups []*targetgroup.Group) string {
|
|
|
|
var s string
|
|
|
|
for i, group := range groups {
|
|
|
|
if i > 0 {
|
|
|
|
s += ","
|
|
|
|
}
|
|
|
|
s += group.Source + ":" + fmt.Sprint(group.Targets)
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
2018-09-05 13:44:52 +00:00
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to sort by the groups's source as the received order is not guaranteed.
|
|
|
|
sort.Sort(byGroupSource(got))
|
|
|
|
sort.Sort(byGroupSource(expected))
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(got, expected) {
|
|
|
|
t.Errorf(msg(format(got), format(expected)))
|
2017-11-29 22:52:38 +00:00
|
|
|
}
|
2018-09-05 13:44:52 +00:00
|
|
|
|
2017-11-29 22:52:38 +00:00
|
|
|
}
|
2017-11-12 02:39:08 +00:00
|
|
|
|
2018-09-01 07:51:31 +00:00
|
|
|
func verifyPresence(t *testing.T, tSets map[poolKey]map[string]*targetgroup.Group, poolKey poolKey, label string, present bool) {
|
|
|
|
if _, ok := tSets[poolKey]; !ok {
|
|
|
|
t.Fatalf("'%s' should be present in Pool keys: %v", poolKey, tSets)
|
|
|
|
return
|
|
|
|
}
|
2017-11-12 02:39:08 +00:00
|
|
|
|
2018-09-01 07:51:31 +00:00
|
|
|
match := false
|
|
|
|
var mergedTargets string
|
|
|
|
for _, targetGroup := range tSets[poolKey] {
|
2017-11-12 02:39:08 +00:00
|
|
|
|
2018-09-01 07:51:31 +00:00
|
|
|
for _, l := range targetGroup.Targets {
|
|
|
|
mergedTargets = mergedTargets + " " + l.String()
|
|
|
|
if l.String() == label {
|
|
|
|
match = true
|
2017-11-29 22:52:38 +00:00
|
|
|
}
|
2017-11-12 02:39:08 +00:00
|
|
|
}
|
2018-09-01 07:51:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
if match != present {
|
|
|
|
msg := ""
|
|
|
|
if !present {
|
|
|
|
msg = "not"
|
2016-11-22 11:48:30 +00:00
|
|
|
}
|
2018-09-01 07:51:31 +00:00
|
|
|
t.Fatalf("'%s' should %s be present in Targets labels: %v", label, msg, mergedTargets)
|
2016-11-22 11:48:30 +00:00
|
|
|
}
|
2018-09-01 07:51:31 +00:00
|
|
|
}
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2018-09-01 07:51:31 +00:00
|
|
|
func TestTargetSetRecreatesTargetGroupsEveryRun(t *testing.T) {
|
2017-11-29 22:52:38 +00:00
|
|
|
cfg := &config.Config{}
|
2016-11-22 11:48:30 +00:00
|
|
|
|
|
|
|
sOne := `
|
2017-11-29 22:52:38 +00:00
|
|
|
scrape_configs:
|
|
|
|
- job_name: 'prometheus'
|
|
|
|
static_configs:
|
|
|
|
- targets: ["foo:9090"]
|
|
|
|
- targets: ["bar:9090"]
|
2016-11-22 11:48:30 +00:00
|
|
|
`
|
2018-04-04 08:07:39 +00:00
|
|
|
if err := yaml.UnmarshalStrict([]byte(sOne), cfg); err != nil {
|
2016-11-22 11:48:30 +00:00
|
|
|
t.Fatalf("Unable to load YAML config sOne: %s", err)
|
|
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2018-09-05 11:32:47 +00:00
|
|
|
discoveryManager := NewManager(ctx, log.NewNopLogger())
|
2018-01-26 13:31:59 +00:00
|
|
|
go discoveryManager.Run()
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2017-12-30 17:47:18 +00:00
|
|
|
c := make(map[string]sd_config.ServiceDiscoveryConfig)
|
|
|
|
for _, v := range cfg.ScrapeConfigs {
|
|
|
|
c[v.JobName] = v.ServiceDiscoveryConfig
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2018-02-26 07:58:10 +00:00
|
|
|
<-discoveryManager.SyncCh()
|
2018-09-01 07:51:31 +00:00
|
|
|
verifyPresence(t, discoveryManager.targets, poolKey{setName: "prometheus", provider: "string/0"}, "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, poolKey{setName: "prometheus", provider: "string/0"}, "{__address__=\"bar:9090\"}", true)
|
2016-11-22 11:48:30 +00:00
|
|
|
|
|
|
|
sTwo := `
|
2017-11-29 22:52:38 +00:00
|
|
|
scrape_configs:
|
|
|
|
- job_name: 'prometheus'
|
|
|
|
static_configs:
|
|
|
|
- targets: ["foo:9090"]
|
2016-11-22 11:48:30 +00:00
|
|
|
`
|
2018-04-04 08:07:39 +00:00
|
|
|
if err := yaml.UnmarshalStrict([]byte(sTwo), cfg); err != nil {
|
2017-11-29 22:52:38 +00:00
|
|
|
t.Fatalf("Unable to load YAML config sOne: %s", err)
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
2017-12-30 17:47:18 +00:00
|
|
|
c = make(map[string]sd_config.ServiceDiscoveryConfig)
|
|
|
|
for _, v := range cfg.ScrapeConfigs {
|
|
|
|
c[v.JobName] = v.ServiceDiscoveryConfig
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
2017-11-06 17:33:52 +00:00
|
|
|
|
2018-02-26 07:58:10 +00:00
|
|
|
<-discoveryManager.SyncCh()
|
2018-09-01 07:51:31 +00:00
|
|
|
verifyPresence(t, discoveryManager.targets, poolKey{setName: "prometheus", provider: "string/0"}, "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, poolKey{setName: "prometheus", provider: "string/0"}, "{__address__=\"bar:9090\"}", false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIdenticalConfigurationsAreCoalesced(t *testing.T) {
|
|
|
|
tmpFile, err := ioutil.TempFile("", "sd")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("error creating temporary file: %v", err)
|
|
|
|
}
|
|
|
|
defer os.Remove(tmpFile.Name())
|
|
|
|
if _, err := tmpFile.Write([]byte(`[{"targets": ["foo:9090"]}]`)); err != nil {
|
|
|
|
t.Fatalf("error writing temporary file: %v", err)
|
|
|
|
}
|
|
|
|
if err := tmpFile.Close(); err != nil {
|
|
|
|
t.Fatalf("error closing temporary file: %v", err)
|
|
|
|
}
|
|
|
|
tmpFile2 := fmt.Sprintf("%s.json", tmpFile.Name())
|
|
|
|
if err = os.Link(tmpFile.Name(), tmpFile2); err != nil {
|
|
|
|
t.Fatalf("error linking temporary file: %v", err)
|
|
|
|
}
|
|
|
|
defer os.Remove(tmpFile2)
|
|
|
|
|
|
|
|
cfg := &config.Config{}
|
|
|
|
|
|
|
|
sOne := `
|
|
|
|
scrape_configs:
|
|
|
|
- job_name: 'prometheus'
|
|
|
|
file_sd_configs:
|
|
|
|
- files: ["%s"]
|
|
|
|
- job_name: 'prometheus2'
|
|
|
|
file_sd_configs:
|
|
|
|
- files: ["%s"]
|
|
|
|
`
|
|
|
|
sOne = fmt.Sprintf(sOne, tmpFile2, tmpFile2)
|
|
|
|
if err := yaml.UnmarshalStrict([]byte(sOne), cfg); err != nil {
|
|
|
|
t.Fatalf("Unable to load YAML config sOne: %s", err)
|
|
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
discoveryManager := NewManager(ctx, nil)
|
2018-09-05 13:44:52 +00:00
|
|
|
discoveryManager.updatert = 500 * time.Millisecond
|
2018-09-01 07:51:31 +00:00
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := make(map[string]sd_config.ServiceDiscoveryConfig)
|
|
|
|
for _, v := range cfg.ScrapeConfigs {
|
|
|
|
c[v.JobName] = v.ServiceDiscoveryConfig
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
<-discoveryManager.SyncCh()
|
|
|
|
verifyPresence(t, discoveryManager.targets, poolKey{setName: "prometheus", provider: "*file.SDConfig/0"}, "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, poolKey{setName: "prometheus2", provider: "*file.SDConfig/0"}, "{__address__=\"foo:9090\"}", true)
|
|
|
|
if len(discoveryManager.providers) != 1 {
|
|
|
|
t.Fatalf("Invalid number of providers: expected 1, got %d", len(discoveryManager.providers))
|
|
|
|
}
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
|
2018-06-13 15:34:59 +00:00
|
|
|
func TestApplyConfigDoesNotModifyStaticProviderTargets(t *testing.T) {
|
|
|
|
cfgText := `
|
|
|
|
scrape_configs:
|
|
|
|
- job_name: 'prometheus'
|
|
|
|
static_configs:
|
|
|
|
- targets: ["foo:9090"]
|
|
|
|
- targets: ["bar:9090"]
|
|
|
|
- targets: ["baz:9090"]
|
|
|
|
`
|
|
|
|
originalConfig := &config.Config{}
|
|
|
|
if err := yaml.UnmarshalStrict([]byte(cfgText), originalConfig); err != nil {
|
|
|
|
t.Fatalf("Unable to load YAML config cfgYaml: %s", err)
|
|
|
|
}
|
|
|
|
origScrpCfg := originalConfig.ScrapeConfigs[0]
|
|
|
|
|
|
|
|
processedConfig := &config.Config{}
|
|
|
|
if err := yaml.UnmarshalStrict([]byte(cfgText), processedConfig); err != nil {
|
|
|
|
t.Fatalf("Unable to load YAML config cfgYaml: %s", err)
|
|
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2018-09-05 11:32:47 +00:00
|
|
|
discoveryManager := NewManager(ctx, log.NewNopLogger())
|
2018-06-13 15:34:59 +00:00
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := make(map[string]sd_config.ServiceDiscoveryConfig)
|
|
|
|
for _, v := range processedConfig.ScrapeConfigs {
|
|
|
|
c[v.JobName] = v.ServiceDiscoveryConfig
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
<-discoveryManager.SyncCh()
|
|
|
|
|
|
|
|
for _, sdcfg := range c {
|
|
|
|
if !reflect.DeepEqual(origScrpCfg.ServiceDiscoveryConfig.StaticConfigs, sdcfg.StaticConfigs) {
|
|
|
|
t.Fatalf("discovery manager modified static config \n expected: %v\n got: %v\n",
|
|
|
|
origScrpCfg.ServiceDiscoveryConfig.StaticConfigs, sdcfg.StaticConfigs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:04:33 +00:00
|
|
|
func TestCoordinationWithEmptyProvider(t *testing.T) {
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
mgr := NewManager(ctx, nil)
|
|
|
|
mgr.updatert = 100 * time.Millisecond
|
|
|
|
go mgr.Run()
|
|
|
|
|
|
|
|
p := emptyProvider{}
|
|
|
|
mgr.StartCustomProvider(ctx, "empty", p)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
t.Fatal("no update received in the expected timeframe")
|
|
|
|
case tgs, ok := <-mgr.SyncCh():
|
|
|
|
if !ok {
|
|
|
|
t.Fatal("discovery manager channel is closed")
|
|
|
|
}
|
|
|
|
if len(tgs) != 0 {
|
|
|
|
t.Fatalf("target groups mismatch, got: %#v, expected: {}\n", tgs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-05 13:44:52 +00:00
|
|
|
func TestCoordinationWithReceiver(t *testing.T) {
|
|
|
|
updateDelay := 100 * time.Millisecond
|
|
|
|
|
|
|
|
type expect struct {
|
|
|
|
delay time.Duration
|
|
|
|
tgs map[string][]*targetgroup.Group
|
|
|
|
}
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
title string
|
|
|
|
providers map[string][]update
|
|
|
|
expected []expect
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
title: "Receiver should get updates even when the channel is blocked",
|
|
|
|
providers: map[string][]update{
|
|
|
|
"mock1": []update{
|
|
|
|
update{
|
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update{
|
|
|
|
interval: 4 * updateDelay / time.Millisecond,
|
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: []expect{
|
|
|
|
{
|
|
|
|
delay: 2 * updateDelay,
|
|
|
|
tgs: map[string][]*targetgroup.Group{
|
|
|
|
"mock1": []*targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
delay: 4 * updateDelay,
|
|
|
|
tgs: map[string][]*targetgroup.Group{
|
|
|
|
"mock1": []*targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tg2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "The receiver gets an update when a target group is gone",
|
|
|
|
providers: map[string][]update{
|
|
|
|
"mock1": []update{
|
|
|
|
update{
|
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update{
|
|
|
|
interval: 2 * updateDelay / time.Millisecond,
|
|
|
|
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][]update{
|
|
|
|
"mock1": []update{
|
|
|
|
// 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][]update{
|
|
|
|
"mock1": []update{
|
|
|
|
// This update is available in the first receive.
|
|
|
|
update{
|
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"mock2": []update{
|
|
|
|
// This update should only arrive after the receiver has read from the channel once.
|
|
|
|
update{
|
|
|
|
interval: 2 * updateDelay / time.Millisecond,
|
|
|
|
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 {
|
|
|
|
tc := tc
|
|
|
|
t.Run(tc.title, func(t *testing.T) {
|
2018-09-11 15:04:33 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
2018-09-05 13:44:52 +00:00
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
mgr := NewManager(ctx, nil)
|
|
|
|
mgr.updatert = updateDelay
|
|
|
|
go mgr.Run()
|
|
|
|
|
|
|
|
for name := range tc.providers {
|
|
|
|
p := newMockDiscoveryProvider(tc.providers[name])
|
|
|
|
mgr.StartCustomProvider(ctx, name, p)
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, expected := range tc.expected {
|
|
|
|
time.Sleep(expected.delay)
|
2018-09-11 15:04:33 +00:00
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
t.Fatal("no update received in the expected timeframe")
|
|
|
|
case tgs, ok := <-mgr.SyncCh():
|
|
|
|
if !ok {
|
|
|
|
t.Fatal("discovery manager channel is closed")
|
|
|
|
}
|
|
|
|
if len(tgs) != len(expected.tgs) {
|
|
|
|
t.Fatalf("step %d: target groups mismatch, got: %d, expected: %d\ngot: %#v\nexpected: %#v",
|
|
|
|
i, len(tgs), len(expected.tgs), tgs, expected.tgs)
|
|
|
|
}
|
|
|
|
for k := range expected.tgs {
|
|
|
|
if _, ok := tgs[k]; !ok {
|
|
|
|
t.Fatalf("step %d: target group not found: %s", i, k)
|
|
|
|
}
|
|
|
|
assertEqualGroups(t, tgs[k], expected.tgs[k], func(got, expected string) string {
|
|
|
|
return fmt.Sprintf("step %d: targets mismatch \ngot: %q \nexpected: %q", i, got, expected)
|
|
|
|
})
|
2018-09-05 13:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-12 02:39:08 +00:00
|
|
|
type update struct {
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 20:01:34 +00:00
|
|
|
targetGroups []targetgroup.Group
|
2017-11-12 02:39:08 +00:00
|
|
|
interval time.Duration
|
|
|
|
}
|
|
|
|
|
2017-11-29 22:52:38 +00:00
|
|
|
type mockdiscoveryProvider struct {
|
|
|
|
updates []update
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 22:52:38 +00:00
|
|
|
func newMockDiscoveryProvider(updates []update) mockdiscoveryProvider {
|
|
|
|
tp := mockdiscoveryProvider{
|
|
|
|
updates: updates,
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
return tp
|
|
|
|
}
|
|
|
|
|
2018-09-05 13:44:52 +00:00
|
|
|
func (tp mockdiscoveryProvider) Run(ctx context.Context, upCh chan<- []*targetgroup.Group) {
|
|
|
|
for _, u := range tp.updates {
|
|
|
|
if u.interval > 0 {
|
|
|
|
t := time.NewTicker(u.interval * time.Millisecond)
|
|
|
|
defer t.Stop()
|
|
|
|
Loop:
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
case <-t.C:
|
|
|
|
break Loop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tgs := make([]*targetgroup.Group, len(u.targetGroups))
|
|
|
|
for i := range u.targetGroups {
|
|
|
|
tgs[i] = &u.targetGroups[i]
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
2018-09-05 13:44:52 +00:00
|
|
|
upCh <- tgs
|
2017-11-06 16:14:15 +00:00
|
|
|
}
|
2018-09-05 13:44:52 +00:00
|
|
|
<-ctx.Done()
|
2017-11-06 16:14:15 +00:00
|
|
|
}
|
2018-01-04 21:41:54 +00:00
|
|
|
|
|
|
|
// byGroupSource implements sort.Interface so we can sort by the Source field.
|
|
|
|
type byGroupSource []*targetgroup.Group
|
|
|
|
|
|
|
|
func (a byGroupSource) Len() int { return len(a) }
|
|
|
|
func (a byGroupSource) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|
|
|
func (a byGroupSource) Less(i, j int) bool { return a[i].Source < a[j].Source }
|
2018-09-11 15:04:33 +00:00
|
|
|
|
|
|
|
// emptyProvider sends no updates and closes the update channel.
|
|
|
|
type emptyProvider struct{}
|
|
|
|
|
|
|
|
func (e emptyProvider) Run(_ context.Context, ch chan<- []*targetgroup.Group) {
|
|
|
|
close(ch)
|
|
|
|
}
|