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:
曹帅
2024-06-04 22:01:20 +08:00
committed by 徐聪
parent 1f64c734d0
commit bc0925b48f
4 changed files with 26 additions and 7 deletions
+4
View File
@@ -154,6 +154,10 @@ type AndroidDevice struct {
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"` LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
} }
func (dev *AndroidDevice) System() string {
return "android"
}
func (dev *AndroidDevice) UUID() string { func (dev *AndroidDevice) UUID() string {
return dev.SerialNumber return dev.SerialNumber
} }
+2 -1
View File
@@ -466,7 +466,8 @@ func WithDriverPlugin(plugin funplugin.IPlugin) DriverOption {
// current implemeted device: IOSDevice, AndroidDevice // current implemeted device: IOSDevice, AndroidDevice
type Device interface { type Device interface {
UUID() string // ios udid or android serial System() string // ios or android
UUID() string // ios udid or android serial
LogEnabled() bool LogEnabled() bool
NewDriver(...DriverOption) (driverExt *DriverExt, err error) NewDriver(...DriverOption) (driverExt *DriverExt, err error)
+4
View File
@@ -289,6 +289,10 @@ type IOSDevice struct {
pcapFile string // saved pcap file path pcapFile string // saved pcap file path
} }
func (dev *IOSDevice) System() string {
return "ios"
}
func (dev *IOSDevice) UUID() string { func (dev *IOSDevice) UUID() string {
return dev.UDID return dev.UDID
} }
+16 -6
View File
@@ -213,6 +213,9 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
continue continue
} }
// 直播预览流线上概率
livePreviewProb := crawler.getLivePreviewProb()
switch currentVideo.Type { switch currentVideo.Type {
case VideoType_PreviewLive: case VideoType_PreviewLive:
isFeed = true isFeed = true
@@ -222,9 +225,8 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
log.Info().Interface("video", currentVideo). log.Info().Interface("video", currentVideo).
Msg("live count achieved, skip entering live room") Msg("live count achieved, skip entering live room")
skipEnterLive = true skipEnterLive = true
} else if rand.Float64() <= 0.50 { } else if rand.Float64() <= livePreviewProb {
// 50% chance skip entering live room log.Info().Interface("livePreviewProb", livePreviewProb).Msg("skip entering preview")
log.Info().Msg("skip entering preview live by 50% chance")
skipEnterLive = true skipEnterLive = true
} }
@@ -288,9 +290,8 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
log.Info().Interface("live", currentVideo). log.Info().Interface("live", currentVideo).
Msg("live count achieved, exit live room") Msg("live count achieved, exit live room")
exitLive = true exitLive = true
} else if rand.Float64() <= 0.50 { } else if rand.Float64() <= livePreviewProb {
// 50% chance exit live room log.Info().Interface("livePreviewProb", livePreviewProb).Msg("exit live room by preview live chance")
log.Info().Msg("exit live room by 10% chance")
exitLive = true exitLive = true
} }
// isFeed:通过预览流进入内流失败的情况下,防止使用退出直播间逻辑,影响:首次进入内流,至少会消费两个直播间才能退出 // isFeed:通过预览流进入内流失败的情况下,防止使用退出直播间逻辑,影响:首次进入内流,至少会消费两个直播间才能退出
@@ -450,3 +451,12 @@ func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) {
Msg("get current video success") Msg("get current video success")
return video, nil 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
}