tcdata

package
v8.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 16 Imported by: 0

Documentation

Overview

Package tcdata provides dynamic loading/unloading of ATC objects to/from a Traffic Ops instance.

This should ONLY be imported by tests, that's the library's only purpose.

Index

Constants

This section is empty.

Variables

View Source
var (
	TOSession       *client.Session
	NoAuthTOSession *client.Session
)

Functions

func SetupAPICapabilities

func SetupAPICapabilities(db *sql.DB) error

func SetupCapabilities

func SetupCapabilities(db *sql.DB) error

func SetupJobs

func SetupJobs(db *sql.DB) error

SetupJobs ...

func SetupRoleCapabilities

func SetupRoleCapabilities(db *sql.DB) error

func SetupRoles

func SetupRoles(db *sql.DB) error

SetupRoles ...

func SetupTenants

func SetupTenants(db *sql.DB) error

SetupTenants ...

func SetupToExtensions

func SetupToExtensions(db *sql.DB) error

SetupToExtensions setup open slot in to_extension table

func SetupTypes

func SetupTypes(db *sql.DB) error

SetupTypes Set up to_extension types

func WrapClient

func WrapClient(
	cl **toclient.Session,
	clF func(t *testing.T, toClient *toclient.Session),
) func(t *testing.T)

WrapClient is a temp func that creates a func(t *testing.T) from a *toclient.Session and a func(t *testing.T, toClient *toclient.Session).

func WrapClientDat

func WrapClientDat(
	cl **toclient.Session,
	dat *totest.TrafficControl,
	clF func(t *testing.T, toClient *toclient.Session, dat totest.TrafficControl),
) func(t *testing.T)

WrapClient is a temp func that creates a func(t *testing.T) from a *toclient.Session, totest.TrafficControl, and a func(t *testing.T, toClient *toclient.Session, dat totest.TrafficControl).

func WrapClientDatDB

func WrapClientDatDB(
	r *TCData,
	cl **toclient.Session,
	dat *totest.TrafficControl,
	clF func(t *testing.T, toClient *toclient.Session, dat totest.TrafficControl, db *sql.DB),
) func(t *testing.T)

func WrapNewClientDat

func WrapNewClientDat(
	r *TCData,
	dat *totest.TrafficControl,
	user *string,
	pass *string,
	clF func(t *testing.T, toClient *toclient.Session, dat totest.TrafficControl),
) func(t *testing.T)

WrapNewClientDat is like WrapClientDat but creates a new custom TO client instead of using the global variable.

Types

type TCData

type TCData struct {
	Config   *config.Config
	TestData *totest.TrafficControl
}

func NewTCData

func NewTCData() *TCData

func (*TCData) LoadFixtures

func (r *TCData) LoadFixtures(fixturesPath string)

LoadFixtures ...

func (*TCData) OpenConnection

func (r *TCData) OpenConnection() (*sql.DB, error)

OpenConnection ...

func (*TCData) QueueUpdatesForServer

func (r *TCData) QueueUpdatesForServer(hostname string, queue bool) error

func (*TCData) SetupSession

func (r *TCData) SetupSession(toReqTimeout time.Duration, toURL string, toUser string, toPass string) error

func (*TCData) SetupTestData

func (r *TCData) SetupTestData(*sql.DB) error

SetupTestData sets up initial data needed by the test suite to perform any tests.

func (*TCData) SetupTmusers

func (r *TCData) SetupTmusers(db *sql.DB) error

SetupTmusers ...

func (*TCData) SwitchSession

func (r *TCData) SwitchSession(toReqTimeout time.Duration, toURL string, toOldUser string, toOldPass string, toNewUser string, toNewPass string) error

func (*TCData) Teardown

func (r *TCData) Teardown(db *sql.DB) error

Teardown - ensures that the data is cleaned up for a fresh run

func (*TCData) TeardownSession

func (r *TCData) TeardownSession(toReqTimeout time.Duration, toURL string, toUser string, toPass string) error

func (*TCData) WithObjs

func (r *TCData) WithObjs(t *testing.T, objs []TCObj, f func())

WithObjs creates the objs in order, runs f, and defers deleting the objs in the same order.

Because deletion is deferred, using this ensures objects will be cleaned up if f panics or calls t.Fatal, as much as possible.

Note that f itself may still create things which are not cleaned up properly, and likewise, the object creation and deletion tests themselves may fail. All tests in the Traffic Ops API Testing framework use the same Traffic Ops instance, with persistent data. Because of this, when any test fails, all subsequent tests should be considered invalid, irrespective whether they pass or fail. Users are encouraged to use `go test -failfast`.

type TCObj

type TCObj int
const (
	ASN TCObj = iota
	CacheGroups
	CacheGroupsDeliveryServices
	// CacheGroupParameters
	CDNs
	CDNFederations
	Coordinates
	DeliveryServices
	DeliveryServicesRegexes
	DeliveryServiceRequests
	DeliveryServiceRequestComments
	DeliveryServicesRequiredCapabilities
	Divisions
	FederationResolvers
	FederationUsers
	Jobs
	Origins
	Parameters
	PhysLocations
	Profiles
	ProfileParameters
	Regions
	Roles
	ServerCapabilities
	ServerChecks
	ServerServerCapabilities
	Servers
	Statuses
	ServiceCategories
	StaticDNSEntries
	SteeringTargets
	Tenants
	ServerCheckExtensions
	Topologies
	Types
	Users
)

type TCObjFuncs

type TCObjFuncs struct {
	Create func(t *testing.T)
	Delete func(t *testing.T)
}

Jump to

Keyboard shortcuts

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