headblock checkpointing up to v3 (#3013)

pull/3015/head^2
Owen Diehl 5 years ago committed by GitHub
parent dcbfecf9e5
commit 854930e661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/chunkenc/memchunk.go
  2. 8
      pkg/chunkenc/memchunk_test.go

@ -211,8 +211,10 @@ func (hb *headBlock) FromCheckpoint(b []byte) error {
if db.err() != nil {
return errors.Wrap(db.err(), "verifying headblock header")
}
if version != chunkFormatV3 {
return errors.New("incompatible headBlock version, only V3 is currently supported")
switch version {
case chunkFormatV1, chunkFormatV2, chunkFormatV3:
default:
return errors.Errorf("incompatible headBlock version (%v), only V1,V2,V3 is currently supported", version)
}
ln := db.uvarint()

@ -901,6 +901,14 @@ func TestCheckpointEncoding(t *testing.T) {
cpy, err := MemchunkFromCheckpoint(chk, head, blockSize, targetSize)
require.Nil(t, err)
// TODO(owen-d): remove once v3+ is the default chunk version
// because that is when we started serializing uncompressed size.
// Until then, nil them out in order to ease equality testing.
for i := range c.blocks {
c.blocks[i].uncompressedSize = 0
}
require.Equal(t, c, cpy)
}

Loading…
Cancel
Save