Skip to content

Conversation

@duanwei33
Copy link
Contributor

@duanwei33 duanwei33 commented Dec 3, 2025

Adding LSO network policy test cases

LSO(and other 3rd Operator) test strategy:
After discussing with the team, we decided not to install/uninstall the Operator/Operand during standard tests, as this would incur significant overhead across all our CI pipelines.
Instead, we will define specific jobs where the Operator/Operand is pre-installed. This approach allows us to cover all configuration-related tests efficiently and with low cost.

Test records:

passed: (11.3s) 2025-12-03T13:16:58 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should ensure required NetworkPolicies exist with correct labels for LSO [Suite:openshift/conformance/parallel]"
passed: (11.1s) 2025-12-03T13:16:58 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for CSI related Operators [Suite:openshift/conformance/parallel]"
passed: (11.6s) 2025-12-03T13:16:59 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for CSO related Operators [Suite:openshift/conformance/parallel]"
passed: (11.8s) 2025-12-03T13:16:59 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for LSO related resources [Suite:openshift/conformance/parallel]"
passed: (12.5s) 2025-12-03T13:17:00 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should ensure required NetworkPolicies exist with correct labels [Suite:openshift/conformance/parallel]"

@openshift-ci-robot
Copy link

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Dec 3, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 3, 2025

@duanwei33: This pull request references STOR-2550 which is a valid jira issue.

Details

In response to this:

Adding LSO network policy test cases

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 3, 2025
@openshift-ci openshift-ci bot requested review from jsafrane and tsmetana December 3, 2025 11:13
@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 3, 2025

@duanwei33: This pull request references STOR-2550 which is a valid jira issue.

Details

In response to this:

Adding LSO network policy test cases

Test records:

passed: (11.3s) 2025-12-03T13:16:58 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should ensure required NetworkPolicies exist with correct labels for LSO [Suite:openshift/conformance/parallel]"
passed: (11.1s) 2025-12-03T13:16:58 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for CSI related Operators [Suite:openshift/conformance/parallel]"
passed: (11.6s) 2025-12-03T13:16:59 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for CSO related Operators [Suite:openshift/conformance/parallel]"
passed: (11.8s) 2025-12-03T13:16:59 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for LSO related resources [Suite:openshift/conformance/parallel]"
passed: (12.5s) 2025-12-03T13:17:00 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should ensure required NetworkPolicies exist with correct labels [Suite:openshift/conformance/parallel]"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@duanwei33 duanwei33 changed the title WIP: STOR-2550: add LSO network policy test case STOR-2550: add LSO network policy test case Dec 3, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 3, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 3, 2025

@duanwei33: This pull request references STOR-2550 which is a valid jira issue.

Details

In response to this:

Adding LSO network policy test cases

LSO(and other 3rd Operator) test strategy:
After discussing with the team, we decided not to install/uninstall the Operator/Operand during standard tests, as this would incur significant overhead across all our CI pipelines.
Instead, we will define specific jobs where the Operator/Operand is pre-installed. This approach allows us to cover all configuration-related tests efficiently and with low cost.

Test records:

