serviceroute

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// NormalInstance is the normal instance
	NormalInstance = 1
	// CanaryInstance is the canary instance
	CanaryInstance = 2
	// OtherCanaryInstance is the other canary instance
	OtherCanaryInstance = 3
)

Variables

This section is empty.

Functions

func CheckInstanceHasCanaryMeta

func CheckInstanceHasCanaryMeta(instance model.Instance, canaryValue string) int

CheckInstanceHasCanaryMeta is used to check the instance has canary metadata

func CircuitBreakerInstance

func CircuitBreakerInstance(instance model.Instance, consumer api.ConsumerAPI, c *check.C)

CircuitBreakerInstance Circuit Breaker Instance

func CloseCbInstance

func CloseCbInstance(instance model.Instance, consumer api.ConsumerAPI, c *check.C)

CloseCbInstance 关闭circuit breaker

func CloseCbInstances

func CloseCbInstances(namespace, service string, consumer api.ConsumerAPI, c *check.C, maxTimes int)

CloseCbInstances is used to close the circuit breaker instance

func DeleteBackUpDir

func DeleteBackUpDir()

DeleteBackUpDir 删除备份目录

func SplitInstances

func SplitInstances(consumer api.ConsumerAPI, canaryVal string) map[int][]model.Instance

SplitInstances is used to split the instances into two groups

Types

type CanaryTestingSuite

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

CanaryTestingSuite 元数据过滤路由插件测试用例

func (*CanaryTestingSuite) GetName

func (t *CanaryTestingSuite) GetName() string

GetName 套件名字

func (*CanaryTestingSuite) SetUpSuite

