Pārlūkot izejas kodu

update test case in manager

reghao 2 gadi atpakaļ
vecāks
revīzija
05c6fc6e37

+ 13 - 1
manager/src/test/java/AccountTest.java

@@ -2,6 +2,8 @@ import cn.reghao.devops.manager.ManagerApplication;
 import cn.reghao.devops.manager.notification.NotifyService;
 import cn.reghao.devops.manager.notification.notifier.ding.DingMsg;
 import cn.reghao.devops.manager.rbac.service.UserService;
+import cn.reghao.devops.manager.util.ConsulNode;
+import cn.reghao.devops.manager.util.ConsulService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -10,6 +12,8 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.List;
+
 /**
  * @author reghao
  * @date 2022-08-17 15:53:04
@@ -42,7 +46,15 @@ public class AccountTest {
         String text = "应用测试内容";
         DingMsg dingMsg = new DingMsg(title, text);
         notifyService.notify(dingMsg);
-
         Thread.sleep(3600_000);
     }
+
+    @Autowired
+    ConsulService consulService;
+    @Test
+    public void consulTest() {
+        List<ConsulNode> nodes = consulService.getNodes();
+        List<String> serviceIds = consulService.getServices();
+        System.out.println();
+    }
 }

+ 35 - 1
manager/src/test/java/BuildTest.java

@@ -1,6 +1,10 @@
 import cn.reghao.devops.common.build.model.constant.RepoAuthType;
 import cn.reghao.devops.common.build.tool.repo.GitImpl;
+import cn.reghao.devops.common.docker.DockerImpl;
+import cn.reghao.devops.common.ws.WsClient;
 import cn.reghao.devops.manager.app.model.po.config.build.RepoAuthConfig;
+import com.github.dockerjava.api.command.InspectContainerResponse;
+import com.github.dockerjava.api.model.Container;
 import org.junit.Test;
 
 import java.util.List;
@@ -25,11 +29,41 @@ public class BuildTest {
     }
 
     @Test
-    public void dockerTest() {
+    public void dockerListTest() {
         Pattern pattern = Pattern.compile("^\\S*$");
         String str = "dfa   safd";
         String str1 = "dfasafd";
         boolean matched = pattern.matcher(str).matches();
         System.out.println();
     }
+
+    @Test
+    public void dockerBuildTest() throws Exception {
+        DockerImpl docker = new DockerImpl();
+        String repoTag = "file:12345678";
+        String compileHome = "/home/reghao/code/aha/tnb/file/file-service";
+        docker.build(repoTag, compileHome);
+    }
+
+    @Test
+    public void dockerTest() {
+        DockerImpl docker = new DockerImpl();
+        InspectContainerResponse containerInfo = docker.ps("dnkt-admin");
+
+        List<Container> list = docker.ps(true);
+        list.forEach(container -> {
+            container.getId();
+        });
+    }
+
+    @Test
+    public void wsTest() throws InterruptedException {
+        String url = "wss://devops.reghao.cn/ws/log/pull?token=12345678";
+        url = "wss://devops.reghao.cn/ws/message?token=12345678";
+
+        WsClient wsClient = new WsClient(url);
+        wsClient.connect();
+
+        Thread.sleep(3600_000);
+    }
 }

+ 0 - 32
manager/src/test/java/ConsulServiceTest.java

@@ -1,32 +0,0 @@
-import cn.reghao.devops.manager.ManagerApplication;
-import cn.reghao.devops.manager.util.ConsulNode;
-import cn.reghao.devops.manager.util.ConsulService;
-import lombok.extern.slf4j.Slf4j;
-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.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2022-05-25 13:56:07
- */
-@Slf4j
-@ActiveProfiles("dev")
-@SpringBootTest(classes = ManagerApplication.class)
-@RunWith(SpringRunner.class)
-public class ConsulServiceTest {
-    @Autowired
-    ConsulService consulService;
-
-    @Test
-    public void consulTest() {
-        List<ConsulNode> nodes = consulService.getNodes();
-        List<String> serviceIds = consulService.getServices();
-        System.out.println();
-    }
-}

+ 0 - 30
manager/src/test/java/DockerTest.java

@@ -1,30 +0,0 @@
-import cn.reghao.devops.common.docker.DockerImpl;
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import com.github.dockerjava.api.model.Container;
-import org.junit.Test;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2022-08-17 21:51:35
- */
-public class DockerTest {
-    @Test
-    public void buildTest() throws Exception {
-        DockerImpl docker = new DockerImpl();
-        String repoTag = "file:12345678";
-        String compileHome = "/home/reghao/code/aha/tnb/file/file-service";
-        docker.build(repoTag, compileHome);
-    }
-
-    public static void main(String[] args) {
-        DockerImpl docker = new DockerImpl();
-        InspectContainerResponse containerInfo = docker.ps("dnkt-admin");
-
-        List<Container> list = docker.ps(true);
-        list.forEach(container -> {
-            container.getId();
-        });
-    }
-}