mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
chore: change live preview prob
* chore: change live preview prob * chore: change exit liveroom https://code.byted.org/iesqa/httprunner/merge_requests/33
This commit is contained in:
@@ -154,6 +154,10 @@ type AndroidDevice struct {
|
||||
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
||||
}
|
||||
|
||||
func (dev *AndroidDevice) System() string {
|
||||
return "android"
|
||||
}
|
||||
|
||||
func (dev *AndroidDevice) UUID() string {
|
||||
return dev.SerialNumber
|
||||
}
|
||||
|
||||
@@ -466,7 +466,8 @@ func WithDriverPlugin(plugin funplugin.IPlugin) DriverOption {
|
||||
|
||||
// current implemeted device: IOSDevice, AndroidDevice
|
||||
type Device interface {
|
||||
UUID() string // ios udid or android serial
|
||||
System() string // ios or android
|
||||
UUID() string // ios udid or android serial
|
||||
LogEnabled() bool
|
||||
NewDriver(...DriverOption) (driverExt *DriverExt, err error)
|
||||
|
||||
|
||||
@@ -289,6 +289,10 @@ type IOSDevice struct {
|
||||
pcapFile string // saved pcap file path
|
||||
}
|
||||
|
||||
func (dev *IOSDevice) System() string {
|
||||
return "ios"
|
||||
}
|
||||
|
||||
func (dev *IOSDevice) UUID() string {
|
||||
return dev.UDID
|
||||
}
|
||||
|
||||
@@ -197,6 +197,9 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 直播预览流线上概率
|
||||
livePreviewProb := crawler.getLivePreviewProb()
|
||||
|
||||
switch currentVideo.Type {
|
||||
case VideoType_PreviewLive:
|
||||
// 直播预览流
|
||||
@@ -205,9 +208,8 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
log.Info().Interface("video", currentVideo).
|
||||
Msg("live count achieved, skip entering live room")
|
||||
skipEnterLive = true
|
||||
} else if rand.Float64() <= 0.10 {
|
||||
// 10% chance skip entering live room
|
||||
log.Info().Msg("skip entering preview live by 10% chance")
|
||||
} else if rand.Float64() <= livePreviewProb {
|
||||
log.Info().Interface("livePreviewProb", livePreviewProb).Msg("skip entering preview")
|
||||
skipEnterLive = true
|
||||
}
|
||||
|
||||
@@ -272,9 +274,8 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
log.Info().Interface("live", currentVideo).
|
||||
Msg("live count achieved, exit live room")
|
||||
exitLive = true
|
||||
} else if rand.Float64() <= 0.10 {
|
||||
// 10% chance exit live room
|
||||
log.Info().Msg("exit live room by 10% chance")
|
||||
} else if rand.Float64() <= livePreviewProb {
|
||||
log.Info().Interface("livePreviewProb", livePreviewProb).Msg("exit live room by preview live chance")
|
||||
exitLive = true
|
||||
}
|
||||
if exitLive && currentVideo.Type == VideoType_Live {
|
||||
@@ -427,3 +428,12 @@ func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) {
|
||||
Msg("get current video success")
|
||||
return video, nil
|
||||
}
|
||||
|
||||
func (vc *VideoCrawler) getLivePreviewProb() float64 {
|
||||
if vc.driverExt.Device.System() == "ios" {
|
||||
return 0.5326
|
||||
} else if vc.driverExt.Device.System() == "android" {
|
||||
return 0.3414
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user