Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static org.apache.fluss.testutils.common.CommonTestUtils.waitUntil;
Expand All @@ -56,16 +57,22 @@
/** Verifies real log boundaries and controlled scanner progress and failure contracts. */
final class FlussLogSplitReaderTest extends FlussTrinoTestBase {
private static final Duration TIMEOUT = Duration.ofMillis(100);

private TablePath tablePath;
private Table table;
private FlussBucketHandle bucket;

@BeforeEach
void setUp() throws Exception {
table = null;
TablePath path = TablePath.of("fluss", "log_reader");
tablePath =
TablePath.of(
"Log_reader_" + UUID.randomUUID().toString().replace("-", ""),
"log_reader");

TableInfo info =
createTable(
path,
tablePath,
TableDescriptor.builder()
.schema(
Schema.newBuilder()
Expand All @@ -74,7 +81,7 @@ void setUp() throws Exception {
.distributedBy(1)
.build());
bucket = new FlussBucketHandle(info.getTableId(), Optional.empty(), 0);
table = catalogTable(path);
table = catalogTable(tablePath);
}

@AfterEach
Expand Down Expand Up @@ -181,7 +188,7 @@ void testRecordBeforeStartFails() throws Exception {

@Test
void testPartitionedSubscription() throws Exception {
TablePath path = TablePath.of("fluss", "partitioned_log_reader");
TablePath path = TablePath.of(tablePath.getDatabaseName(), "partitioned_log_reader");
TableInfo info =
createTable(
path,
Expand Down Expand Up @@ -319,6 +326,6 @@ private void useDataTable() throws Exception {
Table previous = table;
table = null;
previous.close();
table = dataConnection().getTable(TablePath.of("fluss", "log_reader"));
table = dataConnection().getTable(tablePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static io.trino.spi.type.BigintType.BIGINT;
Expand All @@ -59,7 +61,7 @@

/** Verifies real page reads and controlled failures at scanner and resource boundaries. */
final class FlussPageSourceTest extends FlussTrinoTestBase {
private static final TablePath PATH = TablePath.of("Sales", "Users");
private TablePath tablePath;
private TableInfo info;
private FlussTableHandle handle;
private FlussBucketHandle bucket;
Expand All @@ -70,10 +72,15 @@ final class FlussPageSourceTest extends FlussTrinoTestBase {
void setUp() throws Exception {
source = null;
table = null;
info = createTable(PATH, descriptor(true));
tablePath =
TablePath.of(
"Sales_page_source_" + UUID.randomUUID().toString().replace("-", ""),
"Users");

info = createTable(tablePath, descriptor(true));
handle = tableHandle(info);
bucket = new FlussBucketHandle(info.getTableId(), Optional.empty(), 0);
useTable(new TrackedTable(catalogTable(PATH)));
useTable(new TrackedTable(catalogTable(tablePath)));
}

@AfterEach
Expand Down Expand Up @@ -146,7 +153,7 @@ void testBatchSpansPagesWithoutAdditionalPoll() throws Exception {

@Test
void testRealLogPagesCompleteAtStop() throws Exception {
TablePath path = TablePath.of("Sales", "Logs");
TablePath path = TablePath.of(tablePath.getDatabaseName(), "Logs");
info = createTable(path, descriptor(false));
handle = tableHandle(info);
bucket = new FlussBucketHandle(info.getTableId(), Optional.empty(), 0);
Expand Down Expand Up @@ -235,13 +242,13 @@ void testReorderedAndNullColumns() throws Exception {
@Test
void testIdentityAndScanTypeCheckedBeforeScannerCreation() throws Exception {
for (int mismatch = 0; mismatch < 3; mismatch++) {
useTable(new TrackedTable(catalogTable(PATH)));
useTable(new TrackedTable(catalogTable(tablePath)));
handle =
new FlussTableHandle(
"sales",
"users",
"Sales",
"Users",
tablePath.getDatabaseName().toLowerCase(Locale.ENGLISH),
tablePath.getTableName().toLowerCase(Locale.ENGLISH),
tablePath.getDatabaseName(),
tablePath.getTableName(),
info.getTableId() + (mismatch == 0 ? 1 : 0),
info.getSchemaId() + (mismatch == 1 ? 1 : 0),
TupleDomain.all());
Expand Down Expand Up @@ -275,7 +282,7 @@ void testInvalidColumnFailsBeforeScannerCreation() {
void testMetadataFailureClosesTable() throws Exception {
RuntimeException failure = new IllegalStateException("metadata failed");
useTable(
new TrackedTable(catalogTable(PATH)) {
new TrackedTable(catalogTable(tablePath)) {
@Override
public TableInfo getTableInfo() {
throw failure;
Expand All @@ -290,7 +297,9 @@ public TableInfo getTableInfo() {
@Test
void testWorkerRejectsUnsupportedCapabilitiesBeforeScannerCreation() throws Exception {
for (boolean partitioned : new boolean[] {true, false}) {
TablePath path = TablePath.of("Sales", partitioned ? "Partitioned" : "Tiered");
TablePath path =
TablePath.of(
tablePath.getDatabaseName(), partitioned ? "Partitioned" : "Tiered");
TableDescriptor.Builder descriptor =
TableDescriptor.builder()
.schema(
Expand Down Expand Up @@ -320,7 +329,7 @@ void testWorkerRejectsUnsupportedCapabilitiesBeforeScannerCreation() throws Exce
void testInitializationFailureClosesAcquiredTable() throws Exception {
RuntimeException failure = new IllegalStateException("create failed");
useTable(
new TrackedTable(catalogTable(PATH)) {
new TrackedTable(catalogTable(tablePath)) {
@Override
BatchScanner createBatchScanner(Scan scan, TableBucket requested) {
throw failure;
Expand Down Expand Up @@ -507,7 +516,7 @@ public void close() throws IOException {
}
};
useTable(
new TrackedTable(catalogTable(PATH)) {
new TrackedTable(catalogTable(tablePath)) {
@Override
BatchScanner createBatchScanner(Scan scan, TableBucket requested) {
return scanner;
Expand Down Expand Up @@ -601,7 +610,7 @@ void testPollingAndMemoryStayOnCallingThread() throws Exception {
reservations.add(bytes);
};
useTable(
new TrackedTable(dataConnection().getTable(PATH)) {
new TrackedTable(dataConnection().getTable(tablePath)) {
@Override
BatchScanner createBatchScanner(Scan scan, TableBucket requested) {
BatchScanner delegate = super.createBatchScanner(scan, requested);
Expand Down Expand Up @@ -635,7 +644,7 @@ public void close() throws IOException {
void testReadAndCloseUsePluginClassLoader() throws Exception {
writeRows(GenericRow.of(1L, 1L));
useTable(
new TrackedTable(dataConnection().getTable(PATH)) {
new TrackedTable(dataConnection().getTable(tablePath)) {
@Override
public TableInfo getTableInfo() {
assertPluginClassLoader();
Expand Down Expand Up @@ -686,7 +695,7 @@ public void close() throws Exception {

private void useScanner(BatchScanner scanner) throws Exception {
useTable(
new TrackedTable(catalogTable(PATH)) {
new TrackedTable(catalogTable(tablePath)) {
@Override
BatchScanner createBatchScanner(Scan scan, TableBucket requested) {
assertThat(requested).isEqualTo(bucket.toTableBucket());
Expand Down Expand Up @@ -728,7 +737,7 @@ public void close() {
}

private void writeRows(InternalRow... rows) throws Exception {
useTable(new TrackedTable(dataConnection().getTable(PATH)));
useTable(new TrackedTable(dataConnection().getTable(tablePath)));
UpsertWriter writer = table.newUpsert().createWriter();
for (InternalRow row : rows) {
writer.upsert(row).get(30, TimeUnit.SECONDS);
Expand Down
Loading
Loading