mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
refactor: rename ga package to sdk
This commit is contained in:
+4
-4
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/funplugin"
|
"github.com/httprunner/funplugin"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/boomer"
|
"github.com/httprunner/httprunner/hrp/internal/boomer"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/ga"
|
"github.com/httprunner/httprunner/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBoomer(spawnCount int, spawnRate float64) *HRPBoomer {
|
func NewBoomer(spawnCount int, spawnRate float64) *HRPBoomer {
|
||||||
@@ -28,14 +28,14 @@ type HRPBoomer struct {
|
|||||||
|
|
||||||
// Run starts to run load test for one or multiple testcases.
|
// Run starts to run load test for one or multiple testcases.
|
||||||
func (b *HRPBoomer) Run(testcases ...ITestCase) {
|
func (b *HRPBoomer) Run(testcases ...ITestCase) {
|
||||||
event := ga.EventTracking{
|
event := sdk.EventTracking{
|
||||||
Category: "RunLoadTests",
|
Category: "RunLoadTests",
|
||||||
Action: "hrp boom",
|
Action: "hrp boom",
|
||||||
}
|
}
|
||||||
// report start event
|
// report start event
|
||||||
go ga.SendEvent(event)
|
go sdk.SendEvent(event)
|
||||||
// report execution timing event
|
// report execution timing event
|
||||||
defer ga.SendEvent(event.StartTiming("execution"))
|
defer sdk.SendEvent(event.StartTiming("execution"))
|
||||||
|
|
||||||
var taskSlice []*boomer.Task
|
var taskSlice []*boomer.Task
|
||||||
for _, iTestCase := range testcases {
|
for _, iTestCase := range testcases {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/hrp"
|
"github.com/httprunner/httprunner/hrp"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/ga"
|
|
||||||
"github.com/httprunner/httprunner/hrp/internal/json"
|
"github.com/httprunner/httprunner/hrp/internal/json"
|
||||||
|
"github.com/httprunner/httprunner/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -42,14 +42,14 @@ func (h *har) SetOutputDir(dir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *har) GenJSON() (jsonPath string, err error) {
|
func (h *har) GenJSON() (jsonPath string, err error) {
|
||||||
event := ga.EventTracking{
|
event := sdk.EventTracking{
|
||||||
Category: "ConvertTests",
|
Category: "ConvertTests",
|
||||||
Action: "hrp har2case --to-json",
|
Action: "hrp har2case --to-json",
|
||||||
}
|
}
|
||||||
// report start event
|
// report start event
|
||||||
go ga.SendEvent(event)
|
go sdk.SendEvent(event)
|
||||||
// report running timing event
|
// report running timing event
|
||||||
defer ga.SendEvent(event.StartTiming("execution"))
|
defer sdk.SendEvent(event.StartTiming("execution"))
|
||||||
|
|
||||||
tCase, err := h.makeTestCase()
|
tCase, err := h.makeTestCase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -61,14 +61,14 @@ func (h *har) GenJSON() (jsonPath string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *har) GenYAML() (yamlPath string, err error) {
|
func (h *har) GenYAML() (yamlPath string, err error) {
|
||||||
event := ga.EventTracking{
|
event := sdk.EventTracking{
|
||||||
Category: "ConvertTests",
|
Category: "ConvertTests",
|
||||||
Action: "hrp har2case --to-yaml",
|
Action: "hrp har2case --to-yaml",
|
||||||
}
|
}
|
||||||
// report start event
|
// report start event
|
||||||
go ga.SendEvent(event)
|
go sdk.SendEvent(event)
|
||||||
// report running timing event
|
// report running timing event
|
||||||
defer ga.SendEvent(event.StartTiming("execution"))
|
defer sdk.SendEvent(event.StartTiming("execution"))
|
||||||
|
|
||||||
tCase, err := h.makeTestCase()
|
tCase, err := h.makeTestCase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/httprunner/funplugin/shared"
|
"github.com/httprunner/funplugin/shared"
|
||||||
"github.com/httprunner/httprunner/hrp"
|
"github.com/httprunner/httprunner/hrp"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/ga"
|
"github.com/httprunner/httprunner/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PluginType string
|
type PluginType string
|
||||||
@@ -25,7 +25,7 @@ const (
|
|||||||
|
|
||||||
func CreateScaffold(projectName string, pluginType PluginType) error {
|
func CreateScaffold(projectName string, pluginType PluginType) error {
|
||||||
// report event
|
// report event
|
||||||
ga.SendEvent(ga.EventTracking{
|
sdk.SendEvent(sdk.EventTracking{
|
||||||
Category: "Scaffold",
|
Category: "Scaffold",
|
||||||
Action: "hrp startproject",
|
Action: "hrp startproject",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ga
|
package sdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ga
|
package sdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ga
|
package sdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ga
|
package sdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -19,6 +19,7 @@ const (
|
|||||||
var gaClient *GAClient
|
var gaClient *GAClient
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// init GA client
|
||||||
clientID, err := machineid.ProtectedID("hrp")
|
clientID, err := machineid.ProtectedID("hrp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
nodeUUID, _ := uuid.NewUUID()
|
nodeUUID, _ := uuid.NewUUID()
|
||||||
+4
-3
@@ -8,8 +8,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/httprunner/funplugin"
|
"github.com/httprunner/funplugin"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/ga"
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -44,7 +45,7 @@ func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// report event for initializing plugin
|
// report event for initializing plugin
|
||||||
event := ga.EventTracking{
|
event := sdk.EventTracking{
|
||||||
Category: "InitPlugin",
|
Category: "InitPlugin",
|
||||||
Action: fmt.Sprintf("Init %s plugin", plugin.Type()),
|
Action: fmt.Sprintf("Init %s plugin", plugin.Type()),
|
||||||
Value: 0, // success
|
Value: 0, // success
|
||||||
@@ -52,7 +53,7 @@ func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
event.Value = 1 // failed
|
event.Value = 1 // failed
|
||||||
}
|
}
|
||||||
go ga.SendEvent(event)
|
go sdk.SendEvent(event)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -29,8 +29,8 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/hrp/internal/ga"
|
|
||||||
"github.com/httprunner/httprunner/hrp/internal/json"
|
"github.com/httprunner/httprunner/hrp/internal/json"
|
||||||
|
"github.com/httprunner/httprunner/hrp/internal/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -138,14 +138,14 @@ func (r *HRPRunner) GenHTMLReport() *HRPRunner {
|
|||||||
|
|
||||||
// Run starts to execute one or multiple testcases.
|
// Run starts to execute one or multiple testcases.
|
||||||
func (r *HRPRunner) Run(testcases ...ITestCase) error {
|
func (r *HRPRunner) Run(testcases ...ITestCase) error {
|
||||||
event := ga.EventTracking{
|
event := sdk.EventTracking{
|
||||||
Category: "RunAPITests",
|
Category: "RunAPITests",
|
||||||
Action: "hrp run",
|
Action: "hrp run",
|
||||||
}
|
}
|
||||||
// report start event
|
// report start event
|
||||||
go ga.SendEvent(event)
|
go sdk.SendEvent(event)
|
||||||
// report execution timing event
|
// report execution timing event
|
||||||
defer ga.SendEvent(event.StartTiming("execution"))
|
defer sdk.SendEvent(event.StartTiming("execution"))
|
||||||
// record execution data to summary
|
// record execution data to summary
|
||||||
s := newOutSummary()
|
s := newOutSummary()
|
||||||
for _, iTestCase := range testcases {
|
for _, iTestCase := range testcases {
|
||||||
|
|||||||
Reference in New Issue
Block a user