(t *testing.T)
| 177 | } |
| 178 | |
| 179 | func TestCompact(t *testing.T) { |
| 180 | rawR, rawW, _, err := local.New(&local.Config{ |
| 181 | Path: t.TempDir(), |
| 182 | }) |
| 183 | require.NoError(t, err) |
| 184 | |
| 185 | r := backend.NewReader(rawR) |
| 186 | w := backend.NewWriter(rawW) |
| 187 | |
| 188 | blockConfig := common.BlockConfig{Version: VersionString} |
| 189 | blockConfig.RegisterFlagsAndApplyDefaults("", &flag.FlagSet{}) |
| 190 | |
| 191 | require.NoError(t, common.ValidateConfig(&blockConfig)) |
| 192 | |
| 193 | c := NewCompactor(common.CompactionOptions{ |
| 194 | BlockConfig: blockConfig, |
| 195 | OutputBlocks: 1, |
| 196 | ObjectsCombined: func(_, _ int) {}, |
| 197 | }) |
| 198 | |
| 199 | dedicatedColumns := backend.DedicatedColumns{ |
| 200 | {Scope: "resource", Name: "dedicated.resource.1", Type: "string"}, |
| 201 | {Scope: "span", Name: "dedicated.span.1", Type: "string"}, |
| 202 | } |
| 203 | |
| 204 | meta1 := createTestBlock(t, context.Background(), &blockConfig, r, w, 10, 10, 10, 1, dedicatedColumns) |
| 205 | meta2 := createTestBlock(t, context.Background(), &blockConfig, r, w, 10, 10, 10, 1, dedicatedColumns) |
| 206 | |
| 207 | inputs := []*backend.BlockMeta{meta1, meta2} |
| 208 | |
| 209 | newMeta, err := c.Compact(context.Background(), log.NewNopLogger(), r, w, inputs) |
| 210 | require.NoError(t, err) |
| 211 | require.Len(t, newMeta, 1) |
| 212 | require.Equal(t, int64(20), newMeta[0].TotalObjects) |
| 213 | require.Equal(t, uint32(1), newMeta[0].ReplicationFactor) |
| 214 | require.Equal(t, dedicatedColumns, newMeta[0].DedicatedColumns) |
| 215 | } |
| 216 | |
| 217 | type slowWriter struct { |
| 218 | backend.Writer |
nothing calls this directly
no test coverage detected