Merge pull request #7318 from influxdata/jw-sub-panic
Fix panic in subscriber.Statisticspull/7314/head
commit
cd7c39962d
|
@ -5608,6 +5608,50 @@ func TestServer_Query_ShowSeries(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestServer_Query_ShowStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := s.MetaClient.CreateSubscription("db0", "rp0", "foo", "ALL", []string{"udp://localhost:9000"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
test := NewTest("db0", "rp0")
|
||||
test.addQueries([]*Query{
|
||||
&Query{
|
||||
name: `show shots`,
|
||||
command: "SHOW STATS",
|
||||
exp: "subscriber", // Should see a subscriber stat in the json
|
||||
pattern: true,
|
||||
},
|
||||
}...)
|
||||
|
||||
for i, query := range test.queries {
|
||||
if i == 0 {
|
||||
if err := test.init(s); err != nil {
|
||||
t.Fatalf("test init failed: %s", err)
|
||||
}
|
||||
}
|
||||
if query.skip {
|
||||
t.Logf("SKIP:: %s", query.name)
|
||||
continue
|
||||
}
|
||||
if err := query.Execute(s); err != nil {
|
||||
t.Error(query.Error(err))
|
||||
} else if !query.success() {
|
||||
t.Error(query.failureMessage())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_Query_ShowMeasurements(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := OpenServer(NewConfig())
|
||||
|
|
|
@ -417,10 +417,11 @@ func (b *balancewriter) WritePoints(p *coordinator.WritePointsRequest) error {
|
|||
func (b *balancewriter) Statistics(tags map[string]string) []models.Statistic {
|
||||
statistics := make([]models.Statistic, len(b.stats))
|
||||
for i := range b.stats {
|
||||
tags["destination"] = b.stats[i].dest
|
||||
subTags := b.defaultTags.Merge(tags)
|
||||
subTags["destination"] = b.stats[i].dest
|
||||
statistics[i] = models.Statistic{
|
||||
Name: "subscriber",
|
||||
Tags: b.defaultTags.Merge(tags),
|
||||
Tags: subTags,
|
||||
Values: map[string]interface{}{
|
||||
statPointsWritten: atomic.LoadInt64(&b.stats[i].pointsWritten),
|
||||
statWriteFailures: atomic.LoadInt64(&b.stats[i].failures),
|
||||
|
|
Loading…
Reference in New Issue