mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
fix: configure LLMService for UIXTRunner
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-250814
|
v5.0.0-250815
|
||||||
|
|||||||
@@ -35,24 +35,31 @@ type UIXTRunner struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UIXTConfig struct {
|
type UIXTConfig struct {
|
||||||
uixt.DriverCacheConfig
|
uixt.DriverCacheConfig // includes Platform, Serial, AIOptions
|
||||||
|
|
||||||
Ctx context.Context
|
// Runtime context
|
||||||
Cancel context.CancelFunc
|
Ctx context.Context
|
||||||
JSONCase ITestCase
|
Cancel context.CancelFunc `json:"-"`
|
||||||
UIA2 bool // UIAutomator2(Android)
|
|
||||||
LogOn bool // 开启打点日志
|
// Test case configuration
|
||||||
|
JSONCase ITestCase
|
||||||
|
|
||||||
|
// Device specific options
|
||||||
|
UIA2 bool // UIAutomator2(Android)
|
||||||
|
LogOn bool // 开启打点日志
|
||||||
|
WDAPort int // iOS WebDriverAgent port
|
||||||
|
WDAMjpegPort int // iOS WebDriverAgent MJPEG port
|
||||||
|
|
||||||
|
// Agent behavior configuration
|
||||||
Timeout int // seconds
|
Timeout int // seconds
|
||||||
AbortErrors []error // abort errors
|
AbortErrors []error // abort errors
|
||||||
MaxRestartAppCount int // max app restart count
|
MaxRestartAppCount int // max app restart count
|
||||||
MaxRetryCount int // max retry count
|
MaxRetryCount int // max retry count
|
||||||
|
|
||||||
WDAPort int
|
// Backward compatibility fields - legacy API support
|
||||||
WDAMjpegPort int
|
OSType string // deprecated: use Platform from DriverCacheConfig
|
||||||
|
Serial string // deprecated: use Serial from DriverCacheConfig
|
||||||
OSType string // platform
|
LLMService option.LLMServiceType // deprecated: use AIOptions from DriverCacheConfig
|
||||||
Serial string
|
|
||||||
LLMService option.LLMServiceType // LLM 服务类型
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -83,7 +90,7 @@ func NewUIXTRunner(configs *UIXTConfig) (runner *UIXTRunner, err error) {
|
|||||||
}
|
}
|
||||||
config.SetAIOptions(configs.AIOptions...)
|
config.SetAIOptions(configs.AIOptions...)
|
||||||
|
|
||||||
switch configs.OSType {
|
switch configs.Platform {
|
||||||
case "ios":
|
case "ios":
|
||||||
port, err := configs.getWDALocalPort(configs.Serial)
|
port, err := configs.getWDALocalPort(configs.Serial)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -123,7 +130,7 @@ func NewUIXTRunner(configs *UIXTConfig) (runner *UIXTRunner, err error) {
|
|||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
// default to android
|
// default to android
|
||||||
configs.OSType = "android"
|
configs.Platform = "android"
|
||||||
config.SetAndroid(
|
config.SetAndroid(
|
||||||
option.WithSerialNumber(configs.Serial),
|
option.WithSerialNumber(configs.Serial),
|
||||||
option.WithUIA2(configs.UIA2),
|
option.WithUIA2(configs.UIA2),
|
||||||
@@ -144,11 +151,10 @@ func NewUIXTRunner(configs *UIXTConfig) (runner *UIXTRunner, err error) {
|
|||||||
}
|
}
|
||||||
sessionRunner := caseRunner.NewSession()
|
sessionRunner := caseRunner.NewSession()
|
||||||
|
|
||||||
driverCacheConfig := uixt.DriverCacheConfig{
|
// Use configs directly as it inherits DriverCacheConfig
|
||||||
Platform: configs.OSType,
|
driverCacheConfig := configs.DriverCacheConfig
|
||||||
Serial: configs.Serial,
|
driverCacheConfig.AIOptions = config.AIOptions.Options()
|
||||||
AIOptions: config.AIOptions.Options(),
|
|
||||||
}
|
|
||||||
dExt, err := uixt.GetOrCreateXTDriver(driverCacheConfig)
|
dExt, err := uixt.GetOrCreateXTDriver(driverCacheConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "get driver failed")
|
return nil, errors.Wrap(err, "get driver failed")
|
||||||
@@ -181,6 +187,19 @@ func NewUIXTRunner(configs *UIXTConfig) (runner *UIXTRunner, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (configs *UIXTConfig) addDefault() {
|
func (configs *UIXTConfig) addDefault() {
|
||||||
|
// Handle backward compatibility - sync legacy fields to embedded DriverCacheConfig
|
||||||
|
if configs.OSType != "" && configs.Platform == "" {
|
||||||
|
configs.Platform = configs.OSType
|
||||||
|
}
|
||||||
|
if configs.Serial != "" && configs.DriverCacheConfig.Serial == "" {
|
||||||
|
configs.DriverCacheConfig.Serial = configs.Serial
|
||||||
|
}
|
||||||
|
if configs.LLMService != "" && len(configs.AIOptions) == 0 {
|
||||||
|
configs.AIOptions = []option.AIServiceOption{
|
||||||
|
option.WithLLMService(configs.LLMService),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if configs.Ctx == nil {
|
if configs.Ctx == nil {
|
||||||
configs.Ctx = context.Background()
|
configs.Ctx = context.Background()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user