passed: (11.3s) 2025-12-03T13:16:58 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should ensure required NetworkPolicies exist with correct labels for LSO [Suite:openshift/conformance/parallel]"
passed: (11.1s) 2025-12-03T13:16:58 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for CSI related Operators [Suite:openshift/conformance/parallel]"
passed: (11.6s) 2025-12-03T13:16:59 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for CSO related Operators [Suite:openshift/conformance/parallel]"
passed: (11.8s) 2025-12-03T13:16:59 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should verify required labels for LSO related resources [Suite:openshift/conformance/parallel]"
passed: (12.5s) 2025-12-03T13:17:00 "[sig-storage][OCPFeature:StorageNetworkPolicy] Storage Network Policy should ensure required NetworkPolicies exist with correct labels [Suite:openshift/conformance/parallel]"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Comment on lines 368 to 375
if !lsoInstallInfo.Installed {
g.Skip("LSO is not installed on this cluster")
} else if !isLSOVersionSupported(lsoInstallInfo.Version) {
g.Skip(fmt.Sprintf("LSO network policy support requires version >= 4.21.0, current version: %s", lsoInstallInfo.Version))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if !lsoInstallInfo.Installed {
g.Skip("LSO is not installed on this cluster")
} else if !isLSOVersionSupported(lsoInstallInfo.Version) {
g.Skip(fmt.Sprintf("LSO network policy support requires version >= 4.21.0, current version: %s", lsoInstallInfo.Version))
}
if !lsoInstallInfo.Installed {
g.Skip("LSO is not installed on this cluster")
}
if !isLSOVersionSupported(lsoInstallInfo.Version) {
g.Skip(fmt.Sprintf("LSO network policy support requires version >= 4.21.0, current version: %s", lsoInstallInfo.Version))
}

will be more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, it looks clear, will update later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Phaow I have updated the code, but I'm not sure why it doesn't show "Outdated" in the GUI.

Could you check if you have any other comments?

g.Skip(fmt.Sprintf("LSO network policy support requires version >= 4.21.0, current version: %s", lsoInstallInfo.Version))
}

LSOResourcesToCheck := []resourceCheck{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could also consider just append it to CSIResourcesToCheck if lso is installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. I once considered combining, but it will give us the clear result from the case level (skipped if LSO is not installed), so I think we can keep this :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we could keep it, from the reports scope makes sense.

runResourceChecks(oc, LSOResourcesToCheck, currentPlatform)
})

g.It("should ensure required NetworkPolicies exist with correct labels for LSO", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same above, we could just append it in g.It("should ensure required NetworkPolicies exist with correct labels"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same above :)

Comment on lines 520 to 560
// Get all CSVs across all namespaces matching local-storage-operator pattern
// Command: oc get csv -A -o json
output, err := oc.AsAdmin().Run("get").Args("csv", "-A", "-o", "json").Output()
if err != nil {
return info, fmt.Errorf("failed to list ClusterServiceVersions: %v", err)
}

// Parse the JSON output to find local-storage-operator CSV
// The output contains a list of CSVs with metadata.name and metadata.namespace
var csvList struct {
Items []struct {
Metadata struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
} `json:"metadata"`
Spec struct {
Version string `json:"version"`
} `json:"spec"`
Status struct {
Phase string `json:"phase"`
} `json:"status"`
} `json:"items"`
}

if err := json.Unmarshal([]byte(output), &csvList); err != nil {
return info, fmt.Errorf("failed to parse CSV list: %v", err)
}

