You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2022/09/16 05:44:43 UTC

[incubator-streampark] branch dev updated: [Hotfix] Re-arrange the test package structure of streampark-console-service. (#1606)

This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new 1af85af56 [Hotfix] Re-arrange the test package structure of streampark-console-service. (#1606)
1af85af56 is described below

commit 1af85af56d22d830561ecb6c98f85efd8064e2eb
Author: Roc Marshal <fl...@126.com>
AuthorDate: Fri Sep 16 13:44:35 2022 +0800

    [Hotfix] Re-arrange the test package structure of streampark-console-service. (#1606)
---
 .../src/test/java/StreamParkConsoleTest.java       | 47 -----------------
 .../src/test/java/YarnTest.java                    | 60 ----------------------
 .../benmanes/caffeine/cache/RefreshCacheTest.java} | 39 +++++++-------
 .../util/concurrent}/CompletableFutureTest.java    |  6 +--
 .../test/java/{ => java/util/regex}/RegexTest.java |  4 +-
 .../apache/commons/mail}/SendEmailTest.java        |  4 +-
 .../console/core/entity}/DependencyTest.java       |  5 +-
 .../streampark/console/core/entity}/GitTest.java   |  3 +-
 .../console/core/enums}/AlertTypeTest.java         |  2 +-
 .../core/service}/ApplicationServiceTest.java      | 17 +++++-
 .../core/service/alert}/AlertServiceTest.java      |  7 ++-
 .../console/system/authentication}/JWTTest.java    |  4 +-
 12 files changed, 55 insertions(+), 143 deletions(-)

