framework

package
v0.0.0-...-21311fb Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cluster infra.Infra

Cluster is the global instance of the cluster the tests are executed on

TestContext defines the global test configuration for the test run

Functions

func BackupApplication

func BackupApplication()

BackupApplication implements test for backup hook

func CloseDriver

func CloseDriver()

CloseDriver stops and closes the test-global web driver

func ConfigureFlags

func ConfigureFlags()

ConfigureFlags registers common command line flags, parses the command line and interprets the configuration

func ConnectToOpsCenter

func ConnectToOpsCenter(opsCenterURL string, login ServiceLogin) error

ConnectToOpsCenter connects to the Ops Center specified with opsCenterURL using specified login

func CoreDump

func CoreDump()

CoreDump collects diagnostic information into the specified report directory after the tests

func CreateDriver

func CreateDriver()

CreateDriver creates a new instance of the web driver

func Destroy

func Destroy()

Destroy destroys the infrastructure created previously in InitializeCluster and removes state directory

func Distribute

func Distribute(command string, nodes ...infra.Node)

Distribute executes the specified command on nodes

func Failf

func Failf(format string, args ...interface{})

func FakeUpdateApplication

func FakeUpdateApplication()

FakeUpdateApplication implements site update test by downloading the application tarball, incrementing the version and importing the same tarball with a new version.

It downloads the update from one of the remote nodes before returning to ensure that the application update is available

func InitializeCluster

func InitializeCluster()

InitializeCluster creates infrastructure according to configuration

func InstallerNode

func InstallerNode() infra.Node

InstallerNode returns the node with the running installer. Only applicable in wizard mode (TestContext.Wizard == true)

func InstallerURL

func InstallerURL() string

InstallerURL returns URL of the installer for the configured application package

func RestoreApplication

func RestoreApplication()

RestoreApplication implements test for restore hook

func RoboDescribe

func RoboDescribe(text string, body func()) bool

RoboDescribe is local wrapper function for ginkgo.Describe. It adds test namespacing. TODO: eventually benefit from safe test tags: https://github.com/kubernetes/kubernetes/pull/22401.

func RunAgentCommand

func RunAgentCommand(command string, nodes ...infra.Node)

RunAgentCommand interprets the specified command as agent command. It will modify the agent command line to start agent in background and will distribute the command on the specified nodes

func SiteInstallURL

func SiteInstallURL(clusterName string) string

SiteInstallURL returns URL of current cluster installation

func SiteURL

func SiteURL() string

SiteURL returns URL of the site specified in configuration as TestContext.ClusterName

func URLPath

func URLPath(path string) string

URLPath returns a new URL from the configured entry URL using path as new URL path

func URLPathFromString

func URLPathFromString(urlS string, path string) string

URLPathFromString returns a new URL with the specified URL urlS using path as a custom URL path

func UpdateApplicationWithInstaller

func UpdateApplicationWithInstaller()

UpdateApplicationWithInstaller impements site update via installer tarball

func UpdateBackupState

func UpdateBackupState()

func UpdateSiteEntry

func UpdateSiteEntry(entryURL string, login Login, serviceLogin *ServiceLogin)

UpdateSiteEntry specifies new entryURL and login details to use for subsequent site access.

func UpdateState

func UpdateState()

UpdateState updates the state file with the current provisioner state. It validates the context to avoid updating a state file on an inactive or automatically provisioned cluster

Types

type BackupConfig

type BackupConfig struct {
	Addr string `json:"addr" yaml:"addr" `
	// BackupPath defines path where Backup will be stored. Path should be absolute.
	// Also this path used for restore operation on node.
	Path string `json:"path" yaml:"path" `
}

BackupConfig defines configuration for Backup/Restore operations

type BackupState

type BackupState struct {
	// Addr is the address of a node where backup is storing
	Addr string `json:"addr"`
	// Path is an absolute path to the backup file
	Path string `json:"path"`
}

BackupState defines state of backup.

