/**
   * Tests closing all FileSystems
   *
   * @throws Exception
   */
  @Ignore("vfs close file system doesn't seem to work properly")
  @Test
  public void testCloseFileSystems() throws Exception {
    logger.info("*************** testCloseFileSystems");
    String[] validUrls = server.getVFSRootURLs();
    ArrayList<FileObject> fos = new ArrayList<FileObject>();
    for (String validUrl : validUrls) {
      FileObject mounted = VFSMountManagerHelper.mount(validUrl);
      Assert.assertTrue(mounted.exists());
      fos.add(mounted);
    }

    VFSMountManagerHelper.closeFileSystems(Arrays.asList(validUrls));

    boolean onlyExceptions = true;
    for (FileObject closedFo : fos) {
      try {
        FileObject toto = closedFo.resolveFile("toto");
        toto.createFile();
        onlyExceptions = false;
        logger.error(toto.getURL() + " exists : " + toto.exists());
      } catch (FileSystemException e) {
        // this should occur
      }
    }
    Assert.assertTrue("Only Exceptions received", onlyExceptions);
  }
 /**
  * Tests mounting only one valid FileSystem
  *
  * @throws Exception
  */
 @Test
 public void testMountOk() throws Exception {
   logger.info("*************** testMountOk");
   String[] validUrls = server.getVFSRootURLs();
   for (String validUrl : validUrls) {
     FileObject mounted = VFSMountManagerHelper.mount(validUrl);
     Assert.assertTrue(mounted.exists());
   }
 }
Пример #3
0
 private void tryCloseProviderServer() {
   if (providerServerDeployer == null) return;
   try {
     providerServerDeployer.terminate();
   } catch (ProActiveException e) {
     ProActiveLogger.logEatedException(
         logger, "Could not close correctly the ProActive provider", e);
   }
   providerServerDeployer = null;
 }
  @AfterClass
  public static void tearDown() throws ProActiveException {
    server.terminate();

    router.stop();

    VFSMountManagerHelper.terminate();

    if (spacesDir != null && spacesDir.exists()) {
      assertTrue(AbstractIOOperationsBase.deleteRecursively(spacesDir));
      spacesDir = null;
    }
  }
  /**
   * - Insert a valid file vfs root and a valid proactive vfs root in the list of fake uris -
   * verifies that mountAny returns the file system corresponding to the valid uri - do that for all
   * valid uris of the file system server
   *
   * @throws Exception
   */
  @Test
  public void testMountAnyOk() throws Exception {
    logger.info("*************** testMountAnyOk");
    String[] validUris = server.getVFSRootURLs();

    for (String validUrl : validUris) {
      ConcurrentHashMap<String, FileObject> fileSystems =
          new ConcurrentHashMap<String, FileObject>();
      ArrayList<String> uriToMount = new ArrayList<String>(fakeFileUrls);
      uriToMount.add(spacesDir.toURI().toString()); // adds a valid file uri
      uriToMount.addAll(fakeUrls);
      uriToMount.add((int) Math.floor(Math.random() * uriToMount.size()), validUrl);
      VFSMountManagerHelper.mountAny(uriToMount, fileSystems);
      logger.info("Content of map : " + fileSystems.toString());
      Assert.assertTrue("map contains valid Url", fileSystems.containsKey(validUrl));
    }
  }
Пример #6
0
  private BaseScratchSpaceConfiguration startProActiveProviderServer(
      BaseScratchSpaceConfiguration baseScratchConfiguration)
      throws FileSystemException, ConfigurationException {

    final String rootPath = baseScratchConfiguration.getPath();
    final File rootFile = new File(rootPath);

    try {
      if (!rootFile.isDirectory()) rootFile.mkdirs();
    } catch (SecurityException x) {
      throw new FileSystemException(x);
    }
    try {
      final String serviceId =
          Utils.getRuntimeId(node) + '/' + Utils.getNodeId(node) + "/fileSystemServer";
      providerServerDeployer = new FileSystemServerDeployer(serviceId, rootPath, true);
    } catch (IOException e) {
      throw new FileSystemException(e);
    }
    final String vfsRootURL = providerServerDeployer.getVFSRootURL();
    return baseScratchConfiguration.getWithRemoteAccess(vfsRootURL);
  }
  /**
   * Start a PAMR router and a file system server
   *
   * @throws Exception
   */
  @BeforeClass
  public static void setUp() throws Exception {

    RouterConfig config = new RouterConfig();
    config.setPort(PAMRConfig.PA_NET_ROUTER_PORT.getValue());
    router = Router.createAndStart(config);

    protocolsToTest.remove(CentralPAPropertyRepository.PA_COMMUNICATION_PROTOCOL.getValue());

    StringBuilder apstring = new StringBuilder();
    for (String p : protocolsToTest) {
      apstring.append(p + ",");
    }
    apstring.deleteCharAt(apstring.length() - 1);

    CentralPAPropertyRepository.PA_COMMUNICATION_ADDITIONAL_PROTOCOLS.setValue(apstring.toString());

    spacesDir = new File(System.getProperty("java.io.tmpdir"), "ProActive SpaceMountManagerTest");

    if (server == null) {
      server = new FileSystemServerDeployer("inputserver", spacesDir.toString(), true, true);
      System.out.println("Started File Server at " + Arrays.toString(server.getVFSRootURLs()));
    }
  }