integration

package
v0.0.0-...-4a20579 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDomainID     = "default"
	DefaultDomainName   = "default"
	AdminProjectID      = "admin"
	AdminProjectName    = "admin"
	DemoProjectID       = "demo"
	DemoProjectName     = "demo"
	NeutronProjectID    = "aa907485e1f94a14834d8c69ed9cb3b2"
	NeutronProjectName  = "neutron"
	ServiceProjectID    = "service-uuid"
	ServiceProjectName  = "service"
	AdminRoleID         = "admin"
	AdminRoleName       = "admin"
	NeutronRoleID       = "aa907485e1f94a14834d8c69ed9cb3b2"
	NeutronRoleName     = "neutron"
	MemberRoleID        = "Member"
	MemberRoleName      = "Member"
	AdminUserID         = "alice"
	AdminUserName       = "Alice"
	AdminUserPassword   = "alice_password"
	KSAdminUserID       = "admin"
	KSAdminUserName     = "admin"
	KSAdminUserPassword = "contrail123"
	BobUserID           = "bob"
	BobUserName         = "Bob"
	BobUserPassword     = "bob_password"
	ServiceUserID       = "goapi-uuid"
	ServiceUserName     = "goapi"
	ServiceUserPassword = "goapi"
)

Keystone credentials.

View Source
const (
	DefaultGlobalSystemConfigUUID = "beefbeef-beef-beef-beef-beefbeef0001"
	DefaultDomainUUID             = "beefbeef-beef-beef-beef-beefbeef0002"
	DefaultProjectUUID            = "beefbeef-beef-beef-beef-beefbeef0003"
	DomainType                    = "domain"
	ProjectType                   = "project"
	VirtualNetworkSingularPath    = "/virtual-network"
)

Resource constants

View Source
const (
	DefaultClientID = "default"
)

Integration tests constants.

Variables

This section is empty.

Functions

func AdminHTTPConfig

func AdminHTTPConfig(apiServerURL string) *asfclient.HTTPConfig

AdminHTTPConfig returns HTTP client config containing admin credentials.

func CloseFatalIfError

func CloseFatalIfError(c Closer, errChan <-chan error)

CloseFatalIfError calls close and calls log.Fatal if error channel returns an error.

func CloseNoError

func CloseNoError(t *testing.T, c Closer, errChan <-chan error)

CloseNoError calls close and expects that error channel is closed without an error.

func CreateContrailCluster

func CreateContrailCluster(
	t *testing.T, s services.WriteService, obj *models.ContrailCluster,
) *models.ContrailCluster

CreateContrailCluster creates a Contrail cluster resource in given service.

func CreateEndpoint

func CreateEndpoint(t *testing.T, s services.WriteService, obj *models.Endpoint) *models.Endpoint

CreateEndpoint creates an endpoint resource in given service.

func CreateNetworkIpam

func CreateNetworkIpam(t *testing.T, s services.WriteService, obj *models.NetworkIpam) *models.NetworkIpam

CreateNetworkIpam creates a network IPAM resource in given service.

func CreateNetworkPolicy

func CreateNetworkPolicy(
	ctx context.Context, t *testing.T, s services.WriteService, obj *models.NetworkPolicy,
) *models.NetworkPolicy

CreateNetworkPolicy creates a network policy resource in given service.

func CreateProject

func CreateProject(t *testing.T, s services.WriteService, obj *models.Project) *models.Project

CreateProject creates a project resource in given service.

func CreateRouteTarget

func CreateRouteTarget(t *testing.T, s services.WriteService, obj *models.RouteTarget) *models.RouteTarget

CreateRouteTarget creates a route target resource from given service.

func CreateRoutingInstance

func CreateRoutingInstance(t *testing.T, s services.WriteService, obj *models.RoutingInstance) *models.RoutingInstance

CreateRoutingInstance creates a routing instance resource from given service.

func CreateVirtualNetwork

func CreateVirtualNetwork(t *testing.T, s services.WriteService, obj *models.VirtualNetwork) *models.VirtualNetwork

CreateVirtualNetwork creates a virtual network resource from given service.

func DeleteAccessControlList

func DeleteAccessControlList(t *testing.T, s services.WriteService, uuid string)

