From d9bbdbb3aef7528dc942798bf7e22158767bd282 Mon Sep 17 00:00:00 2001 From: gongwenxin Date: Tue, 19 Aug 2025 18:26:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E7=9C=9F=E5=AE=9Ewell=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_stages/dms_crud_scenario_stage.py | 52 +++++++++--------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/custom_stages/dms_crud_scenario_stage.py b/custom_stages/dms_crud_scenario_stage.py index e1738c5..9653aa3 100644 --- a/custom_stages/dms_crud_scenario_stage.py +++ b/custom_stages/dms_crud_scenario_stage.py @@ -370,20 +370,7 @@ class DmsCrudScenarioStage(BaseAPIStage): for pk_field, pk_val in all_pk_values.items(): create_payload[pk_field] = pk_val - # 🔑 关键修复:LLM生成的数据也需要井数据增强 - if hasattr(self, 'orchestrator') and hasattr(self.orchestrator, 'well_data_manager') and self.orchestrator.well_data_manager: - create_payload = self.orchestrator.well_data_manager.enhance_data_with_well_values(create_payload) - self.logger.info(f"LLM生成数据已通过井数据管理器增强") - self.logger.info(f"LLM成功生成智能测试数据: {create_payload}") - - # 🔑 关键修复:预构建请求体,避免测试编排器重新生成数据 - stage_context["create_request_body"] = { - "version": "1.0.0", - "act": -1, - "data": [create_payload] - } - self.logger.info(f"预构建创建请求体完成") else: self.logger.warning("LLM生成的数据格式不符合预期,回退到传统数据生成") raise ValueError("LLM数据格式无效") @@ -423,32 +410,23 @@ class DmsCrudScenarioStage(BaseAPIStage): else: self.logger.warning("No create schema found. Falling back to a minimal payload.") + # 🔑 关键修复:应用井数据增强到创建数据 + if hasattr(self, 'orchestrator') and hasattr(self.orchestrator, 'well_data_manager') and self.orchestrator.well_data_manager: + create_payload = self.orchestrator.well_data_manager.enhance_data_with_well_values(create_payload) + self.logger.info(f"创建数据已通过井数据管理器增强") + # 更新负载基于创建负载,但修改描述字段 update_payload = copy.deepcopy(create_payload) update_payload["description"] = "updated-test-entry-from-scenario" - # 🔑 关键修复:预构建请求体,避免测试编排器重新生成数据 - create_request_body = { - "version": "1.0.0", - "act": -1, - "data": [create_payload] - } - - update_request_body = { - "version": "1.0.0", - "act": -1, - "data": [update_payload] - } - - self.logger.info(f"预构建创建和更新请求体完成") + self.logger.info(f"井数据增强后的创建数据: {create_payload}") + self.logger.info(f"井数据增强后的更新数据: {update_payload}") # Populate stage context stage_context["pk_name"] = pk_name stage_context["pk_value"] = pk_value stage_context["current_payload"] = create_payload stage_context["update_payload"] = update_payload - stage_context["create_request_body"] = create_request_body - stage_context["update_request_body"] = update_request_body stage_context["scenario_endpoints"] = current_scenario # Pre-build the delete body to avoid key-templating issues later @@ -506,8 +484,12 @@ class DmsCrudScenarioStage(BaseAPIStage): endpoint_spec_lookup_key="CREATE", request_overrides={ # DMS标准格式:包含version、act和data字段 - # 使用预生成的数据,避免测试编排器重新生成 - "body": "{{stage_context.create_request_body}}" + # 直接使用预构建的请求体,避免测试编排器重新生成 + "body": { + "version": "1.0.0", + "act": -1, + "data": ["{{stage_context.current_payload}}"] + } }, response_assertions=[validate_response_is_true], outputs_to_context={} @@ -526,8 +508,12 @@ class DmsCrudScenarioStage(BaseAPIStage): endpoint_spec_lookup_key="UPDATE", request_overrides={ # DMS标准格式:包含version、act和data字段 - # 使用预生成的数据,避免测试编排器重新生成 - "body": "{{stage_context.update_request_body}}" + # 直接使用预构建的请求体,避免测试编排器重新生成 + "body": { + "version": "1.0.0", + "act": -1, + "data": ["{{stage_context.update_payload}}"] + } }, response_assertions=[validate_response_is_true] ),