Skip to content

Commit

Permalink
TestQueryWithEndpointQuery passing with only Endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Srushti Sapkale <srushtiisapkale@gmail.com>
  • Loading branch information
SrushtiSapkale committed Aug 27, 2022
1 parent 36378c8 commit 6c6e23e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ func runQuery(
for _, addr := range config.Endpoints {
specs = append(specs, query.NewGRPCEndpointSpec(addr, true))
}

}

for _, dnsProvider := range []*dns.Provider{
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/e2ethanos/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,14 @@ func (q *QuerierBuilder) collectArgs() ([]string, error) {
if q.fileSDPath != "" {
args = append(args, "--store.sd-files="+q.fileSDPath)
}
if (len(q.storeAddresses) == 0 && q.fileSDPath == "") && len(q.endpointConfig) > 0 {
if len(q.endpointConfig) > 0 {
endpointCfgBytes, err := yaml.Marshal(q.endpointConfig)
if err != nil {
return nil, errors.Wrapf(err, "generate endpoint config file: %v", q.endpointConfig)
}
args = append(args, "--endpoint.config="+string(endpointCfgBytes))
}

if q.routePrefix != "" {
args = append(args, "--web.route-prefix="+q.routePrefix)
}
Expand Down
24 changes: 14 additions & 10 deletions test/e2e/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/golang/snappy"
config_util "github.com/prometheus/common/config"
"github.com/prometheus/prometheus/discovery/file"

//"github.com/prometheus/prometheus/discovery/file"
"github.com/prometheus/prometheus/discovery/targetgroup"
"github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/storage/remote"
Expand Down Expand Up @@ -243,22 +244,25 @@ func TestQueryWithEndpointConfig(t *testing.T) {
prom4, sidecar4 := e2ethanos.NewPrometheusWithSidecar(e, "ha2", e2ethanos.DefaultPromConfig("prom-ha", 1, "", "", e2ethanos.LocalPrometheusTarget), "", e2ethanos.DefaultPrometheusImage(), "")
testutil.Ok(t, e2e.StartAndWaitReady(prom1, sidecar1, prom2, sidecar2, prom3, sidecar3, prom4, sidecar4))

// Querier. Both fileSD and directly by flags.
fileSDPath, err := createSDFile(e.SharedDir(), "1", []string{sidecar3.InternalEndpoint("grpc"), sidecar4.InternalEndpoint("grpc")})
testutil.Ok(t, err)
// // Querier. Both fileSD and directly by flags.
// fileSDPath, err := createSDFile(e.SharedDir(), "1", []string{sidecar3.InternalEndpoint("grpc"), sidecar4.InternalEndpoint("grpc")})
// testutil.Ok(t, err)

endpointConfig := []query.EndpointConfig{
{
Endpoints: []string{sidecar1.InternalEndpoint("grpc"), sidecar2.InternalEndpoint("grpc")},
},
{
Endpoints: []string{receiver.InternalEndpoint("grpc")},
EndpointsSD: []file.SDConfig{
{
Files: []string{fileSDPath},
RefreshInterval: model.Duration(time.Minute),
},
},
// EndpointsSD: []file.SDConfig{
// {
// Files: []string{fileSDPath},
// RefreshInterval: model.Duration(time.Minute),
// },
// },
},
{
Endpoints: []string{sidecar3.InternalEndpoint("grpc"), sidecar4.InternalEndpoint("grpc")},
},
}
q := e2ethanos.NewQuerierBuilder(e, "1").WithEndpointConfig(endpointConfig).Init()
Expand Down

0 comments on commit 6c6e23e

Please sign in to comment.