deployment

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvVarTCPNoDelay = "MM_LOADTEST_TCPNODELAY"
)

Variables

This section is empty.

Functions

func BuildLoadDBDumpCmd added in v1.10.0

func BuildLoadDBDumpCmd(dumpFilename string, dbInfo DBSettings) (string, error)

BuildLoadDBDumpCmd returns a command string to feed the provided DB dump file into the database. Example:

zcat dbdump.sql | mysql/psql connection_details

func ClearLicensesCmd added in v1.17.0

func ClearLicensesCmd(dbInfo DBSettings) (string, error)

ClearLicensesCmd returns a command string to connect to the database and delete all rows in the Licenses table and the ActiveLicenseId row in the Systems table

func ProvisionURL added in v1.10.0

func ProvisionURL(client *ssh.Client, url, filename string) error

ProvisionURL takes a URL pointing to a file to be provisioned. It works on both local files prefixed with file:// or remote files. In case of local files, they are uploaded to the server.

Types

type ClusterSubnetIDs added in v1.23.0

type ClusterSubnetIDs struct {
	App           []string `default_size:"0" json:"app"`
	Job           []string `default_size:"0" json:"job"`
	Proxy         []string `default_size:"0" json:"proxy"`
	Agent         []string `default_size:"0" json:"agent"`
	ElasticSearch []string `default_size:"0" json:"elasticsearch"`
	Metrics       []string `default_size:"0" json:"metrics"`
	Keycloak      []string `default_size:"0" json:"keycloak"`
	Database      []string `default_size:"0" json:"database"`
	Redis         []string `default_size:"0" json:"redis"`
}

ClusterSubnetIDs contains the subnet ids for the different types of instances.

func (*ClusterSubnetIDs) IsAnySet added in v1.23.0

func (c *ClusterSubnetIDs) IsAnySet() bool

IsAnySet returns true if any of the subnet ids are set.

func (ClusterSubnetIDs) String added in v1.23.0

func (c ClusterSubnetIDs) String() string

type Cmd added in v1.10.0

type Cmd struct {
	Msg     string
	Value   string
	Clients []*ssh.Client
}

type Config

