ratelimit

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotExistsRateLimitName = "polaris.metric.test.not.exists"
	LocalTestSvcName       = "LocalTestSvcV2"
	RemoteTestSvcName      = "RemoteTestSvcV2"
	WindowExpireSvcName    = "ExpireTestSvcV2"
	RuleChangeSvcName      = "RuleChangeTestSvcV2"
	RuleDeletedSvcName     = "RuleDeleteTestSvcV2"
	SvcDeletedSvcName      = "ServiceDeleteTestSvcV2"
	NetworkFailSvcName     = "NetworkFailTestSvcV2"
)
View Source
const (
	// 初始化
	OperationInit = "init"
	// 上报
	OperationReport = "report"
)
View Source
const (
	NotExistRateLimitPort = 10090
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppIdResult

type AppIdResult struct {
	// contains filtered or unexported fields
}

应用ID到限流结果

type CommonRateLimitSuite

type CommonRateLimitSuite struct {
	// contains filtered or unexported fields
}

限流通用的测试套

func (*CommonRateLimitSuite) SetUpSuite

func (cr *CommonRateLimitSuite) SetUpSuite(c *check.C, startRemote bool)

SetUpSuite 启动测试套程序

func (*CommonRateLimitSuite) TearDownSuite

func (cr *CommonRateLimitSuite) TearDownSuite(c *check.C, s util.NamingTestSuite)

SetUpSuite 结束测试套程序

type IndexResult

type IndexResult struct {
	// contains filtered or unexported fields
}

带标识的结果

type LocalNormalTestingSuite

type LocalNormalTestingSuite struct {
	CommonRateLimitSuite
}

直接拒绝正常用例测试

func (*LocalNormalTestingSuite) GetName

func (rt *LocalNormalTestingSuite) GetName() string

用例名称

func (*LocalNormalTestingSuite) SetUpSuite

func (rt *LocalNormalTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 启动测试套程序

func (*LocalNormalTestingSuite) TearDownSuite

func (rt *LocalNormalTestingSuite) TearDownSuite(c *check.C)

SetUpSuite 结束测试套程序

func (*LocalNormalTestingSuite) TestLocalRegexCombine

func (rt *LocalNormalTestingSuite) TestLocalRegexCombine(c *check.C)

TestLocalRegexCombine 测试本地正则合并匹配限流

func (*LocalNormalTestingSuite) TestLocalRegexSpread

func (rt *LocalNormalTestingSuite) TestLocalRegexSpread(c *check.C)

测试本地精准匹配限流

type MockRateLimitServer

type MockRateLimitServer struct {
	// contains filtered or unexported fields
}

只模拟server异常接口场景,不模拟正常场景

func NewMockRateLimitServer

func NewMockRateLimitServer() *MockRateLimitServer

创建mock server

func (*MockRateLimitServer) MarkOperation4XX

func (m *MockRateLimitServer) MarkOperation4XX(operation string)

标识某个接口固定返回4XX

func (*MockRateLimitServer) MarkOperationDelay

func (m *MockRateLimitServer) MarkOperationDelay(operation string)

标识某个接口延迟一个周期

func (*MockRateLimitServer) MarkOperationNoReturn

func (m *MockRateLimitServer) MarkOperationNoReturn(operation string)

标识某个接口不返回应答

func (*MockRateLimitServer) Reset

func (m *MockRateLimitServer) Reset()

重置

func (*MockRateLimitServer) Service

消息处理接口

func (*MockRateLimitServer) SetClientKey

func (m *MockRateLimitServer) SetClientKey(uid string, key uint32)

设置clientKey

func (*MockRateLimitServer) SetMockMaxAmount

func (m *MockRateLimitServer) SetMockMaxAmount(v int64)

设置最大限流阈值

func (*MockRateLimitServer) TimeAdjust

时间对齐接口

type RemoteNormalTestingSuite

type RemoteNormalTestingSuite struct {
	CommonRateLimitSuite
}

远程正常用例测试

func (*RemoteNormalTestingSuite) GetName

func (rt *RemoteNormalTestingSuite) GetName() string

用例名称

func (*RemoteNormalTestingSuite) SetUpSuite

func (rt *RemoteNormalTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 启动测试套程序

func (*RemoteNormalTestingSuite) TearDownSuite

func (rt *RemoteNormalTestingSuite) TearDownSuite(c *check.C)

SetUpSuite 结束测试套程序

func (*RemoteNormalTestingSuite) TestRemoteRegexCombineV2

func (rt *RemoteNormalTestingSuite) TestRemoteRegexCombineV2(c *check.C)

测试正则表达式的uin限流

func (*RemoteNormalTestingSuite) TestRemoteRegexV2

func (rt *RemoteNormalTestingSuite) TestRemoteRegexV2(c *check.C)

测试正则表达式的uin限流

func (*RemoteNormalTestingSuite) TestRemoteShareEqually

func (rt *RemoteNormalTestingSuite) TestRemoteShareEqually(c *check.C)

测试单机均摊模式限流

func (*RemoteNormalTestingSuite) TestRemoteTwoDuration

func (rt *RemoteNormalTestingSuite) TestRemoteTwoDuration(c *check.C)

测试远程精准匹配限流

type RuleChangeTestingSuite

type RuleChangeTestingSuite struct {
	CommonRateLimitSuite
}

测试规则变更的测试套

func (*RuleChangeTestingSuite) GetName

func (rt *RuleChangeTestingSuite) GetName() string

用例名称

func (*RuleChangeTestingSuite) SetUpSuite

func (rt *RuleChangeTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 启动测试套程序

func (*RuleChangeTestingSuite) TearDownSuite

func (rt *RuleChangeTestingSuite) TearDownSuite(c *check.C)

SetUpSuite 结束测试套程序

func (*RuleChangeTestingSuite) TestAmountChangedV2

func (rt *RuleChangeTestingSuite) TestAmountChangedV2(c *check.C)

测试限流配额发生变更

func (*RuleChangeTestingSuite) TestLabelsChanged

func (rt *RuleChangeTestingSuite) TestLabelsChanged(c *check.C)

测试限流标签发生变更

func (*RuleChangeTestingSuite) TestRuleDeleted

func (rt *RuleChangeTestingSuite) TestRuleDeleted(c *check.C)

测试规则被删除

func (*RuleChangeTestingSuite) TestRuleDisabledV2

func (rt *RuleChangeTestingSuite) TestRuleDisabledV2(c *check.C)

测试规则被屏蔽

func (*RuleChangeTestingSuite) TestServiceDeleted

func (rt *RuleChangeTestingSuite) TestServiceDeleted(c *check.C)

测试服务被删除

type WindowExpireTestingSuite

type WindowExpireTestingSuite struct {
	CommonRateLimitSuite
}

远程正常用例测试

func (*WindowExpireTestingSuite) GetName

func (rt *WindowExpireTestingSuite) GetName() string

用例名称

func (*WindowExpireTestingSuite) SetUpSuite

func (rt *WindowExpireTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 启动测试套程序

func (*WindowExpireTestingSuite) TearDownSuite

func (rt *WindowExpireTestingSuite) TearDownSuite(c *check.C)

SetUpSuite 结束测试套程序

func (*WindowExpireTestingSuite) TestUinExpiredLocal

func (rt *WindowExpireTestingSuite) TestUinExpiredLocal(c *check.C)

测试UIN过期

func (*WindowExpireTestingSuite) TestUinExpiredRemote

func (rt *WindowExpireTestingSuite) TestUinExpiredRemote(c *check.C)

测试UIN过期

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL