node

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: 46 Imported by: 0

README

Node E2E Tests

This directory contains OpenShift end-to-end tests for node-related features.

Test Suites

Suite: openshift/disruptive-longrunning
  • kubeletconfig_features.go - Tests applying KubeletConfig to custom machine config pools, requires node reboots
  • kubelet_secret_pulled_images.go - Tests kubelet credential verification for image pulls (KubeletEnsureSecretPulledImages feature gate). Covers multi-tenancy isolation, credential rotation, ImagePullPolicy behavior, credential verification policy (NeverVerify/AlwaysVerify), and registry availability scenarios. Requires TechPreviewNoUpgrade or CustomNoUpgrade FeatureSet.
  • node_e2e/container_runtime_config.go - ContainerRuntimeConfig pidsLimit (OCP-45351) and overlaySize (OCP-46313) - Verifies CTRCFG settings are applied via MCO rollout and reflected on nodes [Disruptive]
  • node_e2e/image_registry_config.go - Container registry config change (OCP-44820) - Verifies search registry update triggers MCO rollout and lands on nodes [Disruptive]
  • node_e2e/netns_cleanup.go - Network namespace cleanup - Verifies kubelet/CRI-O properly deletes network namespace when a pod is deleted [OTP]
  • node_e2e/pdb_drain.go - PodDisruptionBudget drain blocking (OCP-67564) - Tests that node drain is blocked when PDB has minAvailable=100% with empty selector [Disruptive] [Lifecycle:informing]
  • additional_storage_e2e.go - Additional Storage configuration and functional tests - Verifies ContainerRuntimeConfig with additionalImageStores, additionalLayerStores, and additionalArtifactStores. Tests configuration in storage.conf and CRI-O config, image store pre-population and registry fallback [Disruptive]
Suite: openshift/conformance/parallel
  • Additional Storage Support API Validation - API validation tests for additionalArtifactStores, additionalImageStores, and additionalLayerStores CRI-O configuration

    Availability:

    • OCP 4.22: TechPreview (requires TechPreviewNoUpgrade feature gate)
    • OCP 4.23+/5.0+: GA (Generally Available)

    Suite: openshift/conformance/parallel
    Feature Tag: [Feature:AdditionalStorageSupport]
    Sig Tag: [sig-node]
    OCPFeatureGate: AdditionalStorageConfig

    Test File:

    • additional_storage_api.go - 13 API validation tests using DryRun (non-disruptive, parallel execution)
      • Combined Additional Stores (3 tests): invalid paths, max count enforcement, duplicate detection
      • Additional Layer Stores (8 tests): comprehensive path validation (empty, relative, spaces, special chars, length, max count, consecutive slashes, duplicates)
      • Additional Image Stores (1 smoke test): path validation wiring
      • Additional Artifact Stores (1 smoke test): path validation wiring

    Requirements:

    • AdditionalStorageConfig feature gate must be enabled
    • API tests are non-disruptive (use DryRun)
    • Run in parallel with other conformance tests
    • Skip on MicroShift (no MachineConfig support)
    • Skip on Microsoft Azure (known platform issues)

    Running API validation tests:

    # Run only Additional Storage API validation tests (fast, non-disruptive)
    ./openshift-tests run "openshift/conformance/parallel" --dry-run | \
      grep "\[Feature:AdditionalStorageSupport\]" | \
      ./openshift-tests run -f -
    

    Test Coverage (13 tests, ~2-3 min total):

    • Path format validation (absolute paths, character restrictions, length limits)
    • Count limits enforcement (5 for artifact/layer stores, 10 for image stores)
    • Duplicate path detection within store types
    • Combined store configurations with invalid paths
Suite: openshift/usernamespace
  • nested_container.go - Tests running nested containers (podman-in-pod) with user namespaces and nested-container SCC
Default Suite
  • dra.go - Tests that DRA (Dynamic Resource Allocation) v1 API is available and beta/alpha APIs are disabled
  • image_volume.go - Tests mounting container images as volumes in pods, including subPath and error handling
  • node_swap.go - Tests default kubelet swap settings (failSwapOn and swapBehavior) and rejection of user overrides
  • zstd_chunked.go - Tests building and running images with zstd:chunked compression format
  • node_e2e/probe_termination.go - Probe-level terminationGracePeriodSeconds (OCP-44493) - Tests configurable termination grace period for liveness and startup probes. Includes 3 test cases: probe-level config for liveness probe, probe-level config for startup probe, and fallback to pod-level config when probe-level is not set [Lifecycle:informing]

Directory Structure

