mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
change: update func plugin
This commit is contained in:
@@ -7,9 +7,9 @@ import (
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
funcPlugin "github.com/httprunner/func-plugin"
|
||||
"github.com/httprunner/hrp/internal/boomer"
|
||||
"github.com/httprunner/hrp/internal/ga"
|
||||
pluginInternal "github.com/httprunner/plugin/go"
|
||||
)
|
||||
|
||||
func NewBoomer(spawnCount int, spawnRate float64) *HRPBoomer {
|
||||
@@ -22,8 +22,8 @@ func NewBoomer(spawnCount int, spawnRate float64) *HRPBoomer {
|
||||
|
||||
type HRPBoomer struct {
|
||||
*boomer.Boomer
|
||||
plugins []pluginInternal.IPlugin // each task has its own plugin process
|
||||
pluginsMutex *sync.RWMutex // avoid data race
|
||||
plugins []funcPlugin.IPlugin // each task has its own plugin process
|
||||
pluginsMutex *sync.RWMutex // avoid data race
|
||||
}
|
||||
|
||||
// Run starts to run load test for one or multiple testcases.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## v0.6.4 (2022-03-10)
|
||||
|
||||
- feat: both support gPRC(default) and net/rpc mode in hashicorp plugin, switch with environment `HRP_PLUGIN_TYPE`
|
||||
- refactor: move submodule `plugin` to separate repo `github.com/httprunner/plugin`
|
||||
- refactor: move submodule `plugin` to separate repo `github.com/httprunner/func-plugin`
|
||||
- refactor: replace builtin json library with `json-iterator/go` to improve performance
|
||||
|
||||
## v0.6.3 (2022-03-04)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import "github.com/httprunner/plugin"
|
||||
import (
|
||||
plugin "github.com/httprunner/func-plugin/go"
|
||||
)
|
||||
|
||||
// register functions and build to plugin binary
|
||||
func main() {
|
||||
|
||||
4
go.mod
4
go.mod
@@ -6,7 +6,7 @@ require (
|
||||
github.com/andybalholm/brotli v1.0.4
|
||||
github.com/denisbrodbeck/machineid v1.0.1
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/httprunner/plugin v0.1.1
|
||||
github.com/httprunner/func-plugin v0.2.0
|
||||
github.com/jinzhu/copier v0.3.2
|
||||
github.com/jmespath/go-jmespath v0.4.0
|
||||
github.com/json-iterator/go v1.1.12
|
||||
@@ -21,4 +21,4 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
)
|
||||
|
||||
// replace github.com/httprunner/plugin => ./plugin
|
||||
// replace github.com/httprunner/func-plugin => ../func-plugin
|
||||
|
||||
7
go.sum
7
go.sum
@@ -198,8 +198,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
|
||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||
github.com/httprunner/plugin v0.1.1 h1:tiTRAPVZ6tW6g0AvWTcLeuEmLLXgH7tMuzqXr6X2Nko=
|
||||
github.com/httprunner/plugin v0.1.1/go.mod h1:DShhD3X+JrA6mqaIHHOeNUAMFjY5EFdx+9EWhXMYa14=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
@@ -667,8 +665,8 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
|
||||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20220308174144-ae0e22291548 h1:J5ZNG1QIdstOl8aaUoFoQJfp04FKTsFV+jwkBHEchqs=
|
||||
google.golang.org/genproto v0.0.0-20220308174144-ae0e22291548/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
||||
google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106 h1:ErU+UA6wxadoU8nWrsy5MZUVBs75K17zUCsUCIfrXCE=
|
||||
google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E=
|
||||
google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
@@ -690,7 +688,6 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
||||
@@ -72,7 +72,7 @@ var demoPlugin = `package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/httprunner/plugin"
|
||||
plugin "github.com/httprunner/func-plugin/go"
|
||||
)
|
||||
|
||||
func SumTwoInt(a, b int) int {
|
||||
|
||||
@@ -70,7 +70,7 @@ func CreateScaffold(projectName string) error {
|
||||
}
|
||||
|
||||
// download plugin dependency
|
||||
if err := builtin.ExecCommand(exec.Command("go", "get", "github.com/httprunner/plugin"), pluginDir); err != nil {
|
||||
if err := builtin.ExecCommand(exec.Command("go", "get", "github.com/httprunner/func-plugin"), pluginDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
funcPlugin "github.com/httprunner/func-plugin"
|
||||
"github.com/httprunner/func-plugin/shared"
|
||||
"github.com/httprunner/hrp/internal/builtin"
|
||||
pluginInternal "github.com/httprunner/plugin/go"
|
||||
pluginUtils "github.com/httprunner/plugin/utils"
|
||||
)
|
||||
|
||||
func newParser() *parser {
|
||||
@@ -22,7 +22,7 @@ func newParser() *parser {
|
||||
}
|
||||
|
||||
type parser struct {
|
||||
plugin pluginInternal.IPlugin // plugin is used to call functions
|
||||
plugin funcPlugin.IPlugin // plugin is used to call functions
|
||||
}
|
||||
|
||||
func buildURL(baseURL, stepURL string) string {
|
||||
@@ -253,7 +253,7 @@ func (p *parser) callFunc(funcName string, arguments ...interface{}) (interface{
|
||||
fn := reflect.ValueOf(function)
|
||||
|
||||
// call with builtin function
|
||||
return pluginUtils.CallFunc(fn, arguments...)
|
||||
return shared.CallFunc(fn, arguments...)
|
||||
}
|
||||
|
||||
// merge two variables mapping, the first variables have higher priority
|
||||
|
||||
14
runner.go
14
runner.go
@@ -29,10 +29,10 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
funcPlugin "github.com/httprunner/func-plugin"
|
||||
"github.com/httprunner/hrp/internal/builtin"
|
||||
"github.com/httprunner/hrp/internal/ga"
|
||||
"github.com/httprunner/hrp/internal/json"
|
||||
pluginInternal "github.com/httprunner/plugin/go"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -282,8 +282,8 @@ func (r *caseRunner) run() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func initPlugin(path string, logOn bool) (plugin pluginInternal.IPlugin, err error) {
|
||||
plugin, err = pluginInternal.Init(path, logOn)
|
||||
func initPlugin(path string, logOn bool) (plugin funcPlugin.IPlugin, err error) {
|
||||
plugin, err = funcPlugin.Init(path, logOn)
|
||||
if plugin == nil {
|
||||
return
|
||||
}
|
||||
@@ -298,15 +298,9 @@ func initPlugin(path string, logOn bool) (plugin pluginInternal.IPlugin, err err
|
||||
}()
|
||||
|
||||
// report event for initializing plugin
|
||||
var pluginType string
|
||||
if _, ok := plugin.(*pluginInternal.GoPlugin); ok {
|
||||
pluginType = "go"
|
||||
} else {
|
||||
pluginType = "hashicorp"
|
||||
}
|
||||
event := ga.EventTracking{
|
||||
Category: "InitPlugin",
|
||||
Action: fmt.Sprintf("Init %s plugin", pluginType),
|
||||
Action: fmt.Sprintf("Init %s plugin", plugin.Type()),
|
||||
}
|
||||
if err != nil {
|
||||
event.Value = 1 // failed
|
||||
|
||||
Reference in New Issue
Block a user