type Config struct {
	// AWSProfile is the optional name of the AWS profile to use for all AWS commands
	AWSProfile string `default:""`
	// AWSRegion is the region used to deploy all resources.
	AWSRegion string `default:"us-east-1"`
	// AWSAvailabilityZone defines the Availability Zone
	// in which instances should be deployed.
	AWSAvailabilityZone string `default:"us-east-1c"`
	// AWSAMI is the AMI to use for all EC2 instances.
	AWSAMI string `default:"ami-0fa37863afb290840"`
	// ClusterName is the name of the cluster.
	ClusterName string `default:"loadtest" validate:"alpha"`
	// ClusterVpcID is the id of the VPC associated to the resources.
	ClusterVpcID string
	// ClusterSubnetIDs is the ids of the subnets associated to each resource type.
	ClusterSubnetIDs ClusterSubnetIDs
	// Number of application instances.
	AppInstanceCount int `default:"1" validate:"range:[0,)"`
	// Type of the EC2 instance for app.
	AppInstanceType string `default:"c7i.xlarge" validate:"notempty"`
	// IAM role to attach to the app servers
	AppAttachIAMProfile string `default:""`
	// Type of the EC2 instance for metrics.
	MetricsInstanceType string `default:"t3.xlarge" validate:"notempty"`
	// Number of agents, first agent and coordinator will share the same instance.
	AgentInstanceCount int `default:"2" validate:"range:[0,)"`
	// Type of the EC2 instance for agent.
	AgentInstanceType string `default:"c7i.xlarge" validate:"notempty"`
	// Logs the command output (stdout & stderr) to home directory.
	EnableAgentFullLogs bool `default:"true"`
	// Number of proxy instances.
	ProxyInstanceCount int `default:"1" validate:"range:[0,5]"`
	// Type of the EC2 instance for proxy.
	ProxyInstanceType string `default:"m4.xlarge" validate:"notempty"`
	// Path to the SSH public key.
	SSHPublicKey string `default:"~/.ssh/id_rsa.pub" validate:"notempty"`
	// Terraform database connection and provision settings.
	TerraformDBSettings TerraformDBSettings
	// External database connection settings
	ExternalDBSettings ExternalDBSettings
	// External bucket connection settings.
	ExternalBucketSettings ExternalBucketSettings
	// ExternalAuthProviderSettings contains the settings for configuring an external auth provider.
	ExternalAuthProviderSettings ExternalAuthProviderSettings
	// MattermostDownloadURL supports the following use cases:
	// 1. If it is a URL, it should be the Mattermost release to use.
	// 2. If it is a file:// uri pointing to a binary, use the latest Mattermost release and replace
	//    its binary with the binary pointed to by the file:// uri.
	// 3. If it is a file:// pointing to a tar.gz, use that as the Mattermost release.
	MattermostDownloadURL string `default:"https://latest.mattermost.com/mattermost-enterprise-linux" validate:"url"`
	// Path to the Mattermost EE license file.
	MattermostLicenseFile string `default:"" validate:"empty|file"`
	// Optional path to a partial Mattermost config file to be applied as patch during
	// app server deployment.
	MattermostConfigPatchFile string `default:""`
	// Mattermost instance sysadmin e-mail.
	AdminEmail string `default:"sysadmin@sample.mattermost.com" validate:"email"`
	// Mattermost instance sysadmin user name.
	AdminUsername string `default:"sysadmin" validate:"notempty"`
	// Mattermost instance sysadmin password.
	AdminPassword string `default:"Sys@dmin-sample1" validate:"notempty"`
	// URL from where to download load-test-ng binaries and configuration files.
	// The configuration files provided in the package will be overridden in
	// the deployment process.
	LoadTestDownloadURL   string `` /* 155-byte string literal not displayed */
	ElasticSearchSettings ElasticSearchSettings
	RedisSettings         RedisSettings
	JobServerSettings     JobServerSettings
	LogSettings           logger.Settings
	Report                report.Config
	// Directory under which the .terraform directory and state files are managed.
	// It will be created if it does not exist
	TerraformStateDir string `default:"./ltstate" validate:"notempty"`
	// URI of an S3 bucket whose contents are copied to the bucket created in the deployment
	S3BucketDumpURI string `default:"" validate:"s3uri"`
	// An optional URI to a MM server database dump file
	// to be loaded before running the load-test.
	// The file is expected to be gzip compressed.
	// This can also point to a local file if prefixed with "file://".
	// In such case, the dump file will be uploaded to the app servers.
	DBDumpURI string `default:""`
	// DBExtraSQL are optional URIs to SQL files containing SQL statements to be applied
	// to the Mattermost database.
	// The file is expected to be gzip compressed.
	// This can also point to a local file if prefixed with "file://".
	DBExtraSQL []string `default:"[]"`
	// An optional host name that will:
	//   - Override the SiteUrl
	//   - Point to the proxy IP via a new entry in the server's /etc/hosts file
	SiteURL string `default:"ltserver"`
	// ServerURL is the URL of the Mattermost server URL that the agent client will use to connect to the
	// Mattermost servers. This is used to override the server URL in the agent's config in case there's a
	// proxy in front of the Mattermost server.
	ServerURL string `default:""`
	// UsersFilePath specifies the path to an optional file containing a list of credentials for the controllers
	// to use. If present, it is used to automatically upload it to the agents and override the agent's config's
	// own UsersFilePath.
	UsersFilePath string `default:""`
	// PyroscopeSettings contains the settings for configuring the continuous profiling through Pyroscope
	PyroscopeSettings PyroscopeSettings
	// StorageSizes specifies the sizes of the disks for each instance type
	StorageSizes StorageSizes
	// EnableNetPeekMetrics enables fine grained networking metrics collection through netpeek utility.
	EnableNetPeekMetrics bool `default:"false"`
	// CustomTags is an optional list of key-value pairs, which will be used as default
	// tags for all resources deployed
	CustomTags TerraformMap
}

Config contains the necessary data to deploy and provision a load test environment.

func ReadConfig

func ReadConfig(configFilePath string) (*Config, error)

ReadConfig reads the configuration file from the given string. If the string is empty, it will return a config with default values.

func (*Config) DBName added in v1.3.0

func (c *Config) DBName() string

DBName returns the database name for the deployment.

func (*Config) IsValid

func (c *Config) IsValid() error

IsValid reports whether a given deployment config is valid or not.

type DBParameter added in v1.10.0

type DBParameter struct {
	// The unique name for the parameter.
	Name string `validate:"notempty"`
	// The value for the parameter.
	Value string `validate:"notempty"`
	// The apply method for the parameter. Can be either "immediate" or
	// "pending-reboot". It depends on the db engine used and parameter type.
	ApplyMethod string `validate:"oneof:{immediate, pending-reboot}"`
}

DBParameter contains info regarding a single RDS DB specific parameter.

type DBParameters added in v1.10.0

type DBParameters []DBParameter

func (DBParameters) String added in v1.10.0

func (p DBParameters) String() string

type DBSettings added in v1.10.0

