(t testing.TB, w Writer, tenantID string, blockCount int, recordCount int)
| 855 | } |
| 856 | |
| 857 | func cutTestBlocks(t testing.TB, w Writer, tenantID string, blockCount int, recordCount int) []common.BackendBlock { |
| 858 | blocks := make([]common.BackendBlock, 0) |
| 859 | dec := model.MustNewSegmentDecoder(model.CurrentEncoding) |
| 860 | |
| 861 | wal := w.WAL() |
| 862 | for i := 0; i < blockCount; i++ { |
| 863 | meta := &backend.BlockMeta{BlockID: backend.NewUUID(), TenantID: tenantID} |
| 864 | head, err := wal.NewBlock(meta, model.CurrentEncoding) |
| 865 | require.NoError(t, err) |
| 866 | |
| 867 | for j := 0; j < recordCount; j++ { |
| 868 | id := makeTraceID(i, j) |
| 869 | tr := test.MakeTrace(1, id) |
| 870 | now := uint32(time.Now().Unix()) |
| 871 | writeTraceToWal(t, head, dec, id, tr, now, now) |
| 872 | } |
| 873 | |
| 874 | b, err := w.CompleteBlock(context.Background(), head) |
| 875 | require.NoError(t, err) |
| 876 | blocks = append(blocks, b) |
| 877 | } |
| 878 | |
| 879 | return blocks |
| 880 | } |
| 881 | |
| 882 | func makeTraceID(i int, j int) []byte { |
| 883 | id := make([]byte, 16) |
no test coverage detected