flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefanobortoli <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-1827] and small fixes in some tests
Date Tue, 26 Apr 2016 07:16:01 GMT
Github user stefanobortoli commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1915#discussion_r61037816
  
    --- Diff: flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskManagerStartupTest.java
---
    @@ -53,41 +59,55 @@ public void testStartupWhenTaskmanagerActorPortIsUsed() {
     			blocker = new ServerSocket(0, 50, localAddress);
     			final int port = blocker.getLocalPort();
     
    -			try {
    -				TaskManager.runTaskManager(
    -					localHostName,
    -					ResourceID.generate(),
    -					port,
    -					new Configuration(),
    +			TaskManager.runTaskManager(localHostName, ResourceID.generate(), port, new Configuration(),
     					TaskManager.class);
    -				fail("This should fail with an IOException");
    -			}
    -			catch (IOException e) {
    -				// expected. validate the error message
    -				assertNotNull(e.getMessage());
    -				assertTrue(e.getMessage().contains("Address already in use"));
    +			fail("This should fail with an IOException");
    +
    +		} catch (IOException e) {
    +			// expected. validate the error messagex
    +			List<Throwable> causes = getExceptionCauses(e, new ArrayList<Throwable>());
    +			for (Throwable cause : causes) {
    +				if (cause instanceof BindException) {
    +					throw (BindException) cause;
    +				}
     			}
    -
    -		}
    -		catch (Exception e) {
    +			fail("This should fail with an exception caused by BindException");
    +		} catch (Exception e) {
     			e.printStackTrace();
     			fail(e.getMessage());
    -		}
    -		finally {
    +		} finally {
     			if (blocker != null) {
     				try {
     					blocker.close();
    -				}
    -				catch (IOException e) {
    +				} catch (IOException e) {
     					// no need to log here
     				}
     			}
     		}
     	}
     
     	/**
    -	 * Tests that the TaskManager startup fails synchronously when the I/O directories are
    -	 * not writable.
    +	 * A utility method to analyze the exceptions and collect the clauses
    +	 * 
    +	 * @param e
    +	 *            the root exception (Throwable) object
    +	 * @param causes
    +	 *            the list of exceptions that caused the root exceptions
    +	 * @return
    +	 */
    +	private List<Throwable> getExceptionCauses(Throwable e, List<Throwable>
causes) {
    --- End diff --
    
    sure I can do that


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message