Skip to content

Commit

Permalink
*: fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Giedrius Statkevičius <[email protected]>
  • Loading branch information
GiedriusS committed Sep 4, 2024
1 parent bde2819 commit 042c37c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 49 deletions.
1 change: 1 addition & 0 deletions .bingo/minio.sum
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ github.com/goccy/go-json v0.9.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF
github.com/gocql/gocql v0.0.0-20220224095938-0eacd3183625/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofiber/fiber/v2 v2.11.0/go.mod h1:oZTLWqYnqpMMuF922SjGbsYZsdpE1MCfh416HNdweIM=
github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
Expand Down
82 changes: 41 additions & 41 deletions pkg/query/endpointset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type APIs struct {

type testEndpointMeta struct {
*infopb.InfoResponse
extlsetFn func(addr string) []labelpb.LabelSet
extlsetFn func(addr string) labelpb.LabelSets
infoDelay time.Duration
err error
}
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestEndpointSetUpdate(t *testing.T) {
endpoints: []testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand All @@ -353,7 +353,7 @@ func TestEndpointSetUpdate(t *testing.T) {
{
err: fmt.Errorf("endpoint unavailable"),
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand All @@ -374,7 +374,7 @@ func TestEndpointSetUpdate(t *testing.T) {
{
infoDelay: 5 * time.Second,
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand All @@ -394,7 +394,7 @@ func TestEndpointSetUpdate(t *testing.T) {
endpoints: []testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand All @@ -419,13 +419,13 @@ func TestEndpointSetUpdate(t *testing.T) {
{
InfoResponse: sidecarInfo,
// Simulate very long external labels.
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
sLabel := []string{}
for i := 0; i < 1000; i++ {
sLabel = append(sLabel, "lbl")
sLabel = append(sLabel, "val")
}
return []labelpb.LabelSet{
return labelpb.LabelSets{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
labels.FromStrings(sLabel...),
Expand Down Expand Up @@ -466,7 +466,7 @@ func TestEndpointSetUpdate_DuplicateSpecs(t *testing.T) {
endpoints, err := startTestEndpoints([]testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand Down Expand Up @@ -494,7 +494,7 @@ func TestEndpointSetUpdate_EndpointGoingAway(t *testing.T) {
endpoints, err := startTestEndpoints([]testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand Down Expand Up @@ -528,7 +528,7 @@ func TestEndpointSetUpdate_EndpointComingOnline(t *testing.T) {
{
err: fmt.Errorf("endpoint unavailable"),
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return nil
},
},
Expand Down Expand Up @@ -560,7 +560,7 @@ func TestEndpointSetUpdate_StrictEndpointMetadata(t *testing.T) {
{
err: fmt.Errorf("endpoint unavailable"),
InfoResponse: info,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return nil
},
},
Expand Down Expand Up @@ -606,7 +606,7 @@ func TestEndpointSetUpdate_PruneInactiveEndpoints(t *testing.T) {
endpoints: []testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand All @@ -625,7 +625,7 @@ func TestEndpointSetUpdate_PruneInactiveEndpoints(t *testing.T) {
endpoints: []testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand Down Expand Up @@ -703,7 +703,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
endpoints, err := startTestEndpoints([]testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -720,7 +720,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
},
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -737,7 +737,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
},
{
InfoResponse: queryInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand Down Expand Up @@ -835,7 +835,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
endpoint2, err := startTestEndpoints([]testEndpointMeta{
{
InfoResponse: queryInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -854,7 +854,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
{
// Duplicated Querier, in previous versions it would be deduplicated. Now it should be not.
InfoResponse: queryInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -872,7 +872,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
},
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -886,7 +886,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
{
// Duplicated Sidecar, in previous versions it would be deduplicated. Now it should be not.
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -900,7 +900,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
{
// Querier that duplicates with sidecar, in previous versions it would be deduplicated. Now it should be not.
InfoResponse: queryInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -915,7 +915,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
// Ruler that duplicates with sidecar, in previous versions it would be deduplicated. Now it should be not.
// Warning should be produced.
InfoResponse: ruleInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -929,7 +929,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
{
// Duplicated Rule, in previous versions it would be deduplicated. Now it should be not. Warning should be produced.
InfoResponse: ruleInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -943,21 +943,21 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
// Two pre v0.8.0 store gateway nodes, they don't have ext labels set.
{
InfoResponse: storeGWInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
{
InfoResponse: storeGWInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
// Regression tests against https://github.com/thanos-io/thanos/issues/1632: From v0.8.0 stores advertise labels.
// If the object storage handled by store gateway has only one sidecar we used to hitting issue.
{
InfoResponse: storeGWInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -976,7 +976,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
// Stores v0.8.1 has compatibility labels. Check if they are correctly removed.
{
InfoResponse: storeGWInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -995,7 +995,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
// Duplicated store, in previous versions it would be deduplicated. Now it should be not.
{
InfoResponse: storeGWInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -1013,7 +1013,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
},
{
InfoResponse: receiveInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -1032,7 +1032,7 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) {
// Duplicate receiver
{
InfoResponse: receiveInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand Down Expand Up @@ -1097,7 +1097,7 @@ func TestEndpointSet_Update_NoneAvailable(t *testing.T) {
endpoints, err := startTestEndpoints([]testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -1112,7 +1112,7 @@ func TestEndpointSet_Update_NoneAvailable(t *testing.T) {
},
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand Down Expand Up @@ -1169,7 +1169,7 @@ func TestEndpoint_Update_QuerierStrict(t *testing.T) {
MetricMetadata: &infopb.MetricMetadataInfo{},
Targets: &infopb.TargetsInfo{},
},
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -1194,7 +1194,7 @@ func TestEndpoint_Update_QuerierStrict(t *testing.T) {
MetricMetadata: &infopb.MetricMetadataInfo{},
Targets: &infopb.TargetsInfo{},
},
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand All @@ -1220,7 +1220,7 @@ func TestEndpoint_Update_QuerierStrict(t *testing.T) {
MetricMetadata: &infopb.MetricMetadataInfo{},
Targets: &infopb.TargetsInfo{},
},
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: []labelpb.Label{
Expand Down Expand Up @@ -1298,31 +1298,31 @@ func TestEndpointSet_APIs_Discovery(t *testing.T) {
endpoints, err := startTestEndpoints([]testEndpointMeta{
{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
{
InfoResponse: ruleInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
{
InfoResponse: receiveInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
{
InfoResponse: storeGWInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
{
InfoResponse: queryInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{}
},
},
Expand Down Expand Up @@ -1517,7 +1517,7 @@ func makeInfoResponses(n int) []testEndpointMeta {
for i := 0; i < n; i++ {
responses = append(responses, testEndpointMeta{
InfoResponse: sidecarInfo,
extlsetFn: func(addr string) []labelpb.LabelSet {
extlsetFn: func(addr string) labelpb.LabelSets {
return []labelpb.LabelSet{
{
Labels: labelpb.PromLabelsToLabelpbLabels(
Expand Down
Loading

0 comments on commit 042c37c

Please sign in to comment.