Documentation ¶
Overview ¶
Package imagetest is a library for the orchestration components of CIT. It executes testworkflows (generated by test suites), collates the results into junit xml.
Index ¶
- Constants
- func PrintTests(ctx context.Context, storageClient *storage.Client, ...)
- func RunTests(ctx context.Context, storageClient *storage.Client, ...) (junit.Testsuites, error)
- func ValidateTests(ctx context.Context, storageClient *storage.Client, ...) error
- type Network
- func (n *Network) CreateFirewallRule(firewallName, protocol string, ports, ranges []string) error
- func (n *Network) CreateSubnetwork(name string, ipRange string) (*Subnetwork, error)
- func (n *Network) CreateSubnetworkFromDaisySubnetwork(subnetwork *daisy.Subnetwork) (*Subnetwork, error)
- func (n *Network) SetMTU(mtu int)
- type Subnetwork
- type TestVM
- func (t *TestVM) AddAliasIPRanges(aliasIPRange, rangeName string) error
- func (t *TestVM) AddCustomNetwork(network *Network, subnetwork *Subnetwork) error
- func (t *TestVM) AddDisk(diskType string, initializeParams *compute.AttachedDiskInitializeParams) error
- func (t *TestVM) AddMetadata(key, value string)
- func (t *TestVM) AddScope(scope string)
- func (t *TestVM) AddUser(user, publicKey string)
- func (t *TestVM) CreateDerivativeVM(name string) (*TestVM, error)
- func (t *TestVM) EnableConfidentialInstance()
- func (t *TestVM) EnableSecureBoot()
- func (t *TestVM) ForceMachineType(machinetype string)
- func (t *TestVM) ForceZone(z string)
- func (t *TestVM) Reboot() error
- func (t *TestVM) ResizeDiskAndReboot(diskSize int) error
- func (t *TestVM) Resume() error
- func (t *TestVM) RunTests(runtest string)
- func (t *TestVM) SetMinCPUPlatform(minCPUPlatform string)
- func (t *TestVM) SetNetworkPerformanceTier(tier string) error
- func (t *TestVM) SetPrivateIP(network *Network, networkIP string) error
- func (t *TestVM) SetShutdownScript(script string)
- func (t *TestVM) SetShutdownScriptURL(script string) error
- func (t *TestVM) SetStartupScript(script string)
- func (t *TestVM) SetWindowsShutdownScript(script string)
- func (t *TestVM) SetWindowsShutdownScriptURL(script string) error
- func (t *TestVM) SetWindowsStartupScript(script string)
- func (t *TestVM) UseGVNIC()
- type TestWorkflow
- func (t *TestWorkflow) AddSSHKey(user string) (string, error)
- func (t *TestWorkflow) CreateNetwork(networkName string, autoCreateSubnetworks bool) (*Network, error)
- func (t *TestWorkflow) CreateTestVM(name string) (*TestVM, error)
- func (t *TestWorkflow) CreateTestVMBeta(name string) (*TestVM, error)
- func (t *TestWorkflow) CreateTestVMFromInstanceBeta(i *daisy.InstanceBeta, disks []*compute.Disk) (*TestVM, error)
- func (t *TestWorkflow) CreateTestVMMultipleDisks(disks []*compute.Disk, instanceParams *daisy.Instance) (*TestVM, error)
- func (t *TestWorkflow) LockProject()
- func (t *TestWorkflow) Skip(message string)
- func (t *TestWorkflow) SkippedMessage() string
- func (t *TestWorkflow) WaitForDisksQuota(qa *daisy.QuotaAvailable) error
- func (t *TestWorkflow) WaitForVMQuota(qa *daisy.QuotaAvailable) error
- type TestWorkflowOpts
Constants ¶
const ( // ShouldRebootDuringTest is a local map key to indicate that the // test will reboot and relies on results from the second boot. ShouldRebootDuringTest = "shouldRebootDuringTest" // DefaultSourceRange is the RFC-1918 range used in default rules. DefaultSourceRange = "10.128.0.0/9" // DefaultMTU is the default MTU set for a network. DefaultMTU = 1460 // JumboFramesMTU is the maximum MTU settable for a network. JumboFramesMTU = 8896 // DefaultMachineType is the default machine type when machine type isn't specified. DefaultMachineType = "n1-standard-1" )
const ( // PdStandard disktype string PdStandard = "pd-standard" // PdSsd disktype string PdSsd = "pd-ssd" // PdBalanced disktype string PdBalanced = "pd-balanced" // PdExtreme disktype string PdExtreme = "pd-extreme" // HyperdiskExtreme disktype string HyperdiskExtreme = "hyperdisk-extreme" // HyperdiskThroughput disktype string HyperdiskThroughput = "hyperdisk-throughput" // HyperdiskBalanced disktype string HyperdiskBalanced = "hyperdisk-balanced" // LocalSsd disktype string LocalSsd = "local-ssd" )
Variables ¶
This section is empty.
Functions ¶
func PrintTests ¶
func PrintTests(ctx context.Context, storageClient *storage.Client, testWorkflows []*TestWorkflow, project, zone, gcsPath, localPath string)
PrintTests prints all test workflows.
func RunTests ¶
func RunTests(ctx context.Context, storageClient *storage.Client, testWorkflows []*TestWorkflow, project, zone, gcsPath, localPath string, parallelCount int, parallelStagger string, testProjects []string) (junit.Testsuites, error)
RunTests runs all test workflows.
func ValidateTests ¶
func ValidateTests(ctx context.Context, storageClient *storage.Client, testWorkflows []*TestWorkflow, project, zone, gcsPath, localPath string) error
ValidateTests validates all test workflows.
Types ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network represent network used by vm in setup.go.
func (*Network) CreateFirewallRule ¶
CreateFirewallRule create firewall rule.
func (*Network) CreateSubnetwork ¶
func (n *Network) CreateSubnetwork(name string, ipRange string) (*Subnetwork, error)
CreateSubnetwork creates custom subnetwork. Using AddCustomNetwork method provided by TestVM to config network on vm
func (*Network) CreateSubnetworkFromDaisySubnetwork ¶
func (n *Network) CreateSubnetworkFromDaisySubnetwork(subnetwork *daisy.Subnetwork) (*Subnetwork, error)
CreateSubnetworkFromDaisySubnetwork creates custom subnetwork from daisy subnetwork. Callers that don't need to specify properties beyond ip ranges, region, purpose, and role should call CreateSubnetwork instead.
type Subnetwork ¶
type Subnetwork struct {
// contains filtered or unexported fields
}
Subnetwork represent subnetwork used by vm in setup.go.
func (Subnetwork) AddSecondaryRange ¶
func (s Subnetwork) AddSecondaryRange(rangeName, ipRange string)
AddSecondaryRange add secondary IP range to Subnetwork
func (*Subnetwork) SetPurpose ¶
func (s *Subnetwork) SetPurpose(purpose string)
SetPurpose sets the subnetwork purpose
func (*Subnetwork) SetRegion ¶
func (s *Subnetwork) SetRegion(region string)
SetRegion sets the subnetwork region
func (*Subnetwork) SetRole ¶
func (s *Subnetwork) SetRole(role string)
SetRole sets the subnetwork role
type TestVM ¶
type TestVM struct {
// contains filtered or unexported fields
}
TestVM is a test VM.
func (*TestVM) AddAliasIPRanges ¶
AddAliasIPRanges add alias ip range to current test VMs.
func (*TestVM) AddCustomNetwork ¶
func (t *TestVM) AddCustomNetwork(network *Network, subnetwork *Subnetwork) error
AddCustomNetwork add current test VMs in workflow using provided network and subnetwork. If subnetwork is empty, not using subnetwork, in this case network has to be in auto mode VPC.
func (*TestVM) AddDisk ¶
func (t *TestVM) AddDisk(diskType string, initializeParams *compute.AttachedDiskInitializeParams) error
AddDisk adds a given number of disks to the VM.
func (*TestVM) AddMetadata ¶
AddMetadata adds the specified key:value pair to metadata during VM creation.
func (*TestVM) CreateDerivativeVM ¶
CreateDerivativeVM creates a derivative image using the sourceVM's boot disk as the source and adds it to the test workflow. The new VM is named using the provided name, with a "derivative-" prefix.
func (*TestVM) EnableConfidentialInstance ¶
func (t *TestVM) EnableConfidentialInstance()
EnableConfidentialInstance enabled CVM features for the instance.
func (*TestVM) EnableSecureBoot ¶
func (t *TestVM) EnableSecureBoot()
EnableSecureBoot make the current test VMs in workflow with secure boot.
func (*TestVM) ForceMachineType ¶
ForceMachineType sets the machine type for the test VM. This will override the machine_type flag in the CIT wrapper, and should only be used when a test absolutely requires a specific machine shape.
func (*TestVM) ForceZone ¶
ForceZone sets the zone for the test vm. This will override the zone option from the CIT wrapper and and should only be used when a test requires a specific zone.
func (*TestVM) Reboot ¶
Reboot stops the VM, waits for it to shutdown, then starts it again. Your test package must handle being run twice.
func (*TestVM) ResizeDiskAndReboot ¶
ResizeDiskAndReboot resize the disk of the current test VMs and reboot
func (*TestVM) Resume ¶
Resume waits for the vm to be SUSPENDED, then resumes it. It does not handle suspension.
func (*TestVM) RunTests ¶
RunTests runs only the named tests on the testVM.
From go help test:
-run regexp Run only those tests and examples matching the regular expression. For tests, the regular expression is split by unbracketed slash (/) characters into a sequence of regular expressions, and each part of a test's identifier must match the corresponding element in the sequence, if any. Note that possible parents of matches are run too, so that -run=X/Y matches and runs and reports the result of all tests matching X, even those without sub-tests matching Y, because it must run them to look for those sub-tests.
func (*TestVM) SetMinCPUPlatform ¶
SetMinCPUPlatform sets the minimum CPU platform of the instance.
func (*TestVM) SetNetworkPerformanceTier ¶
SetNetworkPerformanceTier sets the performance tier of the VM. The tier must be one of "DEFAULT" or "TIER_1"
func (*TestVM) SetPrivateIP ¶
SetPrivateIP set IPv4 internal IP address for target network to the current test VMs.
func (*TestVM) SetShutdownScript ¶
SetShutdownScript sets the `shutdown-script` metadata key for a non-Windows VM.
func (*TestVM) SetShutdownScriptURL ¶
SetShutdownScriptURL sets the`shutdown-script-url` metadata key for a non-Windows VM.
func (*TestVM) SetStartupScript ¶
SetStartupScript sets the `startup-script` metadata key for a VM. On Windows VMs, this script does not run on startup: different guest attributes must be set.
func (*TestVM) SetWindowsShutdownScript ¶
SetWindowsShutdownScript sets the `windows-shutdown-script-ps1` metadata key for a Windows VM.
func (*TestVM) SetWindowsShutdownScriptURL ¶
SetWindowsShutdownScriptURL sets the`windows-shutdown-script-url` metadata key for a Windows VM.
func (*TestVM) SetWindowsStartupScript ¶
SetWindowsStartupScript sets the `windows-startup-script-ps1` metadata key for a VM.
type TestWorkflow ¶
type TestWorkflow struct { Name string // Client is a shared client for the compute service. Client daisycompute.Client // Image is the image under test Image *compute.Image // ImageBeta is the image under test using Beta API ImageBeta *computeBeta.Image // ImageURL will be the partial URL of a GCE image. ImageURL string // MachineType is the machine type to be used for the test. This can be overridden by individual test suites. MachineType *compute.MachineType Project *compute.Project Zone *compute.Zone // GCSPath is the destination for workflow outputs in gs://[...] form. GCSPath string // ReservationAffinity is the reservation affinity used for VM creation. ReservationAffinity *compute.ReservationAffinity // ReservationAffinityBeta is the reservation affinity used for VM creation with the beta API. ReservationAffinityBeta *computeBeta.ReservationAffinity // contains filtered or unexported fields }
TestWorkflow defines a test workflow which creates at least one test VM.
func NewTestWorkflow ¶
func NewTestWorkflow(opts *TestWorkflowOpts) (*TestWorkflow, error)
NewTestWorkflow returns a new TestWorkflow.
func (*TestWorkflow) AddSSHKey ¶
func (t *TestWorkflow) AddSSHKey(user string) (string, error)
AddSSHKey generate ssh key pair and return public key.
func (*TestWorkflow) CreateNetwork ¶
func (t *TestWorkflow) CreateNetwork(networkName string, autoCreateSubnetworks bool) (*Network, error)
CreateNetwork creates custom network. Using AddCustomNetwork method provided by TestVM to config network on vm
func (*TestWorkflow) CreateTestVM ¶
func (t *TestWorkflow) CreateTestVM(name string) (*TestVM, error)
CreateTestVM adds the necessary steps to create a VM with the specified name to the workflow.
func (*TestWorkflow) CreateTestVMBeta ¶
func (t *TestWorkflow) CreateTestVMBeta(name string) (*TestVM, error)
CreateTestVMBeta adds the necessary steps to create a VM with the specified name from the compute beta API to the workflow.
func (*TestWorkflow) CreateTestVMFromInstanceBeta ¶
func (t *TestWorkflow) CreateTestVMFromInstanceBeta(i *daisy.InstanceBeta, disks []*compute.Disk) (*TestVM, error)
CreateTestVMFromInstanceBeta creates a test vm struct to run CIT suites on from the given daisy instancebeta and adds it to the test workflow.
func (*TestWorkflow) CreateTestVMMultipleDisks ¶
func (t *TestWorkflow) CreateTestVMMultipleDisks(disks []*compute.Disk, instanceParams *daisy.Instance) (*TestVM, error)
CreateTestVMMultipleDisks adds the necessary steps to create a VM with the specified name to the workflow.
func (*TestWorkflow) LockProject ¶
func (t *TestWorkflow) LockProject()
LockProject indicates this test modifies project-level data and must have exclusive use of the project.
func (*TestWorkflow) Skip ¶
func (t *TestWorkflow) Skip(message string)
Skip marks a test workflow to be skipped.
func (*TestWorkflow) SkippedMessage ¶
func (t *TestWorkflow) SkippedMessage() string
SkippedMessage returns the skip reason message for the workflow.
func (*TestWorkflow) WaitForDisksQuota ¶
func (t *TestWorkflow) WaitForDisksQuota(qa *daisy.QuotaAvailable) error
WaitForDisksQuota appends a list of quotas to the wait for disk quota step. Quotas with a blank region will be populated with the region corresponding to the workflow zone.
func (*TestWorkflow) WaitForVMQuota ¶
func (t *TestWorkflow) WaitForVMQuota(qa *daisy.QuotaAvailable) error
WaitForVMQuota appends a list of quotas to the wait for vm quota step. Quotas with a blank region will be populated with the region corresponding to the workflow zone.
type TestWorkflowOpts ¶
type TestWorkflowOpts struct { // Client is the client used to call the compute service Client daisycompute.Client // ComputeEndpointOverride is an alternate compute endpoint to send requests to compute service to. ComputeEndpointOverride string // Name is the name of the TestWorkflow Name string // Image is an image partial URL, or an image family partial URL Image string // The daisy step timeout Timeout string // Project is the project used to look up images and set up the test workflow. Project string // Zone is the zone used to run the test workflow. Zone string // ExcludeFilter is a filter used to exclude individual test cases within a test suite. Can break test suites if used incorrectly, be careful. ExcludeFilter string // X86Shape is the default shape for x86 images being tested. X86Shape string // ARM64Shape is the default shape for ARM images being tested. ARM64Shape string // UseReservations is whether to consume reservations to create VMs. If true but ReservationURLs is empty, ANY_RESERVATION will be used. UseReservations bool // ReservationURLs is a list of specific reservation URLs to consume. ReservationURLs []string }
TestWorkflowOpts is an options struct for the NewTestWorkflow function.
Directories ¶
Path | Synopsis |
---|---|
Package cleanerupper provides a library of functions to delete gcp resources in a project matching the given deletion policy.
|
Package cleanerupper provides a library of functions to delete gcp resources in a project matching the given deletion policy. |
cmd
|
|
manager
Manager is a cli interface to the orchestration provided by the imagetest library.
|
Manager is a cli interface to the orchestration provided by the imagetest library. |
wrapper
Wrapper is the binary executed inside the test VM.
|
Wrapper is the binary executed inside the test VM. |
test_suites
|
|
acceleratorconfig
Package acceleratorconfig contains tests for validating accelerator VM configuration.
|
Package acceleratorconfig contains tests for validating accelerator VM configuration. |
acceleratorrdma
Package acceleratorrdma validates rdma stacks on accelerator images.
|
Package acceleratorrdma validates rdma stacks on accelerator images. |
cvm
Package cvm is a CIT suite for testing confidential computing features.
|
Package cvm is a CIT suite for testing confidential computing features. |
disk
Package disk is a CIT suite for testing basic disk functionality.
|
Package disk is a CIT suite for testing basic disk functionality. |
guestagent
Package guestagent is a CIT suite for testing guest agent features.
|
Package guestagent is a CIT suite for testing guest agent features. |
hostnamevalidation
Package hostnamevalidation is a CIT suite for testing custom hostnames.
|
Package hostnamevalidation is a CIT suite for testing custom hostnames. |
hotattach
Package hotattach is a CIT suite from testing hot attaching/detaching
|
Package hotattach is a CIT suite from testing hot attaching/detaching |
imageboot
Package imageboot is a CIT suite for testing boot, reboot, and secure boot functionality.
|
Package imageboot is a CIT suite for testing boot, reboot, and secure boot functionality. |
licensevalidation
Package licensevalidation is a CIT suite for validating that an image has expected licenses attached to it.
|
Package licensevalidation is a CIT suite for validating that an image has expected licenses attached to it. |
livemigrate
Package livemigrate is a CIT suite for testing standard live migration, not confidential vm live migration.
|
Package livemigrate is a CIT suite for testing standard live migration, not confidential vm live migration. |
loadbalancer
Package loadbalancer is a CIT suite for testing l3/l7 load balancer backend functionality.
|
Package loadbalancer is a CIT suite for testing l3/l7 load balancer backend functionality. |
lssd
Package lssd is a CIT suite from testing mounting/umounting of disks.
|
Package lssd is a CIT suite from testing mounting/umounting of disks. |
mdsmtls
Package mdsmtls is a CIT suite for testing mtls communication with the mds.
|
Package mdsmtls is a CIT suite for testing mtls communication with the mds. |
mdsroutes
Package mdsroutes is a CIT suite for testing network routes to the metadata server.
|
Package mdsroutes is a CIT suite for testing network routes to the metadata server. |
metadata
Package metadata is a CIT suite for testing metadata script functionality.
|
Package metadata is a CIT suite for testing metadata script functionality. |
network
Package network is a CIT suite for testing network configuration functionality.
|
Package network is a CIT suite for testing network configuration functionality. |
networkinterfacenaming
Package networkinterfacenaming is a CIT suite for testing that network interface names follow an acceptable scheme.
|
Package networkinterfacenaming is a CIT suite for testing that network interface names follow an acceptable scheme. |
networkperf
Package networkperf is a CIT suite for testing that network performance reaches expected targets.
|
Package networkperf is a CIT suite for testing that network performance reaches expected targets. |
oslogin
Package oslogin is a CIT suite for testing oslogin ssh with and without 2fa.
|
Package oslogin is a CIT suite for testing oslogin ssh with and without 2fa. |
packagemanager
Package packagemanager is a CIT suite for testing package manager functionality.
|
Package packagemanager is a CIT suite for testing package manager functionality. |
packageupgrade
Package packageupgrade tests that the guest environment and other necessary drivers can be installed/updated from the testing repos prior to promotion.
|
Package packageupgrade tests that the guest environment and other necessary drivers can be installed/updated from the testing repos prior to promotion. |
packagevalidation
Package packagevalidation tests that the guest environment and other necessary packages are installed and configured correctly.
|
Package packagevalidation tests that the guest environment and other necessary packages are installed and configured correctly. |
security
Package security tests security related OS settings are configured correctly.
|
Package security tests security related OS settings are configured correctly. |
shapevalidation
Package shapevalidation tests that an image can boot and access all expected resources from the largest VM shape in a family.
|
Package shapevalidation tests that an image can boot and access all expected resources from the largest VM shape in a family. |
sql
Package sql tests windows SQL server functionality.
|
Package sql tests windows SQL server functionality. |
ssh
Package ssh tests guest agent metadata ssh key setup.
|
Package ssh tests guest agent metadata ssh key setup. |
storageperf
Package storageperf tests that storage device performance reaches expected values.
|
Package storageperf tests that storage device performance reaches expected values. |
suspendresume
Package suspendresume tests suspend and resume functionality.
|
Package suspendresume tests suspend and resume functionality. |
vmspec
Package vmspec is a test suite that tests that things work after vmspec changes.
|
Package vmspec is a test suite that tests that things work after vmspec changes. |
windowscontainers
Package windowscontainers tests windows containers functionality.
|
Package windowscontainers tests windows containers functionality. |
winrm
Package winrm tests windows remote management functionality.
|
Package winrm tests windows remote management functionality. |
Package utils contains commonly needed utility functions for test suites inside the VM and in test workflow setup.
|
Package utils contains commonly needed utility functions for test suites inside the VM and in test workflow setup. |