testing_tools

package
v0.83.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TestAccountId = "testAccountId"
	TestPeerId    = "testPeerId"
	TestGroupId   = "testGroupId"
	TestKeyId     = "testKeyId"

	TestUserId         = "testUserId"
	TestAdminId        = "testAdminId"
	TestOwnerId        = "testOwnerId"
	TestServiceUserId  = "testServiceUserId"
	TestServiceAdminId = "testServiceAdminId"
	BlockedUserId      = "blockedUserId"
	OtherUserId        = "otherUserId"
	InvalidToken       = "invalidToken"

	NewKeyName   = "newKey"
	NewGroupId   = "newGroupId"
	ExpiresIn    = 3600
	RevokedKeyId = "revokedKeyId"
	ExpiredKeyId = "expiredKeyId"

	ExistingKeyName = "existingKey"

	OperationCreate = "create"
	OperationUpdate = "update"
	OperationDelete = "delete"
	OperationGetOne = "get_one"
	OperationGetAll = "get_all"
)

Variables

View Source
var BenchmarkDuration = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Name: "benchmark_duration_ms",
		Help: "Benchmark duration per op in ms",
	},
	[]string{"module", "operation", "test_case", "branch"},
)

Functions

func BuildRequest

func BuildRequest(t TB, requestBody []byte, requestType, requestPath, user string) *http.Request

func EvaluateAPIBenchmarkResults added in v0.56.0

func EvaluateAPIBenchmarkResults(b *testing.B, testCase string, duration time.Duration, recorder *httptest.ResponseRecorder, module string, operation string)

func EvaluateBenchmarkResults

func EvaluateBenchmarkResults(b *testing.B, testCase string, duration time.Duration, module string, operation string)

func GetDB added in v0.67.2

func GetDB(t *testing.T, s store.Store) *gorm.DB

GetDB extracts the *gorm.DB from a store.Store (must be *SqlStore).

func PopulateTestData

func PopulateTestData(b *testing.B, am account.Manager, peers, groups, users, setupKeys int)

func ReadResponse

func ReadResponse(t *testing.T, recorder *httptest.ResponseRecorder, expectedStatus int, expectResponse bool) ([]byte, bool)

func VerifyAccountSettings added in v0.67.2

func VerifyAccountSettings(t *testing.T, db *gorm.DB) *types.Account

VerifyAccountSettings reads the account and returns its settings from the DB.

func VerifyGroupInDB added in v0.67.2

func VerifyGroupInDB(t *testing.T, db *gorm.DB, groupID string) *types.Group

VerifyGroupInDB reads a group directly from the DB and returns it.

func VerifyGroupNotInDB added in v0.67.2

func VerifyGroupNotInDB(t *testing.T, db *gorm.DB, groupID string)

VerifyGroupNotInDB verifies that a group does not exist in the DB.

func VerifyNSGroupInDB added in v0.67.2

func VerifyNSGroupInDB(t *testing.T, db *gorm.DB, nsGroupID string) *nbdns.NameServerGroup

VerifyNSGroupInDB reads a nameserver group directly from the DB and returns it.

func VerifyNSGroupNotInDB added in v0.67.2

func VerifyNSGroupNotInDB(t *testing.T, db *gorm.DB, nsGroupID string)

VerifyNSGroupNotInDB verifies that a nameserver group does not exist in the DB.

func VerifyNetworkInDB added in v0.67.2

func VerifyNetworkInDB(t *testing.T, db *gorm.DB, networkID string) *networkTypes.Network

VerifyNetworkInDB reads a network directly from the store and returns it.

func VerifyNetworkNotInDB added in v0.67.2

func VerifyNetworkNotInDB(t *testing.T, db *gorm.DB, networkID string)

VerifyNetworkNotInDB verifies that a network does not exist in the DB.

func VerifyNetworkResourceInDB added in v0.67.2

func VerifyNetworkResourceInDB(t *testing.T, db *gorm.DB, resourceID string) *resourceTypes.NetworkResource

VerifyNetworkResourceInDB reads a network resource directly from the DB and returns it.

