testsuit

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 49 Imported by: 0

README

Polaris UnitTest Suit 接入

第三方存储插件接入单元测试体系

  • 实现 TestDataClean 接口
    • test/suit 目录下写入一个 go 文件
    • 利用 go _ import 执行 init 方法的机制,调用 testsuit.SetTestDataClean 注入构建 TestDataClean 的 supplier 行数
  • 测试依赖第三方存储插件时的北极星启动配置文件 polaris-server.yaml 的路径信息,通过设置环境变量 POLARIS_TEST_BOOTSTRAP_FILE

具体参考 polaris-contrib/polaris-store-postgresql

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InjectTestDataClean func() TestDataClean

Functions

func MockRoutingV2 added in v1.16.0

func MockRoutingV2(t *testing.T, cnt int32) []*apitraffic.RouteRule

func RespSuccess

func RespSuccess(resp api.ResponseMessage) bool

判断一个resp是否执行成功

func SetTestDataClean added in v1.17.3

func SetTestDataClean(callback func() TestDataClean)

Types

type Bootstrap

type Bootstrap struct {
	Logger map[string]*commonlog.Options
}

type DiscoverTestSuit

type DiscoverTestSuit struct {
	DefaultCtx context.Context

	Storage store.Store
	// contains filtered or unexported fields
}

func (*DiscoverTestSuit) BatchController added in v1.17.2

func (d *DiscoverTestSuit) BatchController() *batch.Controller

func (*DiscoverTestSuit) CacheMgr added in v1.17.3

func (d *DiscoverTestSuit) CacheMgr() *cache.CacheManager

func (*DiscoverTestSuit) CleanAllService added in v1.17.3

func (d *DiscoverTestSuit) CleanAllService()

从数据库彻底删除全部服务

func (*DiscoverTestSuit) CleanCircuitBreaker added in v1.17.3

func (d *DiscoverTestSuit) CleanCircuitBreaker(id, version string)

彻底删除熔断规则

func (*DiscoverTestSuit) CleanCircuitBreakerRelation added in v1.17.3

func (d *DiscoverTestSuit) CleanCircuitBreakerRelation(name, namespace, ruleID, ruleVersion string)

彻底删除熔断规则发布记录

func (*DiscoverTestSuit) CleanCommonRoutingConfig added in v1.17.3

func (d *DiscoverTestSuit) CleanCommonRoutingConfig(service string, namespace string)

彻底删除一个路由配置

func (*DiscoverTestSuit) CleanCommonRoutingConfigV2 added in v1.17.3

func (d *DiscoverTestSuit) CleanCommonRoutingConfigV2(rules []*apitraffic.RouteRule)

彻底删除一个路由配置

func (*DiscoverTestSuit) CleanInstance added in v1.17.3

func (d *DiscoverTestSuit) CleanInstance(instanceID string)

从数据库彻底删除实例

func (*DiscoverTestSuit) CleanNamespace added in v1.17.3

func (d *DiscoverTestSuit) CleanNamespace(name string)

从数据库彻底删除命名空间

func (*DiscoverTestSuit) CleanRateLimit added in v1.17.3

func (d *DiscoverTestSuit) CleanRateLimit(id string)

彻底删除限流规则

func (*DiscoverTestSuit) CleanReportClient added in v1.17.3

func (d *DiscoverTestSuit) CleanReportClient()

func (*DiscoverTestSuit) CleanService added in v1.17.3

func (d *DiscoverTestSuit) CleanService(name, namespace string)

从数据库彻底删除服务

func (*DiscoverTestSuit) CleanServiceContract added in v1.18.0

func (d *DiscoverTestSuit) CleanServiceContract() error

彻底删除熔断规则发布记录

func (*DiscoverTestSuit) CleanServices added in v1.17.3

func (d *DiscoverTestSuit) CleanServices(services []*apiservice.Service)

clean services

func (*DiscoverTestSuit) ClearTestDataWhenUseRDS added in v1.17.3

func (d *DiscoverTestSuit) ClearTestDataWhenUseRDS() error

func (*DiscoverTestSuit) ConfigServer added in v1.17.3

func (d *DiscoverTestSuit) ConfigServer() config.ConfigCenterServer

func (*DiscoverTestSuit) Destroy

