MCPcopy
hub / github.com/grafana/tempo / TestNoCompactFlag

Function TestNoCompactFlag

tempodb/tempodb_test.go:850–953  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

848}
849
850func TestNoCompactFlag(t *testing.T) {
851 for _, tc := range []struct {
852 name string
853 createWithNoCompactFlag bool
854 skipNoCompactBlocks bool
855 expectedNoCompactFlag bool // flag after block completion
856 isBlockExpected bool // should we expect the block after pull
857 }{
858 {
859 name: "default behaviour",
860 createWithNoCompactFlag: false,
861 skipNoCompactBlocks: false,
862 expectedNoCompactFlag: false,
863 isBlockExpected: true,
864 },
865 {
866 name: "blockbuilder behaviour",
867 createWithNoCompactFlag: true, // blockbuilder creates blocks with the flag
868 skipNoCompactBlocks: false, // but blockbuilder does not skip such block on pull
869 expectedNoCompactFlag: true, // the flag should not be removed after block completion
870 isBlockExpected: true, // blockbuilder sees the block although it has the flag
871 },
872 {
873 name: "compactor sees its own blocks",
874 createWithNoCompactFlag: false, // compactor does not create blocks with the flag
875 skipNoCompactBlocks: true, // but does skip block with the flag on pull
876 expectedNoCompactFlag: false, // no flag on created block
877 isBlockExpected: true, // compactor sees its own blocks
878 },
879 {
880 name: "blockbuilder+compactor behaviour",
881 createWithNoCompactFlag: true, // blockbuilder creates the block with the flag
882 skipNoCompactBlocks: true, // compactor skips the block with the flag on pull
883 expectedNoCompactFlag: true, // the flag should not be removed after block completion
884 isBlockExpected: false, // compactor does not see the block
885 },
886 } {
887 t.Run(tc.name, func(t *testing.T) {
888 r, w, c, _ := testConfig(t, 0, func(c *Config) {
889 c.Block.CreateWithNoCompactFlag = tc.createWithNoCompactFlag
890 })
891
892 ctx, cancel := context.WithCancel(context.Background())
893 defer cancel()
894
895 err := c.EnableCompaction(ctx, &CompactorConfig{
896 MaxCompactionRange: time.Hour,
897 BlockRetention: 0,
898 CompactedBlockRetention: 0,
899 }, &mockSharder{}, &mockOverrides{})
900 require.NoError(t, err)
901
902 r.EnablePolling(ctx, &mockJobSharder{}, tc.skipNoCompactBlocks)
903
904 // Create a test block
905 blockID := backend.NewUUID()
906 wal := w.WAL()
907 meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID}

Callers

nothing calls this directly

Calls 15

NewUUIDFunction · 0.92
MustNewSegmentDecoderFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
NewBlockMethod · 0.80
pollBlocklistMethod · 0.80
testConfigFunction · 0.70
writeTraceToWalFunction · 0.70
EnableCompactionMethod · 0.65
EnablePollingMethod · 0.65
WALMethod · 0.65
CompleteBlockMethod · 0.65

Tested by

no test coverage detected