DeleteAccessControlList deletes an access control list resource from given service.

func DeleteContrailCluster

func DeleteContrailCluster(t *testing.T, s services.WriteService, uuid string)

DeleteContrailCluster deletes a Contrail cluster resource from given service.

func DeleteEndpoint

func DeleteEndpoint(t *testing.T, s services.WriteService, uuid string)

DeleteEndpoint deletes a network IPAM resource from given service.

func DeleteNetworkIpam

func DeleteNetworkIpam(t *testing.T, s services.WriteService, uuid string)

DeleteNetworkIpam deletes a network IPAM resource from given service.

func DeleteNetworkPolicy

func DeleteNetworkPolicy(
	ctx context.Context, t *testing.T, s services.WriteService, uuid string,
)

DeleteNetworkPolicy deletes a network policy resource from given service.

func DeleteProject

func DeleteProject(t *testing.T, s services.WriteService, uuid string)

DeleteProject deletes a project resource using given service.

func DeleteRouteTarget

func DeleteRouteTarget(t *testing.T, s services.WriteService, uuid string)

DeleteRouteTarget deletes a route target resource from given service.

func DeleteRoutingInstance

func DeleteRoutingInstance(t *testing.T, s services.WriteService, uuid string)

DeleteRoutingInstance deletes a routing instance resource from given service.

func DeleteSecurityGroup

func DeleteSecurityGroup(t *testing.T, s services.WriteService, uuid string)

DeleteSecurityGroup deletes a security group resource from given service.

func DeleteVirtualNetwork

func DeleteVirtualNetwork(t *testing.T, s services.WriteService, uuid string)

DeleteVirtualNetwork deletes a virtual network resource from given service.

func GetNetworkIpam

func GetNetworkIpam(t *testing.T, s services.ReadService, uuid string) *models.NetworkIpam

GetNetworkIpam gets a network IPAM resource from given service.

func GetNetworkPolicy

func GetNetworkPolicy(ctx context.Context, t *testing.T, s services.ReadService, uuid string) *models.NetworkPolicy

GetNetworkPolicy gets a network policy resource from given service.

func GetProject

func GetProject(t *testing.T, s services.ReadService, uuid string) *models.Project

GetProject gets a project resource from given service.

func GetRouteTarget

func GetRouteTarget(t *testing.T, s services.ReadService, uuid string) *models.RouteTarget

GetRouteTarget gets a route target resource from given service.

func GetRoutingInstance

func GetRoutingInstance(t *testing.T, s services.ReadService, uuid string) *models.RoutingInstance

GetRoutingInstance gets a routing instance resource from given service.

func GetVirtualNetwork

func GetVirtualNetwork(t *testing.T, s services.ReadService, uuid string) *models.VirtualNetwork

GetVirtualNetwork gets a virtual network resource from given service.

func NewAdminHTTPClient

func NewAdminHTTPClient(apiServerURL string) (*client.HTTP, error)

NewAdminHTTPClient creates HTTP client of API Server using Alice user (admin) credentials.

func NewHTTPClient

func NewHTTPClient(apiServerURL string) (*client.HTTP, error)

NewHTTPClient creates HTTP client of API Server using Bob user credentials.

func NewKeystoneServerFake

func NewKeystoneServerFake(t *testing.T, keystoneAuthURL, user, password string) *httptest.Server

NewKeystoneServerFake creates started Keystone server fake. It registers given user in default domain with admin role.

func RunCacheDB

func RunCacheDB() (*cache.DB, func() error, error)

RunCacheDB runs DB Cache with etcd event producer.

func RunCleanTestScenario

func RunCleanTestScenario(
	t *testing.T,
	ts *TestScenario,
	server *APIServer,
)

RunCleanTestScenario runs test scenario from loaded yaml file, expects no resources leftovers

func RunConcurrently

func RunConcurrently(r Runner) <-chan error

RunConcurrently runs runner in separate goroutine and returns a channel to read Run error.

func RunDirtyTestScenario

func RunDirtyTestScenario(t *testing.T, ts *TestScenario, server *APIServer) func()

RunDirtyTestScenario runs test scenario from loaded yaml file, leaves all resources after scenario

func RunIntentCompilationService

