Documentation
¶
Index ¶
- func RemoveBucketNamePrefix(bucket string) string
- type EC2MetadataAPI
- type Instance
- type Metric
- type Resources
- func (itf Resources) CreateBucket(runId string, outputStream *os.File) error
- func (itf Resources) CreateCfnStack(cfnTemplate string, vpcId string, subnetId string, outputStream *os.File) error
- func (itf Resources) CreateInstance(instanceType string, vCpus string, memory string, osVersion string, ...) (instance Instance, err error)
- func (itf Resources) DeleteBucket() error
- func (itf Resources) DeleteCfnStack() error
- func (itf Resources) DownloadFromBucket(bucket string, localPath string, remotePath string) error
- func (itf Resources) DownloadFromS3(bucketName string, remotePath string) ([]byte, error)
- func (itf Resources) FindBestAvailabilityZone(instanceTypes string, subnetId string) (bestAvailabilityZone string, supportedInstanceTypes []string, err error)
- func (itf Resources) GetAmiId(amiId string, inputStream *os.File, outputStream *os.File) (string, error)
- func (itf Resources) GetCloudWatchData(instances []Instance, testFixture config.TestFixture) (resp *cloudwatch.GetMetricDataOutput, err error)
- func (itf Resources) GetInstancesInCfnStack() (instances []Instance, err error)
- func (itf Resources) GetRegion() (region string, err error)
- func (itf Resources) GetSupportedInstances(instanceTypes []string, amiId string, subnetId string) (instances []Instance, err error)
- func (itf Resources) GetVpcAndSubnetIds(vpcId string, subnetId string, inputStream *os.File, outputStream *os.File) (string, string, error)
- func (itf Resources) IsInstanceRunning(instanceId string) (bool, error)
- func (itf Resources) UploadToBucket(bucket string, localPath string, remotePath string) error
- func (itf Resources) UploadToS3(bucketName string, data io.Reader, remotePath string) error
- func (itf Resources) WaitUntilCfnStackDeleteComplete() error
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveBucketNamePrefix ¶
RemoveBucketNamePrefix removes the prefix from the bucket name and returns the test run ID.
Types ¶
type EC2MetadataAPI ¶
type EC2MetadataAPI interface {
GetInstanceIdentityDocument() (ec2metadata.EC2InstanceIdentityDocument, error)
}
EC2MetadataAPI provides an interface to enable mocking the ec2metadata.EC2Metadata service client's APIs.
type Instance ¶
type Instance struct { InstanceId string `json:"instance-id"` InstanceType string `json:"instance-type"` VCpus string `json:"vCPUs"` Memory string `json:"memory"` Os string `json:"OS"` Architecture string `json:"Architecture"` IsTimeout bool `json:"isTimeout"` Results []Result `json:"results"` }
Instance contains the data of an instance.
type Metric ¶
type Metric struct { MetricUsed string `json:"metric"` Value float64 `json:"value"` Threshold float64 `json:"threshold"` Unit string `json:"unit"` }
Metric represents the metric data.
type Resources ¶
type Resources struct { EC2 ec2iface.EC2API AutoScaling autoscalingiface.AutoScalingAPI S3 s3iface.S3API S3ManagerUploader s3manageriface.UploaderAPI S3ManagerDownloader s3manageriface.DownloaderAPI CloudFormation cloudformationiface.CloudFormationAPI CloudWatch cloudwatchiface.CloudWatchAPI EC2Metadata EC2MetadataAPI }
Resources is used to store clients for AWS services.
func (Resources) CreateBucket ¶
CreateBucket creates a bucket and blocks all public access.
func (Resources) CreateCfnStack ¶
func (itf Resources) CreateCfnStack(cfnTemplate string, vpcId string, subnetId string, outputStream *os.File) error
CreateCfnStack creates the CloudFormation stack for the instance-qualifier run.
func (Resources) CreateInstance ¶
func (itf Resources) CreateInstance(instanceType string, vCpus string, memory string, osVersion string, architecture string) (instance Instance, err error)
CreateInstance populates the Instance struct with metadata.
func (Resources) DeleteBucket ¶
DeleteBucket empties and deletes the instance-qualifier bucket.
func (Resources) DeleteCfnStack ¶
DeleteCfnStack starts the async deletion of instance-qualifier CloudFormation stack.
func (Resources) DownloadFromBucket ¶
DownloadFromBucket downloads a file from the bucket to the specified local location.
func (Resources) DownloadFromS3 ¶
DownloadFromS3 is similar to DownloadFromBucket, but returns bytes directly instead of saving to a local file
func (Resources) FindBestAvailabilityZone ¶
func (itf Resources) FindBestAvailabilityZone(instanceTypes string, subnetId string) (bestAvailabilityZone string, supportedInstanceTypes []string, err error)
FindBestAvailabilityZone finds the Availability Zone that can support the most instance types provided by the user. It returns the name of the best Availability Zone, and user-specified instance types that are available in that Availability Zone.
func (Resources) GetAmiId ¶
func (itf Resources) GetAmiId(amiId string, inputStream *os.File, outputStream *os.File) (string, error)
GetAmiId returns the AMI ID. If the user provides a valid AMI ID, return it; otherwise, return the ID of the latest AMI of Amazon Linux 2 in the current region.
func (Resources) GetCloudWatchData ¶
func (itf Resources) GetCloudWatchData(instances []Instance, testFixture config.TestFixture) (resp *cloudwatch.GetMetricDataOutput, err error)
GetCloudWatchData retrieves instance metric data from CloudWatch
func (Resources) GetInstancesInCfnStack ¶
GetInstancesInCfnStack populates InstanceId and InstanceType fields of the Instance struct for all instances in the CloudFormation stack, and returns them.
func (Resources) GetSupportedInstances ¶
func (itf Resources) GetSupportedInstances(instanceTypes []string, amiId string, subnetId string) (instances []Instance, err error)
GetSupportedInstances returns instances that are supported to be launched. It checks 2 things: 1. Whether the instance type is available in the Availability Zone. 2. Whether the instance type supports the AMI architecture. The metadata of returned instances is also populated.
func (Resources) GetVpcAndSubnetIds ¶
func (itf Resources) GetVpcAndSubnetIds(vpcId string, subnetId string, inputStream *os.File, outputStream *os.File) (string, string, error)
GetVpcAndSubnetIds returns VPC and subnet IDs.
If the user doesn't specify VPC nor subnet, the function returns "NONE" for both VPC and subnet IDs, meaning that a new VPC infrastructure needs to be created.
If the user only specifies VPC, the function asks the user to choose any one of subnets in that VPC. If the VPC ID is invalid, the user will be asked whether to create a new VPC. If there is no subnet in the VPC, an error will be returned.
If the user only specifies subnet, the function finds the corresponding VPC and returns the IDs of them. If the subnet ID is invalid, the user will be asked whether to create a new VPC.
If the user specifies both VPC and subnet, the function validates them. If valid, returns them; otherwise, returns error.
func (Resources) IsInstanceRunning ¶
IsInstanceRunning returns true if an instance is in running state; false otherwise.
func (Resources) UploadToBucket ¶
UploadToBucket uploads a local file to the specified location of the bucket.
func (Resources) UploadToS3 ¶
UploadToS3 is similar to UploadToBucket, but provide data directly instead of a local file
func (Resources) WaitUntilCfnStackDeleteComplete ¶
WaitUntilCfnStackDeleteComplete waits until the stack deletion is complete.