static TransferResult uploadImageFromStorage(URL fsName,
      Configuration conf, NNStorage storage, NameNodeFile nnf, long txid)
      throws IOException {
    return uploadImageFromStorage(fsName, conf, storage, nnf, txid, null);
  }
@Test(timeout = 10000)
  public void testImageUploadTimeout() throws Exception {
    Configuration conf = new HdfsConfiguration();
    NNStorage mockStorage = Mockito.mock(NNStorage.class);
    HttpServer2 testServer = HttpServerFunctionalTest.createServer("hdfs");
    try {
      testServer.addServlet("ImageTransfer", ImageServlet.PATH_SPEC,
          TestImageTransferServlet.class);
      testServer.start();
      URL serverURL = HttpServerFunctionalTest.getServerURL(testServer);
      // set the timeout here, otherwise it will take default.
      TransferFsImage.timeout = 2000;

      File tmpDir = new File(new FileSystemTestHelper().getTestRootDir());
      tmpDir.mkdirs();

      File mockImageFile = File.createTempFile("image", "", tmpDir);
      FileOutputStream imageFile = new FileOutputStream(mockImageFile);
      imageFile.write("data".getBytes());
      imageFile.close();
      Mockito.when(
          mockStorage.findImageFile(Mockito.any(NameNodeFile.class),
              Mockito.anyLong())).thenReturn(mockImageFile);
      Mockito.when(mockStorage.toColonSeparatedString()).thenReturn(
          "storage:info:string");
      
      try {
        TransferFsImage.uploadImageFromStorage(serverURL, conf, mockStorage,
            NameNodeFile.IMAGE, 1L);
        fail("TransferImage Should fail with timeout");
      } catch (SocketTimeoutException e) {
        assertEquals("Upload should timeout", "Read timed out", e.getMessage());
      }
    } finally {
      testServer.stop();
    }
  }