func RunIntentCompilationService(t *testing.T, apiURL string) context.CancelFunc

RunIntentCompilationService runs Intent Compilation process and returns function closing it.

func RunNoError

func RunNoError(t *testing.T, rc RunCloser) (close func(*testing.T))

RunNoError runs RunCloser concurrently and returns callback for stopping the goroutine that also expects no error is returned from Run.

func RunTest

func RunTest(t *testing.T, file string, server *APIServer)

RunTest invokes integration test located in given file.

func RunTestFromTestsDirectory

func RunTestFromTestsDirectory(t *testing.T, name string, server *APIServer)

RunTestFromTestsDirectory invokes integration test located in "tests" directory.

func RunTestTemplate

func RunTestTemplate(t *testing.T, file string, server *APIServer, context map[string]interface{})

RunTestTemplate invokes integration test from template located in given file.

func SetDefaultSyncConfig

func SetDefaultSyncConfig(shouldDump bool)

SetDefaultSyncConfig sets config options required by sync.

func StartWaiters

func StartWaiters(t *testing.T, task string, waiters Waiters) func(t *testing.T)

StartWaiters checks if there are emitted events described before.

func StartWatchers

func StartWatchers(t *testing.T, task string, watchers Watchers, opts ...clientv3.OpOption) func(t *testing.T)

StartWatchers checks if events emitted to etcd match those given in watchers dict.

func TestMain

func TestMain(m *testing.M, s **APIServer)

TestMain is a function that can be called inside package specific TestMain to enable integration testing capabilities.

func UpdateEndpoint

func UpdateEndpoint(t *testing.T, s services.WriteService, obj *models.Endpoint) *models.Endpoint

UpdateEndpoint updates an endpoint resource in given service.

func WithViperConfig

func WithViperConfig(f func())

WithViperConfig initializes Viper configuration and logging and runs given test function.

Types

type APIServer

type APIServer struct {
	APIServer *apiserver.Server
	// contains filtered or unexported fields
}

APIServer is embedded API Server for testing purposes.

func NewRunningAPIServer

func NewRunningAPIServer(t *testing.T, c *APIServerConfig) *APIServer

NewRunningAPIServer creates new running test API Server for testing purposes. Call CloseT() or Close() method to release its resources.

func NewRunningServer

func NewRunningServer(c *APIServerConfig) (*APIServer, error)

NewRunningServer creates new running API server with default testing configuration. Call CloseT() or Close() method to release its resources. TODO(dfurman): modify function to call contrail.StartServer() to remove duplication nolint: gocyclo

func (*APIServer) AddKeystoneProjectAndUser

func (s *APIServer) AddKeystoneProjectAndUser(t testing.TB, testID string) func()

AddKeystoneProjectAndUser adds Keystone project and user in Server internal state. TODO: Remove that, because it modifies internal state of SUT. TODO: Use pre-created Server's keystone assignment.

func (*APIServer) Close

func (s *APIServer) Close() error

Close closes the server.

func (*APIServer) CloseT

func (s *APIServer) CloseT(t *testing.T)

CloseT closes the server.

func (*APIServer) ForceProxyUpdate

func (s *APIServer) ForceProxyUpdate()

ForceProxyUpdate requests an immediate update of endpoints and waits for its completion.

func (*APIServer) URL

func (s *APIServer) URL() string

URL returns server base URL.

type APIServerConfig

type APIServerConfig struct {
	CacheDB              *cache.DB
	RepoRootPath         string
	LogLevel             string
	EnableEtcdNotifier   bool
	DisableLogAPI        bool
	EnableRBAC           bool
	EnableVNCReplication bool
}

APIServerConfig contains parameters for test API Server.

type CleanTask

type CleanTask struct {
	Client string   `yaml:"client,omitempty"`
	Path   string   `yaml:"path,omitempty"`
	FQName []string `yaml:"fq_name,omitempty"`
	Kind   string   `yaml:"kind,omitempty"`
}

CleanTask defines clean task

type ClientsList

type ClientsList map[string]*client.HTTP

ClientsList is the list of clients used in test

func PrepareClients

func PrepareClients(ctx context.Context, t *testing.T, ts *TestScenario, server *APIServer) ClientsList