type DBSettings struct {
	UserName string
	Password string
	DBName   string
	Host     string
	Engine   string
}

type ElasticSearchSettings

type ElasticSearchSettings struct {
	// Elasticsearch instances number.
	InstanceCount int
	// Elasticsearch instance type to be created.
	InstanceType string
	// Elasticsearch version to be deployed.
	Version string `default:"Elasticsearch_7.10"`
	// Set to true if the AWSServiceRoleForAmazonElasticsearchService role should be created.
	CreateRole bool
	// SnapshotRepository is the name of the S3 bucket where the snapshot to restore lives.
	SnapshotRepository string
	// SnapshotName is the name of the snapshot to restore.
	SnapshotName string
	// RestoreTimeoutMinutes is the maximum time, in minutes, that the system will wait for the snapshot to be restored.
	RestoreTimeoutMinutes int `default:"45" validate:"range:[0,)"`
	// ClusterTimeoutMinutes is the maximum time, in minutes, that the system will wait for the cluster status to get green.
	ClusterTimeoutMinutes int `default:"45" validate:"range:[0,)"`
	// ZoneAwarenessEnabled indicates whether to enable zone awareness or not.
	ZoneAwarenessEnabled bool `default:"false"`
	// ZoneAwarenessAZCount indicates the number of availability zones to use for zone awareness.
	ZoneAwarenessAZCount int `default:"2" validate:"range:[1,3]"`
	// EnableCloudwatchLogs indicates whether to enable Cloudwatch logs or not.
	EnableCloudwatchLogs bool `default:"true"`
}

ElasticSearchSettings contains the necessary data to configure an ElasticSearch instance to be deployed and provisioned.

type ExternalAuthProviderSettings added in v1.17.0

type ExternalAuthProviderSettings struct {
	// Enabled is set to true if the external auth provider should be enabled.
	Enabled bool `default:"false"`
	// DevelopmentMode is set to true if the keycloak instance should be started in development mode.
	DevelopmentMode bool `default:"true"`
	// KeycloakVersion is the version of keycloak to deploy.
	KeycloakVersion string `default:"24.0.2"`
	// KeycloakInstanceType is the type of the EC2 instance for keycloak.
	InstanceType string `default:"c7i.xlarge"`
	// KeycloakAdminUser is the username of the keycloak admin interface (admin on the master realm)
	KeycloakAdminUser string `default:"mmuser" validate:"notempty"`
	// KeycloakAdminPassword is the password of the keycloak admin interface (admin on the master realm)
	KeycloakAdminPassword string `default:"mmpass" validate:"alpha"`
	// KeycloakRealmFilePath is the path to the realm file to be uploaded to the keycloak instance.
	// If empty, a default realm file will be used.
	KeycloakRealmFilePath string `default:""`
	// KeycloakDBDumpURI
	// An optional URI to a keycloak database dump file to be uploaded on environment
	// creation.
	// The file is expected to be gzip compressed.
	// This can also point to a local file if prefixed with "file://".
	KeycloakDBDumpURI string `default:""`
	// GenerateUsersCount is the number of users to generate in the keycloak instance.
	GenerateUsersCount int `default:"0" validate:"range:[0,)"`
	// KeycloakRealmName is the name of the realm to be used in Mattermost. Must exist in the keycloak instance.
	// It is used when creating users and to properly set the OpenID configuration in Mattermost.
	KeycloakRealmName string `default:"mattermost"`
	// KeycloakClientID is the client id to be used in Mattermost from the above realm.
	// Must exist in the keycloak instance
	KeycloakClientID string `default:"mattermost-openid"`
	// KeycloakClientSecret is the client secret from the above realm to be used in Mattermost.
	// Must exist in the keycloak instance
	KeycloakClientSecret string `default:"qbdUj4dacwfa5sIARIiXZxbsBFoopTyf"`
	// KeycloakSAMLClientID is the client id to be used in Mattermost from the SAML client.
	KeycloakSAMLClientID string `default:"mattermost-saml"`
	// KeycloakSAMLClientSecret is the SAML client secret from the above realm to be used in Mattermost.
	KeycloakSAMLClientSecret string `default:"9c2edd74-9e20-454d-8cc2-0714e43f5f7e"`
}

ExternalAuthProviderSettings contains the necessary data to configure an external auth provider.

type ExternalBucketSettings added in v1.10.0

type ExternalBucketSettings struct {
	AmazonS3AccessKeyId     string `default:""`
	AmazonS3SecretAccessKey string `default:""`
	AmazonS3Bucket          string `default:""`
	AmazonS3PathPrefix      string `default:""`
	AmazonS3Region          string `default:"us-east-1"`
	AmazonS3Endpoint        string `default:"s3.amazonaws.com"`
	AmazonS3SSL             bool   `default:"true"`
	AmazonS3SignV2          bool   `default:"false"`
	AmazonS3SSE             bool   `default:"false"`
}

