mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 05:46:32 +00:00
## What does this change do? This pull request completes the change to the `metricsgen` metrics. It adds `go generate` directives to all of the files containing the `Metrics` structs. Using the outputs of `metricsdiff` between these generated metrics and `master`, we can see that there is not a diff between the two sets of metrics when run locally. ``` [william@sidewinder] tendermint[wb/metrics-gen-transition]:. ◆ ./scripts/metricsgen/metricsdiff/metricsdiff metrics_master metrics_generated [william@sidewinder] tendermint[wb/metrics-gen-transition]:. ◆ ``` This change also adds parsing for a `metrics:` key in a field comment. If a comment line begins with `//metrics:` the rest of the line is interpreted to be the metric help text. Additionally, a bug where lists of labels were not properly quoted in the `metricsgen` rendered output was fixed.
48 lines
969 B
Go
48 lines
969 B
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
gogotypes "github.com/gogo/protobuf/types"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
)
|
|
|
|
type testMessage = gogotypes.StringValue
|
|
|
|
func TestCloseWhileDequeueFull(t *testing.T) {
|
|
enqueueLength := 5
|
|
chDescs := []*ChannelDescriptor{
|
|
{ID: 0x01, Priority: 1},
|
|
}
|
|
pqueue := newPQScheduler(log.NewNopLogger(), NopMetrics(), newMetricsLabelCache(), chDescs, uint(enqueueLength), 1, 120)
|
|
|
|
for i := 0; i < enqueueLength; i++ {
|
|
pqueue.enqueue() <- Envelope{
|
|
ChannelID: 0x01,
|
|
Message: &testMessage{Value: "foo"}, // 5 bytes
|
|
}
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
go pqueue.process(ctx)
|
|
|
|
// sleep to allow context switch for process() to run
|
|
time.Sleep(10 * time.Millisecond)
|
|
doneCh := make(chan struct{})
|
|
go func() {
|
|
pqueue.close()
|
|
close(doneCh)
|
|
}()
|
|
|
|
select {
|
|
case <-doneCh:
|
|
case <-time.After(2 * time.Second):
|
|
t.Fatal("pqueue failed to close")
|
|
}
|
|
}
|