type BandwagonConfig

type BandwagonConfig struct {
	Organization string `json:"organization" yaml:"organization" `
	Username     string `json:"username" yaml:"username" `
	Password     string `json:"password" yaml:"password" `
	Email        string `json:"email" yaml:"email" `
	// Extra defines extended configuration for bandwagon
	Extra        *BandwagonExtraConfig `json:"extra" yaml:"extra"`
	RemoteAccess bool
}

type BandwagonExtraConfig

type BandwagonExtraConfig struct {
	// PlatformDNS defines address of DNS server for accessing the platform
	PlatformDNS string `json:"platform_dns" yaml:"platform_dns"`
	// NFSServer defines address of NFS server used by platform
	NFSServer string `json:"nfs_server" yaml:"nfs_server"`
	// NFSPath identifies a file system exported by a remote NFS server
	NFSPath string `json:"nfs_path" yaml:"nfs_path"`
}

BandwagonExtraConfig defines configuration for extended bandwagon fields

type ClusterAddress

type ClusterAddress struct {
	// Type defines access type to the web page for installed cluster
	// direct - use cluster endpoints from OpsCenter cluster page
	// public - use public IP addresses, works only with terraform provider
	// loadbalancer - use loadbalancer address, works only with terraform provider
	Type defaults.ClusterAddressType `json:"type" yaml:"type" validate:"eq=direct|eq=loadbalancer|eq=public"`
	// Port defines the port used to access installed cluster web page
	// if omitted - default cluster port(32009) will be used
	Port int `json:"port,omitempty" yaml:"port,omitempty"`
}

ClusterAddress defines configuration for accessing installed cluster web page

type Extensions

type Extensions struct {
	// InstallTimeout specifies the total time to wait for install operation to complete.
	// Defaults to ui/defaults.InstallTimeout if unspecified
	InstallTimeout duration `json:"install_timeout" yaml:"install_timeout" `
	// BackupConfig defines configuration for Backup/Restore operations
	BackupConfig *BackupConfig `json:"backup_config" yaml:"backup_config"`
}

Extensions groups configuration options for individual test steps. TODO: we need to come up with a way to support configuration for arbitraty test steps. This is just to jump-start the solution to the most obvious pain points

type LocatorRef

type LocatorRef struct {
	*loc.Locator
}

LocatorRef defines a reference to a package locator. It is necessary to keep application package optional in the configuration while being able to consume value from environment

func (LocatorRef) MarshalText

func (r LocatorRef) MarshalText() ([]byte, error)

UnmarshalText implements encoding.TextMarshaler

func (*LocatorRef) SetEnv

func (r *LocatorRef) SetEnv(value string) error

SetEnv implements configure.EnvSetter

func (*LocatorRef) UnmarshalText

