
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
MaxCompute Emulator是一款轻量级工具,旨在模拟阿里云MaxCompute(原ODPS)服务的行为。它基于SQLite提供模拟环境,供无实际MaxCompute账户的用户测试功能。该工具特别适用于开发和测试场景,可解决MaxCompute资源访问受限或成本约束的问题。
当前项目处于pre-alpha阶段,已实现主要接口,包括但不限于:
1.** SQL相关接口 :支持SQL语句执行等相关操作 2. 表元数据相关接口 :支持表的创建、 schema 获取等元数据操作 3. Tunnel upsert接口 **:支持Tunnel相关的upsert操作
-** 开发环境 :在本地开发时模拟MaxCompute服务,无需连接实际云服务 - 测试场景 :尤其是端到端(e2e)测试,推荐与TestContainers组件结合使用 - 成本敏感场景 :避免因使用实际MaxCompute服务产生的测试成本 - 资源受限场景 **:在无法访问实际MaxCompute账户的环境中进行功能测试
该项目是典型的SpringBoot应用,可通过以下命令直接运行:
bash# 克隆仓库 git clone https://github.com/dingxin-tech/maxcompute-emulator.git # 进入项目目录 cd maxcompute-emulator # 构建项目 ./mvnw install # 运行项目 ./mvnw spring-boot:run
也可直接使用Docker镜像:
bashdocker run -p 8080:8080 maxcompute/maxcompute-emulator:latest
进行端到端测试时,推荐与TestContainers组件结合使用。使用示例如下:
java// 忽略导入 public class MaxComputeEmulatorTest { public static final DockerImageName MAXCOMPUTE_IMAGE = DockerImageName.parse("maxcompute/maxcompute-emulator:v0.0.1"); @ClassRule public static GenericContainer<?> maxcompute = new GenericContainer<>(MAXCOMPUTE_IMAGE) .withExposedPorts(8080) .waitingFor( Wait.forLogMessage(".*Started MaxcomputeEmulatorApplication.*\\n", 1)); public Odps getTestOdps() { Account account = new AliyunAccount("ak", "sk"); Odps odps = new Odps(account); odps.setEndpoint(getEndpoint()); odps.setTunnelEndpoint(getEndpoint()); return odps; } @Test public void test() { Odps odps = getTestOdps(); // 示例:创建表并获取schema Instance instance = SQLTask.run(odps, "create table test(c1 bigint)"); instance.waitForSuccess(); System.out.println(odps.tables().get("test").getSchema()); } private String getEndpoint() { String ip; if (maxcompute.getHost().equals("localhost")) { try { ip = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { ip = "127.0.0.1"; } } else { ip = maxcompute.getHost(); } return "http://" + ip + ":" + maxcompute.getFirstMappedPort(); } }
当使用需要返回当前服务器IP的接口(如Tunnel相关接口)时,服务器默认返回127.0.0.1。但在容器环境中,服务器IP和端口可能随机分配,因此提供了手动上传IP和端口的接口。使用示例如下:
javapublic class MaxComputeEmulatorTest { // 其他代码同上,此处省略 @Test public void test() throws Exception { sendPOST(getEndpoint() + "/init", getEndpoint()); // 其他逻辑 } // 使用Java HTTP客户端发送POST请求,也可使用okhttp等其他HTTP客户端 public static void sendPOST(String postUrl, String postData) throws Exception { URL url = new URL(postUrl); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.setRequestMethod("POST"); httpURLConnection.setDoOutput(true); httpURLConnection.setRequestProperty("Content-Type", "application/json"); httpURLConnection.setRequestProperty("Content-Length", String.valueOf(postData.length())); try (OutputStream outputStream = httpURLConnection.getOutputStream()) { outputStream.write(postData.getBytes("UTF-8")); outputStream.flush(); } int responseCode = httpURLConnection.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK) { throw new RuntimeException("POST请求失败,响应码: " + responseCode); } } }
欢迎为MaxCompute Emulator贡献代码!如想参与项目贡献,请遵循以下步骤:
如遇到任何问题或需要帮助,请在项目的GitHub Issues页面提交issue。
本项目基于[Apache 2.0]许可 - 详见LICENSE文件。
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务