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"
|
2024-11-03 12:15:51 +00:00
|
|
|
"errors"
|
2017-11-29 22:52:38 +00:00
|
|
|
"fmt"
|
2018-01-04 21:41:54 +00:00
|
|
|
"sort"
|
2017-11-29 22:52:38 +00:00
|
|
|
"strconv"
|
2021-10-20 08:16:20 +00:00
|
|
|
"sync"
|
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
|
|
|
|
2023-10-23 13:55:36 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
2020-07-24 09:10:20 +00:00
|
|
|
client_testutil "github.com/prometheus/client_golang/prometheus/testutil"
|
2017-11-12 02:39:08 +00:00
|
|
|
"github.com/prometheus/common/model"
|
2024-09-10 01:41:53 +00:00
|
|
|
"github.com/prometheus/common/promslog"
|
2020-10-29 09:43:23 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2020-10-22 09:00: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
|
|
|
"github.com/prometheus/prometheus/discovery/targetgroup"
|
2020-07-24 09:10:20 +00:00
|
|
|
"github.com/prometheus/prometheus/util/testutil"
|
2016-11-22 11:48:30 +00:00
|
|
|
)
|
|
|
|
|
2020-07-24 09:10:20 +00:00
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
testutil.TolerantVerifyLeak(m)
|
|
|
|
}
|
|
|
|
|
2024-04-05 14:19:07 +00:00
|
|
|
func NewTestMetrics(t *testing.T, reg prometheus.Registerer) (RefreshMetricsManager, map[string]DiscovererMetrics) {
|
2024-01-23 15:53:55 +00:00
|
|
|
refreshMetrics := NewRefreshMetrics(reg)
|
|
|
|
sdMetrics, err := RegisterSDMetrics(reg, refreshMetrics)
|
|
|
|
require.NoError(t, err)
|
2024-04-05 14:19:07 +00:00
|
|
|
return refreshMetrics, sdMetrics
|
2024-01-23 15:53:55 +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) {
|
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
|
|
|
{
|
2019-02-27 10:22:31 +00:00
|
|
|
title: "Multiple TPs no updates",
|
2017-11-12 02:39:08 +00:00
|
|
|
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{},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 5 * time.Millisecond,
|
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-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{},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 5 * time.Millisecond,
|
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{},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 200 * time.Millisecond,
|
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{},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 100 * time.Millisecond,
|
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
|
|
|
{},
|
|
|
|
{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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"}},
|
2021-10-22 08:06:44 +00:00
|
|
|
},
|
|
|
|
},
|
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"}},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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{},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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"}},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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"}},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 500 * time.Millisecond,
|
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"}},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 100 * time.Millisecond,
|
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"}},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 150 * time.Millisecond,
|
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
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 200 * time.Millisecond,
|
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
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 100 * time.Millisecond,
|
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
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 30 * time.Millisecond,
|
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{},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 10 * time.Millisecond,
|
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
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 300 * time.Millisecond,
|
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) {
|
2018-09-12 14:15:03 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
2018-09-05 13:44:52 +00:00
|
|
|
defer cancel()
|
2018-09-12 14:15:03 +00:00
|
|
|
|
2024-01-23 15:53:55 +00:00
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2018-09-05 13:44:52 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
|
|
|
|
var totalUpdatesCount int
|
|
|
|
for _, up := range tc.updates {
|
|
|
|
if len(up) > 0 {
|
2020-08-03 09:29:59 +00:00
|
|
|
totalUpdatesCount += len(up)
|
2018-09-05 13:44:52 +00:00
|
|
|
}
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
2022-01-05 10:51:06 +00:00
|
|
|
provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount)
|
|
|
|
|
|
|
|
for _, up := range tc.updates {
|
|
|
|
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
|
|
|
|
}
|
2017-11-12 02:39:08 +00:00
|
|
|
|
2018-09-05 13:44:52 +00:00
|
|
|
for x := 0; x < totalUpdatesCount; x++ {
|
|
|
|
select {
|
2018-09-12 14:15:03 +00:00
|
|
|
case <-ctx.Done():
|
2021-09-03 13:14:25 +00:00
|
|
|
require.FailNow(t, "%d: no update arrived within the timeout limit", x)
|
2018-09-05 13:44:52 +00:00
|
|
|
case tgs := <-provUpdates:
|
|
|
|
discoveryManager.updateGroup(poolKey{setName: strconv.Itoa(i), provider: tc.title}, tgs)
|
|
|
|
for _, got := range discoveryManager.allGroups() {
|
2023-04-12 11:05:41 +00:00
|
|
|
assertEqualGroups(t, got, tc.expectedTargets[x])
|
2017-11-29 22:52:38 +00:00
|
|
|
}
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-05 13:44:52 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-12 11:05:41 +00:00
|
|
|
func assertEqualGroups(t *testing.T, got, expected []*targetgroup.Group) {
|
2018-09-05 13:44:52 +00:00
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
// Need to sort by the groups's source as the received order is not guaranteed.
|
|
|
|
sort.Sort(byGroupSource(got))
|
|
|
|
sort.Sort(byGroupSource(expected))
|
|
|
|
|
2020-10-29 09:43:23 +00:00
|
|
|
require.Equal(t, expected, got)
|
2017-11-29 22:52:38 +00:00
|
|
|
}
|
2017-11-12 02:39:08 +00:00
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
func staticConfig(addrs ...string) StaticConfig {
|
|
|
|
var cfg StaticConfig
|
|
|
|
for i, addr := range addrs {
|
|
|
|
cfg = append(cfg, &targetgroup.Group{
|
2024-05-13 15:36:19 +00:00
|
|
|
Source: strconv.Itoa(i),
|
2020-08-20 12:48:26 +00:00
|
|
|
Targets: []model.LabelSet{
|
|
|
|
{model.AddressLabel: model.LabelValue(addr)},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return cfg
|
|
|
|
}
|
|
|
|
|
2021-10-22 08:06:44 +00:00
|
|
|
func verifySyncedPresence(t *testing.T, tGroups map[string][]*targetgroup.Group, key, label string, present bool) {
|
2021-10-20 08:16:20 +00:00
|
|
|
t.Helper()
|
|
|
|
if _, ok := tGroups[key]; !ok {
|
|
|
|
t.Fatalf("'%s' should be present in Group map keys: %v", key, tGroups)
|
|
|
|
}
|
|
|
|
match := false
|
|
|
|
var mergedTargets string
|
|
|
|
for _, targetGroups := range tGroups[key] {
|
|
|
|
for _, l := range targetGroups.Targets {
|
|
|
|
mergedTargets = mergedTargets + " " + l.String()
|
|
|
|
if l.String() == label {
|
|
|
|
match = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if match != present {
|
|
|
|
msg := ""
|
|
|
|
if !present {
|
|
|
|
msg = "not"
|
|
|
|
}
|
|
|
|
t.Fatalf("%q should %s be present in Group labels: %q", label, msg, mergedTargets)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2018-11-30 16:59:57 +00:00
|
|
|
t.Helper()
|
2021-09-03 13:14:25 +00:00
|
|
|
_, ok := tSets[poolKey]
|
|
|
|
require.True(t, ok, "'%s' should be present in Pool keys: %v", poolKey, tSets)
|
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] {
|
|
|
|
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
|
|
|
}
|
2021-09-03 13:14:25 +00:00
|
|
|
require.FailNow(t, "%q should %s be present in Targets labels: %q", 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
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
func pk(provider, setName string, n int) poolKey {
|
|
|
|
return poolKey{
|
|
|
|
setName: setName,
|
|
|
|
provider: fmt.Sprintf("%s/%d", provider, n),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTargetSetTargetGroupsPresentOnConfigReload(t *testing.T) {
|
2016-11-22 11:48:30 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2018-09-12 14:06:31 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
2018-01-26 13:31:59 +00:00
|
|
|
go discoveryManager.Run()
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c := map[string]Configs{
|
2020-04-09 10:29:19 +00:00
|
|
|
"prometheus": {
|
2021-10-20 08:16:20 +00:00
|
|
|
staticConfig("foo:9090"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestTargetSetTargetGroupsPresentOnConfigRename(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2021-10-20 08:16:20 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := map[string]Configs{
|
|
|
|
"prometheus": {
|
|
|
|
staticConfig("foo:9090"),
|
2019-09-24 16:11:43 +00:00
|
|
|
},
|
2017-12-30 17:47:18 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
c["prometheus2"] = c["prometheus"]
|
|
|
|
delete(c, "prometheus")
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
|
|
|
p = pk("static", "prometheus2", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus2", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus2"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestTargetSetTargetGroupsPresentOnConfigDuplicateAndDeleteOriginal(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2021-10-20 08:16:20 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := map[string]Configs{
|
|
|
|
"prometheus": {
|
|
|
|
staticConfig("foo:9090"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
2018-02-26 07:58:10 +00:00
|
|
|
<-discoveryManager.SyncCh()
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
c["prometheus2"] = c["prometheus"]
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 2)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus2", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus2"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 2)
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
delete(c, "prometheus")
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
|
|
|
p = pk("static", "prometheus2", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus2", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus2"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestTargetSetTargetGroupsPresentOnConfigChange(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2021-10-20 08:16:20 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := map[string]Configs{
|
|
|
|
"prometheus": {
|
|
|
|
staticConfig("foo:9090"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
var mu sync.Mutex
|
|
|
|
c["prometheus2"] = Configs{
|
|
|
|
lockStaticConfig{
|
|
|
|
mu: &mu,
|
|
|
|
config: staticConfig("bar:9090"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
mu.Lock()
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
// Original targets should be present as soon as possible.
|
2023-11-15 10:41:12 +00:00
|
|
|
// An empty list should be sent for prometheus2 to drop any stale targets
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
|
|
|
mu.Unlock()
|
2023-11-15 10:41:12 +00:00
|
|
|
require.Len(t, syncedTargets, 2)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2023-11-15 10:41:12 +00:00
|
|
|
require.Empty(t, syncedTargets["prometheus2"])
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
// prometheus2 configs should be ready on second sync.
|
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 2)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus2", "{__address__=\"bar:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus2"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
|
|
|
p = pk("lockstatic", "prometheus2", 1)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"bar:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 2)
|
2021-10-20 08:16:20 +00:00
|
|
|
|
|
|
|
// Delete part of config and ensure only original targets exist.
|
|
|
|
delete(c, "prometheus2")
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifyPresence(t, discoveryManager.targets, pk("static", "prometheus", 0), "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestTargetSetRecreatesTargetGroupsOnConfigChange(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2021-10-20 08:16:20 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := map[string]Configs{
|
|
|
|
"prometheus": {
|
|
|
|
staticConfig("foo:9090", "bar:9090"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"bar:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"bar:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 2)
|
2016-11-22 11:48:30 +00:00
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c["prometheus"] = Configs{
|
|
|
|
staticConfig("foo:9090"),
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
p = pk("static", "prometheus", 1)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"bar:9090\"}", false)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2020-08-20 12:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDiscovererConfigs(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2020-08-20 12:48:26 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
c := map[string]Configs{
|
|
|
|
"prometheus": {
|
|
|
|
staticConfig("foo:9090", "bar:9090"),
|
|
|
|
staticConfig("baz:9090"),
|
2019-09-24 16:11:43 +00:00
|
|
|
},
|
2017-12-30 17:47:18 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
2017-11-06 17:33:52 +00:00
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"bar:9090\"}", true)
|
|
|
|
p = pk("static", "prometheus", 1)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"baz:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 2)
|
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"bar:9090\"}", true)
|
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"baz:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 3)
|
2018-09-01 07:51:31 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 16:59:57 +00:00
|
|
|
// TestTargetSetRecreatesEmptyStaticConfigs ensures that reloading a config file after
|
2024-08-30 11:37:25 +00:00
|
|
|
// removing all targets from the static_configs cleans the corresponding targetGroups entries to avoid leaks and sends an empty update.
|
|
|
|
// The update is required to signal the consumers that the previous targets should be dropped.
|
2018-11-30 16:59:57 +00:00
|
|
|
func TestTargetSetRecreatesEmptyStaticConfigs(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2018-11-30 16:59:57 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c := map[string]Configs{
|
2020-04-09 10:29:19 +00:00
|
|
|
"prometheus": {
|
2020-08-20 12:48:26 +00:00
|
|
|
staticConfig("foo:9090"),
|
2019-09-24 16:11:43 +00:00
|
|
|
},
|
2018-11-30 16:59:57 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
|
|
|
p := pk("static", "prometheus", 0)
|
|
|
|
verifyPresence(t, discoveryManager.targets, p, "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2018-11-30 16:59:57 +00:00
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c["prometheus"] = Configs{
|
|
|
|
StaticConfig{{}},
|
2018-11-30 16:59:57 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets = <-discoveryManager.SyncCh()
|
2024-08-30 11:37:25 +00:00
|
|
|
require.Len(t, discoveryManager.targets, 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
p = pk("static", "prometheus", 1)
|
|
|
|
targetGroups, ok := discoveryManager.targets[p]
|
2024-08-30 11:37:25 +00:00
|
|
|
require.True(t, ok, "'%v' should be present in targets", p)
|
|
|
|
// Otherwise the targetGroups will leak, see https://github.com/prometheus/prometheus/issues/12436.
|
|
|
|
require.Empty(t, targetGroups, 0, "'%v' should no longer have any associated target groups", p)
|
|
|
|
require.Len(t, syncedTargets, 1, "an update with no targetGroups should still be sent.")
|
|
|
|
require.Empty(t, syncedTargets["prometheus"], 0)
|
2018-11-30 16:59:57 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 07:51:31 +00:00
|
|
|
func TestIdenticalConfigurationsAreCoalesced(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
|
|
|
discoveryManager := NewManager(ctx, nil, reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2018-09-12 14:06:31 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
2018-09-01 07:51:31 +00:00
|
|
|
go discoveryManager.Run()
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c := map[string]Configs{
|
2020-04-09 10:29:19 +00:00
|
|
|
"prometheus": {
|
2020-08-20 12:48:26 +00:00
|
|
|
staticConfig("foo:9090"),
|
2019-09-24 16:11:43 +00:00
|
|
|
},
|
2020-04-09 10:29:19 +00:00
|
|
|
"prometheus2": {
|
2020-08-20 12:48:26 +00:00
|
|
|
staticConfig("foo:9090"),
|
2019-09-24 16:11:43 +00:00
|
|
|
},
|
2018-09-01 07:51:31 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
syncedTargets := <-discoveryManager.SyncCh()
|
|
|
|
verifyPresence(t, discoveryManager.targets, pk("static", "prometheus", 0), "{__address__=\"foo:9090\"}", true)
|
|
|
|
verifyPresence(t, discoveryManager.targets, pk("static", "prometheus2", 0), "{__address__=\"foo:9090\"}", true)
|
2021-09-03 13:14:25 +00:00
|
|
|
require.Len(t, discoveryManager.providers, 1, "Invalid number of providers.")
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets, 2)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus"], 1)
|
2021-10-20 08:16:20 +00:00
|
|
|
verifySyncedPresence(t, syncedTargets, "prometheus2", "{__address__=\"foo:9090\"}", true)
|
2023-12-07 11:35:01 +00:00
|
|
|
require.Len(t, syncedTargets["prometheus2"], 1)
|
2017-11-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
func TestApplyConfigDoesNotModifyStaticTargets(t *testing.T) {
|
|
|
|
originalConfig := Configs{
|
|
|
|
staticConfig("foo:9090", "bar:9090", "baz:9090"),
|
2018-06-13 15:34:59 +00:00
|
|
|
}
|
2020-08-20 12:48:26 +00:00
|
|
|
processedConfig := Configs{
|
|
|
|
staticConfig("foo:9090", "bar:9090", "baz:9090"),
|
2018-06-13 15:34:59 +00:00
|
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2018-09-12 14:06:31 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
2018-06-13 15:34:59 +00:00
|
|
|
go discoveryManager.Run()
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
cfgs := map[string]Configs{
|
|
|
|
"prometheus": processedConfig,
|
2018-06-13 15:34:59 +00:00
|
|
|
}
|
2020-08-20 12:48:26 +00:00
|
|
|
discoveryManager.ApplyConfig(cfgs)
|
2018-06-13 15:34:59 +00:00
|
|
|
<-discoveryManager.SyncCh()
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
for _, cfg := range cfgs {
|
2020-10-29 09:43:23 +00:00
|
|
|
require.Equal(t, originalConfig, cfg)
|
2018-06-13 15:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
type errorConfig struct{ err error }
|
|
|
|
|
|
|
|
func (e errorConfig) Name() string { return "error" }
|
|
|
|
func (e errorConfig) NewDiscoverer(DiscovererOptions) (Discoverer, error) { return nil, e.err }
|
|
|
|
|
2024-01-23 15:53:55 +00:00
|
|
|
// NewDiscovererMetrics implements discovery.Config.
|
|
|
|
func (errorConfig) NewDiscovererMetrics(prometheus.Registerer, RefreshMetricsInstantiator) DiscovererMetrics {
|
|
|
|
return &NoopDiscovererMetrics{}
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
type lockStaticConfig struct {
|
|
|
|
mu *sync.Mutex
|
|
|
|
config StaticConfig
|
|
|
|
}
|
|
|
|
|
2024-01-23 15:53:55 +00:00
|
|
|
// NewDiscovererMetrics implements discovery.Config.
|
|
|
|
func (lockStaticConfig) NewDiscovererMetrics(prometheus.Registerer, RefreshMetricsInstantiator) DiscovererMetrics {
|
|
|
|
return &NoopDiscovererMetrics{}
|
|
|
|
}
|
|
|
|
|
2021-10-20 08:16:20 +00:00
|
|
|
func (s lockStaticConfig) Name() string { return "lockstatic" }
|
2023-04-12 11:05:41 +00:00
|
|
|
func (s lockStaticConfig) NewDiscoverer(DiscovererOptions) (Discoverer, error) {
|
2021-10-20 08:16:20 +00:00
|
|
|
return (lockStaticDiscoverer)(s), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type lockStaticDiscoverer lockStaticConfig
|
|
|
|
|
|
|
|
func (s lockStaticDiscoverer) Run(ctx context.Context, up chan<- []*targetgroup.Group) {
|
|
|
|
// TODO: existing implementation closes up chan, but documentation explicitly forbids it...?
|
|
|
|
defer close(up)
|
|
|
|
s.mu.Lock()
|
|
|
|
defer s.mu.Unlock()
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
case up <- s.config:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-22 09:24:19 +00:00
|
|
|
func TestGaugeFailedConfigs(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2019-02-22 09:24:19 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c := map[string]Configs{
|
2020-04-09 10:29:19 +00:00
|
|
|
"prometheus": {
|
2024-11-03 12:15:51 +00:00
|
|
|
errorConfig{errors.New("tests error 0")},
|
|
|
|
errorConfig{errors.New("tests error 1")},
|
|
|
|
errorConfig{errors.New("tests error 2")},
|
2019-09-24 16:11:43 +00:00
|
|
|
},
|
2019-02-22 09:24:19 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
<-discoveryManager.SyncCh()
|
|
|
|
|
2023-10-23 13:55:36 +00:00
|
|
|
failedCount := client_testutil.ToFloat64(discoveryManager.metrics.FailedConfigs)
|
2021-09-03 13:14:25 +00:00
|
|
|
require.Equal(t, 3.0, failedCount, "Expected to have 3 failed configs.")
|
2019-02-22 09:24:19 +00:00
|
|
|
|
2020-08-20 12:48:26 +00:00
|
|
|
c["prometheus"] = Configs{
|
|
|
|
staticConfig("foo:9090"),
|
2019-02-22 09:24:19 +00:00
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
<-discoveryManager.SyncCh()
|
|
|
|
|
2023-10-23 13:55:36 +00:00
|
|
|
failedCount = client_testutil.ToFloat64(discoveryManager.metrics.FailedConfigs)
|
2021-09-03 13:14:25 +00:00
|
|
|
require.Equal(t, 0.0, failedCount, "Expected to get no failed config.")
|
2019-02-22 09:24:19 +00:00
|
|
|
}
|
|
|
|
|
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
|
2018-09-12 08:15:57 +00:00
|
|
|
providers map[string]Discoverer
|
2018-09-05 13:44:52 +00:00
|
|
|
expected []expect
|
|
|
|
}{
|
2018-09-12 08:15:57 +00:00
|
|
|
{
|
2018-09-12 14:02:15 +00:00
|
|
|
title: "Receiver should get all updates even when one provider closes its channel",
|
2018-09-12 08:15:57 +00:00
|
|
|
providers: map[string]Discoverer{
|
|
|
|
"once1": &onceProvider{
|
|
|
|
tgs: []*targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"mock1": newMockDiscoveryProvider(
|
|
|
|
update{
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 2 * updateDelay,
|
2018-09-12 08:15:57 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
},
|
|
|
|
expected: []expect{
|
|
|
|
{
|
|
|
|
tgs: map[string][]*targetgroup.Group{
|
2019-01-16 22:28:08 +00:00
|
|
|
"once1": {
|
2018-09-12 08:15:57 +00:00
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
2023-11-15 10:41:12 +00:00
|
|
|
"mock1": {},
|
2018-09-12 08:15:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
tgs: map[string][]*targetgroup.Group{
|
2019-01-16 22:28:08 +00:00
|
|
|
"once1": {
|
2018-09-12 08:15:57 +00:00
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
2019-01-16 22:28:08 +00:00
|
|
|
"mock1": {
|
2018-09-12 08:15:57 +00:00
|
|
|
{
|
|
|
|
Source: "tg2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-09-05 13:44:52 +00:00
|
|
|
{
|
2018-09-12 14:02:15 +00:00
|
|
|
title: "Receiver should get all updates even when the channel is blocked",
|
2018-09-12 08:15:57 +00:00
|
|
|
providers: map[string]Discoverer{
|
|
|
|
"mock1": newMockDiscoveryProvider(
|
2018-09-05 13:44:52 +00:00
|
|
|
update{
|
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update{
|
2018-09-12 08:20:34 +00:00
|
|
|
interval: 4 * updateDelay,
|
2018-09-05 13:44:52 +00:00
|
|
|
targetGroups: []targetgroup.Group{
|
|
|
|
{
|
|
|
|
Source: "tg2",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "2"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-09-12 08:15:57 +00:00
|
|
|
),
|
2018-09-05 13:44:52 +00:00
|
|
|
},
|
|
|
|
expected: []expect{
|
|
|
|
{
|
|
|
|
delay: 2 * updateDelay,
|
|
|
|
tgs: map[string][]*targetgroup.Group{
|
2019-01-16 22:28:08 +00:00
|
|
|
"mock1": {
|
2018-09-05 13:44:52 +00:00
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
delay: 4 * updateDelay,
|
|
|
|
tgs: map[string][]*targetgroup.Group{
|
2019-01-16 22:28:08 +00:00
|
|
|
"mock1": {
|
2018-09-05 13:44:52 +00:00
|
|
|
{
|
|
|
|
Source: "tg1",
|
|
|
|
Targets: []model.LabelSet{{"__instance__": "1"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
|
2024-01-23 15:53:55 +00:00
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
|
|
|
mgr := NewManager(ctx, nil, reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, mgr)
|
2018-09-05 13:44:52 +00:00
|
|
|
mgr.updatert = updateDelay
|
|
|
|
go mgr.Run()
|
|
|
|
|
2018-09-12 08:15:57 +00:00
|
|
|
for name, p := range tc.providers {
|
2018-09-05 13:44:52 +00:00
|
|
|
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():
|
2021-09-03 13:14:25 +00:00
|
|
|
require.FailNow(t, "step %d: no update received in the expected timeframe", i)
|
2018-09-11 15:04:33 +00:00
|
|
|
case tgs, ok := <-mgr.SyncCh():
|
2021-09-03 13:14:25 +00:00
|
|
|
require.True(t, ok, "step %d: discovery manager channel is closed", i)
|
|
|
|
require.Equal(t, len(expected.tgs), len(tgs), "step %d: targets mismatch", i)
|
|
|
|
|
2018-09-11 15:04:33 +00:00
|
|
|
for k := range expected.tgs {
|
2021-09-03 13:14:25 +00:00
|
|
|
_, ok := tgs[k]
|
|
|
|
require.True(t, ok, "step %d: target group not found: %s", i, k)
|
2023-04-12 11:05:41 +00:00
|
|
|
assertEqualGroups(t, tgs[k], expected.tgs[k])
|
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
|
|
|
}
|
|
|
|
|
2018-09-12 08:15:57 +00:00
|
|
|
func newMockDiscoveryProvider(updates ...update) mockdiscoveryProvider {
|
2017-11-29 22:52:38 +00:00
|
|
|
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 {
|
2020-08-03 09:29:59 +00:00
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
case <-time.After(u.interval):
|
2018-09-05 13:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2021-10-29 22:44:32 +00:00
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
case 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
|
|
|
|
2018-09-12 08:15:57 +00:00
|
|
|
// onceProvider sends updates once (if any) and closes the update channel.
|
|
|
|
type onceProvider struct {
|
|
|
|
tgs []*targetgroup.Group
|
|
|
|
}
|
2018-09-11 15:04:33 +00:00
|
|
|
|
2018-09-12 08:15:57 +00:00
|
|
|
func (o onceProvider) Run(_ context.Context, ch chan<- []*targetgroup.Group) {
|
|
|
|
if len(o.tgs) > 0 {
|
|
|
|
ch <- o.tgs
|
|
|
|
}
|
2018-09-11 15:04:33 +00:00
|
|
|
close(ch)
|
|
|
|
}
|
2021-11-05 00:13:04 +00:00
|
|
|
|
|
|
|
// TestTargetSetTargetGroupsUpdateDuringApplyConfig is used to detect races when
|
|
|
|
// ApplyConfig happens at the same time as targets update.
|
2023-10-23 13:55:36 +00:00
|
|
|
func TestTargetSetTargetGroupsUpdateDuringApplyConfig(t *testing.T) {
|
2021-11-05 00:13:04 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2024-01-23 15:53:55 +00:00
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
_, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2023-11-15 17:13:40 +00:00
|
|
|
require.NotNil(t, discoveryManager)
|
2021-11-05 00:13:04 +00:00
|
|
|
discoveryManager.updatert = 100 * time.Millisecond
|
|
|
|
go discoveryManager.Run()
|
|
|
|
|
|
|
|
td := newTestDiscoverer()
|
|
|
|
|
|
|
|
c := map[string]Configs{
|
|
|
|
"prometheus": {
|
|
|
|
td,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(2000)
|
|
|
|
|
|
|
|
start := make(chan struct{})
|
|
|
|
for i := 0; i < 1000; i++ {
|
|
|
|
go func() {
|
|
|
|
<-start
|
|
|
|
td.update([]*targetgroup.Group{
|
|
|
|
{
|
|
|
|
Targets: []model.LabelSet{
|
|
|
|
{model.AddressLabel: model.LabelValue("127.0.0.1:9090")},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
wg.Done()
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < 1000; i++ {
|
|
|
|
go func(i int) {
|
|
|
|
<-start
|
|
|
|
c := map[string]Configs{
|
|
|
|
fmt.Sprintf("prometheus-%d", i): {
|
|
|
|
td,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
discoveryManager.ApplyConfig(c)
|
|
|
|
wg.Done()
|
|
|
|
}(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
close(start)
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
// testDiscoverer is a config and a discoverer that can adjust targets with a
|
|
|
|
// simple function.
|
|
|
|
type testDiscoverer struct {
|
|
|
|
up chan<- []*targetgroup.Group
|
|
|
|
ready chan struct{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTestDiscoverer() *testDiscoverer {
|
|
|
|
return &testDiscoverer{
|
|
|
|
ready: make(chan struct{}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-23 15:53:55 +00:00
|
|
|
// NewDiscovererMetrics implements discovery.Config.
|
|
|
|
func (*testDiscoverer) NewDiscovererMetrics(prometheus.Registerer, RefreshMetricsInstantiator) DiscovererMetrics {
|
|
|
|
return &NoopDiscovererMetrics{}
|
|
|
|
}
|
|
|
|
|
2021-11-05 00:13:04 +00:00
|
|
|
// Name implements Config.
|
|
|
|
func (t *testDiscoverer) Name() string {
|
|
|
|
return "test"
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDiscoverer implements Config.
|
|
|
|
func (t *testDiscoverer) NewDiscoverer(DiscovererOptions) (Discoverer, error) {
|
|
|
|
return t, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run implements Discoverer.
|
|
|
|
func (t *testDiscoverer) Run(ctx context.Context, up chan<- []*targetgroup.Group) {
|
|
|
|
t.up = up
|
|
|
|
close(t.ready)
|
|
|
|
<-ctx.Done()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *testDiscoverer) update(tgs []*targetgroup.Group) {
|
|
|
|
<-t.ready
|
|
|
|
t.up <- tgs
|
|
|
|
}
|
2024-04-05 14:19:07 +00:00
|
|
|
|
|
|
|
func TestUnregisterMetrics(t *testing.T) {
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
// Check that all metrics can be unregistered, allowing a second manager to be created.
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
|
|
|
refreshMetrics, sdMetrics := NewTestMetrics(t, reg)
|
|
|
|
|
2024-09-10 01:41:53 +00:00
|
|
|
discoveryManager := NewManager(ctx, promslog.NewNopLogger(), reg, sdMetrics)
|
2024-04-05 14:19:07 +00:00
|
|
|
// discoveryManager will be nil if there was an error configuring metrics.
|
|
|
|
require.NotNil(t, discoveryManager)
|
|
|
|
// Unregister all metrics.
|
|
|
|
discoveryManager.UnregisterMetrics()
|
|
|
|
for _, sdMetric := range sdMetrics {
|
|
|
|
sdMetric.Unregister()
|
|
|
|
}
|
|
|
|
refreshMetrics.Unregister()
|
|
|
|
cancel()
|
|
|
|
}
|
|
|
|
}
|