luoyuxia commented on code in PR #1572: URL: https://github.com/apache/fluss/pull/1572#discussion_r2293053206
########## fluss-lake/fluss-lake-iceberg/src/test/java/com/alibaba/fluss/lake/iceberg/tiering/IcebergTieringITCase.java: ########## @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.fluss.lake.iceberg.tiering; + +import com.alibaba.fluss.config.AutoPartitionTimeUnit; +import com.alibaba.fluss.config.ConfigOptions; +import com.alibaba.fluss.lake.iceberg.testutils.FlinkIcebergTieringTestBase; +import com.alibaba.fluss.metadata.Schema; +import com.alibaba.fluss.metadata.TableBucket; +import com.alibaba.fluss.metadata.TableDescriptor; +import com.alibaba.fluss.metadata.TablePath; +import com.alibaba.fluss.row.InternalRow; +import com.alibaba.fluss.types.DataTypes; +import com.alibaba.fluss.utils.types.Tuple2; + +import org.apache.flink.core.execution.JobClient; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.alibaba.fluss.lake.committer.BucketOffset.FLUSS_LAKE_SNAP_BUCKET_OFFSET_PROPERTY; +import static com.alibaba.fluss.testutils.DataTestUtils.row; + +/** The ITCase for tiering into iceberg. */ +class IcebergTieringITCase extends FlinkIcebergTieringTestBase { + + protected static final String DEFAULT_DB = "fluss"; + + private static StreamExecutionEnvironment execEnv; + + @BeforeAll + protected static void beforeAll() { + FlinkIcebergTieringTestBase.beforeAll(); + execEnv = StreamExecutionEnvironment.getExecutionEnvironment(); + execEnv.setParallelism(2); + execEnv.enableCheckpointing(1000); + } + + @Test + void testTiering() throws Exception { + // create a pk table, write some records and wait until snapshot finished + TablePath t1 = TablePath.of(DEFAULT_DB, "pkTable"); + long t1Id = createPkTable(t1); + TableBucket t1Bucket = new TableBucket(t1Id, 0); + // write records + List<InternalRow> rows = Arrays.asList(row(1, "v1"), row(2, "v2"), row(3, "v3")); + writeRows(t1, rows, false); + waitUntilSnapshot(t1Id, 1, 0); + + // then start tiering job + JobClient jobClient = buildTieringJob(execEnv); + + // check the status of replica after synced + assertReplicaStatus(t1Bucket, 3); + + checkDataInIcebergPrimaryKeyTable(t1, rows); + // check snapshot property in paimon + Map<String, String> properties = + new HashMap<String, String>() { + { + put( + FLUSS_LAKE_SNAP_BUCKET_OFFSET_PROPERTY, + "[{\"bucket_id\":0,\"log_offset\":3}]"); + } + }; + checkSnapshotPropertyInIceberg(t1, properties); + + // then, create another log table + TablePath t2 = TablePath.of(DEFAULT_DB, "logTable"); + long t2Id = createLogTable(t2); + TableBucket t2Bucket = new TableBucket(t2Id, 0); + List<InternalRow> flussRows = new ArrayList<>(); + // write records + for (int i = 0; i < 10; i++) { + rows = Arrays.asList(row(1, "v1"), row(2, "v2"), row(3, "v3")); + flussRows.addAll(rows); + // write records + writeRows(t2, rows, true); + } + // check the status of replica after synced; Review Comment: There's no snapshot in t2 which is a log table. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
