Files
Joe Elliottandzeekay e94374166e [Tempo 3.0] Remove compactor and v2 block encoding code (#6273)
* o7 compactor

Signed-off-by: Joe Elliott <[email protected]>

* wip: o7 v2

Signed-off-by: Joe Elliott <[email protected]>

* test cleanup

Signed-off-by: Joe Elliott <[email protected]>

* remove compactor from jsonnet

Signed-off-by: Joe Elliott <[email protected]>

* changelog

Signed-off-by: Joe Elliott <[email protected]>

* gen manifest

Signed-off-by: Joe Elliott <[email protected]>

* config cleanup

Signed-off-by: Joe Elliott <[email protected]>

* docs

Signed-off-by: Joe Elliott <[email protected]>

* jsonnet

Signed-off-by: Joe Elliott <[email protected]>

* remove encoding

Signed-off-by: Joe Elliott <[email protected]>

* remove data encoding

Signed-off-by: Joe Elliott <[email protected]>

* lint and cleanup

Signed-off-by: Joe Elliott <[email protected]>

* unflake TestWorker\?

Signed-off-by: Joe Elliott <[email protected]>

---------

Signed-off-by: Joe Elliott <[email protected]>
2026-02-22 00:55:18 -08:00

108 lines
2.4 KiB
Go

package backend
import (
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestIndexMarshalUnmarshal(t *testing.T) {
tests := []struct {
idx *TenantIndex
}{
{
idx: &TenantIndex{},
},
{
idx: &TenantIndex{
CreatedAt: time.Now(),
Meta: []*BlockMeta{
NewBlockMeta("test", uuid.New(), "v1"),
NewBlockMeta("test", uuid.New(), "v2"),
NewBlockMeta("test", uuid.New(), "v3"),
},
},
},
{
idx: &TenantIndex{
CreatedAt: time.Now(),
CompactedMeta: []*CompactedBlockMeta{
{
BlockMeta: *NewBlockMeta("test", uuid.New(), "v1"),
CompactedTime: time.Now(),
},
{
BlockMeta: *NewBlockMeta("test", uuid.New(), "v1"),
CompactedTime: time.Now(),
},
{
BlockMeta: *NewBlockMeta("test", uuid.New(), "v1"),
CompactedTime: time.Now(),
},
},
},
},
{
idx: &TenantIndex{
Meta: []*BlockMeta{
NewBlockMeta("test", uuid.New(), "v1"),
NewBlockMeta("test", uuid.New(), "v2"),
NewBlockMeta("test", uuid.New(), "v3"),
},
CompactedMeta: []*CompactedBlockMeta{
{
BlockMeta: *NewBlockMeta("test", uuid.New(), "v1"),
CompactedTime: time.Now(),
},
{
BlockMeta: *NewBlockMeta("test", uuid.New(), "v1"),
CompactedTime: time.Now(),
},
{
BlockMeta: *NewBlockMeta("test", uuid.New(), "v1"),
CompactedTime: time.Now(),
},
},
},
},
}
for _, tc := range tests {
// json
buff, err := tc.idx.marshal()
require.NoError(t, err)
actual := &TenantIndex{}
err = actual.unmarshal(buff)
require.NoError(t, err)
// cmp.Equal used due to time marshalling: https://github.com/stretchr/testify/issues/502
// assert.Equal(t, tc.idx, actual)
assert.True(t, cmp.Equal(tc.idx, actual))
}
for _, tc := range tests {
// proto
buff, err := tc.idx.marshalPb()
require.NoError(t, err)
actual := &TenantIndex{}
err = actual.unmarshalPb(buff)
require.NoError(t, err)
// cmp.Equal used due to time marshalling: https://github.com/stretchr/testify/issues/502
// assert.Equal(t, tc.idx, actual)
assert.True(t, cmp.Equal(tc.idx, actual))
}
}
func TestIndexUnmarshalErrors(t *testing.T) {
test := &TenantIndex{}
err := test.unmarshal([]byte("bad data"))
assert.Error(t, err)
}