ExternalBucketSettings contains the necessary data to connect to an existing S3 bucket.

type ExternalDBSettings added in v1.2.0

type ExternalDBSettings struct {
	// Mattermost database driver
	DriverName string `default:"postgres" validate:"oneof:{mysql, postgres, cockroach}"`
	// DSN to connect to the database
	DataSource string `default:""`
	// DSN to connect to the database replicas
	DataSourceReplicas []string `default:""`
	// DSN to connect to the database search replicas
	DataSourceSearchReplicas []string `default:""`
}

ExternalDBSettings contains the necessary data to configure an instance to be deployed and provisioned.

type JobServerSettings added in v1.3.0

type JobServerSettings struct {
	// Job server instances count.
	InstanceCount int `default:"0" validate:"range:[0,1]"`
	// Job server instance type to be created.
	InstanceType string `default:"c7i.xlarge"`
}

JobServerSettings contains the necessary data to deploy a job server.

type PyroscopeSettings added in v1.11.0

type PyroscopeSettings struct {
	// Enable profiling of all the app instances
	EnableAppProfiling bool `default:"true"`
	// Enable profiling of all the agent instances
	EnableAgentProfiling bool `default:"true"`
	// Set the pprof block profile rate.
	// This value applies to both agent and Mattermost server processes.
	BlockProfileRate int `default:"0"`
}

PyroscopeSettings contains flags to enable/disable the profiling of the different parts of the deployment.

type RedisSettings added in v1.20.0

type RedisSettings struct {
	// Enabled indicates whether to add Redis or not.
	Enabled bool
	// NodeType indicates the instance type.
	NodeType string `default:"cache.m7g.2xlarge"`
	// ParameterGroupName indicates the parameter group to attach.
	ParameterGroupName string `default:"default.redis7"`
	// EngineVersion indicates the engine version.
	EngineVersion string `default:"7.1"`
}

type StorageSizes added in v1.11.0

type StorageSizes struct {
	// Size, in GiB, for the storage of the agents instances
	Agent int `default:"10"`
	// Size, in GiB, for the storage of the proxy instance
	Proxy int `default:"10"`
	// Size, in GiB, for the storage of the app instances
	App int `default:"10"`
	// Size, in GiB, for the storage of the metrics instance
	Metrics int `default:"50"`
	// Size, in GiB, for the storage of the job server instances
	Job int `default:"50"`
	// Size, in GiB, for the storage of the elasticsearch instances
	ElasticSearch int `default:"100"`
	// Size, in GiB, for the storage of the keycloak instances
	KeyCloak int `default:"10"`
}

type TerraformDBSettings added in v1.2.0

type TerraformDBSettings struct {
	// Number of DB instances.
	InstanceCount int `default:"1" validate:"range:[0,)"`
	// Type of the DB instance.
	InstanceType string `default:"db.r7g.large" validate:"notempty"`
	// Type of the DB instance - postgres or mysql.
	InstanceEngine string `default:"aurora-postgresql" validate:"oneof:{aurora-mysql, aurora-postgresql}"`
	// Username to connect to the DB.
	UserName string `default:"mmuser" validate:"notempty"`
	// Password to connect to the DB.
	Password string `default:"mostest80098bigpass_" validate:"notempty"`
	// If set to true enables performance insights for the created DB instances.
	EnablePerformanceInsights bool `default:"true"`
	// A list of DB specific parameters to use for the created instance.
	DBParameters DBParameters
	// ClusterIdentifier indicates to point to an existing cluster
	ClusterIdentifier string `default:""`
	// DBName specifies the name of the database.
	// If ClusterIdentifier is not empty, DBName should be set to the name of the database in such cluster.
	// If ClusterIdentifier is empty, the database created will use DBName as its name.
	DBName string `default:""`
}

TerraformDBSettings contains the necessary data to configure an instance to be deployed and provisioned.

type TerraformMap added in v1.22.0

type TerraformMap map[string]string

TerraformMap is a map of string -> string that serializes to the format expected by the Terraform AWS provider when formatted as a string

func (TerraformMap) String added in v1.22.0

func (t TerraformMap) String() string

Directories

Path Synopsis
ssh
Package ssh is a simple wrapper around an ssh.Client which implements utilities to be performed with a remote server.
Package ssh is a simple wrapper around an ssh.Client which implements utilities to be performed with a remote server.

Jump to

Keyboard shortcuts

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