func (d *DiscoverTestSuit) Destroy()

func (*DiscoverTestSuit) DiscoverServer

func (d *DiscoverTestSuit) DiscoverServer() service.DiscoverServer

func (*DiscoverTestSuit) GetBootstrapConfig added in v1.18.0

func (d *DiscoverTestSuit) GetBootstrapConfig() *TestConfig

func (*DiscoverTestSuit) GetTestDataClean added in v1.17.3

func (d *DiscoverTestSuit) GetTestDataClean() TestDataClean

func (*DiscoverTestSuit) HealthCheckServer

func (d *DiscoverTestSuit) HealthCheckServer() *healthcheck.Server

func (*DiscoverTestSuit) Initialize

func (d *DiscoverTestSuit) Initialize(opts ...options) error

func (*DiscoverTestSuit) InjectSuit added in v1.17.3

func (d *DiscoverTestSuit) InjectSuit(*DiscoverTestSuit)

func (*DiscoverTestSuit) NamespaceServer

func (d *DiscoverTestSuit) NamespaceServer() ns.NamespaceOperateServer

func (*DiscoverTestSuit) OriginConfigServer added in v1.17.3

func (d *DiscoverTestSuit) OriginConfigServer() *config.Server

func (*DiscoverTestSuit) OriginDiscoverServer

func (d *DiscoverTestSuit) OriginDiscoverServer() service.DiscoverServer

func (*DiscoverTestSuit) ReplaceStore added in v1.17.3

func (d *DiscoverTestSuit) ReplaceStore(caller func() store.Store)

func (*DiscoverTestSuit) StrategyServer added in v1.17.3

func (d *DiscoverTestSuit) StrategyServer() auth.StrategyServer

func (*DiscoverTestSuit) TruncateCommonRoutingConfigV2 added in v1.17.3

func (d *DiscoverTestSuit) TruncateCommonRoutingConfigV2()

func (*DiscoverTestSuit) UpdateCacheInterval

func (d *DiscoverTestSuit) UpdateCacheInterval() time.Duration

func (*DiscoverTestSuit) UserServer added in v1.17.3

func (d *DiscoverTestSuit) UserServer() auth.UserServer

type TestConfig

type TestConfig struct {
	Bootstrap           Bootstrap      `yaml:"bootstrap"`
	Cache               cache.Config   `yaml:"cache"`
	Namespace           ns.Config      `yaml:"namespace"`
	Naming              service.Config `yaml:"naming"`
	DisableConfig       bool
	Config              config.Config      `yaml:"config"`
	HealthChecks        healthcheck.Config `yaml:"healthcheck"`
	Store               store.Config       `yaml:"store"`
	DisableAuth         bool
	Auth                auth.Config   `yaml:"auth"`
	Plugin              plugin.Config `yaml:"plugin"`
	ReplaceStore        store.Store
	ServiceCacheEntries []cachetypes.ConfigEntry
}

type TestDataClean added in v1.17.3

type TestDataClean interface {
	InjectSuit(*DiscoverTestSuit)
	// CleanNamespace
	CleanNamespace(name string)
	// CleanReportClient
	CleanReportClient()
	// CleanAllService
	CleanAllService()
	// CleanService
	CleanService(name, namespace string)
	// CleanServices
	CleanServices(services []*apiservice.Service)
	// CleanInstance
	CleanInstance(instanceID string)
	// CleanCommonRoutingConfig
	CleanCommonRoutingConfig(service string, namespace string)
	// TruncateCommonRoutingConfigV2
	TruncateCommonRoutingConfigV2()
	// CleanCommonRoutingConfigV2
	CleanCommonRoutingConfigV2(rules []*apitraffic.RouteRule)
	// CleanRateLimit
	CleanRateLimit(id string)
	// CleanCircuitBreaker
	CleanCircuitBreaker(id, version string)
	// CleanCircuitBreakerRelation
	CleanCircuitBreakerRelation(name, namespace, ruleID, ruleVersion string)
	// ClearTestDataWhenUseRDS
	ClearTestDataWhenUseRDS() error
	// CleanServiceContract
	CleanServiceContract() error
}

TestDataClean 测试套件数据清理

Jump to

Keyboard shortcuts

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