e2e

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

README

Baremetal Operator end to end tests

The work here is heavily inspired by the Cluster API e2e framework.

The idea is to have fairly flexible framework that allows running tests in different contexts. For CI we mainly rely on libvirt, but the tests are meant to be reusable so that they can run also on real hardware. This is accomplished by tuning the tests based on a configuration file and flags. Examples can be seen in config.

In the CI system we set up a pre-configured minikube cluster that is then used for the tests, as seen in ci-e2e.sh. This allows us to have control over the network and have a static configuration for Ironic and the Baremetal Operator. The script creates a VM to represent a BareMetalHost, and configures either VBMC or sushy-tools to be used as BMC.

Currently there are two sets of tests, which cannot be ran together in the same cluster. One is the "optional" set, currently consists of only the upgrade tests, and the "main" set, which are the ones required to run in every BMO PR. One can switch between these sets by manipulating the GINKGO_FOCUS and GINKGO_SKIP env vars. In the default setting, the script sets GINKGO_SKIP to upgrade.

E.g. Here is how to run the E2E main tests:

./hack/ci-e2e.sh

And here is how to run the E2E optional tests:

export GINKGO_FOCUS="upgrade"
./hack/ci-e2e.sh

It is also possible to run the tests with the fixture provider instead of Ironic. Without any changes, the whole suite (including optional tests) will be run. Please note, however, that it is quite questionable to call this configuration "end to end".

Fixture provider is configured to be the default one. This is how to run the e2e test suite with it:

make test-e2e

BMCs config

In case you want to run the tests with your own hardware, the information regarding BMCs should be stored in a yaml file, whose path is exported to E2E_BMCS_CONF_FILE variable (please take a look at bmcs-redfish-virtualmedia.yaml to understand the file structure).

Tests

Here is a list of the currently implemented tests. As mentioned above, we divide them into two sets, one required and one optional. The required tests must pass on every PR before merging. Optional tests may be triggered for extra verification but are not expected to run on all PRs. All tests are checked with both redfish and ipmi protocols in CI.

Required tests:

  • Inspection: Check that a BareMetalHost is registered and inspected when created, and that it becomes available after the inspection.
  • External inspection: Check that a BareMetalHost, with inspection disabled and hardware details added through an annotation, skips inspection, accepts the hardware details from the annotation and becomes available.
  • Re-inspection: Check that an available BareMetalHost is re-inspected when the inspect annotation is added and that this updates the hardware details.
  • Provisioning: Check that an available BareMetalHost can be provisioned, that it can be detatched, deleted and re-created, with the status annotation, without affecting the host. Finally checks that the BareMetalHost can be deprovisioned and becomes available again.
  • Live-ISO: Check that an available BareMetalHost can be provisioned with a live-ISO image.

Optional tests:

  • Bare Metal Operator upgrade: Check that an older version of the Bare Metal Operator works by creating a BareMetalHost with external inspection. Then upgrade the Bare Metal Operator and check the the BareMetalHost can be provisioned with the upgraded version.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAndApplyKustomization added in v0.6.0

func BuildAndApplyKustomization(ctx context.Context, input *BuildAndApplyKustomizationInput) error

BuildAndApplyKustomization takes input from BuildAndApplyKustomizationInput. It builds the provided kustomization and apply it to the cluster provided by clusterProxy.

func BuildAndRemoveKustomization added in v0.6.0

func BuildAndRemoveKustomization(ctx context.Context, kustomization string, clusterProxy framework.ClusterProxy) error

BuildAndRemoveKustomization builds the provided kustomization to resources and removes them from the cluster provided by clusterProxy.

func CreateSecret

func CreateSecret(ctx context.Context, client client.Client, secretNamespace, secretName string, data map[string]string)

func DeploymentRolledOut added in v0.6.0

func DeploymentRolledOut(ctx context.Context, clusterProxy framework.ClusterProxy, name string, namespace string, desiredGeneration int64) bool

func EstablishSSHConnection

func EstablishSSHConnection(e2eConfig *Config, auth ssh.AuthMethod, user, address string) *ssh.Client

func HasRootOnDisk

func HasRootOnDisk(output string) bool

HasRootOnDisk parses the output from 'df -h' and checks if the root filesystem is on a disk (as opposed to tmpfs).

