You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/01/03 15:07:46 UTC

[GitHub] tillrohrmann commented on a change in pull request #7345: [FLINK-11163][tests] Use random port in RestClusterClientTest

tillrohrmann commented on a change in pull request #7345: [FLINK-11163][tests] Use random port in RestClusterClientTest 
URL: https://github.com/apache/flink/pull/7345#discussion_r245025401
 
 

 ##########
 File path: flink-clients/src/test/java/org/apache/flink/client/program/rest/RestClusterClientTest.java
 ##########
 @@ -167,20 +163,25 @@
 	private JobGraph jobGraph;
 	private JobID jobId;
 
-	@Before
-	public void setUp() throws Exception {
-		MockitoAnnotations.initMocks(this);
+	private static final Configuration restConfig;
 
+	static {
 		final Configuration config = new Configuration();
 		config.setString(JobManagerOptions.ADDRESS, "localhost");
 		config.setInteger(RestOptions.RETRY_MAX_ATTEMPTS, 10);
 		config.setLong(RestOptions.RETRY_DELAY, 0);
+		config.setInteger(RestOptions.PORT, 0);
+
+		restConfig = config;
+	}
 
-		restServerEndpointConfiguration = RestServerEndpointConfiguration.fromConfiguration(config);
+	@Before
+	public void setUp() throws Exception {
+		restServerEndpointConfiguration = RestServerEndpointConfiguration.fromConfiguration(restConfig);
 		mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway);
 
 		executor = Executors.newSingleThreadExecutor(new ExecutorThreadFactory(RestClusterClientTest.class.getSimpleName()));
-		final RestClient restClient = new RestClient(RestClientConfiguration.fromConfiguration(config), executor) {
+		restClient = new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
 
 Review comment:
   I think we should only create a `RestClient` if we also create a `RestClusterClient`. Otherwise, we might not properly close the `RestClient` (e.g. in the `testRESTManualConfigurationOverride` test).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services