[GitHub] GJL commented on a change in pull request #7541: [FLINK-11356][tests] Port JobManagerStartupTest to new code base

2019-01-22 Thread GitBox
GJL commented on a change in pull request #7541: [FLINK-11356][tests] Port 
JobManagerStartupTest to new code base
URL: https://github.com/apache/flink/pull/7541#discussion_r249718882
 
 

 ##
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerTest.java
 ##
 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.blob;
+
+import org.apache.flink.configuration.BlobServerOptions;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.util.OperatingSystem;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import javax.annotation.Nonnull;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+/**
+ * Tests for the {@link BlobServer}.
+ */
+public class BlobServerTest extends TestLogger {
+
+   @ClassRule
+   public static TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+   /**
+* Tests that the {@link BlobServer} fails if the blob storage directory
+* cannot be created.
+*/
+   @Test
+   public void testFailureIfStorageDirectoryCannotBeCreated() throws 
IOException {
+   assumeTrue(!OperatingSystem.isWindows()); //setWritable doesn't 
work on Windows.
 
 Review comment:
   I would prefer to move the _assumption_ closer to 
`createNonWritableDirectory`. This makes the comment clearer. Also consider 
`assumeFalse` as `!` can be overlooked.
   ```suggestion
assumeFalse(OperatingSystem.isWindows()); //setWritable doesn't 
work on Windows.
final File blobStorageDirectory = createNonWritableDirectory();
   
final Configuration configuration = new Configuration();
final String nonExistDirectory = new File(blobStorageDirectory, 
"does_not_exist_for_sure").getAbsolutePath();
configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, 
nonExistDirectory);
   ```


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] GJL commented on a change in pull request #7541: [FLINK-11356][tests] Port JobManagerStartupTest to new code base

2019-01-22 Thread GitBox
GJL commented on a change in pull request #7541: [FLINK-11356][tests] Port 
JobManagerStartupTest to new code base
URL: https://github.com/apache/flink/pull/7541#discussion_r249714551
 
 

 ##
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/BootstrapToolsTest.java
 ##
 @@ -360,4 +368,32 @@ public void testConcurrentActorSystemCreation() throws 
Exception {
ExecutorUtils.gracefulShutdown(1L, 
TimeUnit.MILLISECONDS, executorService);
}
}
+
+   /**
+* Tests that the {@link ActorSystem} fails with an expressive 
exception if it cannot be
+* instantiated due to an occupied port.
+*/
+   @Test
+   public void testActorSystemInstantiationFailureWhenPortOccupied() 
throws Exception {
+   ServerSocket portOccupier;
+   final int port;
+
+   try {
+   port = NetUtils.getAvailablePort();
+   portOccupier = new ServerSocket(port, 10, 
InetAddress.getByName("0.0.0.0"));
+   }
+   catch (Throwable t) {
+   // could not find free port, or open a connection there
 
 Review comment:
   It's acceptable to silently fail if we cannot open a socket?


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:
us...@infra.apache.org


With regards,
Apache Git Services