func IsBootedFromDisk

func IsBootedFromDisk(client *ssh.Client) (bool, error)

IsBootedFromDisk checks if the system, accessed via the provided ssh.Client, is booted from a disk. It executes the 'df -h' command on the remote system to analyze the filesystem layout. In the case of a disk boot, the output includes a disk-based root filesystem (e.g., '/dev/vda1'). Conversely, in the case of a Live-ISO boot, the primary filesystems are memory-based (tmpfs).

func KubectlDelete added in v0.6.0

func KubectlDelete(ctx context.Context, kubeconfigPath string, resources []byte, args ...string) error

KubectlDelete shells out to kubectl delete.

func LoadBMCConfig added in v0.6.0

func LoadBMCConfig(configPath string) *[]BMC

func PerformSSHBootCheck

func PerformSSHBootCheck(e2eConfig *Config, expectedBootMode string, auth ssh.AuthMethod, sshAddress string)

PerformSSHBootCheck performs an SSH check to verify the node's boot source. The `expectedBootMode` parameter should be "disk" or "memory". The `auth` parameter is an ssh.AuthMethod for authentication.

func WaitForBmhDeleted

func WaitForBmhDeleted(ctx context.Context, input WaitForBmhDeletedInput, intervals ...interface{})

WaitForBmhDeleted waits until the BMH object has been deleted.

func WaitForBmhInPowerState

func WaitForBmhInPowerState(ctx context.Context, input WaitForBmhInPowerStateInput, intervals ...interface{})

func WaitForBmhInProvisioningState

func WaitForBmhInProvisioningState(ctx context.Context, input WaitForBmhInProvisioningStateInput, intervals ...interface{})

func WaitForNamespaceDeleted

func WaitForNamespaceDeleted(ctx context.Context, input WaitForNamespaceDeletedInput, intervals ...interface{})

WaitForNamespaceDeleted waits until the namespace object has been deleted.

Types

type BMC added in v0.6.0

type BMC struct {
	// BMC initial username
	User string `yaml:"user,omitempty"`
	// BMC initial password
	Password string `yaml:"password,omitempty"`
	// BMC initial address
	Address string `yaml:"address,omitempty"`
	// BMC Mac address
	BootMacAddress string `yaml:"bootMacAddress,omitempty"`
	// The Hostname of the node, which will be read into BMH object
	HostName string `yaml:"hostName,omitempty"`
	// The IP address of the node
	// Optional. Only needed if e2eConfig variable
	// SSH_CHECK_PROVISIONED is true
	IPAddress string `yaml:"ipAddress,omitempty"`
	// Optional. Only needed if e2eConfig variable
	// SSH_CHECK_PROVISIONED is true
	SSHPort string `yaml:"sshPort,omitempty"`
}

BMC defines a BMH to use in the tests.

type BMOIronicUpgradeInput added in v0.6.0

type BMOIronicUpgradeInput struct {
	// DeployIronic determines if Ironic should be installed at the beginning of the test.
	// This should be generally set to `true`, but can be `false` in case Ironic is either pre-installed
	// or not required (for e.g. in `fixture` setup)
	DeployIronic bool `yaml:"deployIronic,omitempty"`
	// DeployBMO determines if BMO should be installed at the beginning of the test.
	// This should be generally set to `true`, but can be `false` in case BMO is pre-installed
	DeployBMO bool `yaml:"deployBMO,omitempty"`
	// Path to the Ironic kustomization that should be installed at the beginning of the test.
	// Not used if DeployIronic is false
	InitIronicKustomization string `yaml:"initIronicKustomization,omitempty"`
	// Path to the BMO kustomization that should be installed at the beginning of the test.
	// Not used if DeployBMO is false
	InitBMOKustomization string `yaml:"initBMOKustomization,omitempty"`
	// Name of the entity that should be upgraded and tested. It should be either `bmo` or `ironic`.
	UpgradeEntityName string `yaml:"upgradeEntityName,omitempty"`
	// Path to the kustomization of the entity that should be used in upgrading.
	UpgradeEntityKustomization string `yaml:"upgradeEntityKustomization,omitempty"`
}

type BuildAndApplyKustomizationInput added in v0.6.0