Test Files
  • All *.go files in the root directory are Ginkgo-based test suites
  • Each file focuses on a specific node feature
Utility Files
  • node_utils.go - Shared helper functions for node selection and kubelet configuration retrieval
Test Data

Test fixtures are referenced via exutil.FixturePath from:

  • testdata/node/machineconfigpool/ - Machine config pool fixtures
  • testdata/node/kubeletconfig/ - Kubelet config fixtures
  • testdata/node/zstd-chunked/, testdata/node/nested_container/ - Custom build fixtures

Running Tests

Running Long-Running Disruptive Tests

The openshift/disruptive-longrunning suite is a general-purpose suite for long-running disruptive tests across all teams. Node team tests are tagged with [sig-node] to identify them.

To run the entire long-running disruptive test suite on a cluster manually:

./openshift-tests run "openshift/disruptive-longrunning" --cluster-stability=Disruptive

To run only node-specific long-running disruptive tests:

./openshift-tests run "openshift/disruptive-longrunning" --dry-run | grep "\[sig-node\]" | ./openshift-tests run -f - --cluster-stability=Disruptive
Running User Namespace Tests
./openshift-tests run "openshift/usernamespace"

Prerequisites

  • Make sure to set oc binary to match the cluster version
  • Make sure to set the kubeconfig to point to a live OCP cluster

Submitting PRs

Adding Tests to openshift/disruptive-longrunning

Before submitting a PR that adds a test to the openshift/disruptive-longrunning suite, run the following payload job and include the results in your PR:

/payload-job periodic-ci-openshift-release-main-nightly-4.22-e2e-aws-disruptive-longrunning

Useful links for periodic-ci-openshift-release-main-nightly-4.22-e2e-aws-disruptive-longrunning:

Important Notes

  • Note that dry-run option won't list the test as it does not connect to a live cluster
  • Run make update if the test data is changed

Documentation

Index

Constants

View Source
const (
	// DebugNamespace is the namespace for debug pods
	DebugNamespace = "openshift-machine-config-operator"
)

Variables

This section is empty.

Functions

func ApplyContainerRuntimeConfigAndWaitForMCP

func ApplyContainerRuntimeConfigAndWaitForMCP(ctx context.Context, mcClient *machineconfigclient.Clientset, ctrcfg *machineconfigv1.ContainerRuntimeConfig, mcpName string, rolloutTimeout time.Duration) error

ApplyContainerRuntimeConfigAndWaitForMCP creates a ContainerRuntimeConfig and waits for the MCP rollout to complete.

func ApplyKubeletConfigAndWaitForMCP

func ApplyKubeletConfigAndWaitForMCP(ctx context.Context, mcClient *machineconfigclient.Clientset, kubeletConfig *machineconfigv1.KubeletConfig, mcpName string, rolloutTimeout time.Duration) error

ApplyKubeletConfigAndWaitForMCP creates a KubeletConfig and waits for the MCP rollout to complete.

func CalculateEventTimeDiff

func CalculateEventTimeDiff(startEvent, endEvent *corev1.Event) time.Duration

CalculateEventTimeDiff calculates the time difference between two Kubernetes events. It uses LastTimestamp for both events to handle repeated events correctly. For repeated events (like container restarts), Kubernetes reuses the event object and updates LastTimestamp while keeping FirstTimestamp at the original occurrence. Falls back to FirstTimestamp if LastTimestamp is zero.

func CheckNetNsCleaned

func CheckNetNsCleaned(ctx context.Context, oc *exutil.CLI, nodeName, netNsPath string) error

CheckNetNsCleaned verifies that the network namespace file has been cleaned up. It checks if the NetNS path no longer exists on the node. Returns nil if the file is cleaned, error if it still exists.

func CleanupContainerRuntimeConfig

func CleanupContainerRuntimeConfig(ctx context.Context, mcClient *machineconfigclient.Clientset, ctrcfgName, mcpName string) error

CleanupContainerRuntimeConfig deletes a ContainerRuntimeConfig. If mcpName is non-empty, waits for that MCP to stabilize.

func CleanupCustomMCP

func CleanupCustomMCP(ctx context.Context, config *CustomMCPConfig) error

CleanupCustomMCP removes the node label, deletes the custom MCP, and waits for the worker MCP to stabilize.

func CleanupKubeletConfig

func CleanupKubeletConfig(ctx context.Context, mcClient *machineconfigclient.Clientset, kcName, mcpName string) error

CleanupKubeletConfig deletes a KubeletConfig. If mcpName is non-empty, waits for that MCP to stabilize.

func CreateContainerRuntimeConfig

