From 318c1f3493254df3b5906f64adc8cc14895d1367 Mon Sep 17 00:00:00 2001 From: harryteng9527 Date: Thu, 3 Oct 2024 00:01:45 +0800 Subject: [PATCH 1/2] Extract bootstrap methods to a superclass and let those tests extends superclass --- .../volume/TestOMVolumeCreateResponse.java | 43 ++-------------- .../volume/TestOMVolumeDeleteResponse.java | 39 ++------------ .../response/volume/TestOMVolumeResponse.java | 36 +++++++++++++ .../volume/TestOMVolumeSetOwnerResponse.java | 51 +++---------------- .../volume/TestOMVolumeSetQuotaResponse.java | 36 +------------ 5 files changed, 53 insertions(+), 152 deletions(-) create mode 100644 hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java index 9d8de4bbb20..40ef546b79c 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java @@ -18,10 +18,6 @@ package org.apache.hadoop.ozone.om.response.volume; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.ozone.om.OMConfigKeys; -import org.apache.hadoop.ozone.om.OMMetadataManager; -import org.apache.hadoop.ozone.om.OmMetadataManagerImpl; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -31,13 +27,8 @@ import org.apache.hadoop.ozone.storage.proto. OzoneManagerStorageProtos.PersistedUserVolumeInfo; import org.apache.hadoop.util.Time; -import org.apache.hadoop.hdds.utils.db.BatchOperation; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import java.nio.file.Path; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -45,29 +36,7 @@ /** * This class tests OMVolumeCreateResponse. */ -public class TestOMVolumeCreateResponse { - - @TempDir - private Path folder; - - private OMMetadataManager omMetadataManager; - private BatchOperation batchOperation; - - @BeforeEach - public void setup() throws Exception { - OzoneConfiguration ozoneConfiguration = new OzoneConfiguration(); - ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, - folder.toAbsolutePath().toString()); - omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration, null); - batchOperation = omMetadataManager.getStore().initBatchOperation(); - } - - @AfterEach - public void tearDown() { - if (batchOperation != null) { - batchOperation.close(); - } - } +public class TestOMVolumeCreateResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { @@ -79,10 +48,10 @@ public void testAddToDBBatch() throws Exception { .addVolumeNames(volumeName).build(); OMResponse omResponse = OMResponse.newBuilder() - .setCmdType(OzoneManagerProtocolProtos.Type.CreateVolume) - .setStatus(OzoneManagerProtocolProtos.Status.OK) - .setSuccess(true) - .setCreateVolumeResponse(CreateVolumeResponse.getDefaultInstance()) + .setCmdType(OzoneManagerProtocolProtos.Type.CreateVolume) + .setStatus(OzoneManagerProtocolProtos.Status.OK) + .setSuccess(true) + .setCreateVolumeResponse(CreateVolumeResponse.getDefaultInstance()) .build(); OmVolumeArgs omVolumeArgs = OmVolumeArgs.newBuilder() @@ -125,6 +94,4 @@ void testAddToDBBatchNoOp() throws Exception { assertEquals(0, omMetadataManager.countRowsInTable( omMetadataManager.getVolumeTable())); } - - } diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java index 70dd23a7b04..e5235ee9e8f 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java @@ -18,10 +18,6 @@ package org.apache.hadoop.ozone.om.response.volume; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.ozone.om.OMConfigKeys; -import org.apache.hadoop.ozone.om.OMMetadataManager; -import org.apache.hadoop.ozone.om.OmMetadataManagerImpl; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -30,14 +26,9 @@ .OMResponse; import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.PersistedUserVolumeInfo; import org.apache.hadoop.util.Time; -import org.apache.hadoop.hdds.utils.db.BatchOperation; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; import java.util.UUID; -import java.nio.file.Path; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertNull; @@ -45,33 +36,10 @@ /** * This class tests OMVolumeCreateResponse. */ -public class TestOMVolumeDeleteResponse { - - @TempDir - private Path folder; - - private OMMetadataManager omMetadataManager; - private BatchOperation batchOperation; - - @BeforeEach - public void setup() throws Exception { - OzoneConfiguration ozoneConfiguration = new OzoneConfiguration(); - ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, - folder.toAbsolutePath().toString()); - omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration, null); - batchOperation = omMetadataManager.getStore().initBatchOperation(); - } - - @AfterEach - public void tearDown() { - if (batchOperation != null) { - batchOperation.close(); - } - } +public class TestOMVolumeDeleteResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { - String volumeName = UUID.randomUUID().toString(); String userName = "user1"; PersistedUserVolumeInfo volumeList = PersistedUserVolumeInfo.newBuilder() @@ -95,7 +63,7 @@ public void testAddToDBBatch() throws Exception { // As we are deleting updated volume list should be empty. PersistedUserVolumeInfo updatedVolumeList = PersistedUserVolumeInfo.newBuilder() - .setObjectID(1).setUpdateID(1).build(); + .setObjectID(1).setUpdateID(1).build(); OMVolumeDeleteResponse omVolumeDeleteResponse = new OMVolumeDeleteResponse(omResponse, volumeName, userName, updatedVolumeList); @@ -107,7 +75,7 @@ public void testAddToDBBatch() throws Exception { omMetadataManager.getStore().commitBatchOperation(batchOperation); assertNull(omMetadataManager.getVolumeTable().get( - omMetadataManager.getVolumeKey(volumeName))); + omMetadataManager.getVolumeKey(volumeName))); assertNull(omMetadataManager.getUserTable().get( omMetadataManager.getUserKey(userName))); @@ -127,5 +95,4 @@ public void testAddToDBBatchNoOp() { omResponse); assertDoesNotThrow(() -> omVolumeDeleteResponse.checkAndUpdateDB(omMetadataManager, batchOperation)); } - } diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java new file mode 100644 index 00000000000..97701ef212d --- /dev/null +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java @@ -0,0 +1,36 @@ +package org.apache.hadoop.ozone.om.response.volume; + +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.ozone.om.OMConfigKeys; +import org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.OmMetadataManagerImpl; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; + +import java.nio.file.Path; + +public class TestOMVolumeResponse { + @TempDir + private Path folder; + + protected OMMetadataManager omMetadataManager; + protected BatchOperation batchOperation; + + @BeforeEach + public void setup() throws Exception { + OzoneConfiguration ozoneConfiguration = new OzoneConfiguration(); + ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, + folder.toAbsolutePath().toString()); + omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration, null); + batchOperation = omMetadataManager.getStore().initBatchOperation(); + } + + @AfterEach + public void tearDown() { + if (batchOperation != null) { + batchOperation.close(); + } + } +} diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java index aa640067ca4..94074b7b7c7 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java @@ -18,10 +18,6 @@ package org.apache.hadoop.ozone.om.response.volume; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.ozone.om.OMConfigKeys; -import org.apache.hadoop.ozone.om.OMMetadataManager; -import org.apache.hadoop.ozone.om.OmMetadataManagerImpl; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -30,14 +26,9 @@ .OMResponse; import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.PersistedUserVolumeInfo; import org.apache.hadoop.util.Time; -import org.apache.hadoop.hdds.utils.db.BatchOperation; import org.apache.hadoop.hdds.utils.db.Table; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import java.nio.file.Path; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -45,30 +36,7 @@ /** * This class tests OMVolumeCreateResponse. */ -public class TestOMVolumeSetOwnerResponse { - - @TempDir - private Path folder; - - private OMMetadataManager omMetadataManager; - private BatchOperation batchOperation; - - @BeforeEach - public void setup() throws Exception { - OzoneConfiguration ozoneConfiguration = new OzoneConfiguration(); - ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, - folder.toAbsolutePath().toString()); - omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration, null); - batchOperation = omMetadataManager.getStore().initBatchOperation(); - } - - @AfterEach - public void tearDown() { - if (batchOperation != null) { - batchOperation.close(); - } - } - +public class TestOMVolumeSetOwnerResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { @@ -94,25 +62,24 @@ public void testAddToDBBatch() throws Exception { new OMVolumeCreateResponse(omResponse, omVolumeArgs, volumeList); - String newOwner = "user2"; PersistedUserVolumeInfo newOwnerVolumeList = PersistedUserVolumeInfo.newBuilder() - .setObjectID(1) - .setUpdateID(1) - .addVolumeNames(volumeName).build(); + .setObjectID(1) + .setUpdateID(1) + .addVolumeNames(volumeName).build(); PersistedUserVolumeInfo oldOwnerVolumeList = PersistedUserVolumeInfo.newBuilder() - .setObjectID(2) - .setUpdateID(2) - .build(); + .setObjectID(2) + .setUpdateID(2) + .build(); OmVolumeArgs newOwnerVolumeArgs = OmVolumeArgs.newBuilder() .setOwnerName(newOwner).setAdminName(newOwner) .setVolume(volumeName).setCreationTime(omVolumeArgs.getCreationTime()) .build(); OMVolumeSetOwnerResponse omVolumeSetOwnerResponse = - new OMVolumeSetOwnerResponse(omResponse, oldOwner, oldOwnerVolumeList, + new OMVolumeSetOwnerResponse(omResponse, oldOwner, oldOwnerVolumeList, newOwnerVolumeList, newOwnerVolumeArgs); omVolumeCreateResponse.addToDBBatch(omMetadataManager, batchOperation); @@ -155,6 +122,4 @@ void testAddToDBBatchNoOp() throws Exception { assertEquals(0, omMetadataManager.countRowsInTable( omMetadataManager.getVolumeTable())); } - - } diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java index fbc8e3c944d..8f8fb05edbe 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java @@ -18,10 +18,6 @@ package org.apache.hadoop.ozone.om.response.volume; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.ozone.om.OMConfigKeys; -import org.apache.hadoop.ozone.om.OMMetadataManager; -import org.apache.hadoop.ozone.om.OmMetadataManagerImpl; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -29,14 +25,9 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos .OMResponse; import org.apache.hadoop.util.Time; -import org.apache.hadoop.hdds.utils.db.BatchOperation; import org.apache.hadoop.hdds.utils.db.Table; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import java.nio.file.Path; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -44,30 +35,7 @@ /** * This class tests OMVolumeCreateResponse. */ -public class TestOMVolumeSetQuotaResponse { - - @TempDir - private Path folder; - - private OMMetadataManager omMetadataManager; - private BatchOperation batchOperation; - - @BeforeEach - public void setup() throws Exception { - OzoneConfiguration ozoneConfiguration = new OzoneConfiguration(); - ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, - folder.toAbsolutePath().toString()); - omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration, null); - batchOperation = omMetadataManager.getStore().initBatchOperation(); - } - - @AfterEach - public void tearDown() { - if (batchOperation != null) { - batchOperation.close(); - } - } - +public class TestOMVolumeSetQuotaResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { @@ -123,6 +91,4 @@ void testAddToDBBatchNoOp() throws Exception { assertEquals(0, omMetadataManager.countRowsInTable( omMetadataManager.getVolumeTable())); } - - } From 9fa2f97705cd0caedafa0a337a47011b037456f1 Mon Sep 17 00:00:00 2001 From: harryteng9527 Date: Thu, 3 Oct 2024 11:04:56 +0800 Subject: [PATCH 2/2] Add license header and resolve checkstyle --- .../volume/TestOMVolumeCreateResponse.java | 8 +++-- .../volume/TestOMVolumeDeleteResponse.java | 7 +++- .../response/volume/TestOMVolumeResponse.java | 32 +++++++++++++++++-- .../volume/TestOMVolumeSetOwnerResponse.java | 8 +++-- .../volume/TestOMVolumeSetQuotaResponse.java | 8 +++-- 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java index 40ef546b79c..075dad5ee03 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeCreateResponse.java @@ -18,6 +18,8 @@ package org.apache.hadoop.ozone.om.response.volume; +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.ozone.om.OMMetadataManager; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -40,7 +42,8 @@ public class TestOMVolumeCreateResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); String volumeName = UUID.randomUUID().toString(); String userName = "user1"; PersistedUserVolumeInfo volumeList = PersistedUserVolumeInfo.newBuilder() @@ -78,7 +81,8 @@ public void testAddToDBBatch() throws Exception { @Test void testAddToDBBatchNoOp() throws Exception { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); OMResponse omResponse = OMResponse.newBuilder() .setCmdType(OzoneManagerProtocolProtos.Type.CreateVolume) .setStatus(OzoneManagerProtocolProtos.Status.VOLUME_ALREADY_EXISTS) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java index e5235ee9e8f..e4b93881137 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeDeleteResponse.java @@ -18,6 +18,8 @@ package org.apache.hadoop.ozone.om.response.volume; +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.ozone.om.OMMetadataManager; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -40,6 +42,8 @@ public class TestOMVolumeDeleteResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); String volumeName = UUID.randomUUID().toString(); String userName = "user1"; PersistedUserVolumeInfo volumeList = PersistedUserVolumeInfo.newBuilder() @@ -83,7 +87,8 @@ public void testAddToDBBatch() throws Exception { @Test public void testAddToDBBatchNoOp() { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); OMResponse omResponse = OMResponse.newBuilder() .setCmdType(OzoneManagerProtocolProtos.Type.DeleteVolume) .setStatus(OzoneManagerProtocolProtos.Status.VOLUME_NOT_FOUND) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java index 97701ef212d..7edbaedf2dd 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeResponse.java @@ -1,3 +1,21 @@ +/** + * 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.hadoop.ozone.om.response.volume; import org.apache.hadoop.hdds.conf.OzoneConfiguration; @@ -11,12 +29,15 @@ import java.nio.file.Path; +/** + * Base test class for OM volume response. + */ public class TestOMVolumeResponse { @TempDir private Path folder; - protected OMMetadataManager omMetadataManager; - protected BatchOperation batchOperation; + private OMMetadataManager omMetadataManager; + private BatchOperation batchOperation; @BeforeEach public void setup() throws Exception { @@ -33,4 +54,11 @@ public void tearDown() { batchOperation.close(); } } + + protected OMMetadataManager getOmMetadataManager() { + return omMetadataManager; + } + protected BatchOperation getBatchOperation() { + return batchOperation; + } } diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java index 94074b7b7c7..00da2029c1e 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetOwnerResponse.java @@ -18,6 +18,8 @@ package org.apache.hadoop.ozone.om.response.volume; +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.ozone.om.OMMetadataManager; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -40,7 +42,8 @@ public class TestOMVolumeSetOwnerResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); String volumeName = UUID.randomUUID().toString(); String oldOwner = "user1"; PersistedUserVolumeInfo volumeList = PersistedUserVolumeInfo.newBuilder() @@ -106,7 +109,8 @@ public void testAddToDBBatch() throws Exception { @Test void testAddToDBBatchNoOp() throws Exception { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); OMResponse omResponse = OMResponse.newBuilder() .setCmdType(OzoneManagerProtocolProtos.Type.SetVolumeProperty) .setStatus(OzoneManagerProtocolProtos.Status.VOLUME_NOT_FOUND) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java index 8f8fb05edbe..c33e9d174a9 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/volume/TestOMVolumeSetQuotaResponse.java @@ -18,6 +18,8 @@ package org.apache.hadoop.ozone.om.response.volume; +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.ozone.om.OMMetadataManager; import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos @@ -39,7 +41,8 @@ public class TestOMVolumeSetQuotaResponse extends TestOMVolumeResponse { @Test public void testAddToDBBatch() throws Exception { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); String volumeName = UUID.randomUUID().toString(); String userName = "user1"; @@ -75,7 +78,8 @@ public void testAddToDBBatch() throws Exception { @Test void testAddToDBBatchNoOp() throws Exception { - + OMMetadataManager omMetadataManager = getOmMetadataManager(); + BatchOperation batchOperation = getBatchOperation(); OMResponse omResponse = OMResponse.newBuilder() .setCmdType(OzoneManagerProtocolProtos.Type.CreateVolume) .setStatus(OzoneManagerProtocolProtos.Status.VOLUME_NOT_FOUND)