mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 21:39:41 +08:00
feat: report GA4 events for hrp cmd
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
**go version**
|
**go version**
|
||||||
|
|
||||||
|
- feat: report GA4 events for hrp cmd
|
||||||
- change: create python venv with httprunner minimum version v4.3.5
|
- change: create python venv with httprunner minimum version v4.3.5
|
||||||
- fix #1603: ensure path suffix '/' exists
|
- fix #1603: ensure path suffix '/' exists
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (b *HRPBoomer) Run(testcases ...ITestCase) {
|
|||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
// report boom event
|
// report boom event
|
||||||
sdk.SendGA4Event("hrp_boom", map[string]interface{}{
|
sdk.SendGA4Event("hrp_boomer_run", map[string]interface{}{
|
||||||
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
13
hrp/build.go
13
hrp/build.go
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -172,6 +173,12 @@ func (pt *pluginTemplate) generateGo(output string) error {
|
|||||||
// buildGo builds debugtalk.go to debugtalk.bin
|
// buildGo builds debugtalk.go to debugtalk.bin
|
||||||
func buildGo(path string, output string) error {
|
func buildGo(path string, output string) error {
|
||||||
log.Info().Str("path", path).Str("output", output).Msg("start to build go plugin")
|
log.Info().Str("path", path).Str("output", output).Msg("start to build go plugin")
|
||||||
|
|
||||||
|
// report GA event
|
||||||
|
sdk.SendGA4Event("hrp_build_plugin", map[string]interface{}{
|
||||||
|
"pluginType": "go",
|
||||||
|
})
|
||||||
|
|
||||||
content, err := os.ReadFile(path)
|
content, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("failed to read file")
|
log.Error().Err(err).Msg("failed to read file")
|
||||||
@@ -197,6 +204,12 @@ func buildGo(path string, output string) error {
|
|||||||
// buildPy completes funppy information in debugtalk.py
|
// buildPy completes funppy information in debugtalk.py
|
||||||
func buildPy(path string, output string) error {
|
func buildPy(path string, output string) error {
|
||||||
log.Info().Str("path", path).Str("output", output).Msg("start to prepare python plugin")
|
log.Info().Str("path", path).Str("output", output).Msg("start to prepare python plugin")
|
||||||
|
|
||||||
|
// report GA event
|
||||||
|
sdk.SendGA4Event("hrp_build_plugin", map[string]interface{}{
|
||||||
|
"pluginType": "python",
|
||||||
|
})
|
||||||
|
|
||||||
// check the syntax of debugtalk.py
|
// check the syntax of debugtalk.py
|
||||||
err := myexec.ExecPython3Command("py_compile", path)
|
err := myexec.ExecPython3Command("py_compile", path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +21,16 @@ func format(data map[string]string) string {
|
|||||||
var listAndroidDevicesCmd = &cobra.Command{
|
var listAndroidDevicesCmd = &cobra.Command{
|
||||||
Use: "devices",
|
Use: "devices",
|
||||||
Short: "List all Android devices",
|
Short: "List all Android devices",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_adb_devices", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
deviceList, err := uixt.GetAndroidDevices(serial)
|
deviceList, err := uixt.GetAndroidDevices(serial)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|||||||
@@ -3,16 +3,28 @@ package adb
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var screencapAndroidDevicesCmd = &cobra.Command{
|
var screencapAndroidDevicesCmd = &cobra.Command{
|
||||||
Use: "screencap",
|
Use: "screencap",
|
||||||
Short: "Start android screen capture",
|
Short: "Start android screen capture",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_adb_screencap", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
device, err := getDevice(serial)
|
device, err := getDevice(serial)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp"
|
"github.com/httprunner/httprunner/v4/hrp"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +30,16 @@ var boomCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
setLogLevel(logLevel)
|
setLogLevel(logLevel)
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_boom", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
var paths []hrp.ITestCase
|
var paths []hrp.ITestCase
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
path := hrp.TestCasePath(arg)
|
path := hrp.TestCasePath(arg)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp"
|
"github.com/httprunner/httprunner/v4/hrp"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var buildCmd = &cobra.Command{
|
var buildCmd = &cobra.Command{
|
||||||
@@ -16,7 +20,15 @@ var buildCmd = &cobra.Command{
|
|||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setLogLevel(logLevel)
|
setLogLevel(logLevel)
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_build", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
return hrp.BuildPlugin(args[0], output)
|
return hrp.BuildPlugin(args[0], output)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package ios
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/gidevice"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/gidevice"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,7 +22,16 @@ var listAppsCmd = &cobra.Command{
|
|||||||
Use: "apps",
|
Use: "apps",
|
||||||
Short: "List all iOS installed apps",
|
Short: "List all iOS installed apps",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_apps", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
device, err := getDevice(udid)
|
device, err := getDevice(udid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/gidevice"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/gidevice"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
@@ -69,7 +72,16 @@ var listDevicesCmd = &cobra.Command{
|
|||||||
Use: "devices",
|
Use: "devices",
|
||||||
Short: "List all iOS devices",
|
Short: "List all iOS devices",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_devices", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
devices, err := uixt.GetIOSDevices(udid)
|
devices, err := uixt.GetIOSDevices(udid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|||||||
@@ -5,18 +5,29 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
// mountCmd represents the mount command
|
// mountCmd represents the mount command
|
||||||
var mountCmd = &cobra.Command{
|
var mountCmd = &cobra.Command{
|
||||||
Use: "mount",
|
Use: "mount",
|
||||||
Short: "A brief description of your command",
|
Short: "A brief description of your command",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_mount", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
device, err := getDevice(udid)
|
device, err := getDevice(udid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ios
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,13 +12,23 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pcapCmd = &cobra.Command{
|
var pcapCmd = &cobra.Command{
|
||||||
Use: "pcap",
|
Use: "pcap",
|
||||||
Short: "capture ios network packets",
|
Short: "capture ios network packets",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_pcap", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
pcapOptions := []uixt.IOSPcapOption{}
|
pcapOptions := []uixt.IOSPcapOption{}
|
||||||
if pid > 0 {
|
if pid > 0 {
|
||||||
pcapOptions = append(pcapOptions, uixt.WithIOSPcapPID(pid))
|
pcapOptions = append(pcapOptions, uixt.WithIOSPcapPID(pid))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ios
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,13 +12,23 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var perfCmd = &cobra.Command{
|
var perfCmd = &cobra.Command{
|
||||||
Use: "perf",
|
Use: "perf",
|
||||||
Short: "capture ios performance data (cpu,mem,disk,net,fps,etc.)",
|
Short: "capture ios performance data (cpu,mem,disk,net,fps,etc.)",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_perf", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
perfOptions := []uixt.IOSPerfOption{}
|
perfOptions := []uixt.IOSPerfOption{}
|
||||||
for _, p := range indicators {
|
for _, p := range indicators {
|
||||||
switch p {
|
switch p {
|
||||||
|
|||||||
@@ -2,17 +2,29 @@ package ios
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var psCmd = &cobra.Command{
|
var psCmd = &cobra.Command{
|
||||||
Use: "ps",
|
Use: "ps",
|
||||||
Short: "show running processes",
|
Short: "show running processes",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_ps", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
device, err := getDevice(udid)
|
device, err := getDevice(udid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -2,15 +2,28 @@ package ios
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rebootCmd = &cobra.Command{
|
var rebootCmd = &cobra.Command{
|
||||||
Use: "reboot",
|
Use: "reboot",
|
||||||
Short: "reboot or shutdown ios device",
|
Short: "reboot or shutdown ios device",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_reboot", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
device, err := getDevice(udid)
|
device, err := getDevice(udid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -4,17 +4,30 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var xctestCmd = &cobra.Command{
|
var xctestCmd = &cobra.Command{
|
||||||
Use: "xctest",
|
Use: "xctest",
|
||||||
Short: "run xctest",
|
Short: "run xctest",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_ios_xctest", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
if bundleID == "" {
|
if bundleID == "" {
|
||||||
return fmt.Errorf("bundleID is required")
|
return fmt.Errorf("bundleID is required")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/pytest"
|
"github.com/httprunner/httprunner/v4/hrp/internal/pytest"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,11 +22,20 @@ var pytestCmd = &cobra.Command{
|
|||||||
setLogLevel(logLevel)
|
setLogLevel(logLevel)
|
||||||
},
|
},
|
||||||
DisableFlagParsing: true, // allow to pass any args to pytest
|
DisableFlagParsing: true, // allow to pass any args to pytest
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_pytest", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
packages := []string{
|
packages := []string{
|
||||||
fmt.Sprintf("httprunner==%s", version.HttpRunnerMinimumVersion),
|
fmt.Sprintf("httprunner==%s", version.HttpRunnerMinimumVersion),
|
||||||
}
|
}
|
||||||
_, err := myexec.EnsurePython3Venv(venv, packages...)
|
_, err = myexec.EnsurePython3Venv(venv, packages...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("python3 venv is not ready")
|
log.Error().Err(err).Msg("python3 venv is not ready")
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/wiki"
|
"github.com/httprunner/httprunner/v4/hrp/internal/wiki"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,7 +17,15 @@ var wikiCmd = &cobra.Command{
|
|||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setLogLevel(logLevel)
|
setLogLevel(logLevel)
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_wiki", map[string]interface{}{
|
||||||
|
"args": strings.Join(args, "-"),
|
||||||
|
"success": err == nil,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
return wiki.OpenWiki()
|
return wiki.OpenWiki()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package pytest
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunPytest(args []string) error {
|
func RunPytest(args []string) error {
|
||||||
sdk.SendGA4Event("hrp_pytest", nil)
|
|
||||||
|
|
||||||
args = append([]string{"run"}, args...)
|
args = append([]string{"run"}, args...)
|
||||||
return myexec.ExecPython3Command("httprunner", args...)
|
return myexec.ExecPython3Command("httprunner", args...)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,15 @@ func CopyFile(templateFile, targetFile string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreateScaffold(projectName string, pluginType PluginType, venv string, force bool) error {
|
func CreateScaffold(projectName string, pluginType PluginType, venv string, force bool) error {
|
||||||
// report event
|
// report GA event
|
||||||
sdk.SendGA4Event("hrp_startproject", nil)
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
sdk.SendGA4Event("hrp_startproject", map[string]interface{}{
|
||||||
|
"pluginType": string(pluginType),
|
||||||
|
"force": force,
|
||||||
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("projectName", projectName).
|
Str("projectName", projectName).
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init GA4 client
|
// init GA4 client
|
||||||
ga4Client = NewGA4Client(ga4MeasurementID, ga4APISecret)
|
ga4Client = NewGA4Client(ga4MeasurementID, ga4APISecret, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GA4Client struct {
|
type GA4Client struct {
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func OpenWiki() error {
|
func OpenWiki() error {
|
||||||
sdk.SendGA4Event("hrp_wiki", nil)
|
|
||||||
log.Info().Msgf("%s https://httprunner.com", openCmd)
|
log.Info().Msgf("%s https://httprunner.com", openCmd)
|
||||||
return myexec.RunCommand(openCmd, "https://httprunner.com")
|
return myexec.RunCommand(openCmd, "https://httprunner.com")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package convert
|
|||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
@@ -138,22 +139,25 @@ func (c *TCaseConverter) loadCase(casePath string, fromType FromType) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TCaseConverter) Convert(casePath string, fromType FromType, outputType OutputType) error {
|
func (c *TCaseConverter) Convert(casePath string, fromType FromType, outputType OutputType) (err error) {
|
||||||
// report event
|
// report GA event
|
||||||
sdk.SendGA4Event(
|
startTime := time.Now()
|
||||||
"hrp_convert",
|
defer func() {
|
||||||
map[string]interface{}{
|
sdk.SendGA4Event("hrp_convert", map[string]interface{}{
|
||||||
"from": fromType.String(),
|
"from": fromType.String(),
|
||||||
"to": outputType.String(),
|
"to": outputType.String(),
|
||||||
},
|
"success": err == nil,
|
||||||
)
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
log.Info().Str("path", casePath).
|
log.Info().Str("path", casePath).
|
||||||
Str("fromType", fromType.String()).
|
Str("fromType", fromType.String()).
|
||||||
Str("outputType", outputType.String()).
|
Str("outputType", outputType.String()).
|
||||||
Msg("convert testcase")
|
Msg("convert testcase")
|
||||||
|
|
||||||
// load source file
|
// load source file
|
||||||
err := c.loadCase(casePath, fromType)
|
err = c.loadCase(casePath, fromType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ func (r *HRPRunner) Run(testcases ...ITestCase) (err error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// report run event
|
// report run event
|
||||||
sdk.SendGA4Event("hrp_run", map[string]interface{}{
|
sdk.SendGA4Event("hrp_run", map[string]interface{}{
|
||||||
|
"success": err == nil,
|
||||||
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
"engagement_time_msec": time.Since(startTime).Milliseconds(),
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
@@ -512,6 +513,9 @@ func (r *SessionRunner) inheritConnection(src *SessionRunner) {
|
|||||||
// Start runs the test steps in sequential order.
|
// Start runs the test steps in sequential order.
|
||||||
// givenVars is used for data driven
|
// givenVars is used for data driven
|
||||||
func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
||||||
|
// report GA event
|
||||||
|
sdk.SendGA4Event("hrp_session_runner_start", nil)
|
||||||
|
|
||||||
config := r.caseRunner.testCase.Config
|
config := r.caseRunner.testCase.Config
|
||||||
log.Info().Str("testcase", config.Name).Msg("run testcase start")
|
log.Info().Str("testcase", config.Name).Msg("run testcase start")
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -564,6 +565,11 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err
|
|||||||
mobileStep = step.Android
|
mobileStep = step.Android
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// report GA event
|
||||||
|
sdk.SendGA4Event("hrp_run_ui", map[string]interface{}{
|
||||||
|
"osType": osType,
|
||||||
|
})
|
||||||
|
|
||||||
stepResult = &StepResult{
|
stepResult = &StepResult{
|
||||||
Name: step.Name,
|
Name: step.Name,
|
||||||
StepType: StepType(osType),
|
StepType: StepType(osType),
|
||||||
|
|||||||
Reference in New Issue
Block a user