flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java
/**
	 * Test receive registration with invalid address from job master
	 */
Test receive registration with invalid address from job master
Test receive registration with invalid address from job master
@Test
	public void testRegisterJobMasterFromInvalidAddress() throws Exception {
		String jobMasterAddress = "/jobMasterAddress1";
		JobID jobID = mockJobMaster(jobMasterAddress);
		TestingLeaderElectionService resourceManagerLeaderElectionService = new TestingLeaderElectionService();
		TestingLeaderRetrievalService jobMasterLeaderRetrievalService = new TestingLeaderRetrievalService(
			"localhost",
			HighAvailabilityServices.DEFAULT_LEADER_ID);
		TestingFatalErrorHandler testingFatalErrorHandler = new TestingFatalErrorHandler();
		final ResourceManager<?> resourceManager = createAndStartResourceManager(resourceManagerLeaderElectionService, jobID, jobMasterLeaderRetrievalService, testingFatalErrorHandler);
		final ResourceManagerGateway rmGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
		final ResourceID jmResourceId = new ResourceID(jobMasterAddress);
		resourceManagerLeaderElectionService.isLeader(UUID.randomUUID()).get();
		String invalidAddress = "/jobMasterAddress2";
		CompletableFuture<RegistrationResponse> invalidAddressFuture = rmGateway.registerJobManager(
			new JobMasterId(HighAvailabilityServices.DEFAULT_LEADER_ID),
			jmResourceId,
			invalidAddress,
			jobID,
			timeout);
		assertTrue(invalidAddressFuture.get(5, TimeUnit.SECONDS) instanceof RegistrationResponse.Decline);
		if (testingFatalErrorHandler.hasExceptionOccurred()) {
			testingFatalErrorHandler.rethrowError();
		}
	}
@ Test public void testRegisterJobMasterFromInvalidAddress ( ) throws Exception { String jobMasterAddress = "/jobMasterAddress1" ; JobID jobID = mockJobMaster ( jobMasterAddress ) ; TestingLeaderElectionService resourceManagerLeaderElectionService = new TestingLeaderElectionService ( ) ; TestingLeaderRetrievalService jobMasterLeaderRetrievalService = new TestingLeaderRetrievalService ( "localhost" , HighAvailabilityServices . DEFAULT_LEADER_ID ) ; TestingFatalErrorHandler testingFatalErrorHandler = new TestingFatalErrorHandler ( ) ; final ResourceManager < ? > resourceManager = createAndStartResourceManager ( resourceManagerLeaderElectionService , jobID , jobMasterLeaderRetrievalService , testingFatalErrorHandler ) ; final ResourceManagerGateway rmGateway = resourceManager . getSelfGateway ( ResourceManagerGateway . class ) ; final ResourceID jmResourceId = new ResourceID ( jobMasterAddress ) ; resourceManagerLeaderElectionService . isLeader ( UUID . randomUUID ( ) ) . get ( ) ; String invalidAddress = "/jobMasterAddress2" ; CompletableFuture < RegistrationResponse > invalidAddressFuture = rmGateway . registerJobManager ( new JobMasterId ( HighAvailabilityServices . DEFAULT_LEADER_ID ) , jmResourceId , invalidAddress , jobID , timeout ) ; assertTrue ( invalidAddressFuture . get ( 5 , TimeUnit . SECONDS ) instanceof RegistrationResponse . Decline ) ; if ( testingFatalErrorHandler . hasExceptionOccurred ( ) ) { testingFatalErrorHandler . rethrowError ( ) ; } }
Test receive registration with invalid address from job master
Test receive registration with invalid address from job master
// wait until the leader election has been completed // test throw exception when receive a registration from job master which takes invalid address