Aitozi commented on code in PR #168:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/168#discussion_r854741545


##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/artifact/ArtifactManagerTest.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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.kubernetes.operator.artifact;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.kubernetes.operator.TestUtils;
+import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration;
+import org.apache.flink.kubernetes.operator.config.OperatorConfigOptions;
+import org.apache.flink.util.Preconditions;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.URL;
+import java.nio.file.Path;
+
+/** Test for {@link ArtifactManager}. */
+public class ArtifactManagerTest {
+
+    @TempDir Path tempDir;
+    private ArtifactManager artifactManager;
+
+    @BeforeEach
+    public void setup() {
+        Configuration configuration = new Configuration();
+        configuration.setString(
+                OperatorConfigOptions.OPERATOR_USER_JAR_BASE_DIR,
+                tempDir.toAbsolutePath().toString());
+        artifactManager =
+                new 
ArtifactManager(FlinkOperatorConfiguration.fromConfiguration(configuration));
+    }
+
+    @Test
+    public void testGenerateJarDir() {
+        String baseDir =
+                artifactManager.generateJarDir(
+                        TestUtils.buildSessionCluster(), 
TestUtils.buildSessionJob());
+        String expected =
+                tempDir.toString()
+                        + File.separator
+                        + TestUtils.TEST_NAMESPACE
+                        + File.separator
+                        + TestUtils.TEST_DEPLOYMENT_NAME
+                        + File.separator
+                        + TestUtils.TEST_SESSION_JOB_NAME;
+        Assertions.assertEquals(expected, baseDir);
+    }
+
+    @Test
+    public void testFilesystemFetch() throws Exception {
+        var sourceFile = mockTheJarFile();
+        File file =
+                artifactManager.fetch(
+                        String.format("file://%s", 
sourceFile.getAbsolutePath()),
+                        tempDir.toString());
+        Assertions.assertTrue(file.exists());
+        Assertions.assertEquals(tempDir.toString(), 
file.getParentFile().toString());
+    }
+
+    @Test
+    public void testHttpFetch() throws Exception {
+        HttpServer httpServer = null;
+        try {
+            httpServer = HttpServer.create(new InetSocketAddress(1234), 0);

Review Comment:
   Fixed by start with retry



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to