mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-26 01:51:29 +08:00
refactor: move boomer from hrp internal to pkg
This commit is contained in:
@@ -13,10 +13,10 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
||||
)
|
||||
|
||||
func NewStandaloneBoomer(spawnCount int64, spawnRate float64) *HRPBoomer {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
||||
)
|
||||
|
||||
// boomCmd represents the boom command
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/convert"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
||||
)
|
||||
|
||||
var runCurlCmd = &cobra.Command{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package boomer
|
||||
|
||||
import (
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
"golang.org/x/net/context"
|
||||
"math"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -11,6 +9,9 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
)
|
||||
|
||||
// Mode is the running mode of boomer, both standalone and distributed are supported.
|
||||
@@ -156,7 +157,6 @@ func NewWorkerBoomer(masterHost string, masterPort int) *Boomer {
|
||||
// SetAutoStart auto start to load testing
|
||||
func (b *Boomer) SetAutoStart() {
|
||||
b.masterRunner.autoStart = true
|
||||
|
||||
}
|
||||
|
||||
// RunMaster start to run master runner
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
@@ -15,10 +17,8 @@ import (
|
||||
"google.golang.org/grpc/credentials/oauth"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer/data"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer/grpc/messager"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer/data"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer/grpc/messager"
|
||||
)
|
||||
|
||||
type grpcClient struct {
|
||||
@@ -247,7 +247,7 @@ func (c *grpcClient) recv() {
|
||||
msg, err := c.config.getBiStreamClient().Recv()
|
||||
if err != nil {
|
||||
time.Sleep(1 * time.Second)
|
||||
//log.Error().Err(err).Msg("failed to get message")
|
||||
// log.Error().Err(err).Msg("failed to get message")
|
||||
continue
|
||||
}
|
||||
if msg == nil {
|
||||
@@ -317,7 +317,7 @@ func (c *grpcClient) sendMessage(msg *genericMessage) {
|
||||
atomic.StoreInt32(&c.failCount, 0)
|
||||
return
|
||||
}
|
||||
//log.Error().Err(err).Interface("genericMessage", *msg).Msg("failed to send message")
|
||||
// log.Error().Err(err).Interface("genericMessage", *msg).Msg("failed to send message")
|
||||
if msg.Type == "heartbeat" {
|
||||
atomic.AddInt32(&c.failCount, 1)
|
||||
}
|
||||
@@ -38,7 +38,6 @@ func init() {
|
||||
}
|
||||
hrpPath = filepath.Join(home, ".hrp")
|
||||
_ = builtin.EnsureFolderExists(filepath.Join(hrpPath, "x509"))
|
||||
|
||||
}
|
||||
|
||||
// Path returns the absolute path the given relative file or directory path
|
||||
@@ -7,10 +7,11 @@
|
||||
package messager
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -458,17 +459,20 @@ func file_grpc_proto_messager_proto_rawDescGZIP() []byte {
|
||||
return file_grpc_proto_messager_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_grpc_proto_messager_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_grpc_proto_messager_proto_goTypes = []interface{}{
|
||||
(*StreamRequest)(nil), // 0: message.StreamRequest
|
||||
(*StreamResponse)(nil), // 1: message.StreamResponse
|
||||
(*RegisterRequest)(nil), // 2: message.RegisterRequest
|
||||
(*RegisterResponse)(nil), // 3: message.RegisterResponse
|
||||
(*SignOutRequest)(nil), // 4: message.SignOutRequest
|
||||
(*SignOutResponse)(nil), // 5: message.SignOutResponse
|
||||
nil, // 6: message.StreamRequest.DataEntry
|
||||
nil, // 7: message.StreamResponse.DataEntry
|
||||
}
|
||||
var (
|
||||
file_grpc_proto_messager_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
file_grpc_proto_messager_proto_goTypes = []interface{}{
|
||||
(*StreamRequest)(nil), // 0: message.StreamRequest
|
||||
(*StreamResponse)(nil), // 1: message.StreamResponse
|
||||
(*RegisterRequest)(nil), // 2: message.RegisterRequest
|
||||
(*RegisterResponse)(nil), // 3: message.RegisterResponse
|
||||
(*SignOutRequest)(nil), // 4: message.SignOutRequest
|
||||
(*SignOutResponse)(nil), // 5: message.SignOutResponse
|
||||
nil, // 6: message.StreamRequest.DataEntry
|
||||
nil, // 7: message.StreamResponse.DataEntry
|
||||
}
|
||||
)
|
||||
|
||||
var file_grpc_proto_messager_proto_depIdxs = []int32{
|
||||
6, // 0: message.StreamRequest.data:type_name -> message.StreamRequest.DataEntry
|
||||
7, // 1: message.StreamResponse.data:type_name -> message.StreamResponse.DataEntry
|
||||
@@ -8,6 +8,7 @@ package messager
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
@@ -95,15 +96,16 @@ type MessageServer interface {
|
||||
}
|
||||
|
||||
// UnimplementedMessageServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedMessageServer struct {
|
||||
}
|
||||
type UnimplementedMessageServer struct{}
|
||||
|
||||
func (UnimplementedMessageServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedMessageServer) SignOut(context.Context, *SignOutRequest) (*SignOutResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SignOut not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedMessageServer) BidirectionalStreamingMessage(Message_BidirectionalStreamingMessageServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method BidirectionalStreamingMessage not implemented")
|
||||
}
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer/grpc/messager"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer/grpc/messager"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -6,9 +6,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer/grpc/messager"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer/grpc/messager"
|
||||
)
|
||||
|
||||
type HitOutput struct {
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
@@ -17,9 +18,8 @@ import (
|
||||
"google.golang.org/grpc/reflection"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer/data"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer/grpc/messager"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer/data"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer/grpc/messager"
|
||||
)
|
||||
|
||||
type WorkerNode struct {
|
||||
@@ -110,7 +110,6 @@ func TestLogError(t *testing.T) {
|
||||
if err400.occurrences != 2 {
|
||||
t.Error("Error occurrences is wrong, expected: 2, got:", err400.occurrences)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func BenchmarkLogError(b *testing.B) {
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/shirou/gopsutil/cpu"
|
||||
"github.com/shirou/gopsutil/mem"
|
||||
@@ -32,7 +32,6 @@ func TestRound(t *testing.T) {
|
||||
if roundOne != roundTwo {
|
||||
t.Error("round(58360) should be equal to round(58460)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGenMD5(t *testing.T) {
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/boomer"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
||||
)
|
||||
|
||||
const jsonContentType = "application/json; encoding=utf-8"
|
||||
|
||||
Reference in New Issue
Block a user