add 真实well数据覆盖
This commit is contained in:
parent
4875a68f1c
commit
75d42b7aab
@ -534,6 +534,33 @@ class APITestOrchestrator:
|
|||||||
else:
|
else:
|
||||||
self.logger.info("No stages_dir provided, stage testing will be skipped.")
|
self.logger.info("No stages_dir provided, stage testing will be skipped.")
|
||||||
|
|
||||||
|
# 完成其他初始化
|
||||||
|
self.output_dir_path = Path(output_dir) if output_dir else Path("./test_reports_orchestrator")
|
||||||
|
try:
|
||||||
|
self.output_dir_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
self.logger.info(f"Orchestrator output directory set to: {self.output_dir_path.resolve()}")
|
||||||
|
except OSError as e:
|
||||||
|
self.logger.warning(f"Could not create orchestrator output directory {self.output_dir_path}: {e}. Falling back to current directory.")
|
||||||
|
self.output_dir_path = Path(".")
|
||||||
|
|
||||||
|
self.schema_cache: Dict[str, Type[BaseModel]] = {}
|
||||||
|
self.model_name_counts: Dict[str, int] = defaultdict(int)
|
||||||
|
self.parser = InputParser()
|
||||||
|
self.json_resolver_cache: Dict[str, Any] = {}
|
||||||
|
self.json_validator = JSONSchemaValidator()
|
||||||
|
|
||||||
|
# 将字符串类型的 strictness_level 转换为 TestSeverity 枚举成员
|
||||||
|
self.strictness_level: Optional[TestSeverity] = None
|
||||||
|
if strictness_level and hasattr(TestSeverity, strictness_level):
|
||||||
|
self.strictness_level = TestSeverity[strictness_level]
|
||||||
|
logging.info(f"strictness_level: {self.strictness_level}")
|
||||||
|
elif strictness_level:
|
||||||
|
logging.warning(f"提供了无效的严格等级 '{strictness_level}'。将使用默认行为。有效值: {', '.join([e.name for e in TestSeverity])}")
|
||||||
|
|
||||||
|
# 将这些属性的初始化移到此处,并设为None,避免在_execute_tests_from_parsed_spec之前被错误使用
|
||||||
|
self.json_schema_validator: Optional[JSONSchemaValidator] = None
|
||||||
|
self.schema_provider: Optional[SchemaProvider] = None
|
||||||
|
|
||||||
def initialize_well_data(self) -> bool:
|
def initialize_well_data(self) -> bool:
|
||||||
"""
|
"""
|
||||||
初始化井数据,在测试开始前获取真实的井和井筒数据
|
初始化井数据,在测试开始前获取真实的井和井筒数据
|
||||||
@ -555,37 +582,6 @@ class APITestOrchestrator:
|
|||||||
self.logger.error(f"井数据初始化失败: {e}")
|
self.logger.error(f"井数据初始化失败: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _complete_initialization(self, output_dir: Optional[str], strictness_level: Optional[str]):
|
|
||||||
"""完成初始化过程"""
|
|
||||||
self.output_dir_path = Path(output_dir) if output_dir else Path("./test_reports_orchestrator")
|
|
||||||
try:
|
|
||||||
self.output_dir_path.mkdir(parents=True, exist_ok=True)
|
|
||||||
self.logger.info(f"Orchestrator output directory set to: {self.output_dir_path.resolve()}")
|
|
||||||
except OSError as e:
|
|
||||||
self.logger.warning(f"Could not create orchestrator output directory {self.output_dir_path}: {e}. Falling back to current directory.")
|
|
||||||
self.output_dir_path = Path(".")
|
|
||||||
|
|
||||||
self.schema_cache: Dict[str, Type[BaseModel]] = {}
|
|
||||||
self.model_name_counts: Dict[str, int] = defaultdict(int)
|
|
||||||
self.parser = InputParser()
|
|
||||||
self.json_resolver_cache: Dict[str, Any] = {}
|
|
||||||
self.json_validator = JSONSchemaValidator()
|
|
||||||
|
|
||||||
# 将字符串类型的 strictness_level 转换为 TestSeverity 枚举成员
|
|
||||||
self.strictness_level: Optional[TestSeverity] = None
|
|
||||||
if strictness_level and hasattr(TestSeverity, strictness_level):
|
|
||||||
self.strictness_level = TestSeverity[strictness_level]
|
|
||||||
logging.info(f"strictness_level: {self.strictness_level}")
|
|
||||||
elif strictness_level:
|
|
||||||
logging.warning(f"提供了无效的严格等级 '{strictness_level}'。将使用默认行为。有效值: {', '.join([e.name for e in TestSeverity])}")
|
|
||||||
|
|
||||||
# 将这些属性的初始化移到此处,并设为None,避免在_execute_tests_from_parsed_spec之前被错误使用
|
|
||||||
self.json_schema_validator: Optional[JSONSchemaValidator] = None
|
|
||||||
self.schema_provider: Optional[SchemaProvider] = None
|
|
||||||
|
|
||||||
# 完成初始化
|
|
||||||
self._complete_initialization(output_dir, strictness_level)
|
|
||||||
|
|
||||||
def get_api_call_details(self) -> List[APICallDetail]:
|
def get_api_call_details(self) -> List[APICallDetail]:
|
||||||
"""Returns the collected list of API call details."""
|
"""Returns the collected list of API call details."""
|
||||||
return self.global_api_call_details
|
return self.global_api_call_details
|
||||||
|
|||||||
@ -14,10 +14,11 @@
|
|||||||
- **错误处理**: 当井数据获取失败时,自动回退到模拟数据
|
- **错误处理**: 当井数据获取失败时,自动回退到模拟数据
|
||||||
|
|
||||||
### 支持的字段
|
### 支持的字段
|
||||||
- `wellId` / `well_id` - 井ID
|
- `wellId` - 井ID(严格匹配字段名)
|
||||||
- `wellboreId` / `wellbore_id` - 井筒ID
|
- `wellboreId` - 井筒ID(严格匹配字段名)
|
||||||
- `wellCommonName` / `well_common_name` - 井通用名称
|
- `wellCommonName` - 井通用名称(严格匹配字段名)
|
||||||
- `wellboreCommonName` / `wellbore_common_name` - 井筒通用名称
|
|
||||||
|
> **注意**: 字段名称严格按照DMS接口规范,不支持变体命名(如well_id、WELL_ID等)
|
||||||
|
|
||||||
## 🏗️ 架构设计
|
## 🏗️ 架构设计
|
||||||
|
|
||||||
|
|||||||
73
test_orchestrator_init.py
Normal file
73
test_orchestrator_init.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
测试APITestOrchestrator初始化的脚本
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
from ddms_compliance_suite.test_orchestrator import APITestOrchestrator
|
||||||
|
|
||||||
|
def test_orchestrator_initialization():
|
||||||
|
"""测试APITestOrchestrator的初始化"""
|
||||||
|
|
||||||
|
# 设置日志
|
||||||
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
logger.info("开始测试APITestOrchestrator初始化...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 初始化编排器
|
||||||
|
orchestrator = APITestOrchestrator(
|
||||||
|
base_url="https://www.dev.ideas.cnpc",
|
||||||
|
strictness_level="CRITICAL",
|
||||||
|
ignore_ssl=True,
|
||||||
|
enable_well_data=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# 检查关键属性是否正确初始化
|
||||||
|
logger.info("✅ APITestOrchestrator初始化成功")
|
||||||
|
|
||||||
|
# 检查strictness_level属性
|
||||||
|
if hasattr(orchestrator, 'strictness_level'):
|
||||||
|
logger.info(f"✅ strictness_level属性存在: {orchestrator.strictness_level}")
|
||||||
|
else:
|
||||||
|
logger.error("❌ strictness_level属性不存在")
|
||||||
|
return False
|
||||||
|
|
||||||
|
# 检查井数据管理器
|
||||||
|
if hasattr(orchestrator, 'well_data_manager'):
|
||||||
|
if orchestrator.well_data_manager:
|
||||||
|
logger.info("✅ 井数据管理器已初始化")
|
||||||
|
else:
|
||||||
|
logger.info("ℹ️ 井数据管理器未启用")
|
||||||
|
else:
|
||||||
|
logger.error("❌ well_data_manager属性不存在")
|
||||||
|
return False
|
||||||
|
|
||||||
|
# 检查其他关键属性
|
||||||
|
required_attrs = [
|
||||||
|
'base_url', 'api_caller', 'test_case_registry',
|
||||||
|
'global_api_call_details', 'ignore_ssl', 'llm_config',
|
||||||
|
'output_dir_path', 'schema_cache', 'parser'
|
||||||
|
]
|
||||||
|
|
||||||
|
for attr in required_attrs:
|
||||||
|
if hasattr(orchestrator, attr):
|
||||||
|
logger.info(f"✅ {attr}属性存在")
|
||||||
|
else:
|
||||||
|
logger.error(f"❌ {attr}属性不存在")
|
||||||
|
return False
|
||||||
|
|
||||||
|
logger.info("🎉 所有属性检查通过")
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"❌ APITestOrchestrator初始化失败: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
success = test_orchestrator_initialization()
|
||||||
|
sys.exit(0 if success else 1)
|
||||||
Loading…
x
Reference in New Issue
Block a user