// Search for local-storage-operator CSV
for _, csv := range csvList.Items {
// Match CSV name pattern: local-storage-operator.*
if strings.HasPrefix(csv.Metadata.Name, "local-storage-operator") {
// Only consider CSVs in Succeeded phase
if csv.Status.Phase == "Succeeded" {
info.Installed = true
info.Namespace = csv.Metadata.Namespace
info.Version = csv.Spec.Version
return info, nil
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be a better way to do this. oc.AsAdmin().Run() spawns a new oc process, then there is a new custom struct to unmarshal the text output. You could instead use the API types directly from operator-framework here:
https://github.com/operator-framework/api/blob/ebdb4e0b321b668f7bc5146e2972b1ce4529d109/pkg/operators/v1alpha1/clusterserviceversion_types.go#L601-L619

oadp-operator for example imports the API here:
https://github.com/openshift/oadp-operator/blob/oadp-dev/must-gather/pkg/cli.go#L15
then adds it to the scheme here:
https://github.com/openshift/oadp-operator/blob/oadp-dev/must-gather/pkg/cli.go#L82

IMO, you should at least be able to use ClusterServiceVersionList from the operator-framework repo, instead of defining the new csvList struct here. Even better if you can add some new method to test/extended/util/client.go to get a client that supports ClusterServiceVersion so you could list CSV's the same way you list NetworkPolicies and avoid oc.AsAdmin().Run().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I followed the example to use typed controller-runtime client, it looks better, could you help take a look?
But I have to be careful of the dependency update due to the github.com/operator-framework/api introduced.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new code looks good, thanks for making this change :)
I don't see any obvious problem with the dependency updates.

@dobsonj
Copy link
Member

dobsonj commented Dec 6, 2025

Instead, we will define specific jobs where the Operator/Operand is pre-installed. This approach allows us to cover all configuration-related tests efficiently and with low cost.

@duanwei33 Does this mean you will have a follow-up PR to openshift/release to define a new workflow to install LSO and run this test?

@openshift-ci openshift-ci bot added the vendor-update Touching vendor dir or related files label Dec 11, 2025
@duanwei33
Copy link
Contributor Author

/hold
(Need to verify more tests due to the dependency update)

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 11, 2025
@duanwei33
Copy link
Contributor Author

Instead, we will define specific jobs where the Operator/Operand is pre-installed. This approach allows us to cover all configuration-related tests efficiently and with low cost.

@duanwei33 Does this mean you will have a follow-up PR to openshift/release to define a new workflow to install LSO and run this test?

Yes you are right. wdyt of this idea?

@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@dobsonj
Copy link
Member

dobsonj commented Dec 11, 2025

Instead, we will define specific jobs where the Operator/Operand is pre-installed. This approach allows us to cover all configuration-related tests efficiently and with low cost.

@duanwei33 Does this mean you will have a follow-up PR to openshift/release to define a new workflow to install LSO and run this test?

Yes you are right. wdyt of this idea?

Works for me, just wanted to understand how it will run, since existing LSO presubmits don't call this (yet).

@dobsonj
Copy link
Member

dobsonj commented Dec 11, 2025

/retest
?

@duanwei33
Copy link
Contributor Author

/retest

@dobsonj
Copy link
Member

dobsonj commented Dec 12, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 12, 2025
@duanwei33
Copy link
Contributor Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 15, 2025
go.mod Outdated
go 1.24.0
go 1.24.6

toolchain go1.24.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go will prefer or auto-download Go 1.24.11, is this expected? We'd better use the builder go version consistently.

@Phaow
Copy link
Contributor

Phaow commented Dec 15, 2025

Others LGTM.

refactor LSO network policy test to use operator-framework API
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 15, 2025
@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@Phaow
Copy link
Contributor

Phaow commented Dec 15, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 15, 2025
@duanwei33
Copy link
Contributor Author

@DennisPeriquet
Hi, could you please help review and approve it?

@DennisPeriquet
Copy link
Contributor

@duanwei33 I am no expert here but I see other people have LGTM'ed.

Please keep an eye on any blocking jobs that might fail with these changes and be ready to revert as needed.

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 16, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DennisPeriquet, dobsonj, duanwei33, Phaow

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 16, 2025
@duanwei33
Copy link
Contributor Author

/label acknowledge-critical-fixes-only
Needed to add coverage for new 4.21 feature.

@openshift-ci openshift-ci bot added the acknowledge-critical-fixes-only Indicates if the issuer of the label is OK with the policy. label Dec 17, 2025
@duanwei33
Copy link
Contributor Author

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Dec 17, 2025
@openshift-ci-robot
Copy link

@duanwei33: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 26236de and 2 for PR HEAD 2f72685 in total

@duanwei33
Copy link
Contributor Author

/retest-required

@dobsonj
Copy link
Member

dobsonj commented Dec 17, 2025

/retest

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 89d0a87 and 1 for PR HEAD 2f72685 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 553fdbc and 0 for PR HEAD 2f72685 in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 18, 2025

@duanwei33: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit f641fde into openshift:main Dec 18, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

acknowledge-critical-fixes-only Indicates if the issuer of the label is OK with the policy. approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. vendor-update Touching vendor dir or related files verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants