extensions

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ComponentAnnotation is the annotation on ImageStreamTags that advertise a non-payload extension.
	// Value format: product-name-component-name.
	ComponentAnnotation = "testextension.redhat.io/component"
	// BinaryAnnotation is the annotation on ImageStreamTags that identifies the binary path
	// and optional args. Value format: <binary-path>.gz [--argument=value]
	BinaryAnnotation = "testextension.redhat.io/binary"
)

Variables

View Source
var EnvironmentFlagVersions = map[EnvironmentFlagName]string{
	// contains filtered or unexported fields
}

EnvironmentFlagVersions holds the "Since" version metadata for each flag.

View Source
var ExcludedTests = []string{
	"[Disabled:",
	"[Disruptive]",
	"[Skipped]",
	"[Slow]",
	"[Flaky]",
	"[Local]",
}

Functions

func DetermineRegistryAuthFilePath

func DetermineRegistryAuthFilePath(tmpDir string, oc *util.CLI) (string, error)

func DetermineReleasePayloadImage

func DetermineReleasePayloadImage() (string, error)

func ExtractAllTestBinaries

func ExtractAllTestBinaries(ctx context.Context, parallelism int) (func(), TestBinaries, []UnpermittedExtension, error)

ExtractAllTestBinaries determines the optimal release payload to use, and extracts all the external test binaries from it (payload + permitted non-payload), and returns cleanup, binaries, and any unpermitted non-payload extensions for synthetic skip tests.

func ExtractReleaseImageStream

func ExtractReleaseImageStream(extractPath, releaseImage string,
	registryAuthFilePath string) (*imagev1.ImageStream, string, error)

ExtractReleaseImageStream extracts image references from the given releaseImage and returns an ImageStream object with tags associated with image-references from that payload.

func InitializeOpenShiftTestsExtensionFramework

func InitializeOpenShiftTestsExtensionFramework() (*extension.Registry, *extension.Extension, error)

InitializeOpenShiftTestsExtensionFramework creates and initializes the extension registry with the origin tests extension.

func MatchesAnyPermit

func MatchesAnyPermit(namespace, imagestream string, patterns []PermitPattern) bool

MatchesAnyPermit returns true if (namespace, imagestream) matches any of the patterns.

func Time

func Time(t *dbtime.DBTime) time.Time

Types

type EnvironmentFlag

type EnvironmentFlag struct {
	Name         EnvironmentFlagName
	Value        string
	SinceVersion string
}

EnvironmentFlag contains the info required to build an argument to pass to the external binary for the given Name

func (EnvironmentFlag) ArgString

func (ef EnvironmentFlag) ArgString() string

type EnvironmentFlagName

type EnvironmentFlagName string

EnvironmentFlagName enumerates each possible EnvironmentFlag's name to be passed to the external binary

type EnvironmentFlags

type EnvironmentFlags []EnvironmentFlag

func (EnvironmentFlags) ArgStrings

func (ef EnvironmentFlags) ArgStrings() []string

ArgStrings properly formats all EnvironmentFlags as a list of argument strings to pass to the external binary

func (EnvironmentFlags) LogFields

func (ef EnvironmentFlags) LogFields() logrus.Fields

func (EnvironmentFlags) String

func (ef EnvironmentFlags) String() string

type EnvironmentFlagsBuilder

type EnvironmentFlagsBuilder struct {
	// contains filtered or unexported fields
}

func (*EnvironmentFlagsBuilder) AddAPIGroups

func (e *EnvironmentFlagsBuilder) AddAPIGroups(values ...string) *EnvironmentFlagsBuilder

func (*EnvironmentFlagsBuilder) AddArchitecture

func (e *EnvironmentFlagsBuilder) AddArchitecture(value string) *EnvironmentFlagsBuilder

func (*EnvironmentFlagsBuilder) AddExternalConnectivity

func (e *EnvironmentFlagsBuilder) AddExternalConnectivity(value string) *EnvironmentFlagsBuilder

func (*EnvironmentFlagsBuilder) AddFact

func (*EnvironmentFlagsBuilder) AddFeatureGates

func (e *EnvironmentFlagsBuilder) AddFeatureGates(values ...string) *EnvironmentFlagsBuilder

func (*EnvironmentFlagsBuilder) AddNetwork

func (*EnvironmentFlagsBuilder) AddNetworkStack