diff --git a/streampark-console/streampark-console-service/src/test/java/StreamParkConsoleTest.java b/streampark-console/streampark-console-service/src/test/java/StreamParkConsoleTest.java
deleted file mode 100644
index 6d04abaf7..000000000
--- a/streampark-console/streampark-console-service/src/test/java/StreamParkConsoleTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-import org.apache.streampark.console.StreamParkConsoleBootstrap;
-import org.apache.streampark.console.core.entity.Application;
-import org.apache.streampark.console.core.service.ApplicationService;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = StreamParkConsoleBootstrap.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class StreamParkConsoleTest {
-
-    @Autowired
-    private ApplicationService applicationService;
-
-    @Test
-    public void start() throws Exception {
-        Application application = new Application();
-        application.setId(1304056220683497473L);
-        application.setFlameGraph(false);
-        application.setRestart(false);
-        application.setSavePointed(false);
-        application.setAllowNonRestored(false);
-
-        applicationService.start(application, false);
-    }
-
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/YarnTest.java b/streampark-console/streampark-console-service/src/test/java/YarnTest.java
deleted file mode 100644
index 29451ef3e..000000000
--- a/streampark-console/streampark-console-service/src/test/java/YarnTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-
-import org.apache.streampark.common.util.HadoopUtils;
-import org.apache.streampark.common.util.PropertiesUtils;
-import org.apache.streampark.common.util.YarnUtils;
-
-import org.apache.hadoop.yarn.api.records.NodeState;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-public class YarnTest {
-
-    @Test
-    public void vcore() throws IOException, YarnException {
-        int numYarnMaxVcores = HadoopUtils.yarnClient().getNodeReports(NodeState.RUNNING)
-            .stream()
-            .mapToInt(report -> report.getCapability().getVirtualCores())
-            .max()
-            .orElse(0);
-        System.out.println(numYarnMaxVcores);
-    }
-
-    @Test
-    public void getURL() {
-        /**
-         * 将hadoop的配置文件放到一个目录下,
-         * 在运行该类的时候加上jvm级别的参数(idea里的 vmOption ) -DHADOOP_CONF_DIR=${目录}
-         */
-        String url = YarnUtils.getRMWebAppURL();
-        System.out.println(url);
-    }
-
-    @Test
-    public void loadFlinkYaml() {
-        String path = System.getenv("FLINK_HOME").concat("/conf/flink-conf.yaml");
-        File yaml = new File(path);
-        Map<String, String> map = PropertiesUtils.loadFlinkConfYaml(yaml);
-        System.out.println(map.size());
-    }
-
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/GitTest.java b/streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java
similarity index 54%
copy from streampark-console/streampark-console-service/src/test/java/GitTest.java
copy to streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java
index 647627bc7..31386b927 100644
--- a/streampark-console/streampark-console-service/src/test/java/GitTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java
@@ -15,33 +15,34 @@
  * limitations under the License.
  */
 
-import org.apache.streampark.console.core.entity.Project;
-import org.apache.streampark.console.core.enums.GitAuthorizedError;
+package com.github.benmanes.caffeine.cache;
 
-import org.junit.Before;
 import org.junit.Test;
 
-import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
-public class GitTest {
+public class RefreshCacheTest {
 
-    private Project project = new Project();
-
-    @Before
-    public void before() {
-        project.setUrl("https://github.com/streamxhub/streampark-quickstart");
-    }
+    Cache<String, String> caffeine = null;
 
     @Test
-    public void getBranchs() {
-        List<String> branches =  project.getAllBranches();
-        branches.forEach(System.out::println);
+    public void cache() throws Exception {
+        if (caffeine == null) {
+            caffeine = Caffeine.newBuilder()
+                .refreshAfterWrite(50, TimeUnit.MILLISECONDS)
+                .build(this::refresh);
+        }
+        caffeine.put("config", "hadoop");
+        int count = 4;
+        while (count > 0) {
+            System.out.println(caffeine.getIfPresent("config"));
+            Thread.sleep(100L);
+            --count;
+        }
     }
 
-    @Test
-    public void auth() {
-        GitAuthorizedError error =  project.gitCheck();
-        System.out.println(error);
+    public String refresh(String value) {
+        return UUID.randomUUID() + "@" + value;
     }
-
 }
diff --git a/streampark-console/streampark-console-service/src/test/java/CompletableFutureTest.java b/streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java
similarity index 96%
rename from streampark-console/streampark-console-service/src/test/java/CompletableFutureTest.java
rename to streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java
index 0637e4d38..61dca2cb3 100644
--- a/streampark-console/streampark-console-service/src/test/java/CompletableFutureTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+package java.util.concurrent;
+
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
@@ -22,10 +24,6 @@ import org.apache.streampark.common.util.CompletableFutureUtils;
 
 import org.junit.Test;
 
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 public class CompletableFutureTest {
diff --git a/streampark-console/streampark-console-service/src/test/java/RegexTest.java b/streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java
similarity index 98%
rename from streampark-console/streampark-console-service/src/test/java/RegexTest.java
rename to streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java
index fe6ab06d1..74e3bb20f 100644
--- a/streampark-console/streampark-console-service/src/test/java/RegexTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+package java.util.regex;
+
 import org.apache.streampark.common.util.CommandUtils;
 
 import org.junit.Test;
@@ -26,8 +28,6 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 public class RegexTest {
diff --git a/streampark-console/streampark-console-service/src/test/java/SendEmailTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java
similarity index 98%
rename from streampark-console/streampark-console-service/src/test/java/SendEmailTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java
index dcc72debc..1b9799725 100644
--- a/streampark-console/streampark-console-service/src/test/java/SendEmailTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+package org.apache.commons.mail;
+
 import org.apache.streampark.common.util.DateUtils;
 import org.apache.streampark.common.util.YarnUtils;
 import org.apache.streampark.console.base.util.FreemarkerUtils;
@@ -24,8 +26,6 @@ import org.apache.streampark.console.core.entity.Application;
 import org.apache.streampark.console.core.enums.FlinkAppState;
 
 import freemarker.template.Template;
-import org.apache.commons.mail.EmailException;
-import org.apache.commons.mail.HtmlEmail;
 import org.junit.Before;
 import org.junit.Test;
 
diff --git a/streampark-console/streampark-console-service/src/test/java/DependencyTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java
similarity index 96%
rename from streampark-console/streampark-console-service/src/test/java/DependencyTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java
index f6786d0b9..524b72373 100644
--- a/streampark-console/streampark-console-service/src/test/java/DependencyTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java
@@ -15,8 +15,9 @@
  * limitations under the License.
  */
 
+package org.apache.streampark.console.core.entity;
+
 import org.apache.streampark.common.util.DependencyUtils;
-import org.apache.streampark.console.core.entity.Application;
 
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
@@ -33,7 +34,7 @@ import scala.collection.JavaConversions;
 public class DependencyTest {
 
     @Test
-    public void resolveMavenDependencies() throws Throwable {
+    public void resolveMavenDependencies() {
         /**
          * <dependency>
          *      <groupId>org.apache.flink</groupId>
diff --git a/streampark-console/streampark-console-service/src/test/java/GitTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java
similarity index 96%
rename from streampark-console/streampark-console-service/src/test/java/GitTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java
index 647627bc7..06c48f5b5 100644
--- a/streampark-console/streampark-console-service/src/test/java/GitTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java
@@ -15,7 +15,8 @@
  * limitations under the License.
  */
 
-import org.apache.streampark.console.core.entity.Project;
+package org.apache.streampark.console.core.entity;
+
 import org.apache.streampark.console.core.enums.GitAuthorizedError;
 
 import org.junit.Before;
diff --git a/streampark-console/streampark-console-service/src/test/java/AlertTypeTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/enums/AlertTypeTest.java
similarity index 95%
rename from streampark-console/streampark-console-service/src/test/java/AlertTypeTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/enums/AlertTypeTest.java
index bfadb209f..d0c02b2c4 100644
--- a/streampark-console/streampark-console-service/src/test/java/AlertTypeTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/enums/AlertTypeTest.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-import org.apache.streampark.console.core.enums.AlertType;
+package org.apache.streampark.console.core.enums;
 
 import org.junit.jupiter.api.Test;
 
diff --git a/streampark-console/streampark-console-service/src/test/java/ApplicationServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java
similarity index 84%
rename from streampark-console/streampark-console-service/src/test/java/ApplicationServiceTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java
index e27e2fabc..379e31810 100644
--- a/streampark-console/streampark-console-service/src/test/java/ApplicationServiceTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java
@@ -15,9 +15,10 @@
  * limitations under the License.
  */
 
+package org.apache.streampark.console.core.service;
+
 import org.apache.streampark.console.StreamParkConsoleBootstrap;
 import org.apache.streampark.console.core.entity.Application;
-import org.apache.streampark.console.core.service.ApplicationService;
 
 import org.junit.Test;
 import org.junit.jupiter.api.Assertions;
@@ -29,7 +30,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import java.util.Date;
 
 /**
- * ApplicationServiceTest
+ * org.apache.streampark.console.core.service.ApplicationServiceTest
  */
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = StreamParkConsoleBootstrap.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -76,4 +77,16 @@ public class ApplicationServiceTest {
         Assertions.assertDoesNotThrow(() -> applicationService.updateLaunch(app));
     }
 
+    @Test
+    public void start() throws Exception {
+        Application application = new Application();
+        application.setId(1304056220683497473L);
+        application.setFlameGraph(false);
+        application.setRestart(false);
+        application.setSavePointed(false);
+        application.setAllowNonRestored(false);
+
+        applicationService.start(application, false);
+    }
+
 }
diff --git a/streampark-console/streampark-console-service/src/test/java/AlertServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java
similarity index 96%
rename from streampark-console/streampark-console-service/src/test/java/AlertServiceTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java
index 5a1df8093..6c4896894 100644
--- a/streampark-console/streampark-console-service/src/test/java/AlertServiceTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java
@@ -14,6 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+package org.apache.streampark.console.core.service.alert;
+
 import org.apache.streampark.common.util.DateUtils;
 import org.apache.streampark.console.core.bean.AlertConfigWithParams;
 import org.apache.streampark.console.core.bean.AlertDingTalkParams;
@@ -58,7 +61,7 @@ public class AlertServiceTest {
 
     public void before2() {
         alertTemplate = new AlertTemplate();
-        alertTemplate.setTitle("告警: StreamPark alert job for test");
+        alertTemplate.setTitle("Alert: StreamPark alert job for test");
         alertTemplate.setSubject("StreamPark Alert: test-job OTHER");
         alertTemplate.setJobName("StreamPark alert job for test");
         alertTemplate.setLink("http://127.0.0.1:8080");
@@ -103,7 +106,7 @@ public class AlertServiceTest {
     }
 
     @Test
-    public void larkAlertTest() throws Exception {
+    public void larkAlertTest() {
         LarkAlertNotifyServiceImpl notifyService = new LarkAlertNotifyServiceImpl(restTemplate, mapper);
         notifyService.loadTemplateFile();
 
diff --git a/streampark-console/streampark-console-service/src/test/java/JWTTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java
similarity index 96%
rename from streampark-console/streampark-console-service/src/test/java/JWTTest.java
rename to streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java
index 71aafd91a..8ac7d28f6 100644
--- a/streampark-console/streampark-console-service/src/test/java/JWTTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java
@@ -14,8 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+package org.apache.streampark.console.system.authentication;
+
 import org.apache.streampark.common.util.DateUtils;
-import org.apache.streampark.console.system.authentication.JWTUtil;
 import org.apache.streampark.console.system.entity.AccessToken;
 
 import com.auth0.jwt.JWT;