Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions pkg/healthcheck/microshift_optional_workloads.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package healthcheck

import (
"github.com/openshift/microshift/pkg/config"
"github.com/openshift/microshift/pkg/util"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -40,16 +41,39 @@ var optionalWorkloadPaths = map[string]optionalWorkloads{
}

// fillOptionalMicroShiftWorkloads assembles list of optional MicroShift workloads
// existing on the filesystem as manifests (in comparison to Multus which
// manifests are part of MicroShift binary).
// that are both present on the filesystem and included in the configured
// kustomizePaths. This ensures the healthcheck only waits for optional
// components that MicroShift was configured to deploy.
func fillOptionalMicroShiftWorkloads(workloadsToCheck map[string]NamespaceWorkloads) error {
cfg, err := config.ActiveConfig()
if err != nil {
return err
}

configuredPaths, err := cfg.Manifests.GetKustomizationPaths()
if err != nil {
return err
}

configuredSet := make(map[string]bool, len(configuredPaths))
for _, p := range configuredPaths {
configuredSet[p] = true
}

for path, ow := range optionalWorkloadPaths {
if exists, err := util.PathExists(path); err != nil {
return err
} else if exists {
klog.Infof("Optional component path exists: %s - expecting %v in namespace %q", path, ow.Workloads.String(), ow.Namespace)
workloadsToCheck[ow.Namespace] = ow.Workloads
} else if !exists {
continue
}

if !configuredSet[path] {
klog.Infof("Optional component path exists but is not in configured kustomizePaths: %s - skipping", path)
continue
}

klog.Infof("Optional component path exists and is configured: %s - expecting %v in namespace %q", path, ow.Workloads.String(), ow.Namespace)
workloadsToCheck[ow.Namespace] = ow.Workloads
}
return nil
}
54 changes: 54 additions & 0 deletions test/resources/optional-config.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
*** Settings ***
Documentation Keywords for reconfiguring MicroShift with per-suite
... optional components via kustomizePaths.

Library Collections
Library String
Resource common.resource
Resource microshift-config.resource
Resource microshift-process.resource
Resource ostree-health.resource


*** Keywords ***
Setup MicroShift With Optionals
[Documentation] Reconfigure MicroShift to load only the specified optional
... manifests.d directories, clean all data, and restart fresh.
... Each argument is a directory name under /usr/lib/microshift/manifests.d/
... (e.g. 001-microshift-olm). Call with no arguments to run base MicroShift
... without any optional components.
[Arguments] @{manifests_dirs}
Save Default MicroShift Config
${kustomize_yaml}= Build Optionals Config @{manifests_dirs}
${config}= Replace MicroShift Config ${kustomize_yaml}
Stop MicroShift
Upload MicroShift Config ${config}
Cleanup MicroShift --all --keep-images
Systemctl start microshift.service
Wait For MicroShift Healthcheck Success
Setup Kubeconfig

Teardown MicroShift With Optionals
[Documentation] Restore the original MicroShift config after a suite.
... If setup never completed, the default config variable may not exist,
... so fall back to clearing the config file.
${exists}= Run Keyword And Return Status Variable Should Exist ${DEFAULT_MICROSHIFT_CONFIG}
IF ${exists}
Restore Default MicroShift Config
ELSE
Clear MicroShift Config
END

Build Optionals Config
[Documentation] Build a config.yaml string with kustomizePaths containing
... only the base manifests path and the specified manifests.d entries.
[Arguments] @{manifests_dirs}
VAR @{lines}=
... manifests:
... \ \ kustomizePaths:
... \ \ \ \ - /usr/lib/microshift/manifests
FOR ${dir} IN @{manifests_dirs}
Append To List ${lines} \ \ \ \ - /usr/lib/microshift/manifests.d/${dir}
END
${config}= Catenate SEPARATOR=\n @{lines}
RETURN ${config}
5 changes: 5 additions & 0 deletions test/scenarios-bootc/el9/presubmits/el98-src@optional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Sourced from scenario.sh and uses functions defined there.

# Each optional suite restarts MicroShift with its own kustomizePaths config,
# adding ~10 minutes of restart overhead to the total execution time.
# shellcheck disable=SC2034 # used elsewhere
TEST_EXECUTION_TIMEOUT=60m

# shellcheck disable=SC2034 # used elsewhere
# Increase greenboot timeout for optional packages (more services to start)
GREENBOOT_TIMEOUT=1200
Expand Down
5 changes: 5 additions & 0 deletions test/scenarios/periodics/el98-src@optional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Sourced from scenario.sh and uses functions defined there.

# Each optional suite restarts MicroShift with its own kustomizePaths config,
# adding ~10 minutes of restart overhead to the total execution time.
# shellcheck disable=SC2034 # used elsewhere
TEST_EXECUTION_TIMEOUT=60m

# Redefine network-related settings to use the dedicated network bridge
VM_BRIDGE_IP="$(get_vm_bridge_ip "${VM_MULTUS_NETWORK}")"
# shellcheck disable=SC2034 # used elsewhere
Expand Down
17 changes: 15 additions & 2 deletions test/suites/optional/cert-manager.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ Resource ../../resources/oc.resource
Resource ../../resources/microshift-config.resource
Resource ../../resources/microshift-network.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/optional-config.resource
Resource ../../resources/ostree-health.resource

Suite Setup Setup Suite With Namespace
Suite Teardown Teardown Suite With Namespace
Suite Setup Setup
Suite Teardown Teardown

Test Tags cert-manager certificates tls

Expand Down Expand Up @@ -96,6 +97,18 @@ Test Cert manager with local acme server


*** Keywords ***
Setup
[Documentation] Setup cert-manager suite with only its required optionals
Setup Suite
Setup MicroShift With Optionals 060-microshift-cert-manager
${ns}= Create Unique Namespace
VAR ${NAMESPACE}= ${ns} scope=SUITE

Teardown
[Documentation] Restore config and teardown suite
Teardown MicroShift With Optionals
Teardown Suite With Namespace

Deploy Hello MicroShift
[Documentation] Deploys the hello microshift application (service included)
... in the given namespace.
Expand Down
18 changes: 16 additions & 2 deletions test/suites/optional/gateway-api.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Documentation Test Gateway API functionality

Resource ../../resources/microshift-network.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/optional-config.resource
Resource ../../resources/oc.resource

Suite Setup Setup Suite With Namespace
Suite Teardown Teardown Suite With Namespace
Suite Setup Setup
Suite Teardown Teardown

Test Tags optional gateway-api

Expand Down Expand Up @@ -38,6 +40,18 @@ Test Simple HTTP Route


*** Keywords ***
Setup
[Documentation] Setup gateway-api suite with only its required optionals
Setup Suite
Setup MicroShift With Optionals 000-microshift-gateway-api
${ns} Create Unique Namespace
VAR ${NAMESPACE} ${ns} scope=SUITE

Teardown
[Documentation] Restore config and teardown suite
Teardown MicroShift With Optionals
Teardown Suite With Namespace

Deploy Hello MicroShift
[Documentation] Deploys the hello microshift application (service included)
... in the given namespace.
Expand Down
19 changes: 13 additions & 6 deletions test/suites/optional/generic-device-plugin.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Documentation Generic Device Plugin

Resource ../../resources/microshift-config.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/optional-config.resource
Resource ../../resources/ostree-health.resource
Variables strings.py
Library strings.py

Suite Setup Setup Suite With Namespace
Suite Teardown Teardown Suite With GDP Cleanup
Suite Setup Setup Suite With Optionals
Suite Teardown Teardown Suite With GDP Cleanup And Optionals

Test Tags generic-device-plugin

Expand Down Expand Up @@ -244,11 +245,17 @@ Create Pod And Verify Allocation
# Verify node shows correct allocation
Verify Node Device Allocation ${expected_total_allocated}

Teardown Suite With GDP Cleanup
[Documentation] Suite teardown that cleans up GDP configuration and restarts MicroShift
# Clean up any remaining GDP configuration
Setup Suite With Optionals
[Documentation] Setup suite with base MicroShift only (no optional components)
Setup Suite
Setup MicroShift With Optionals
${ns}= Create Unique Namespace
VAR ${NAMESPACE}= ${ns} scope=SUITE

Teardown Suite With GDP Cleanup And Optionals
[Documentation] Suite teardown that cleans up GDP configuration and restores optionals config
Remove Drop In MicroShift Config 10-gdp
# Restart MicroShift to clean state for next suite
Restart MicroShift
Wait For MicroShift Healthcheck Success
Teardown MicroShift With Optionals
Teardown Suite With Namespace
17 changes: 15 additions & 2 deletions test/suites/optional/healthchecks-disabled-service.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ Documentation Test if healthcheck exits quickly when MicroShift service is

Resource ../../resources/common.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/optional-config.resource
Library DateTime

Suite Setup Setup Suite
Suite Teardown Teardown Suite
Suite Setup Setup
Suite Teardown Teardown


*** Test Cases ***
Expand Down Expand Up @@ -36,3 +37,15 @@ Healthchecks Should Exit Fast And Successful When MicroShift Is Disabled
Should Contain ${stderr} microshift.service is not enabled
END
[Teardown] Enable MicroShift


*** Keywords ***
Setup
[Documentation] Setup suite with base MicroShift only (no optional components)
Setup Suite
Setup MicroShift With Optionals

Teardown
[Documentation] Restore config and teardown suite
Teardown MicroShift With Optionals
Teardown Suite
18 changes: 15 additions & 3 deletions test/suites/optional/multus.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Resource ../../resources/common.resource
Resource ../../resources/multus.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/microshift-rpm.resource
Resource ../../resources/optional-config.resource

Suite Setup Setup
Suite Teardown Teardown Suite With Namespace
Suite Teardown Teardown

Test Tags vm-only

Expand Down Expand Up @@ -111,15 +112,26 @@ Ipvlan
*** Keywords ***
Setup
[Documentation] Setup test suite
Setup Suite With Namespace
Setup Suite
Setup MicroShift With Optionals
${ns}= Create Unique Namespace
VAR ${NAMESPACE}= ${ns} scope=SUITE
Setup Network Interfaces
Verify MicroShift RPM Install

Setup Network Interfaces
[Documentation] Detect network interfaces for macvlan and ipvlan tests
${out}= Command Should Work ip route list default | cut -d' ' -f5
@{enps}= String.Split To Lines ${out}
${len}= Get Length ${enps}
Should Be True ${len}>=2
VAR ${MACVLAN_MASTER}= ${enps[0]} scope=SUITE
VAR ${IPVLAN_MASTER}= ${enps[1]} scope=SUITE
Verify MicroShift RPM Install

Teardown
[Documentation] Restore config and teardown suite
Teardown MicroShift With Optionals
Teardown Suite With Namespace

Template And Create NAD And Pod
[Documentation] Template NAD and create it along with Pod
Expand Down
23 changes: 15 additions & 8 deletions test/suites/optional/observability.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Library ../../resources/prometheus.py
Library ../../resources/loki.py
Resource ../../resources/kubeconfig.resource
Resource ../../resources/common.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/optional-config.resource
Resource ../../resources/systemd.resource
Resource ../../resources/observability.resource
Resource ../../resources/microshift-network.resource
Expand Down Expand Up @@ -68,19 +70,23 @@ Logs Should Not Contain Receiver Errors
Setup Suite And Prepare Test Host
[Documentation] The service starts after MicroShift starts and thus will start generating pertinent log data
... right away. When the suite is executed, immediately get the cursor for the microshift-observability unit.
Setup Suite With Namespace
# Configure the firewall for the Prometheus exporter
Setup Suite
Setup MicroShift With Optionals 003-microshift-observability
${ns} Create Unique Namespace
VAR ${NAMESPACE} ${ns} scope=SUITE
Configure Firewall And Observability
Create Hello MicroShift Pod
Expose Hello MicroShift
${cur} Get Journal Cursor unit=microshift-observability
VAR ${JOURNAL_CUR} ${cur} scope=SUITE

Configure Firewall And Observability
[Documentation] Configure firewall for Prometheus exporter and set up observability
Command Should Work sudo firewall-cmd --permanent --zone=public --add-port=8889/tcp
Command Should Work sudo firewall-cmd --reload
# Configure observability settings
Check Required Observability Variables
Ensure Loki Is Ready
Set Test OTEL Configuration
# We need to do something to the cluster to generate new kube events
Create Hello MicroShift Pod
Expose Hello MicroShift
${cur} Get Journal Cursor unit=microshift-observability
VAR ${JOURNAL_CUR} ${cur} scope=SUITE

Check Required Observability Variables
[Documentation] Check if the required proxy variables are set
Expand Down Expand Up @@ -124,6 +130,7 @@ Set Test OTEL Configuration
Teardown Suite And Revert Test Host
[Documentation] Set back original OTEL config and teardown Suite
Set Back Original OTEL Configuration
Teardown MicroShift With Optionals
Teardown Suite With Namespace

Set Back Original OTEL Configuration
Expand Down
3 changes: 3 additions & 0 deletions test/suites/optional/olm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Documentation Operator Lifecycle Manager on MicroShift
Resource ../../resources/common.resource
Resource ../../resources/microshift-process.resource
Resource ../../resources/microshift-rpm.resource
Resource ../../resources/optional-config.resource
Resource ../../resources/oc.resource
Library DataFormats.py

Expand Down Expand Up @@ -148,6 +149,7 @@ Setup
Login MicroShift Host
Setup Kubeconfig
Verify MicroShift RPM Install
Setup MicroShift With Optionals 001-microshift-olm

Setup Test
[Documentation] Test setup
Expand All @@ -164,6 +166,7 @@ Setup Test

Teardown
[Documentation] Test suite teardown
Teardown MicroShift With Optionals
Logout MicroShift Host
Remove Kubeconfig

Expand Down
Loading