Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -57,6 +57,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.slf4j.event.Level.DEBUG;

import java.io.File;
Expand Down Expand Up @@ -130,6 +131,7 @@
import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.OzoneManagerVersion;
import org.apache.hadoop.ozone.OzoneTestUtils;
import org.apache.hadoop.ozone.TestDataUtil;
import org.apache.hadoop.ozone.audit.AuditLogTestUtils;
Expand Down Expand Up @@ -1226,6 +1228,7 @@ public void testPutKey() throws IOException {
@ParameterizedTest
@EnumSource
void rewriteKey(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
OmKeyArgs keyArgs = toOmKeyArgs(keyDetails);
Expand All @@ -1243,6 +1246,7 @@ void rewriteKey(BucketLayout layout) throws IOException {
@ParameterizedTest
@EnumSource
void overwriteAfterRewrite(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
rewriteKey(bucket, keyDetails, "rewrite".getBytes(UTF_8));
Expand All @@ -1257,6 +1261,7 @@ void overwriteAfterRewrite(BucketLayout layout) throws IOException {
@ParameterizedTest
@EnumSource
void rewriteAfterRename(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
String newKeyName = "rewriteAfterRename-" + layout;
Expand All @@ -1277,6 +1282,7 @@ void rewriteAfterRename(BucketLayout layout) throws IOException {
@ParameterizedTest
@EnumSource
void renameAfterRewrite(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
final byte[] rewriteContent = "rewrite".getBytes(UTF_8);
Expand All @@ -1294,6 +1300,7 @@ void renameAfterRewrite(BucketLayout layout) throws IOException {
@ParameterizedTest
@EnumSource
void rewriteFailsDueToOutdatedGeneration(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
OmKeyArgs keyArgs = toOmKeyArgs(keyDetails);
Expand All @@ -1317,6 +1324,7 @@ void rewriteFailsDueToOutdatedGeneration(BucketLayout layout) throws IOException
@ParameterizedTest
@EnumSource
void rewriteFailsDueToOutdatedGenerationAtCommit(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
final byte[] overwriteContent = "overwrite".getBytes(UTF_8);
Expand Down Expand Up @@ -1351,6 +1359,7 @@ void rewriteFailsDueToOutdatedGenerationAtCommit(BucketLayout layout) throws IOE
@ParameterizedTest
@EnumSource
void cannotRewriteDeletedKey(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
bucket.deleteKey(keyDetails.getName());
Expand All @@ -1363,6 +1372,7 @@ void cannotRewriteDeletedKey(BucketLayout layout) throws IOException {
@ParameterizedTest
@EnumSource
void cannotRewriteRenamedKey(BucketLayout layout) throws IOException {
checkFeatureEnable();
OzoneBucket bucket = createBucket(layout);
OzoneKeyDetails keyDetails = createTestKey(bucket);
bucket.renameKey(keyDetails.getName(), "newKeyName-" + layout.name());
Expand Down Expand Up @@ -1440,6 +1450,14 @@ private static void assertMetadataUnchanged(OzoneKeyDetails original, OzoneKeyDe
assertEquals(original.getMetadata(), rewritten.getMetadata());
}

private static void checkFeatureEnable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make the function name clear

Suggested change
private static void checkFeatureEnable() {
private static void checkAtomicKeyRewriteFeatureEnable() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be better to keep the name and add a parameter for the feature being checked.

try {
cluster.getOzoneManager().checkFeatureEnabled(OzoneManagerVersion.ATOMIC_REWRITE_KEY);
} catch (OMException e) {
assumeFalse(OMException.ResultCodes.NOT_SUPPORTED_OPERATION == e.getResult());
}
}

@Test
public void testCheckUsedBytesQuota() throws IOException {
String volumeName = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Timeout;
Expand All @@ -36,6 +37,7 @@ public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
conf.setInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, 1);
conf.setBoolean(OzoneConfigKeys.OZONE_ACL_ENABLED, true);
conf.set(OMConfigKeys.OZONE_OM_FEATURES_DISABLED, "ATOMIC_REWRITE_KEY");
Copy link
Member

@peterxcli peterxcli Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would disable the feature for the whole, we can add some test cases and set the disabled feature configuration in them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's enough if the test passes with this setting, no need to really set it in the config.

Tested without this by temporarily adding:

  <property>
    <name>ozone.om.features.disabled</name>
    <value>ATOMIC_REWRITE_KEY</value>
  </property>

in hadoop-ozone/integration-test/src/test/resources/ozone-site.xml.

conf.set(OzoneConfigKeys.OZONE_ACL_AUTHORIZER_CLASS,
OzoneConfigKeys.OZONE_ACL_AUTHORIZER_CLASS_NATIVE);
startCluster(conf);
Expand Down