Search in sources :

Example 11 with RemoteSpace

use of org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace in project scheduling by ow2-proactive.

the class DataTransferTest method testUploadAllFilesInDirectory.

@Test
public void testUploadAllFilesInDirectory() throws Exception {
    // entire folder
    TestFilesToUploadCreator testFiles = new TestFilesToUploadCreator().invoke();
    File tempTextFile = testFiles.getTempTextFile();
    File tempFile = testFiles.getTempFile();
    // use standard client
    IDataSpaceClient client = clientInstance();
    LocalDirSource source = new LocalDirSource(tmpDir.getRoot());
    RemoteDestination dest = new RemoteDestination(USER, "testUploadAllFilesInDirectory");
    assertTrue(client.upload(source, dest));
    String destRootUri = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    assertTrue(Files.equal(tempTextFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TXT_NAME)));
    assertTrue(Files.equal(tempFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TMP_PATH)));
    // use RemoteSpace API
    FileUtils.deleteDirectory(new File(destRootUri, "testUploadAllFilesInDirectory"));
    client.getUserSpace().pushFile(tmpDir.getRoot(), "testUploadAllFilesInDirectory");
    assertTrue(Files.equal(tempTextFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TXT_NAME)));
    assertTrue(Files.equal(tempFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TMP_PATH)));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 12 with RemoteSpace

use of org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace in project scheduling by ow2-proactive.

the class DataTransferTest method testDownloadAllFilesInDirectory.