func (e *EnvironmentFlagsBuilder) AddNetworkStack(value string) *EnvironmentFlagsBuilder

func (*EnvironmentFlagsBuilder) AddOptionalCapability

func (e *EnvironmentFlagsBuilder) AddOptionalCapability(value string) *EnvironmentFlagsBuilder

func (*EnvironmentFlagsBuilder) AddPlatform

func (*EnvironmentFlagsBuilder) AddTopology

func (*EnvironmentFlagsBuilder) AddUpgrade

func (*EnvironmentFlagsBuilder) AddVersion

func (*EnvironmentFlagsBuilder) Build

type EnvironmentSelector

type EnvironmentSelector struct {
	Include string `json:"include,omitempty"`
	Exclude string `json:"exclude,omitempty"`
}

type Extension

type Extension struct {
	*extension.Extension

	// -- origin specific info --
	Binary               *TestBinary `json:"-"`
	Source               Source      `json:"source"`
	ExtensionArtifactDir string      `json:"extension_artifact_dir"`
}

Extension represents an extension to openshift-tests.

type ExtensionTestResult

type ExtensionTestResult struct {
	*extensiontests.ExtensionTestResult

	// Source is the information from the extension binary (it's image tag, repo, commit sha, etc), reported
	// up by origin so it's easy to identify where a particular result came from in the overall combined result JSON.
	Source Source `json:"source"`
}

type ExtensionTestResults

type ExtensionTestResults []*ExtensionTestResult

func (ExtensionTestResults) ToHTML

func (results ExtensionTestResults) ToHTML(suiteName string, mode HTMLOutputMode) ([]byte, error)

ToHTML converts the extension test results to an HTML representation. It marshals origin's results (which include SourceImage/SourceBinary) directly and uses RenderResultsHTML to preserve those fields in the HTML output.

type ExtensionTestSpec

type ExtensionTestSpec struct {
	*extensiontests.ExtensionTestSpec

	// Binary invokes a link to the external binary that provided this test
	Binary *TestBinary
}

type ExtensionTestSpecs

type ExtensionTestSpecs []*ExtensionTestSpec

func FilterWrappedSpecs

func FilterWrappedSpecs(
	wrappedSpecs ExtensionTestSpecs,
	qualifiers []string,
) (ExtensionTestSpecs, error)

FilterWrappedSpecs applies the upstream Filter method (defined on extensiontests.ExtensionTestSpecs) while preserving our local ExtensionTestSpec wrappers.

This is a bit awkward because our ExtensionTestSpecs is a slice of wrappers around *extensiontests.ExtensionTestSpec, but the Filter method only exists on the upstream slice type. To work around this, we:

  1. Extract the underlying *extensiontests.ExtensionTestSpec values.
  2. Call the upstream Filter.
  3. Map the filtered results back to the original wrapped specs using pointer identity.

This preserves metadata like the Binary field stored in our wrapper.

type ExternalBinaryProvider

type ExternalBinaryProvider struct {
	// contains filtered or unexported fields
}

ExternalBinaryProvider handles extracting external test binaries from a given payload. By default, it uses a cache directory for extracted binaries assuming they'll be reused, especially when developing locally. Set OPENSHIFT_TESTS_DISABLE_CACHE to any non-empty value to use a temporary directory instead that will be removed at end of execution. When using caching, files older than 7 days will be removed.

func NewExternalBinaryProvider

func NewExternalBinaryProvider(releaseImage, registryAuthfilePath string) (*ExternalBinaryProvider, error)

func (*ExternalBinaryProvider) Cleanup

func (provider *ExternalBinaryProvider) Cleanup()

func (*ExternalBinaryProvider) ExtractBinaryFromImage

func (provider *ExternalBinaryProvider) ExtractBinaryFromImage(imageRef, binaryPath, imageTag string) (*TestBinary, error)

ExtractBinaryFromImage extracts a binary from an arbitrary image (e.g. from a non-payload ImageStreamTag). imageRef is the pull spec; binaryPath is the path inside the image; imageTag is the identifier for the TestBinary (e.g. namespace/imagestream:tag for non-payload). Uses the same lock/cache/ungzip/arch check as ExtractBinaryFromReleaseImage.

func (*ExternalBinaryProvider) ExtractBinaryFromReleaseImage

func (provider *ExternalBinaryProvider) ExtractBinaryFromReleaseImage(tag, binary string) (*TestBinary, error)