CreateContainerRuntimeConfig creates a ContainerRuntimeConfig resource.

func CreateKubeletConfig

func CreateKubeletConfig(ctx context.Context, mcClient *machineconfigclient.Clientset, kubeletConfig *machineconfigv1.KubeletConfig) (*machineconfigv1.KubeletConfig, error)

CreateKubeletConfig creates a KubeletConfig resource.

func CreateOrUpdateKubeletConfig

func CreateOrUpdateKubeletConfig(ctx context.Context, mcClient *machineconfigclient.Clientset, kubeletConfig *machineconfigv1.KubeletConfig) (*machineconfigv1.KubeletConfig, error)

CreateOrUpdateKubeletConfig creates a KubeletConfig or updates it if it already exists.

func CreatePodAndWaitForRunning

func CreatePodAndWaitForRunning(ctx context.Context, oc *exutil.CLI, pod *corev1.Pod) *corev1.Pod

func EnsureNodeHasNoCustomRole

func EnsureNodeHasNoCustomRole(ctx context.Context, oc *exutil.CLI, nodeName string) error

func EnsureNodesReady

func EnsureNodesReady(ctx context.Context, oc *exutil.CLI)

func ExecOnNodeWithChroot

func ExecOnNodeWithChroot(ctx context.Context, oc *exutil.CLI, nodeName string, cmd ...string) (string, error)

func ExecOnNodeWithNsenter

func ExecOnNodeWithNsenter(ctx context.Context, oc *exutil.CLI, nodeName string, cmd ...string) (string, error)

func GetFirstReadyWorkerNode

func GetFirstReadyWorkerNode(oc *exutil.CLI) string

GetFirstReadyWorkerNode returns the name of the first Ready worker node in the cluster.

func GetNotReadyNodes

func GetNotReadyNodes(ctx context.Context, oc *exutil.CLI) ([]string, error)

func GetPodNetNs

func GetPodNetNs(ctx context.Context, oc *exutil.CLI, nodeName, podName string) (string, error)

GetPodNetNs retrieves the network namespace path for a pod using crictl. It uses crictl to get the sandbox ID and then inspects it to extract the NetNS path. Returns the NetNS path and an error if not found.

func IsAdditionalStorageConfigEnabled

func IsAdditionalStorageConfigEnabled(ctx context.Context, oc *exutil.CLI) (bool, string)

IsAdditionalStorageConfigEnabled checks whether the AdditionalStorageConfig feature gate is enabled on the cluster and the platform is supported. Returns false with a reason string if the test should be skipped.

func NodeHasCustomRole

func NodeHasCustomRole(node corev1.Node) (string, bool)

func SkipOnMicroShift

func SkipOnMicroShift(oc *exutil.CLI)

SkipOnMicroShift skips the current test if the cluster is MicroShift.

func WaitForMCP

func WaitForMCP(ctx context.Context, mcClient *machineconfigclient.Clientset, poolName string, timeout time.Duration, opts ...func(*waitMCPOptions)) error

WaitForMCP waits for a MachineConfigPool to be ready (not updating, updated, and all machines ready). By default it returns an error immediately if the MCP becomes degraded.

func WaitForMCPUpdating

func WaitForMCPUpdating(ctx context.Context, mcClient *machineconfigclient.Clientset, mcpName string, timeout time.Duration) error

WaitForMCPUpdating waits for an MCP to enter the "Updating" state.

func WaitMCPAllowDegraded

func WaitMCPAllowDegraded() func(*waitMCPOptions)

WaitMCPAllowDegraded tolerates transient Degraded/RenderDegraded during polling instead of failing immediately. The pool must still become fully healthy (!degraded, !renderDegraded, updated, all machines ready) before this wait succeeds.

func WaitMCPWithMachineCount

func WaitMCPWithMachineCount(count int32) func(*waitMCPOptions)

WaitMCPWithMachineCount waits until the pool has the exact machine count.

Types

type CustomMCPConfig

type CustomMCPConfig struct {
	Name       string
	NodeName   string
	MCClient   *machineconfigclient.Clientset
	KubeClient *exutil.CLI
}

CustomMCPConfig holds state needed to clean up a custom MCP created by CreateCustomMCPForNode.

func CreateCustomMCPForNode

func CreateCustomMCPForNode(ctx context.Context, oc *exutil.CLI, mcClient *machineconfigclient.Clientset, mcpName, nodeName string) (*CustomMCPConfig, error)

CreateCustomMCPForNode labels a node and creates a custom MCP targeting it.

Directories

Path Synopsis
dra

Jump to

Keyboard shortcuts

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