adoroszlai commented on a change in pull request #2926: URL: https://github.com/apache/ozone/pull/2926#discussion_r774068921
########## File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientWithKeyLatestVersion.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 org.apache.hadoop.ozone.client.rpc; + +import org.apache.hadoop.hdds.client.ReplicationConfig; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.protocol.proto.HddsProtos; +import org.apache.hadoop.hdds.scm.ScmConfigKeys; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.client.BucketArgs; +import org.apache.hadoop.ozone.client.ObjectStore; +import org.apache.hadoop.ozone.client.OzoneBucket; +import org.apache.hadoop.ozone.client.OzoneClient; +import org.apache.hadoop.ozone.client.OzoneClientFactory; +import org.apache.hadoop.ozone.client.OzoneVolume; +import org.apache.hadoop.ozone.client.io.OzoneInputStream; +import org.apache.hadoop.ozone.client.io.OzoneOutputStream; +import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType.RATIS; +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_KEY_LATEST_VERSION_LOCATION; + + +/** + * Main purpose of this test is with OZONE_CLIENT_KEY_LATEST_VERSION_LOCATION + * set/unset key create/read works properly or not for buckets + * with/with out versioning. + */ +public class TestOzoneRpcClientWithKeyLatestVersion { + + private static MiniOzoneCluster cluster; + + private static ObjectStore objectStore; + + private static OzoneClient ozClient; + + private boolean getLatestVersion; + + @BeforeClass + public static void setup() throws Exception { + OzoneConfiguration conf = new OzoneConfiguration(); + conf.setInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, 1); + cluster = MiniOzoneCluster.newBuilder(conf) + .setNumDatanodes(3) + .setScmId(UUID.randomUUID().toString()) + .setClusterId(UUID.randomUUID().toString()) + .build(); + cluster.waitForClusterToBeReady(); + } + + @AfterClass + public static void tearDown() throws Exception { + if(ozClient != null) { + ozClient.close(); + } + + if (cluster != null) { + cluster.shutdown(); + } + } + + + @Test + public void testWithGetLatestVersion() throws Exception { + getLatestVersion = false; + setupClient(); Review comment: The idea is to setup cluster in `@BeforeClass`, but client in `@Before`, since client is parameterized. This lets us avoid code duplication in test case. ```diff diff --git hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientWithKeyLatestVersion.java hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientWithKeyLatestVersion.java index 0756c86a0..4cce7dac4 100644 --- hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientWithKeyLatestVersion.java +++ hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientWithKeyLatestVersion.java @@ -32,11 +32,18 @@ import org.apache.hadoop.ozone.client.io.OzoneInputStream; import org.apache.hadoop.ozone.client.io.OzoneOutputStream; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; +import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -51,15 +58,25 @@ * set/unset key create/read works properly or not for buckets * with/with out versioning. */ +@RunWith(Parameterized.class) public class TestOzoneRpcClientWithKeyLatestVersion { private static MiniOzoneCluster cluster; - private static ObjectStore objectStore; + private ObjectStore objectStore; - private static OzoneClient ozClient; + private OzoneClient ozClient; - private boolean getLatestVersion; + private final boolean getLatestVersion; + + @Parameterized.Parameters + public static Collection<Object> data() { + return Arrays.asList(true, false); + } + + public TestOzoneRpcClientWithKeyLatestVersion(boolean latestVersion) { + getLatestVersion = latestVersion; + } @BeforeClass public static void setup() throws Exception { @@ -75,28 +92,25 @@ public static void setup() throws Exception { @AfterClass public static void tearDown() throws Exception { - if(ozClient != null) { - ozClient.close(); - } - if (cluster != null) { cluster.shutdown(); } } + @After + public void closeClient() throws IOException { + if(ozClient != null) { + ozClient.close(); + } + } @Test public void testWithGetLatestVersion() throws Exception { - getLatestVersion = false; - setupClient(); - testOverrideAndReadKey(); - - getLatestVersion = true; - setupClient(); testOverrideAndReadKey(); } - private void setupClient() throws Exception { + @Before + public void setupClient() throws Exception { OzoneConfiguration conf = cluster.getConf(); conf.setBoolean(OZONE_CLIENT_KEY_LATEST_VERSION_LOCATION, getLatestVersion); ozClient = OzoneClientFactory.getRpcClient(conf); ``` -- 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]
