use of org.apache.ozone.test.tag.Flaky in project ozone by apache.
the class TestOzoneFileSystem method testTrash.
/**
* 1.Move a Key to Trash
* 2.Verify that the key gets deleted by the trash emptier.
*/
@Test
@Flaky("HDDS-6645")
public void testTrash() throws Exception {
String testKeyName = "testKey2";
Path path = new Path(OZONE_URI_DELIMITER, testKeyName);
ContractTestUtils.touch(fs, path);
Assert.assertTrue(trash.getConf().getClass("fs.trash.classname", TrashPolicy.class).isAssignableFrom(TrashPolicyOzone.class));
assertEquals(TRASH_INTERVAL, trash.getConf().getFloat(OMConfigKeys.OZONE_FS_TRASH_INTERVAL_KEY, 0), 0);
// Call moveToTrash. We can't call protected fs.rename() directly
trash.moveToTrash(path);
// Construct paths
String username = UserGroupInformation.getCurrentUser().getShortUserName();
Path trashRoot = new Path(OZONE_URI_DELIMITER, TRASH_PREFIX);
Path userTrash = new Path(trashRoot, username);
Path userTrashCurrent = new Path(userTrash, "Current");
Path trashPath = new Path(userTrashCurrent, testKeyName);
// Wait until the TrashEmptier purges the key
GenericTestUtils.waitFor(() -> {
try {
return !o3fs.exists(trashPath);
} catch (IOException e) {
LOG.error("Delete from Trash Failed");
Assert.fail("Delete from Trash Failed");
return false;
}
}, 1000, 120000);
// userTrash path will contain the checkpoint folder
Assert.assertEquals(1, fs.listStatus(userTrash).length);
// wait for deletion of checkpoint dir
GenericTestUtils.waitFor(() -> {
try {
return o3fs.listStatus(userTrash).length == 0;
} catch (IOException e) {
LOG.error("Delete from Trash Failed", e);
Assert.fail("Delete from Trash Failed");
return false;
}
}, 1000, 120000);
}
use of org.apache.ozone.test.tag.Flaky in project ozone by apache.
the class TestOzoneFileSystem method testRenameToTrashEnabled.
/**
* Check that files are moved to trash.
* since fs.rename(src,dst,options) is enabled.
*/
@Test
@Flaky("HDDS-6646")
public void testRenameToTrashEnabled() throws Exception {
// Create a file
String testKeyName = "testKey1";
Path path = new Path(OZONE_URI_DELIMITER, testKeyName);
try (FSDataOutputStream stream = fs.create(path)) {
stream.write(1);
}
// Call moveToTrash. We can't call protected fs.rename() directly
trash.moveToTrash(path);
// Construct paths
String username = UserGroupInformation.getCurrentUser().getShortUserName();
Path trashRoot = new Path(OZONE_URI_DELIMITER, TRASH_PREFIX);
Path userTrash = new Path(trashRoot, username);
Path userTrashCurrent = new Path(userTrash, "Current");
Path trashPath = new Path(userTrashCurrent, testKeyName);
// Trash Current directory should still have been created.
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
}
use of org.apache.ozone.test.tag.Flaky in project ozone by apache.
the class TestMiniOzoneCluster method testDNstartAfterSCM.
/**
* Test that a DN can register with SCM even if it was started before the SCM.
* @throws Exception
*/
@Test
@Timeout(100)
@Flaky("HDDS-6111")
public void testDNstartAfterSCM() throws Exception {
// Start a cluster with 3 DN
cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build();
cluster.waitForClusterToBeReady();
// Stop the SCM
StorageContainerManager scm = cluster.getStorageContainerManager();
scm.stop();
// Restart DN
cluster.restartHddsDatanode(0, false);
// DN should be in GETVERSION state till the SCM is restarted.
// Check DN endpoint state for 20 seconds
DatanodeStateMachine dnStateMachine = cluster.getHddsDatanodes().get(0).getDatanodeStateMachine();
for (int i = 0; i < 20; i++) {
for (EndpointStateMachine endpoint : dnStateMachine.getConnectionManager().getValues()) {
Assert.assertEquals(EndpointStateMachine.EndPointStates.GETVERSION, endpoint.getState());
}
Thread.sleep(1000);
}
// DN should successfully register with the SCM after SCM is restarted.
// Restart the SCM
cluster.restartStorageContainerManager(true);
// Wait for DN to register
cluster.waitForClusterToBeReady();
// DN should be in HEARTBEAT state after registering with the SCM
for (EndpointStateMachine endpoint : dnStateMachine.getConnectionManager().getValues()) {
Assert.assertEquals(EndpointStateMachine.EndPointStates.HEARTBEAT, endpoint.getState());
}
}
use of org.apache.ozone.test.tag.Flaky in project ozone by apache.
the class TestSCMInstallSnapshot method testInstallCheckPoint.
@Test
@Flaky("HDDS-6116")
public void testInstallCheckPoint() throws Exception {
DBCheckpoint checkpoint = downloadSnapshot();
StorageContainerManager scm = cluster.getStorageContainerManager();
DBStore db = HAUtils.loadDB(conf, checkpoint.getCheckpointLocation().getParent().toFile(), checkpoint.getCheckpointLocation().getFileName().toString(), new SCMDBDefinition());
// Hack the transaction index in the checkpoint so as to ensure the
// checkpointed transaction index is higher than when it was downloaded
// from.
Assert.assertNotNull(db);
HAUtils.getTransactionInfoTable(db, new SCMDBDefinition()).put(OzoneConsts.TRANSACTION_INFO_KEY, TransactionInfo.builder().setCurrentTerm(10).setTransactionIndex(100).build());
db.close();
ContainerID cid = scm.getContainerManager().getContainers().get(0).containerID();
PipelineID pipelineID = scm.getPipelineManager().getPipelines().get(0).getId();
scm.getScmMetadataStore().getPipelineTable().delete(pipelineID);
scm.getContainerManager().deleteContainer(cid);
Assert.assertNull(scm.getScmMetadataStore().getPipelineTable().get(pipelineID));
Assert.assertFalse(scm.getContainerManager().containerExist(cid));
SCMStateMachine sm = scm.getScmHAManager().getRatisServer().getSCMStateMachine();
sm.pause();
sm.setInstallingDBCheckpoint(checkpoint);
sm.reinitialize();
Assert.assertNotNull(scm.getScmMetadataStore().getPipelineTable().get(pipelineID));
Assert.assertNotNull(scm.getScmMetadataStore().getContainerTable().get(cid));
Assert.assertTrue(scm.getPipelineManager().containsPipeline(pipelineID));
Assert.assertTrue(scm.getContainerManager().containerExist(cid));
Assert.assertEquals(100, scm.getScmMetadataStore().getTransactionInfoTable().get(OzoneConsts.TRANSACTION_INFO_KEY).getTransactionIndex());
Assert.assertEquals(100, scm.getScmHAManager().asSCMHADBTransactionBuffer().getLatestTrxInfo().getTermIndex().getIndex());
}
use of org.apache.ozone.test.tag.Flaky in project ozone by apache.
the class TestPipelineClose method testPipelineCloseWithLogFailure.
@Test
@Flaky("HDDS-5604")
public void testPipelineCloseWithLogFailure() throws IOException {
EventQueue eventQ = (EventQueue) scm.getEventQueue();
PipelineActionHandler pipelineActionTest = Mockito.mock(PipelineActionHandler.class);
eventQ.addHandler(SCMEvents.PIPELINE_ACTIONS, pipelineActionTest);
ArgumentCaptor<PipelineActionsFromDatanode> actionCaptor = ArgumentCaptor.forClass(PipelineActionsFromDatanode.class);
ContainerInfo containerInfo = containerManager.allocateContainer(RatisReplicationConfig.getInstance(ReplicationFactor.THREE), "testOwner");
ContainerWithPipeline containerWithPipeline = new ContainerWithPipeline(containerInfo, pipelineManager.getPipeline(containerInfo.getPipelineID()));
Pipeline openPipeline = containerWithPipeline.getPipeline();
RaftGroupId groupId = RaftGroupId.valueOf(openPipeline.getId().getId());
try {
pipelineManager.getPipeline(openPipeline.getId());
} catch (PipelineNotFoundException e) {
Assert.assertTrue("pipeline should exist", false);
}
DatanodeDetails datanodeDetails = openPipeline.getNodes().get(0);
int index = cluster.getHddsDatanodeIndex(datanodeDetails);
XceiverServerRatis xceiverRatis = (XceiverServerRatis) cluster.getHddsDatanodes().get(index).getDatanodeStateMachine().getContainer().getWriteChannel();
/**
* Notify Datanode Ratis Server endpoint of a Ratis log failure.
* This is expected to trigger an immediate pipeline actions report to SCM
*/
xceiverRatis.handleNodeLogFailure(groupId, null);
// verify SCM receives a pipeline action report "immediately"
Mockito.verify(pipelineActionTest, Mockito.timeout(100)).onMessage(actionCaptor.capture(), Mockito.any(EventPublisher.class));
PipelineActionsFromDatanode actionsFromDatanode = actionCaptor.getValue();
// match the pipeline id
verifyCloseForPipeline(openPipeline, actionsFromDatanode);
}
Aggregations