type BuildAndApplyKustomizationInput struct {
	// Path to the kustomization to build
	Kustomization string

	ClusterProxy framework.ClusterProxy

	// If this is set to true. Perform a wait until the deployment specified by
	// DeploymentName and DeploymentNamespace is available or WaitIntervals is timed out
	WaitForDeployment bool

	// If this is set to true. Set up a log watcher for the deployment specified by
	// DeploymentName and DeploymentNamespace
	WatchDeploymentLogs bool

	// DeploymentName and DeploymentNamespace specified a deployment that will be waited and/or logged
	DeploymentName      string
	DeploymentNamespace string

	// Path to store the deployment logs
	LogPath string

	// Intervals to use in checking and waiting for the deployment
	WaitIntervals []interface{}
}

BuildAndApplyKustomizationInput provides input for BuildAndApplyKustomize(). If WaitForDeployment and/or WatchDeploymentLogs is set to true, then DeploymentName and DeploymentNamespace are expected.

type Config

type Config struct {
	// Images is a list of container images to load into the Kind cluster.
	// Note that this not relevant when using an existing cluster.
	Images []clusterctl.ContainerImage `json:"images,omitempty"`

	// Variables to be used in the tests.
	Variables map[string]string `json:"variables,omitempty"`

	// Intervals to be used for long operations during tests.
	Intervals map[string][]string `json:"intervals,omitempty"`

	// BMOIronicUpgradeSpecs
	BMOIronicUpgradeSpecs []BMOIronicUpgradeInput `yaml:"bmoIronicUpgradeSpecs,omitempty"`
}

Config defines the configuration of an e2e test environment.

func LoadE2EConfig

func LoadE2EConfig(configPath string) *Config

LoadE2EConfig loads the configuration for the e2e test environment.

func (*Config) Defaults

func (c *Config) Defaults()

Defaults assigns default values to the object. More specifically: - Images gets LoadBehavior = MustLoadImage if not otherwise specified.

func (*Config) GetIntervals

func (c *Config) GetIntervals(spec, key string) []interface{}

GetIntervals returns the intervals to be applied to a Eventually operation. It searches for [spec]/[key] intervals first, and if it is not found, it searches for default/[key]. If also the default/[key] intervals are not found, ginkgo DefaultEventuallyTimeout and DefaultEventuallyPollingInterval are used.

func (*Config) GetVariable

func (c *Config) GetVariable(varName string) string

GetVariable returns a variable from environment variables or from the e2e config file.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration. More specifically: - Image should have name and loadBehavior be one of [mustload, tryload]. - Intervals should be valid ginkgo intervals.

type LoadImageBehavior

type LoadImageBehavior string

LoadImageBehavior indicates the behavior when loading an image.

const (
	// MustLoadImage causes a load operation to fail if the image cannot be
	// loaded.
	MustLoadImage LoadImageBehavior = "mustLoad"

	// TryLoadImage causes any errors that occur when loading an image to be
	// ignored.
	TryLoadImage LoadImageBehavior = "tryLoad"
)

type PowerState

type PowerState string
const (
	PoweredOn  PowerState = "on"
	PoweredOff PowerState = "off"
)

type WaitForBmhDeletedInput

type WaitForBmhDeletedInput struct {
	Client          client.Client
	BmhName         string
	Namespace       string
	UndesiredStates []metal3api.ProvisioningState
}

WaitForBmhDeletedInput is the input for WaitForBmhDeleted.

type WaitForBmhInPowerStateInput

type WaitForBmhInPowerStateInput struct {
	Client client.Client
	Bmh    metal3api.BareMetalHost
	State  PowerState
}

type WaitForBmhInProvisioningStateInput

type WaitForBmhInProvisioningStateInput struct {
	Client          client.Client
	Bmh             metal3api.BareMetalHost
	State           metal3api.ProvisioningState
	UndesiredStates []metal3api.ProvisioningState
}

type WaitForNamespaceDeletedInput

type WaitForNamespaceDeletedInput struct {
	Getter    framework.Getter
	Namespace corev1.Namespace
}

WaitForNamespaceDeletedInput is the input for WaitForNamespaceDeleted.

Jump to

Keyboard shortcuts

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