func VerifyNetworkResourceNotInDB added in v0.67.2

func VerifyNetworkResourceNotInDB(t *testing.T, db *gorm.DB, resourceID string)

VerifyNetworkResourceNotInDB verifies that a network resource does not exist in the DB.

func VerifyNetworkRouterInDB added in v0.67.2

func VerifyNetworkRouterInDB(t *testing.T, db *gorm.DB, routerID string) *routerTypes.NetworkRouter

VerifyNetworkRouterInDB reads a network router directly from the DB and returns it.

func VerifyNetworkRouterNotInDB added in v0.67.2

func VerifyNetworkRouterNotInDB(t *testing.T, db *gorm.DB, routerID string)

VerifyNetworkRouterNotInDB verifies that a network router does not exist in the DB.

func VerifyPATInDB added in v0.67.2

func VerifyPATInDB(t *testing.T, db *gorm.DB, tokenID string) *types.PersonalAccessToken

VerifyPATInDB reads a PAT directly from the DB and returns it.

func VerifyPATNotInDB added in v0.67.2

func VerifyPATNotInDB(t *testing.T, db *gorm.DB, tokenID string)

VerifyPATNotInDB verifies that a PAT does not exist in the DB.

func VerifyPeerInDB added in v0.67.2

func VerifyPeerInDB(t *testing.T, db *gorm.DB, peerID string) *nbpeer.Peer

VerifyPeerInDB reads a peer directly from the DB and returns it.

func VerifyPeerNotInDB added in v0.67.2

func VerifyPeerNotInDB(t *testing.T, db *gorm.DB, peerID string)

VerifyPeerNotInDB verifies that a peer does not exist in the DB.

func VerifyPolicyInDB added in v0.67.2

func VerifyPolicyInDB(t *testing.T, db *gorm.DB, policyID string) *types.Policy

VerifyPolicyInDB reads a policy directly from the DB and returns it.

func VerifyPolicyNotInDB added in v0.67.2

func VerifyPolicyNotInDB(t *testing.T, db *gorm.DB, policyID string)

VerifyPolicyNotInDB verifies that a policy does not exist in the DB.

func VerifyRouteInDB added in v0.67.2

func VerifyRouteInDB(t *testing.T, db *gorm.DB, routeID route.ID) *route.Route

VerifyRouteInDB reads a route directly from the DB and returns it.

func VerifyRouteNotInDB added in v0.67.2

func VerifyRouteNotInDB(t *testing.T, db *gorm.DB, routeID route.ID)

VerifyRouteNotInDB verifies that a route does not exist in the DB.

func VerifySetupKeyInDB added in v0.67.2

func VerifySetupKeyInDB(t *testing.T, db *gorm.DB, keyID string) *types.SetupKey

VerifySetupKeyInDB reads a setup key directly from the DB and returns it.

func VerifySetupKeyNotInDB added in v0.67.2

func VerifySetupKeyNotInDB(t *testing.T, db *gorm.DB, keyID string)

VerifySetupKeyNotInDB verifies that a setup key does not exist in the DB.

func VerifyUserInDB added in v0.67.2

func VerifyUserInDB(t *testing.T, db *gorm.DB, userID string) *types.User

VerifyUserInDB reads a user directly from the DB and returns it.

func VerifyUserNotInDB added in v0.67.2

func VerifyUserNotInDB(t *testing.T, db *gorm.DB, userID string)

VerifyUserNotInDB verifies that a user does not exist in the DB.

Types

type BenchmarkCase

type BenchmarkCase struct {
	Peers     int
	Groups    int
	Users     int
	SetupKeys int
}

BenchmarkCase defines a single benchmark test case

type PerformanceMetrics

type PerformanceMetrics struct {
	MinMsPerOpLocal float64
	MaxMsPerOpLocal float64
	MinMsPerOpCICD  float64
	MaxMsPerOpCICD  float64
}

PerformanceMetrics holds the performance expectations

type TB

type TB interface {
	Cleanup(func())
	Helper()
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
	TempDir() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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