ExtractBinaryFromReleaseImage resolves the tag from the release image and extracts the binary, checking if the binary is compatible with the current systems' architecture. It returns an error if extraction fails or if the binary is incompatible.

Note: When developing openshift-tests on a non-Linux non-AMD64 computer (i.e. on Apple Silicon), external binaries won't work. You would need to run it in a Linux environment (VM or container), and even then override the payload selection with an aarch64 payload unless x86 emulation is enabled.

type HTMLOutputMode

type HTMLOutputMode int

HTMLOutputMode controls what content is included in the HTML output.

const (
	// HTMLOutputSummary elides output/error/details for passed tests to reduce file size.
	HTMLOutputSummary HTMLOutputMode = iota
	// HTMLOutputEverything includes all output/error/details for all tests.
	HTMLOutputEverything
)

type Image

type Image struct {
	Index    int    `json:"index"`
	Registry string `json:"registry"`
	Name     string `json:"name"`
	Version  string `json:"version"`
}

Image represents a single container image generated by the "images" command.

type ImageSet

type ImageSet map[k8simage.ImageID]k8simage.Config

ImageSet maps a Kubernetes image ID to its corresponding configuration. It represents a collection of container images with their registry, name, and version.

type PermitPattern

type PermitPattern struct {
	Namespace   string
	ImageStream string
}

PermitPattern represents one entry from TestExtensionAdmission spec.permit. Namespace and ImageStream may be "*" to match any. ImageStream is the ImageStream resource name only (tag is irrelevant for matching).

func DiscoverNonPayloadBinaryAdmission

func DiscoverNonPayloadBinaryAdmission(ctx context.Context, config *rest.Config) ([]PermitPattern, error)

DiscoverNonPayloadBinaryAdmission checks for the TestExtensionAdmission CRD, lists instances, and builds the permit set

func ParsePermitPattern

func ParsePermitPattern(permit string) (PermitPattern, bool)

ParsePermitPattern parses a permit string "namespace/imagestream" into a PermitPattern. Supports "*" for namespace and/or imagestream (e.g. "openshift/*", "*/*", "ns/stream").

type Source

type Source struct {
	*extension.Source

	// SourceImage contains the payload image it was extracted from.
	SourceImage string `json:"source_image,omitempty"`

	// SourceBinary contains the path in the source image for this extension.
	SourceBinary string `json:"source_binary,omitempty"`
}

Source contains the details of the commit and source URL.

type TestBinaries

type TestBinaries []*TestBinary

func (TestBinaries) Info

func (binaries TestBinaries) Info(ctx context.Context, parallelism int) ([]*Extension, error)

Info fetches the info from all TestBinaries using the specified parallelism.

func (TestBinaries) ListImages

func (binaries TestBinaries) ListImages(ctx context.Context, parallelism int) ([]ImageSet, error)

func (TestBinaries) ListTests

func (binaries TestBinaries) ListTests(ctx context.Context, parallelism int, envFlags EnvironmentFlags) (ExtensionTestSpecs, error)

ListTests extracts the tests from all TestBinaries using the specified parallelism, and passes the provided EnvironmentFlags for proper filtering of results.

type TestBinary

type TestBinary struct {
	// contains filtered or unexported fields
}

TestBinary implements the openshift-tests extension interface (Info, ListTests, RunTests, etc).

func (*TestBinary) Info

func (b *TestBinary) Info(ctx context.Context) (*Extension, error)

Info returns information about this particular extension.

func (*TestBinary) ListImages

func (b *TestBinary) ListImages(ctx context.Context) (ImageSet, error)

func (*TestBinary) ListTests

func (b *TestBinary) ListTests(ctx context.Context, envFlags EnvironmentFlags) (ExtensionTestSpecs, error)

ListTests takes a list of EnvironmentFlags to pass to the command so it can determine for itself which tests are relevant. returns which tests this binary advertises.

func (*TestBinary) RunTests

func (b *TestBinary) RunTests(ctx context.Context, timeout time.Duration, env []string,
	names ...string) []*ExtensionTestResult

RunTests executes the named tests and returns the results.

type UnpermittedExtension

type UnpermittedExtension struct {
	Namespace   string
	ImageStream string
	Tag         string
	Component   string
}

UnpermittedExtension describes a discovered non-payload extension that is not permitted by any TestExtensionAdmission. Used to generate a synthetic skip test.

Jump to

Keyboard shortcuts

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