Search in sources :

Example 1 with CopyableDataset

use of org.apache.gobblin.data.management.copy.CopyableDataset in project incubator-gobblin by apache.

the class DeletingCopyDataPublisherTest method testDeleteOnSource.

@Test
public void testDeleteOnSource() throws Exception {
    State state = getTestState("testDeleteOnSource");
    Path testMethodTempPath = new Path(testClassTempPath, "testDeleteOnSource");
    DeletingCopyDataPublisher copyDataPublisher = closer.register(new DeletingCopyDataPublisher(state));
    File outputDir = new File(testMethodTempPath.toString(), "task-output/jobid/1f042f494d1fe2198e0e71a17faa233f33b5099b");
    outputDir.mkdirs();
    outputDir.deleteOnExit();
    WorkUnitState wus = new WorkUnitState();
    CopyableDataset copyableDataset = new TestCopyableDataset(new Path("origin"));
    CopyableDatasetMetadata metadata = new CopyableDatasetMetadata(copyableDataset);
    CopyEntity cf = CopyableFileUtils.createTestCopyableFile(new Path(testMethodTempPath, "test.txt").toString());
    CopySource.serializeCopyableDataset(wus, metadata);
    CopySource.serializeCopyEntity(wus, cf);
    Assert.assertTrue(fs.exists(new Path(testMethodTempPath, "test.txt")));
    wus.setWorkingState(WorkingState.SUCCESSFUL);
    copyDataPublisher.publishData(ImmutableList.of(wus));
    Assert.assertFalse(fs.exists(new Path(testMethodTempPath, "test.txt")));
}
Also used : Path(org.apache.hadoop.fs.Path) TestCopyableDataset(org.apache.gobblin.data.management.copy.TestCopyableDataset) CopyableDataset(org.apache.gobblin.data.management.copy.CopyableDataset) TestCopyableDataset(org.apache.gobblin.data.management.copy.TestCopyableDataset) CopyEntity(org.apache.gobblin.data.management.copy.CopyEntity) WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) State(org.apache.gobblin.configuration.State) WorkingState(org.apache.gobblin.configuration.WorkUnitState.WorkingState) WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) CopyableDatasetMetadata(org.apache.gobblin.data.management.copy.CopyableDatasetMetadata) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

File (java.io.File)1 State (org.apache.gobblin.configuration.State)1 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)1 WorkingState (org.apache.gobblin.configuration.WorkUnitState.WorkingState)1 CopyEntity (org.apache.gobblin.data.management.copy.CopyEntity)1 CopyableDataset (org.apache.gobblin.data.management.copy.CopyableDataset)1 CopyableDatasetMetadata (org.apache.gobblin.data.management.copy.CopyableDatasetMetadata)1 TestCopyableDataset (org.apache.gobblin.data.management.copy.TestCopyableDataset)1 Path (org.apache.hadoop.fs.Path)1 Test (org.testng.annotations.Test)1