-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDDS-1779. TestWatchForCommit tests are flaky. #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
68f9369
HDDS-1779. TestWatchForCommit tests are flaky.
bshashikant 446cb7d
Addressed review comments.
bshashikant 04f2adf
Fix few more failed tests by increasing the retry interval.
bshashikant 420cca4
Fixed leader election timeout value wic was causing test failures as …
bshashikant e8e074e
Addressed Chheckstyle issues.
bshashikant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
156 changes: 156 additions & 0 deletions
156
...egration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/Test2WayCommitInRatis.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/** | ||
* 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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.conf.StorageUnit; | ||
import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
import org.apache.hadoop.hdds.scm.XceiverClientManager; | ||
import org.apache.hadoop.hdds.scm.XceiverClientRatis; | ||
import org.apache.hadoop.hdds.scm.XceiverClientReply; | ||
import org.apache.hadoop.hdds.scm.XceiverClientSpi; | ||
import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline; | ||
import org.apache.hadoop.hdds.scm.pipeline.Pipeline; | ||
import org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB; | ||
import org.apache.hadoop.ozone.MiniOzoneCluster; | ||
import org.apache.hadoop.ozone.OzoneConfigKeys; | ||
import org.apache.hadoop.ozone.client.ObjectStore; | ||
import org.apache.hadoop.ozone.client.OzoneClient; | ||
import org.apache.hadoop.ozone.client.OzoneClientFactory; | ||
import org.apache.hadoop.ozone.container.ContainerTestHelper; | ||
import org.apache.hadoop.test.GenericTestUtils; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_SCM_WATCHER_TIMEOUT; | ||
|
||
/** | ||
* This class tests the 2 way commit in Ratis. | ||
*/ | ||
public class Test2WayCommitInRatis { | ||
|
||
private MiniOzoneCluster cluster; | ||
private OzoneClient client; | ||
private ObjectStore objectStore; | ||
private String volumeName; | ||
private String bucketName; | ||
private int chunkSize; | ||
private int flushSize; | ||
private int maxFlushSize; | ||
private int blockSize; | ||
private StorageContainerLocationProtocolClientSideTranslatorPB | ||
storageContainerLocationClient; | ||
private static String containerOwner = "OZONE"; | ||
|
||
/** | ||
* Create a MiniDFSCluster for testing. | ||
* <p> | ||
* Ozone is made active by setting OZONE_ENABLED = true | ||
* | ||
* @throws IOException | ||
*/ | ||
private void startCluster(OzoneConfiguration conf) throws Exception { | ||
chunkSize = 100; | ||
flushSize = 2 * chunkSize; | ||
maxFlushSize = 2 * flushSize; | ||
blockSize = 2 * maxFlushSize; | ||
|
||
conf.setTimeDuration(HDDS_SCM_WATCHER_TIMEOUT, 1000, TimeUnit.MILLISECONDS); | ||
conf.setTimeDuration( | ||
OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_RETRY_INTERVAL_KEY, | ||
1, TimeUnit.SECONDS); | ||
|
||
conf.setQuietMode(false); | ||
cluster = MiniOzoneCluster.newBuilder(conf) | ||
.setNumDatanodes(7) | ||
.setBlockSize(blockSize) | ||
.setChunkSize(chunkSize) | ||
.setStreamBufferFlushSize(flushSize) | ||
.setStreamBufferMaxSize(maxFlushSize) | ||
.setStreamBufferSizeUnit(StorageUnit.BYTES) | ||
.build(); | ||
cluster.waitForClusterToBeReady(); | ||
//the easiest way to create an open container is creating a key | ||
client = OzoneClientFactory.getClient(conf); | ||
objectStore = client.getObjectStore(); | ||
volumeName = "watchforcommithandlingtest"; | ||
bucketName = volumeName; | ||
objectStore.createVolume(volumeName); | ||
objectStore.getVolume(volumeName).createBucket(bucketName); | ||
storageContainerLocationClient = cluster | ||
.getStorageContainerLocationClient(); | ||
} | ||
|
||
|
||
/** | ||
* Shutdown MiniDFSCluster. | ||
*/ | ||
private void shutdown() { | ||
if (cluster != null) { | ||
cluster.shutdown(); | ||
} | ||
} | ||
|
||
|
||
@Test | ||
public void test2WayCommitForRetryfailure() throws Exception { | ||
OzoneConfiguration conf = new OzoneConfiguration(); | ||
conf.setTimeDuration(OzoneConfigKeys.OZONE_CLIENT_WATCH_REQUEST_TIMEOUT, 20, | ||
TimeUnit.SECONDS); | ||
conf.setInt(OzoneConfigKeys.DFS_RATIS_CLIENT_REQUEST_MAX_RETRIES_KEY, 20); | ||
startCluster(conf); | ||
GenericTestUtils.LogCapturer logCapturer = | ||
GenericTestUtils.LogCapturer.captureLogs(XceiverClientRatis.LOG); | ||
XceiverClientManager clientManager = new XceiverClientManager(conf); | ||
|
||
ContainerWithPipeline container1 = storageContainerLocationClient | ||
.allocateContainer(HddsProtos.ReplicationType.RATIS, | ||
HddsProtos.ReplicationFactor.THREE, containerOwner); | ||
XceiverClientSpi xceiverClient = clientManager | ||
.acquireClient(container1.getPipeline()); | ||
Assert.assertEquals(1, xceiverClient.getRefcount()); | ||
Assert.assertEquals(container1.getPipeline(), | ||
xceiverClient.getPipeline()); | ||
Pipeline pipeline = xceiverClient.getPipeline(); | ||
XceiverClientRatis ratisClient = (XceiverClientRatis) xceiverClient; | ||
XceiverClientReply reply = xceiverClient.sendCommandAsync( | ||
ContainerTestHelper.getCreateContainerRequest( | ||
container1.getContainerInfo().getContainerID(), | ||
xceiverClient.getPipeline())); | ||
reply.getResponse().get(); | ||
Assert.assertEquals(3, ratisClient.getCommitInfoMap().size()); | ||
cluster.shutdownHddsDatanode(pipeline.getNodes().get(0)); | ||
reply = xceiverClient.sendCommandAsync(ContainerTestHelper | ||
.getCloseContainer(pipeline, | ||
container1.getContainerInfo().getContainerID())); | ||
reply.getResponse().get(); | ||
xceiverClient.watchForCommit(reply.getLogIndex(), 20000); | ||
|
||
// commitInfo Map will be reduced to 2 here | ||
Assert.assertEquals(2, ratisClient.getCommitInfoMap().size()); | ||
clientManager.releaseClient(xceiverClient, false); | ||
Assert.assertTrue(logCapturer.getOutput().contains("3 way commit failed")); | ||
Assert | ||
.assertTrue(logCapturer.getOutput().contains("Committed by majority")); | ||
logCapturer.stopCapturing(); | ||
shutdown(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of a Random increment, why not increment by a fixed number everytime - say 100 or 110? This applies to all the other modified test cases as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is to run the test each time with unique number so any possible hacks/errors get caught if any.