func (t *CanaryTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 启动测试套程序

func (*CanaryTestingSuite) TearDownSuite

func (t *CanaryTestingSuite) TearDownSuite(c *check.C)

TearDownSuite 结束测试套程序

func (*CanaryTestingSuite) TestCanaryException01

func (t *CanaryTestingSuite) TestCanaryException01(c *check.C)

TestCanaryException01 异常测试, 服务启用金丝雀路由,有两个目标金丝雀实例, 1个正常实例, 1个其他版本金丝实例 先一个目标金丝雀实例熔断 -- 只能获取到可用的一个金丝雀实例 两个目标金丝雀实例熔断 -- 获取正常实例 正常实例熔断 -- 获取到 其他版本金丝实例 其他版本金丝实例熔断 -- 获取到金丝雀实例

func (*CanaryTestingSuite) TestCanaryException02

func (t *CanaryTestingSuite) TestCanaryException02(c *check.C)

TestCanaryException02 异常测试, 服务启用金丝雀路由,测试不带金丝雀标签, 有1个目标金丝雀实例, 2个正常实例, 1个其他版本金丝实例 先一个目标正常实例熔断 -- 只能获取到可用的一个正常实例 两个目标正常实例熔断 -- 获取正常带金丝雀标签实例(共2个) 带金丝雀标签实例熔断 -- 获取到正常实例

func (*CanaryTestingSuite) TestCanaryException03

func (t *CanaryTestingSuite) TestCanaryException03(c *check.C)

TestCanaryException03 异常测试, 服务启用金丝雀路由,测试带金丝雀标签, 有1个目标金丝雀实例, 1个正常实例 获取到金丝雀实例 金丝雀实例熔断, 获取到正常实例 金丝雀实例恢复, 获取到金丝雀实例

func (*CanaryTestingSuite) TestCanaryException04

func (t *CanaryTestingSuite) TestCanaryException04(c *check.C)

TestCanaryException04 异常测试, 服务启用金丝雀路由,测试不带带金丝雀标签, 有1个目标金丝雀实例, 1个正常实例 获取到正常实例 正常实例熔断, 获取到金丝雀实例 正常实例恢复, 获取到正常实例

func (*CanaryTestingSuite) TestCanaryNormal01

func (t *CanaryTestingSuite) TestCanaryNormal01(c *check.C)

TestCanaryNormal01 正常逻辑测试

func (*CanaryTestingSuite) TestCanaryNormal02

func (t *CanaryTestingSuite) TestCanaryNormal02(c *check.C)

TestCanaryNormal02 正常逻辑不带金丝雀标签

func (*CanaryTestingSuite) TestCanaryNormal03

func (t *CanaryTestingSuite) TestCanaryNormal03(c *check.C)

TestCanaryNormal03 服务不启用金丝雀

func (*CanaryTestingSuite) TestCanaryNormal04

func (t *CanaryTestingSuite) TestCanaryNormal04(c *check.C)

TestCanaryNormal04 测试canary切换到normal 和SetDivision一起使用 set路由过滤后有金丝雀实例

func (*CanaryTestingSuite) TestCanaryNormal05

func (t *CanaryTestingSuite) TestCanaryNormal05(c *check.C)

TestCanaryNormal05 和nearbyRouter一起使用

type DstMetaTestingSuite

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

元数据过滤路由插件测试用例

func (*DstMetaTestingSuite) GetName

func (t *DstMetaTestingSuite) GetName() string

套件名字

func (*DstMetaTestingSuite) SetUpSuite

func (t *DstMetaTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 启动测试套程序

func (*DstMetaTestingSuite) TearDownSuite

func (t *DstMetaTestingSuite) TearDownSuite(c *check.C)

SetUpSuite 结束测试套程序

func (*DstMetaTestingSuite) TestFailOverDefaultMetaNormalWithCustomMeta

func (t *DstMetaTestingSuite) TestFailOverDefaultMetaNormalWithCustomMeta(c *check.C)

测试元数据路由兜底策略:自定义meta

func (*DstMetaTestingSuite) TestFailOverDefaultMetaNormalWithGetOneHealth

func (t *DstMetaTestingSuite) TestFailOverDefaultMetaNormalWithGetOneHealth(c *check.C)

测试元数据路由兜底策略:通配所有可用ip实例

func (*DstMetaTestingSuite) TestFailOverDefaultMetaNormalWithNotContainMeta

func (t *DstMetaTestingSuite) TestFailOverDefaultMetaNormalWithNotContainMeta(c *check.C)

测试元数据路由兜底策略:匹配不带 metaData key路由

func (*DstMetaTestingSuite) TestFailOverDefaultMetaWrongWithCustomMeta01

func (t *DstMetaTestingSuite) TestFailOverDefaultMetaWrongWithCustomMeta01(c *check.C)

测试元数据路由兜底策略:自定义meta

func (*DstMetaTestingSuite) TestFailOverDefaultMetaWrongWithCustomMeta02

func (t *DstMetaTestingSuite) TestFailOverDefaultMetaWrongWithCustomMeta02(c *check.C)

测试元数据路由兜底策略:自定义meta

func (*DstMetaTestingSuite) TestFailOverDefaultMetaWrongWithType

func (t *DstMetaTestingSuite) TestFailOverDefaultMetaWrongWithType(c *check.C)

测试元数据路由兜底策略正确设置类型

func (*DstMetaTestingSuite) TestGetMetaNormal

func (t *DstMetaTestingSuite) TestGetMetaNormal(c *check.C)

测试正常获取元数据实例

type InstanceMetadataAndNum

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

InstanceMetadataAndNum 测试实例的 metadata 和 num

type NearbyTestingSuite

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

NearbyTestingSuite 路由API测试套

func (*NearbyTestingSuite) GetName

func (t *NearbyTestingSuite) GetName() string

套件名字

func (*NearbyTestingSuite) SetUpSuite

func (t *NearbyTestingSuite) SetUpSuite(c *check.C)

设置模拟桩服务器

func (*NearbyTestingSuite) TearDownSuite

func (t *NearbyTestingSuite) TearDownSuite(c *check.C)

SetUpSuite 结束测试套程序

func (*NearbyTestingSuite) TestCase10

func (t *NearbyTestingSuite) TestCase10(c *check.C)

func (*NearbyTestingSuite) TestCase11

func (t *NearbyTestingSuite) TestCase11(c *check.C)

func (*NearbyTestingSuite) TestCase2

func (t *NearbyTestingSuite) TestCase2(c *check.C)

recover percent: 0.2,开启降级,降级percent:100,matchLevel:zone,lowestMatchLevel:"" A-a-0实例:3个健康,1个不健康 A-b-1实例:3个健康 B-b-2实例:10个健康A-b-1实例 期望:返回3个健康A-a-0实例(不降级,健康实例比例为0.75)

func (*NearbyTestingSuite) TestCase3

func (t *NearbyTestingSuite) TestCase3(c *check.C)

recover percent: 0.2,开启降级,降级percent:100,matchLevel:zone,lowestMatchLevel:"" A-a-0实例:4个不健康 A-b-1实例:4个不健康 B-b-2实例:4个健康 期望:返回4个健康B-b-2实例(降级到"",健康实例比例为0.333)

func (*NearbyTestingSuite) TestCase4

func (t *NearbyTestingSuite) TestCase4(c *check.C)

recover percent: 0.2,开启降级,降级percent:100,matchLevel:zone,lowestMatchLevel:"" A-a-0实例:4个不健康 A-b-1实例:4个不健康 B-b-2实例:4个不健康 期望:返回4个不健康A-a-0实例(不降级,触发全死全活)

func (*NearbyTestingSuite) TestCase5

func (t *NearbyTestingSuite) TestCase5(c *check.C)

recover percent: 0.2,开启降级,降级percent:100,matchLevel:zone,lowestMatchLevel:"" A-a-0实例:0个 A-b-1实例:4个不健康 B-b-2实例:4个不健康 期望:返回4个健康B-b-2实例(降级到region,触发全死全活)

func (*NearbyTestingSuite) TestCase6

func (t *NearbyTestingSuite) TestCase6(c *check.C)

recover percent: 0.2,开启降级,降级percent:100,matchLevel:campus,lowestMatchLevel:zone A-a-0实例:0个 A-b-1实例:4个不健康 B-b-2实例:4个不健康 期望:返回错误,在zone和campus两个级别之间没有足够的实例

func (*NearbyTestingSuite) TestCase7

func (t *NearbyTestingSuite) TestCase7(c *check.C)

recover percent: 0.2,不开启降级,matchLevel:zone A-a-0实例:4个不健康 A-b-1实例:4个健康 B-b-2实例:4个健康 期望:开启全死全活,返回4个不健康A-a-0实例(不降级,触发全死全活);关闭全死全活,不返回实例

func (*NearbyTestingSuite) TestCase8

func (t *NearbyTestingSuite) TestCase8(c *check.C)

recover percent: 0.2,开启降级,降级percent:50,matchLevel:zone,lowestMatchLevel:"" A-a-0实例:2个健康,2个不健康 A-b-1实例:2个健康 B-b-2实例:4个健康 期望:返回2个健康A-a-0实例和2个健康A-b-1实例(降级到region,不触发全死全活)

func (*NearbyTestingSuite) TestCase9

func (t *NearbyTestingSuite) TestCase9(c *check.C)

func (*NearbyTestingSuite) TestCaseNB1

func (t *NearbyTestingSuite) TestCaseNB1(c *check.C)

recover percent: 0.2,开启降级,降级percent:100,matchLevel:zone,lowestMatchLevel:"" A-a-0实例:3个不健康 A-b-1实例:3个健康,6个不健康 B-b-2实例:10个健康A-b-1实例 期望:返回3个健康A-b-1实例(降级到region,健康实例比例为3/(3+3+6)=0.25)

func (*NearbyTestingSuite) TestEnabledNearbyWithIDC

func (t *NearbyTestingSuite) TestEnabledNearbyWithIDC(c *check.C)

进行就近路由时,匹配到idc级别

func (*NearbyTestingSuite) TestEnabledNearbyWithoutIDC

func (t *NearbyTestingSuite) TestEnabledNearbyWithoutIDC(c *check.C)

进行就近路由匹配,以城市为最小级别

func (*NearbyTestingSuite) TestMetadataNearby

func (t *NearbyTestingSuite) TestMetadataNearby(c *check.C)

测试由metadata控制就近路由的开启

func (*NearbyTestingSuite) TestStrictNearby

func (t *NearbyTestingSuite) TestStrictNearby(c *check.C)

测试strictnearby的效果

type RuleRoutingTestingSuite

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

RuleRoutingTestingSuite 规则路由API测试套

func (*RuleRoutingTestingSuite) GetName

func (t *RuleRoutingTestingSuite) GetName() string

GetName 套件名字

func (*RuleRoutingTestingSuite) RegisterInstancesWithMetadataAndNum

func (t *RuleRoutingTestingSuite) RegisterInstancesWithMetadataAndNum(svc *service_manage.Service, metadatas []*InstanceMetadataAndNum)

RegisterInstancesWithMetadataAndNum 测试实例的 metadata 和 num

func (*RuleRoutingTestingSuite) SetUpSuite

func (t *RuleRoutingTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 设置模拟桩服务器

func (*RuleRoutingTestingSuite) TearDownSuite

func (t *RuleRoutingTestingSuite) TearDownSuite(c *check.C)

TearDownSuite 结束测试套程序

func (*RuleRoutingTestingSuite) TestBadVariable

func (t *RuleRoutingTestingSuite) TestBadVariable(c *check.C)

TestBadVariable test bad variable

func (*RuleRoutingTestingSuite) TestDestPriority

func (t *RuleRoutingTestingSuite) TestDestPriority(c *check.C)

TestDestPriority 测试目标规则的优先级

func (*RuleRoutingTestingSuite) TestDestWeight

func (t *RuleRoutingTestingSuite) TestDestWeight(c *check.C)

TestDestWeight 测试目标规则的weight(包括0权重)

func (*RuleRoutingTestingSuite) TestHasInvalidRules

func (t *RuleRoutingTestingSuite) TestHasInvalidRules(c *check.C)

TestHasInvalidRules test has invalid rules

func (*RuleRoutingTestingSuite) TestHasNoRules

func (t *RuleRoutingTestingSuite) TestHasNoRules(c *check.C)

TestHasNoRules test has no rules

func (*RuleRoutingTestingSuite) TestInboundAddAndDelete

func (t *RuleRoutingTestingSuite) TestInboundAddAndDelete(c *check.C)

TestInboundAddAndDelete 测试inbound add and delete

func (*RuleRoutingTestingSuite) TestInboundNoSourceService

func (t *RuleRoutingTestingSuite) TestInboundNoSourceService(c *check.C)

TestInboundNoSourceService 测试只有入流量规则的前提下,不传入sourceService能否成功路由

func (*RuleRoutingTestingSuite) TestInboundNoSources

func (t *RuleRoutingTestingSuite) TestInboundNoSources(c *check.C)

TestInboundNoSources 测试inbound no sources

func (*RuleRoutingTestingSuite) TestInboundRuleRegex

func (t *RuleRoutingTestingSuite) TestInboundRuleRegex(c *check.C)

TestInboundRuleRegex 测试正则匹配inbound rules

func (*RuleRoutingTestingSuite) TestInboundRules

func (t *RuleRoutingTestingSuite) TestInboundRules(c *check.C)

TestInboundRules inbound rules

func (*RuleRoutingTestingSuite) TestMatchInboundAndOutboundRules

func (t *RuleRoutingTestingSuite) TestMatchInboundAndOutboundRules(c *check.C)

TestMatchInboundAndOutboundRules match inbound & outbound rules

func (*RuleRoutingTestingSuite) TestMatchMissingRouteRule

func (t *RuleRoutingTestingSuite) TestMatchMissingRouteRule(c *check.C)

TestMatchMissingRouteRule 测试匹配残缺的路由规则

func (*RuleRoutingTestingSuite) TestMultiBaseEnvWithVariable

func (t *RuleRoutingTestingSuite) TestMultiBaseEnvWithVariable(c *check.C)

TestMultiBaseEnvWithVariable 服务实例:2个基线环境b,2个特性环境f case1:metadata带上特性环境名f,variable设置为基线环境名b,访问到特性环境f case2: metadata不带上环境名,variable设置为基线环境名b,访问到基线环境b case3:metadata不带上环境名,variable设置为不存在的基线环境名b1,返回错误

func (*RuleRoutingTestingSuite) TestMultiVariables

func (t *RuleRoutingTestingSuite) TestMultiVariables(c *check.C)

TestMultiVariables 服务实例:2个基线环境b,2个特性环境f

func (*RuleRoutingTestingSuite) TestMultipleParameters

func (t *RuleRoutingTestingSuite) TestMultipleParameters(c *check.C)

TestMultipleParameters 服务实例:2个基线环境b,2个特性环境f

func (*RuleRoutingTestingSuite) TestOneBaseEnvWithParameter

func (t *RuleRoutingTestingSuite) TestOneBaseEnvWithParameter(c *check.C)

TestOneBaseEnvWithParameter 使用parameter路由,进行基线特性环境匹配

func (*RuleRoutingTestingSuite) TestOutboundRules

func (t *RuleRoutingTestingSuite) TestOutboundRules(c *check.C)

TestOutboundRules inbound rules

func (*RuleRoutingTestingSuite) TestParameterRegex

func (t *RuleRoutingTestingSuite) TestParameterRegex(c *check.C)

TestParameterRegex test parameter regex

func (*RuleRoutingTestingSuite) TestReturnDefault

func (t *RuleRoutingTestingSuite) TestReturnDefault(c *check.C)

TestReturnDefault return default(兜底)

func (*RuleRoutingTestingSuite) TestVariableRegex

func (t *RuleRoutingTestingSuite) TestVariableRegex(c *check.C)

TestVariableRegex test variable regex

type SetDivisionTestingSuite

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

SetDivisionTestingSuite set分组API测试套

func (*SetDivisionTestingSuite) GetName

func (t *SetDivisionTestingSuite) GetName() string

GetName 套件名字

func (*SetDivisionTestingSuite) SetUpSuite

func (t *SetDivisionTestingSuite) SetUpSuite(c *check.C)

SetUpSuite 设置模拟桩

func (*SetDivisionTestingSuite) TearDownSuite

func (t *SetDivisionTestingSuite) TearDownSuite(c *check.C)

TearDownSuite 结束测试套程序

func (*SetDivisionTestingSuite) TestAllGroup

func (t *SetDivisionTestingSuite) TestAllGroup(c *check.C)

TestAllGroup 测试主调的 set分组为*的情况

func (*SetDivisionTestingSuite) TestDestinationSet

func (t *SetDivisionTestingSuite) TestDestinationSet(c *check.C)

TestDestinationSet 测试使用了destination set的情况

func (*SetDivisionTestingSuite) TestDstNotSet

func (t *SetDivisionTestingSuite) TestDstNotSet(c *check.C)

TestDstNotSet 测试被调没启用set的情况

func (*SetDivisionTestingSuite) TestNoSet

func (t *SetDivisionTestingSuite) TestNoSet(c *check.C)

TestNoSet 测试主调没启用set的情况

func (*SetDivisionTestingSuite) TestSameGroup

func (t *SetDivisionTestingSuite) TestSameGroup(c *check.C)

TestSameGroup 测试没有本分组,匹配最后的情况

func (*SetDivisionTestingSuite) TestSetExcatMatch

func (t *SetDivisionTestingSuite) TestSetExcatMatch(c *check.C)

TestSetExcatMatch 测试set刚好匹配的情况

func (*SetDivisionTestingSuite) TestSetNotMatch

func (t *SetDivisionTestingSuite) TestSetNotMatch(c *check.C)

TestSetNotMatch 启用set了,但set不匹配,返回空

Jump to

Keyboard shortcuts

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