PrepareClients creates HTTP clients based on given configurations and logs them in if needed. It assigns created clients to given test scenario.

type Closer

type Closer interface {
	Close()
}

Closer can be closed.

type CloserFunc

type CloserFunc func()

CloserFunc is a function that implements Closer interface.

func (CloserFunc) Close

func (f CloserFunc) Close()

Close calls the function.

type Event

type Event struct {
	Data     map[string]interface{} `yaml:"data,omitempty"`
	SyncOnly bool                   `yaml:"sync_only,omitempty"`
}

Event represents event received from etcd watch.

type HTTPAPIClient

type HTTPAPIClient struct {
	*client.HTTP
	// contains filtered or unexported fields
}

HTTPAPIClient is API Server client for testing purposes.

func NewTestingHTTPClient

func NewTestingHTTPClient(t *testing.T, apiServerURL string, userID string) *HTTPAPIClient

NewTestingHTTPClient creates HTTP client of API Server with testing capabilities. It logs in with given userID, such as "alice" and "bob".

func (*HTTPAPIClient) CheckResourceDoesNotExist

func (c *HTTPAPIClient) CheckResourceDoesNotExist(t *testing.T, path string)

CheckResourceDoesNotExist checks that there is no resource with given path.

func (*HTTPAPIClient) Chown

func (c *HTTPAPIClient) Chown(t *testing.T, owner, uuid string)

Chown performs "chown" request.

func (*HTTPAPIClient) EnsureContrailClusterDeleted

func (c *HTTPAPIClient) EnsureContrailClusterDeleted(t *testing.T, uuid string)

EnsureContrailClusterDeleted deletes resource with given UUID, ignoring "not found" error.

func (*HTTPAPIClient) EnsureEndpointDeleted

func (c *HTTPAPIClient) EnsureEndpointDeleted(t *testing.T, uuid string)

EnsureEndpointDeleted deletes resource with given UUID, ignoring "not found" error.

func (*HTTPAPIClient) FQNameToID

func (c *HTTPAPIClient) FQNameToID(t *testing.T, fqName []string, resourceType string) (uuid string)

FQNameToID performs FQName to ID request.

type RunCloser

type RunCloser interface {
	Runner
	Closer
}

RunCloser is a Runner that is also a Closer.

type Runner

type Runner interface {
	Run() error
}

Runner can be run and return an error.

type RunnerFunc

type RunnerFunc func() error

RunnerFunc is a function that implements the Runner interface.

func (RunnerFunc) Run

func (f RunnerFunc) Run() error

Run calls the function.

type Task

type Task struct {
	Name     string             `yaml:"name,omitempty"`
	Client   string             `yaml:"client,omitempty"`
	Request  *asfclient.Request `yaml:"request,omitempty"`
	Expect   interface{}        `yaml:"expect,omitempty"`
	Watchers Watchers           `yaml:"watchers,omitempty"`
	Waiters  Waiters            `yaml:"await,omitempty"`
}

Task has API request and expected response.

type TestScenario

type TestScenario struct {
	Name                  string                           `yaml:"name,omitempty"`
	Description           string                           `yaml:"description,omitempty"`
	IntentCompilerEnabled bool                             `yaml:"intent_compiler_enabled,omitempty"`
	Tables                []string                         `yaml:"tables,omitempty"`
	ClientConfigs         map[string]*asfclient.HTTPConfig `yaml:"clients,omitempty"`
	Clients               ClientsList                      `yaml:"-"`
	CleanTasks            []CleanTask                      `yaml:"cleanup,omitempty"`
	Workflow              []*Task                          `yaml:"workflow,omitempty"`
	Watchers              Watchers                         `yaml:"watchers,omitempty"`
	TestData              interface{}                      `yaml:"test_data,omitempty"`
}

TestScenario defines integration test scenario.

func LoadTest

func LoadTest(file string, ctx map[string]interface{}) (*TestScenario, error)

LoadTest loads test scenario from given file.

type Waiters

type Waiters map[string][]Event

Waiters map contains slices of events that have to be emitted during single task.

type Watchers

type Watchers map[string][]Event

Watchers map contains slices of events that should be emitted on etcd key matching the map key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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