func (r *LocatorRef) UnmarshalText(p []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type Login

type Login struct {
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
	// AuthProvider specifies the authentication provider to use for login.
	// Available providers are `email` and `gogole`
	AuthProvider string `json:"auth_provider,omitempty" yaml:"auth_provider,omitempty"`
}

Login defines Ops Center authentication parameters

func (Login) IsEmpty

func (r Login) IsEmpty() bool

type OnpremConfig

type OnpremConfig struct {
	// NumNodes defines the total cluster capacity.
	NumNodes int `json:"nodes" yaml:"nodes"`
	// InstallerURL defines the location of the installer tarball.
	// Depending on the provisioner - this can be either a URL or local path
	InstallerURL string `json:"installer_url" yaml:"installer_url"`
	// ScriptPath defines the path to the provisioner script.
	// TODO: if unspecified, scripts in assets/<provisioner> are used
	ScriptPath string `json:"script_path" yaml:"script_path"`
	// PostInstallerScript defines a path to the script on a remote node
	// that is executed after the installer has been downloaded
	PostInstallerScript string `json:"post_installer_script" yaml:"post_installer_script"`
	// ExpandProfile specifies an optional name of the server profile for On-Premise expand operation.
	// If the profile is unspecified, the test will use the first available.
	ExpandProfile string `json:"expand_profile" yaml:"expand_profile"`
	// OS defines OS flavor, ubuntu | redhat | centos | debian
	OS string `json:"os" yaml:"os" validate:"required,eq=ubuntu|eq=redhat|eq=centos|eq=debian"`
	// DockerDevice block device for docker data - set to /dev/xvdb
	DockerDevice string `json:"docker_device" yaml:"docker_device" validate:"required"`
	// ClusterAddress defines configuration for accessing installed cluster web page
	ClusterAddress *ClusterAddress `json:"cluster_address" yaml:"cluster_address"`
	// VarFilePath defines the path to file with custom terraform variables
	VarFilePath string `json:"variables_file" yaml:"variables_file"`
	// OnpremProvider specifies if the installation is on-premise
	OnpremProvider bool `json:"onprem_provider" yaml:"onprem_provider"`
}

OnpremConfig defines the test configuration for bare metal tests

func (OnpremConfig) IsEmpty

func (r OnpremConfig) IsEmpty() bool

type Provisioner

type Provisioner struct {
	// Type defines the type of provisioner to use
	Type provisionerType `json:"type" yaml:"type" `
	// LoadFromState used to control provisioning process. If set to true, then
	// robotest will parse output from external provisioner. If set to false robotest
	// will provision cluster by itself.
	LoadFromState bool `json:"load_from_state" yaml:"load_from_state"`
	// StateFile defines path to file with provisioner output data
	StateFile string `json:"state_file" yaml:"state_file"`
}

Provisioner defines configuration for provisioner

type ServiceLogin

type ServiceLogin struct {
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

ServiceLogin defines authentication options for Ops Center service access

func (ServiceLogin) IsEmpty

func (r ServiceLogin) IsEmpty() bool

type T

type T struct {
	Page *web.Page
}

T defines a framework type. Framework stores attributes common to a single context

func New

func New() *T

New creates a new instance of the framework. Creating a framework instance installs a set of BeforeEach/AfterEach to emulate BeforeAll/AfterAll for controlled access to resources that should only be created once per context

func (*T) AfterEach

func (r *T) AfterEach()

func (*T) BeforeEach

func (r *T) BeforeEach()

BeforeEach emulates BeforeAll for a context. It creates a new web page that is only initialized once per series of It grouped in any given context

type TestContextType

type TestContextType struct {
	// Wizard specifies whether wizard was used to bootstrap cluster
	Wizard bool `json:"-" yaml:"-"`
	// Provisioner defines configuration for provisioner
	Provisioner *Provisioner `json:"provisioner" yaml:"provisioner"`
	// CloudProvider defines cloud to deploy
	CloudProvider string `json:"cloud_provider" yaml:"cloud_provider" validate:"omitempty,eq=aws|eq=azure"`
	// DumpCore specifies a command to collect all installation/operation logs
	DumpCore bool `json:"-" yaml:"-"`
	// StateDir specifies the location for test-specific temporary data
	StateDir string `json:"state_dir" yaml:"state_dir" `
	// Teardown specifies the command to destroy the infrastructure
	Teardown bool `json:"-" yaml:"-"`
	// ForceRemoteAccess explicitly enables the remote access for the installed site.
	// If unspecified (or false), remote access is configured automatically:
	//  - if installing into existing Ops Center, remote access is enabled
	//  - in wizard mode remote access is disabled
	//
	// TODO: automatically determine when to enable remote access
	ForceRemoteAccess bool `json:"remote_access,omitempty" yaml:"remote_access,omitempty" `
	// ForceLocalEndpoint specifies whether to use the local application endpoint
	// instead of Ops Center to control the installed site
	//
	// TODO: automatically determine when to use local endpoint
	ForceLocalEndpoint bool `json:"local_endpoint,omitempty" yaml:"local_endpoint,omitempty" `
	// ReportDir defines location to store the results of the test
	ReportDir string `json:"report_dir" yaml:"report_dir" `
	// ClusterName defines the name to use for domain name or state directory
	ClusterName string `json:"cluster_name" yaml:"cluster_name" `
	// License specifies the application license
	License string `json:"license" yaml:"license" `
	// OpsCenterURL specifies the Ops Center to use for tests.
	// OpsCenterURL is mandatory when running tests on an existing Ops Center.
	// In wizard mode, this is automatically populated by the wizard (incl. Application, see below)
	OpsCenterURL string `json:"ops_url" yaml:"ops_url" `
	// Application defines the application package to test.
	// In wizard mode, this is automatically set by the wizard
	Application LocatorRef `json:"application" yaml:"application"`
	// Login defines the login details to access existing Ops Center.
	// Mandatory only in non-wizard mode
	Login Login `json:"login" yaml:"login"`
	// ServiceLogin defines the login parameters for service access to the Ops Center
	ServiceLogin ServiceLogin `json:"service_login" yaml:"service_login"`
	// FlavorLabel specifies the installation flavor label to use for the test.
	// This is application-specific, e.g. `3 nodes` or `medium`
	FlavorLabel string `json:"flavor_label" yaml:"flavor_label" `

	// AWS defines the AWS-specific test configuration
	AWS *aws.Config `json:"aws" yaml:"aws"`
	// Azure defines Azure cloud specific parameters
	Azure *azure.Config `json:"azure" yaml:"azure"`
	// GCE defines Google Compute Engine specific parameters
	GCE *gce.Config `json:"gce" yaml:"gce"`
	// Onprem defines the test configuration for bare metal tests
	Onprem *OnpremConfig `json:"onprem" yaml:"onprem"`

	// Bandwagon defines the test configuration for post-install setup in bandwagon
	Bandwagon BandwagonConfig `json:"bandwagon" yaml:"bandwagon"`
	// WebDriverURL specifies optional WebDriver URL to use
	WebDriverURL string `json:"web_driver_url,omitempty" yaml:"web_driver_url,omitempty" `
	// Extensions groups arbitrary test step configuration
	Extensions Extensions `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

TestContextType defines the configuration context of a single test run

func (*TestContextType) Validate

func (r *TestContextType) Validate() error

type TestState

type TestState struct {
	// EntryURL defines the entry point to the application.
	// This can be the address of existing Ops Center or local application endpoint URL
	EntryURL string `json:"ops_url,omitempty"`
	// Application defines the application package to test as retrieved from the wizard
	Application *loc.Locator `json:"application,omitempty"`
	// Login specifies optional login to connect to the EntryURL.
	// Falls back to TestContext.Login if unspecified
	Login *Login `json:"login,omitempty"`
	// ServiceLogin specifies optional service login to connect to the EntryURL.
	ServiceLogin *ServiceLogin `json:"service_login,omitempty"`
	// Bandwagon specifies bandwagon creation details
	Bandwagon *BandwagonConfig `json:"bandwagon,omitempty"`
	// Provisioner defines the provisioner used to create the infrastructure.
	// This can be empty for the automatic provisioner
	Provisioner *Provisioner `json:"provisioner,omitempty"`
	// Onprem defines the provisioner state.
	// The provisioner used is specified by Provisioner.
	// With automatic provisioner, no provisioner state is stored
	ProvisionerState *infra.ProvisionerState `json:"provisioner_state,omitempty"`
	// StateDir specifies the location of temporary state used for a single test run
	// (from bootstrapping to destroy)
	StateDir string `json:"state_dir"`
	// BackupState defines state of backup.
	// Used for backup/restore operations.
	BackupState *BackupState `json:"backup_state,omitempty"`
}

TestState represents the state of the test between boostrapping a cluster and teardown. The state is updated on each in-between test run to sync the provisioner state.

func (TestState) Validate

func (r TestState) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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