Kaynağa Gözat

删除测试脚本

luojunhui 1 hafta önce
ebeveyn
işleme
20802a2aa4

+ 0 - 152
server/src/main/java/com/tzld/videoVector/MaterialEmbeddingTestRunner.java

@@ -1,152 +0,0 @@
-package com.tzld.videoVector;
-
-import com.tzld.videoVector.job.MaterialVectorJob;
-import com.xxl.job.core.biz.model.ReturnT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Component;
-
-/**
- * 离线测试启动入口(独立 main,不依赖 XXL-Job / Eureka / Apollo)
- * <p>
- * 用途:本地手动跑一次 MaterialVectorJob,验证 AIGC API → material_deconstruct_result → embedding → material_vectors 链路。
- * <p>
- * 启动方式(在项目根目录):
- * <pre>
- *   ./script/run_material_embedding_test.sh        # 默认处理 5 条
- *   ./script/run_material_embedding_test.sh 10     # 处理 10 条
- * </pre>
- * 或在 IDE 中直接 Run 这个类,VM Options 加:
- * <pre>
- *   -Dspring.profiles.active=test-local
- *   -Dembedding.test.maxTaskCount=5
- * </pre>
- * <p>
- * 排除项:
- * <ul>
- *   <li>{@link com.tzld.videoVector.config.XxlJobConfig}:跳过 XxlJob admin 注册</li>
- *   <li>filter / aop / controller 包:避免不必要的 Web 依赖</li>
- *   <li>非 MaterialVectorJob 的其它 Job:避免 @ApolloJsonValue 等无关依赖加载失败</li>
- *   <li>application-test-local.yml 中关闭 Eureka / Apollo</li>
- * </ul>
- */
-@SpringBootApplication
-@ComponentScan(
-        basePackages = "com.tzld.videoVector",
-        excludeFilters = {
-                // 排除主 Application(带 @EnableDiscoveryClient/@EnableFeignClients)
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.Application"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.config\\.XxlJobConfig"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.config\\.AliOssConfig"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.config\\.SwaggerConfig"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.config\\.WebMvcConfig"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.config\\.SchedulingConfig"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.filter\\..*"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.aop\\..*"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.controller\\..*"),
-                // 仅保留 MaterialVectorJob,排除其它 Job(避免 @ApolloJsonValue 等无关依赖)
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.job\\.VideoTitleVectorJob"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.job\\.AiUnderstandingSyncJob"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.job\\.ChannelDemandMatchJob"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.job\\.VideoDetailSyncJob"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.job\\.VideoVectorJob"),
-                // 排除不需要的 Service 实现
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.service\\.impl\\.MaterialSearchServiceImpl"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.service\\.impl\\.VideoSearchServiceImpl"),
-                @ComponentScan.Filter(type = FilterType.REGEX,
-                        pattern = "com\\.tzld\\.videoVector\\.service\\.recall\\..*")
-        }
-)
-public class MaterialEmbeddingTestRunner {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(MaterialEmbeddingTestRunner.class);
-
-    public static void main(String[] args) {
-        if (System.getProperty("spring.profiles.active") == null) {
-            System.setProperty("spring.profiles.active", "test-local");
-        }
-        System.setProperty("spring.main.web-application-type", "none");
-        // 只加载 test-local 配置,跳过 application.yml(含未过滤的 @mavenBuildTime@ 占位符)
-        System.setProperty("spring.config.location", "classpath:/application-test-local.yml");
-
-        ConfigurableApplicationContext ctx = SpringApplication.run(MaterialEmbeddingTestRunner.class, args);
-        LOGGER.info("=========== 测试运行器启动完成,开始执行 MaterialVectorJob ===========");
-        Runtime.getRuntime().addShutdownHook(new Thread(() -> ctx.close()));
-    }
-
-    @Component
-    @Profile("test-local")
-    public static class TestKickoffRunner implements CommandLineRunner {
-
-        private final MaterialVectorJob job;
-        private final org.springframework.core.env.Environment env;
-
-        public TestKickoffRunner(MaterialVectorJob job,
-                                 org.springframework.core.env.Environment env) {
-            this.job = job;
-            this.env = env;
-        }
-
-        @Override
-        public void run(String... args) {
-            try {
-                Integer maxMaterialCount = parseMax(args);
-                LOGGER.info(">>> [TestRunner] 开始执行 MaterialVectorJob.runOnce(maxMaterialCount={})", maxMaterialCount);
-                ReturnT<String> result = job.runOnce(maxMaterialCount);
-                LOGGER.info(">>> [TestRunner] 执行完成,code={}, msg={}",
-                        result == null ? -1 : result.getCode(),
-                        result == null ? null : result.getMsg());
-            } catch (Exception e) {
-                LOGGER.error(">>> [TestRunner] 执行异常: {}", e.getMessage(), e);
-            } finally {
-                LOGGER.info(">>> [TestRunner] 退出 JVM");
-                System.exit(0);
-            }
-        }
-
-        /**
-         * 解析 maxMaterialCount,优先级: 命令行参数 --max=N > -Dembedding.test.maxTaskCount > 默认 5
-         */
-        private Integer parseMax(String[] args) {
-            for (String a : args) {
-                if (a != null && a.startsWith("--max=")) {
-                    try {
-                        return Integer.parseInt(a.substring("--max=".length()).trim());
-                    } catch (NumberFormatException ignored) {
-                    }
-                }
-            }
-            String prop = env.getProperty("embedding.test.maxTaskCount");
-            if (prop != null && !prop.isEmpty()) {
-                try {
-                    return Integer.parseInt(prop.trim());
-                } catch (NumberFormatException ignored) {
-                }
-            }
-            return 5;
-        }
-    }
-}