anoopj commented on code in PR #19006: URL: https://github.com/apache/iceberg/pull/19006#discussion_r4602508259
########## core/src/test/java/org/apache/iceberg/TestRemoveSnapshotsV4.java: ########## @@ -0,0 +1,113 @@ +/* + * 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 org.apache.iceberg; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import java.io.File; +import java.util.Set; +import org.apache.iceberg.exceptions.ValidationException; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +class TestRemoveSnapshotsV4 { + private static final String CLEANUP_UNSUPPORTED_MESSAGE = + "Cannot expire snapshots with file cleanup: table has a snapshot with a root manifest " + + "(use CleanupLevel.NONE to only remove snapshot metadata)"; + private static final long ROOT_MANIFEST_SNAPSHOT_ID = 42L; + private static final long FAR_FUTURE_MS = System.currentTimeMillis() + 100_000; + + @TempDir private File tableDir; + + @AfterEach + void clearTables() { + TestTables.clearTables(); + } + + @ParameterizedTest + @EnumSource( + value = ExpireSnapshots.CleanupLevel.class, + mode = EnumSource.Mode.EXCLUDE, + names = "NONE") + void rejectsFileCleanupWithRootManifestSnapshot(ExpireSnapshots.CleanupLevel cleanupLevel) { + Table table = tableWithRootManifestSnapshot(); + + assertThatThrownBy(() -> table.expireSnapshots().cleanupLevel(cleanupLevel).commit()) + .isInstanceOf(ValidationException.class) + .hasMessage(CLEANUP_UNSUPPORTED_MESSAGE); + + assertThat(table.snapshots()).as("no snapshot should be expired").hasSize(2); Review Comment: Thanks for catching that @huaxingao! -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
