Documentation ¶
Index ¶
- Constants
- func AdminHTTPConfig(apiServerURL string) *asfclient.HTTPConfig
- func CloseFatalIfError(c Closer, errChan <-chan error)
- func CloseNoError(t *testing.T, c Closer, errChan <-chan error)
- func CreateContrailCluster(t *testing.T, s services.WriteService, obj *models.ContrailCluster) *models.ContrailCluster
- func CreateEndpoint(t *testing.T, s services.WriteService, obj *models.Endpoint) *models.Endpoint
- func CreateNetworkIpam(t *testing.T, s services.WriteService, obj *models.NetworkIpam) *models.NetworkIpam
- func CreateNetworkPolicy(ctx context.Context, t *testing.T, s services.WriteService, ...) *models.NetworkPolicy
- func CreateProject(t *testing.T, s services.WriteService, obj *models.Project) *models.Project
- func CreateRouteTarget(t *testing.T, s services.WriteService, obj *models.RouteTarget) *models.RouteTarget
- func CreateRoutingInstance(t *testing.T, s services.WriteService, obj *models.RoutingInstance) *models.RoutingInstance
- func CreateVirtualNetwork(t *testing.T, s services.WriteService, obj *models.VirtualNetwork) *models.VirtualNetwork
- func DeleteAccessControlList(t *testing.T, s services.WriteService, uuid string)
- func DeleteContrailCluster(t *testing.T, s services.WriteService, uuid string)
- func DeleteEndpoint(t *testing.T, s services.WriteService, uuid string)
- func DeleteNetworkIpam(t *testing.T, s services.WriteService, uuid string)
- func DeleteNetworkPolicy(ctx context.Context, t *testing.T, s services.WriteService, uuid string)
- func DeleteProject(t *testing.T, s services.WriteService, uuid string)
- func DeleteRouteTarget(t *testing.T, s services.WriteService, uuid string)
- func DeleteRoutingInstance(t *testing.T, s services.WriteService, uuid string)
- func DeleteSecurityGroup(t *testing.T, s services.WriteService, uuid string)
- func DeleteVirtualNetwork(t *testing.T, s services.WriteService, uuid string)
- func GetNetworkIpam(t *testing.T, s services.ReadService, uuid string) *models.NetworkIpam
- func GetNetworkPolicy(ctx context.Context, t *testing.T, s services.ReadService, uuid string) *models.NetworkPolicy
- func GetProject(t *testing.T, s services.ReadService, uuid string) *models.Project
- func GetRouteTarget(t *testing.T, s services.ReadService, uuid string) *models.RouteTarget
- func GetRoutingInstance(t *testing.T, s services.ReadService, uuid string) *models.RoutingInstance
- func GetVirtualNetwork(t *testing.T, s services.ReadService, uuid string) *models.VirtualNetwork
- func NewAdminHTTPClient(apiServerURL string) (*client.HTTP, error)
- func NewHTTPClient(apiServerURL string) (*client.HTTP, error)
- func NewKeystoneServerFake(t *testing.T, keystoneAuthURL, user, password string) *httptest.Server
- func RunCacheDB() (*cache.DB, func() error, error)
- func RunCleanTestScenario(t *testing.T, ts *TestScenario, server *APIServer)
- func RunConcurrently(r Runner) <-chan error
- func RunDirtyTestScenario(t *testing.T, ts *TestScenario, server *APIServer) func()
- func RunIntentCompilationService(t *testing.T, apiURL string) context.CancelFunc
- func RunNoError(t *testing.T, rc RunCloser) (close func(*testing.T))
- func RunTest(t *testing.T, file string, server *APIServer)
- func RunTestFromTestsDirectory(t *testing.T, name string, server *APIServer)
- func RunTestTemplate(t *testing.T, file string, server *APIServer, context map[string]interface{})
- func SetDefaultSyncConfig(shouldDump bool)
- func StartWaiters(t *testing.T, task string, waiters Waiters) func(t *testing.T)
- func StartWatchers(t *testing.T, task string, watchers Watchers, opts ...clientv3.OpOption) func(t *testing.T)
- func TestMain(m *testing.M, s **APIServer)
- func UpdateEndpoint(t *testing.T, s services.WriteService, obj *models.Endpoint) *models.Endpoint
- func WithViperConfig(f func())
- type APIServer
- type APIServerConfig
- type CleanTask
- type ClientsList
- type Closer
- type CloserFunc
- type Event
- type HTTPAPIClient
- func (c *HTTPAPIClient) CheckResourceDoesNotExist(t *testing.T, path string)
- func (c *HTTPAPIClient) Chown(t *testing.T, owner, uuid string)
- func (c *HTTPAPIClient) EnsureContrailClusterDeleted(t *testing.T, uuid string)
- func (c *HTTPAPIClient) EnsureEndpointDeleted(t *testing.T, uuid string)
- func (c *HTTPAPIClient) FQNameToID(t *testing.T, fqName []string, resourceType string) (uuid string)
- type RunCloser
- type Runner
- type RunnerFunc
- type Task
- type TestScenario
- type Waiters
- type Watchers
Constants ¶
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.
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
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 ¶
CloseFatalIfError calls close and calls log.Fatal if error channel returns an error.
func CloseNoError ¶
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 ¶
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 ¶
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 ¶
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 ¶
NewAdminHTTPClient creates HTTP client of API Server using Alice user (admin) credentials.
func NewHTTPClient ¶
NewHTTPClient creates HTTP client of API Server using Bob user credentials.
func NewKeystoneServerFake ¶
NewKeystoneServerFake creates started Keystone server fake. It registers given user in default domain with admin role.
func RunCacheDB ¶
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 ¶
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 ¶
RunNoError runs RunCloser concurrently and returns callback for stopping the goroutine that also expects no error is returned from Run.
func RunTestFromTestsDirectory ¶
RunTestFromTestsDirectory invokes integration test located in "tests" directory.
func RunTestTemplate ¶
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 ¶
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 ¶
TestMain is a function that can be called inside package specific TestMain to enable integration testing capabilities.
func UpdateEndpoint ¶
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 ¶
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 ¶
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) ForceProxyUpdate ¶
func (s *APIServer) ForceProxyUpdate()
ForceProxyUpdate requests an immediate update of endpoints and waits for its completion.
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 ¶
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 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 ¶
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 RunnerFunc ¶
type RunnerFunc func() error
RunnerFunc is a function that implements the Runner interface.
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.