mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 17:13:22 +00:00
Merge branch 'release-1.5'
This merges forward the bug-fixes from the release1.5 branch.
This commit is contained in:
commit
4daffbef12
@ -305,6 +305,7 @@ func (app *countingAppender) Append(s *model.Sample) error {
|
||||
// It returns a label set before relabeling was applied as the second return value.
|
||||
// Returns a nil label set if the target is dropped during relabeling.
|
||||
func populateLabels(lset model.LabelSet, cfg *config.ScrapeConfig) (res, orig model.LabelSet, err error) {
|
||||
lset = lset.Clone()
|
||||
if _, ok := lset[model.AddressLabel]; !ok {
|
||||
return nil, nil, fmt.Errorf("no address")
|
||||
}
|
||||
|
@ -140,10 +140,14 @@ func TestPopulateLabels(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for i, c := range cases {
|
||||
in := c.in.Clone()
|
||||
res, orig, err := populateLabels(c.in, c.cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("case %d: %s", i, err)
|
||||
}
|
||||
if !reflect.DeepEqual(c.in, in) {
|
||||
t.Errorf("case %d: input lset was changed was\n\t%+v\n now\n\t%+v", i, in, c.in)
|
||||
}
|
||||
if !reflect.DeepEqual(res, c.res) {
|
||||
t.Errorf("case %d: expected res\n\t%+v\n got\n\t%+v", i, c.res, res)
|
||||
}
|
||||
|
@ -310,6 +310,7 @@ func newPersistence(
|
||||
dirtyFileName: dirtyPath,
|
||||
fLock: fLock,
|
||||
shouldSync: shouldSync,
|
||||
minShrinkRatio: minShrinkRatio,
|
||||
// Create buffers of length 3*chunkLenWithHeader by default because that is still reasonably small
|
||||
// and at the same time enough for many uses. The contract is to never return buffer smaller than
|
||||
// that to the pool so that callers can rely on a minimum buffer size.
|
||||
|
@ -42,7 +42,7 @@ var (
|
||||
func newTestPersistence(t *testing.T, encoding chunk.Encoding) (*persistence, testutil.Closer) {
|
||||
chunk.DefaultEncoding = encoding
|
||||
dir := testutil.NewTemporaryDirectory("test_persistence", t)
|
||||
p, err := newPersistence(dir.Path(), false, false, func() bool { return false }, 0.1)
|
||||
p, err := newPersistence(dir.Path(), false, false, func() bool { return false }, 0.15)
|
||||
if err != nil {
|
||||
dir.Close()
|
||||
t.Fatal(err)
|
||||
@ -173,6 +173,25 @@ func testPersistLoadDropChunks(t *testing.T, encoding chunk.Encoding) {
|
||||
|
||||
}
|
||||
}
|
||||
// Try to drop one chunk, which must be prevented by the shrink ratio.
|
||||
for fp, _ := range fpToChunks {
|
||||
firstTime, offset, numDropped, allDropped, err := p.dropAndPersistChunks(fp, 1, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if offset != 0 {
|
||||
t.Errorf("want offset 0, got %d", offset)
|
||||
}
|
||||
if firstTime != 0 {
|
||||
t.Errorf("want first time 0, got %d", firstTime)
|
||||
}
|
||||
if numDropped != 0 {
|
||||
t.Errorf("want 0 dropped chunks, got %v", numDropped)
|
||||
}
|
||||
if allDropped {
|
||||
t.Error("all chunks dropped")
|
||||
}
|
||||
}
|
||||
// Drop half of the chunks.
|
||||
for fp, expectedChunks := range fpToChunks {
|
||||
firstTime, offset, numDropped, allDropped, err := p.dropAndPersistChunks(fp, 5, nil)
|
||||
|
Loading…
Reference in New Issue
Block a user