update deps as regular cadence (#3488)
This commit is contained in:
@@ -55,8 +55,7 @@ var (
|
||||
minioAddPolicyMock func(name string, policy *iampolicy.Policy) error
|
||||
minioSetPolicyMock func(policyName, entityName string, isGroup bool) error
|
||||
|
||||
minioStartProfiling func(profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
|
||||
minioStopProfiling func() (io.ReadCloser, error)
|
||||
minioStartProfiling func(profiler madmin.ProfilerType, duration time.Duration) (io.ReadCloser, error)
|
||||
|
||||
minioServiceRestartMock func(ctx context.Context) error
|
||||
|
||||
@@ -248,13 +247,8 @@ func (ac AdminClientMock) setPolicy(_ context.Context, policyName, entityName st
|
||||
}
|
||||
|
||||
// mock function for startProfiling()
|
||||
func (ac AdminClientMock) startProfiling(_ context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
return minioStartProfiling(profiler)
|
||||
}
|
||||
|
||||
// mock function for stopProfiling()
|
||||
func (ac AdminClientMock) stopProfiling(_ context.Context) (io.ReadCloser, error) {
|
||||
return minioStopProfiling()
|
||||
func (ac AdminClientMock) startProfiling(_ context.Context, profiler madmin.ProfilerType, duration time.Duration) (io.ReadCloser, error) {
|
||||
return minioStartProfiling(profiler, duration)
|
||||
}
|
||||
|
||||
// mock function of serviceRestart()
|
||||
|
||||
@@ -20,42 +20,30 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/madmin-go/v3"
|
||||
"github.com/minio/websocket"
|
||||
)
|
||||
|
||||
var items []*models.StartProfilingItem
|
||||
|
||||
type profileOptions struct {
|
||||
Types string
|
||||
Types string
|
||||
Duration time.Duration
|
||||
}
|
||||
|
||||
func getProfileOptionsFromReq(req *http.Request) (*profileOptions, error) {
|
||||
pOptions := profileOptions{}
|
||||
pOptions.Types = req.FormValue("types")
|
||||
pOptions.Duration = 10 * time.Second // TODO: make this configurable
|
||||
return &pOptions, nil
|
||||
}
|
||||
|
||||
func startProfiling(ctx context.Context, conn WSConn, client MinioAdmin, pOpts *profileOptions) error {
|
||||
profilingResults, err := client.startProfiling(ctx, madmin.ProfilerType(pOpts.Types))
|
||||
data, err := client.startProfiling(ctx, madmin.ProfilerType(pOpts.Types), pOpts.Duration)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
items = []*models.StartProfilingItem{}
|
||||
for _, result := range profilingResults {
|
||||
items = append(items, &models.StartProfilingItem{
|
||||
Success: result.Success,
|
||||
Error: result.Error,
|
||||
NodeName: result.NodeName,
|
||||
})
|
||||
}
|
||||
zippedData, err := client.stopProfiling(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
message, err := io.ReadAll(zippedData)
|
||||
message, err := io.ReadAll(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/minio/madmin-go/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -52,22 +53,7 @@ func TestStartProfiling(t *testing.T) {
|
||||
|
||||
// Test-1 : startProfiling() Get response from MinIO server with one profiling object without errors
|
||||
// mock function response from startProfiling()
|
||||
minioStartProfiling = func(_ madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
return []madmin.StartProfilingResult{
|
||||
{
|
||||
NodeName: "http://127.0.0.1:9000/",
|
||||
Success: true,
|
||||
Error: "",
|
||||
},
|
||||
{
|
||||
NodeName: "http://127.0.0.1:9001/",
|
||||
Success: true,
|
||||
Error: "",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
// mock function response from stopProfiling()
|
||||
minioStopProfiling = func() (io.ReadCloser, error) {
|
||||
minioStartProfiling = func(_ madmin.ProfilerType, _ time.Duration) (io.ReadCloser, error) {
|
||||
return &ClosingBuffer{bytes.NewBufferString("In memory string eaeae")}, nil
|
||||
}
|
||||
// mock function response from mockConn.writeMessage()
|
||||
@@ -82,7 +68,7 @@ func TestStartProfiling(t *testing.T) {
|
||||
|
||||
// Test-2 : startProfiling() Correctly handles errors returned by MinIO
|
||||
// mock function response from startProfiling()
|
||||
minioStartProfiling = func(_ madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
minioStartProfiling = func(_ madmin.ProfilerType, _ time.Duration) (io.ReadCloser, error) {
|
||||
return nil, errors.New("error")
|
||||
}
|
||||
err = startProfiling(ctx, mockWSConn, adminClient, testOptions)
|
||||
|
||||
@@ -65,8 +65,7 @@ type MinioAdmin interface {
|
||||
delConfigKV(ctx context.Context, kv string) (err error)
|
||||
serviceRestart(ctx context.Context) error
|
||||
serverInfo(ctx context.Context) (madmin.InfoMessage, error)
|
||||
startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
|
||||
stopProfiling(ctx context.Context) (io.ReadCloser, error)
|
||||
startProfiling(ctx context.Context, profiler madmin.ProfilerType, duration time.Duration) (io.ReadCloser, error)
|
||||
serviceTrace(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo
|
||||
getLogs(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
|
||||
AccountInfo(ctx context.Context) (madmin.AccountInfo, error)
|
||||
@@ -259,7 +258,7 @@ func (ac AdminClient) delConfigKV(ctx context.Context, kv string) (err error) {
|
||||
|
||||
// implements madmin.ServiceRestart()
|
||||
func (ac AdminClient) serviceRestart(ctx context.Context) (err error) {
|
||||
return ac.Client.ServiceRestart(ctx)
|
||||
return ac.Client.ServiceRestartV2(ctx)
|
||||
}
|
||||
|
||||
// implements madmin.ServerInfo()
|
||||
@@ -268,13 +267,8 @@ func (ac AdminClient) serverInfo(ctx context.Context) (madmin.InfoMessage, error
|
||||
}
|
||||
|
||||
// implements madmin.StartProfiling()
|
||||
func (ac AdminClient) startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
return ac.Client.StartProfiling(ctx, profiler)
|
||||
}
|
||||
|
||||
// implements madmin.DownloadProfilingData()
|
||||
func (ac AdminClient) stopProfiling(ctx context.Context) (io.ReadCloser, error) {
|
||||
return ac.Client.DownloadProfilingData(ctx)
|
||||
func (ac AdminClient) startProfiling(ctx context.Context, profiler madmin.ProfilerType, duration time.Duration) (io.ReadCloser, error) {
|
||||
return ac.Client.Profile(ctx, profiler, duration)
|
||||
}
|
||||
|
||||
// implements madmin.ServiceTrace()
|
||||
|
||||
Reference in New Issue
Block a user