@Test
public void testDownloadAllFilesInDirectory() throws Exception {
    String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    String dirName = "testDownloadAllFilesInDirectory";
    TestFilesToDownloadCreator testFilesToDownloadCreator = new TestFilesToDownloadCreator(srcDirPath, dirName).invoke();
    File srcTextFile = testFilesToDownloadCreator.getSrcTextFile();
    File srcTempFile = testFilesToDownloadCreator.getSrcTempFile();
    File destTempDir = tmpDir.newFolder(TEMP_DIR_NAME);
    // use standard client
    IDataSpaceClient client = clientInstance();
    RemoteSource source = new RemoteSource(USER, "testDownloadAllFilesInDirectory");
    LocalDestination dest = new LocalDestination(destTempDir);
    assertTrue(client.download(source, dest));
    assertTrue(Files.equal(srcTextFile, new File(destTempDir, TEMP_FILE_TXT_NAME)));
    assertTrue(Files.equal(srcTempFile, new File(destTempDir, TEMP_FILE_TMP_PATH)));
    // use RemoteSpace API
    File destTempDir2 = tmpDir.newFolder(TEMP_DIR2_NAME);
    client.getUserSpace().pullFile("testDownloadAllFilesInDirectory", destTempDir2);
    assertTrue(Files.equal(srcTextFile, new File(destTempDir2, TEMP_FILE_TXT_NAME)));
    assertTrue(Files.equal(srcTempFile, new File(destTempDir2, TEMP_FILE_TMP_PATH)));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 13 with RemoteSpace

use of org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace in project scheduling by ow2-proactive.

the class DataTransferTest method testListFilesNonRecursive.

@Test
public void testListFilesNonRecursive() throws Exception {
    System.out.println("testListFilesNonRecursive");
    createFilesInUserSpace("testListFilesNonRecursive");
    // use standard client
    IDataSpaceClient client = clientInstance();
    RemoteSource source = new RemoteSource(USER, "testListFilesNonRecursive");
    source.setIncludes("*");
    ListFile listFile = client.list(source);
    List<String> directories = listFile.getDirectoryListing();
    System.out.println("Directories : " + directories);
    assertEquals(1, directories.size());
    assertEquals(TEMP_DIR_NAME, directories.get(0));
    List<String> files = listFile.getFileListing();
    System.out.println("Files : " + files);
    assertEquals(1, files.size());
    assertEquals(TEMP_FILE_TXT_NAME, files.get(0));
    // use RemoteSpace API
    List<String> foundFiles = client.getUserSpace().listFiles("testListFilesNonRecursive", "*");
    System.out.println("Full : " + foundFiles);
    assertEquals(2, foundFiles.size());
    assertArrayEquals(new String[] { TEMP_DIR_NAME, TEMP_FILE_TXT_NAME }, foundFiles.toArray(new String[0]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) Test(org.junit.Test)

Example 14 with RemoteSpace

use of org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace in project scheduling by ow2-proactive.

the class DataTransferTest method testUploadSelectedFilesUsingGlobPattern.

@Test
public void testUploadSelectedFilesUsingGlobPattern() throws Exception {
    TestFilesToUploadCreator testFiles = new TestFilesToUploadCreator().invoke();
    File tempTextFile = testFiles.getTempTextFile();
    File tempFile = testFiles.getTempFile();
    // use standard client
    IDataSpaceClient client = clientInstance();
    LocalDirSource source = new LocalDirSource(tmpDir.getRoot());
    source.setIncludes("*.txt");
    RemoteDestination dest = new RemoteDestination(USER, "testUploadSelectedFilesUsingGlobPattern");
    assertTrue(client.upload(source, dest));
    String destRootUri = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    File[] destRootFiles = new File(destRootUri, "testUploadSelectedFilesUsingGlobPattern").listFiles();
    assertEquals(1, destRootFiles.length);
    assertTrue(Files.equal(tempTextFile, destRootFiles[0]));
    // use RemoteSpace API
    FileUtils.deleteDirectory(new File(destRootUri, "testUploadSelectedFilesUsingGlobPattern"));
    client.getUserSpace().pushFiles(tmpDir.getRoot(), "*.txt", "testUploadSelectedFilesUsingGlobPattern");
    destRootFiles = new File(destRootUri, "testUploadSelectedFilesUsingGlobPattern").listFiles();
    assertEquals(1, destRootFiles.length);
    assertTrue(Files.equal(tempTextFile, destRootFiles[0]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 15 with RemoteSpace

use of org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace in project scheduling by ow2-proactive.

the class DataTransferTest method testDownloadSelectedFilesUsingGlobPattern.

@Test
public void testDownloadSelectedFilesUsingGlobPattern() throws Exception {
    String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    String dirName = "testDownloadSelectedFilesUsingGlobPattern";
    TestFilesToDownloadCreator testFilesToDownloadCreator = new TestFilesToDownloadCreator(srcDirPath, dirName).invoke();
    File srcTextFile = testFilesToDownloadCreator.getSrcTextFile();
    File srcTempFile = testFilesToDownloadCreator.getSrcTempFile();
    File destTempDir = tmpDir.newFolder(TEMP_DIR_NAME);
    // use standard client
    IDataSpaceClient client = clientInstance();
    RemoteSource source = new RemoteSource(USER, dirName);
    source.setIncludes("*.txt");
    LocalDestination dest = new LocalDestination(destTempDir);
    assertTrue(client.download(source, dest));
    File[] listFiles = destTempDir.listFiles();
    assertEquals(1, listFiles.length);
    assertTrue(Files.equal(srcTextFile, listFiles[0]));
    // use RemoteSpace API
    File destTempDir2 = tmpDir.newFolder(TEMP_DIR2_NAME);
    client.getUserSpace().pullFiles(dirName, "*.txt", destTempDir2);
    listFiles = destTempDir2.listFiles();
    assertEquals(1, listFiles.length);
    assertTrue(Files.equal(srcTextFile, listFiles[0]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Aggregations

ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)13 File (java.io.File)11 Test (org.junit.Test)11 RemoteSpace (org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace)3 SchedulerNodeClient (org.ow2.proactive.scheduler.task.client.SchedulerNodeClient)3 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)3 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)3 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 Stopwatch (com.google.common.base.Stopwatch)1 URI (java.net.URI)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 LoginException (javax.security.auth.login.LoginException)1 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)1 DataSpaceNodeClient (org.ow2.proactive.scheduler.task.client.DataSpaceNodeClient)1 Decrypter (org.ow2.proactive.scheduler.task.utils.Decrypter)1 TaskLogger (org.ow2.proactive.scheduler.util.TaskLogger)1 ScriptResult (org.ow2.proactive.scripting.ScriptResult)1