(t *testing.T, tenant string, bb [][]byte, w backend.Writer)
| 363 | } |
| 364 | |
| 365 | func pushBlocksToTenant(t *testing.T, tenant string, bb [][]byte, w backend.Writer) []uuid.UUID { |
| 366 | // Randomly pick a block boundary |
| 367 | r := mathrand.IntN(len(bb)) |
| 368 | |
| 369 | base := bb[r] |
| 370 | t.Logf("base: %v", base) |
| 371 | expected := []uuid.UUID{} |
| 372 | |
| 373 | // Include the min and max in each tenant for testing |
| 374 | expected = append(expected, uuid.MustParse("00000000-0000-0000-0000-000000000000")) |
| 375 | expected = append(expected, uuid.MustParse("ffffffff-ffff-ffff-ffff-ffffffffffff")) |
| 376 | |
| 377 | // If we are above zero, then we have room to decrement |
| 378 | if r > 0 { |
| 379 | decrementUUIDBytes(base) |
| 380 | expected = append(expected, uuid.UUID(base)) |
| 381 | } |
| 382 | |
| 383 | // If we are n-1 then we have room to increment |
| 384 | if r < len(bb)-1 { |
| 385 | // Grab the one after the boundary |
| 386 | incrementUUIDBytes(base) |
| 387 | expected = append(expected, uuid.UUID(base)) |
| 388 | } |
| 389 | |
| 390 | // If we are n-2 then we have room to increment again |
| 391 | if r < len(bb)-2 { |
| 392 | // Grab the one after the boundary |
| 393 | incrementUUIDBytes(base) |
| 394 | expected = append(expected, uuid.UUID(base)) |
| 395 | } |
| 396 | |
| 397 | // If we are n-3 then we have room to increment again |
| 398 | if r < len(bb)-3 { |
| 399 | // Grab the one after the boundary |
| 400 | incrementUUIDBytes(base) |
| 401 | expected = append(expected, uuid.UUID(base)) |
| 402 | } |
| 403 | |
| 404 | // Write the blocks using the expectaed block IDs |
| 405 | writeTenantBlocks(t, w, tenant, expected) |
| 406 | |
| 407 | sort.Slice(expected, func(i, j int) bool { return expected[i].String() < expected[j].String() }) |
| 408 | // t.Logf("expected: %v", expected) |
| 409 | |
| 410 | return expected |
| 411 | } |
no test coverage detected