Skip to content

ci-operator-checkconfig: Forbid some chars in multistage test name#5190

Open
danilo-gemoli wants to merge 1 commit into
openshift:mainfrom
danilo-gemoli:feat/ci-operator/multistage-test-name-forbi-chars
Open

ci-operator-checkconfig: Forbid some chars in multistage test name#5190
danilo-gemoli wants to merge 1 commit into
openshift:mainfrom
danilo-gemoli:feat/ci-operator/multistage-test-name-forbi-chars

Conversation

@danilo-gemoli
Copy link
Copy Markdown
Contributor

This is an alternative solution to #5188

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR adds validation to reject multi-stage test names containing forbidden characters (.) when configured with steps or literal_steps. The implementation introduces a constant, refactors validation logic to precompute boolean flags, extends the validation branch, and covers the new behavior with a test case.

Changes

Forbidden character validation for multi-stage test names

Layer / File(s) Summary
Implement forbidden character validation
pkg/validation/test.go, pkg/validation/test_test.go
New constant multiStageTestNameForbiddenChars defines . as forbidden in test names. Precomputed booleans (hasCommands, hasSteps, hasLiteral) enable reuse across validation checks. New validation branch rejects names containing forbidden characters when steps or literal_steps are set. Test case verifies the validation error for forbidden characters.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 12 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Coverage For New Features ⚠️ Warning Test coverage incomplete. New forbidden-character validation applies to both steps and literal_steps (hasSteps || hasLiteral), but only steps case is tested. Add test case for forbidden characters with MultiStageTestConfigurationLiteral to cover the literal_steps code path.
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: forbidding certain characters in multistage test names, which aligns with the validation logic added to prevent dots in test names.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Go Error Handling ✅ Passed All error handling patterns follow Go best practices: errors are checked after _, err := calls; wrapped with fmt.Errorf %w; no panic() calls; safe nil pointer handling via nil checks.
Stable And Deterministic Test Names ✅ Passed The PR uses standard Go testing, not Ginkgo. The new test case ID "test name contains forbidden chars" is static, descriptive, and contains no dynamic information.
Test Structure And Quality ✅ Passed Check targets Ginkgo tests. Codebase uses standard Go testing with table-driven tests. New test case follows established patterns: single responsibility, meaningful assertions, consistent structure.
Microshift Test Compatibility ✅ Passed This PR modifies validation logic and adds unit tests using Go's testing package. No Ginkgo e2e tests are added, so the MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies validation logic for CI configuration, not Ginkgo e2e tests. The SNO compatibility check applies only to new e2e tests. No Ginkgo e2e tests are added here.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only configuration validation code, not deployment manifests, operator code, or controllers. No scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed PR modifies validation library code only. No OTE binary or process-level stdout writes found in changes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR adds validation logic for CI test configurations, not Ginkgo e2e tests. The custom check applies only to new Ginkgo e2e tests (It(), Describe(), etc.), which are not present here.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from Prucek and pruan-rht May 19, 2026 10:29
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pkg/validation/test.go (1)

46-48: 💤 Low value

Consider adding a comment explaining why the character is forbidden.

The constant is clear, but a brief comment explaining the rationale (e.g., conflicts with step naming conventions, reserved for system use, etc.) would help future maintainers understand the constraint without needing to trace back to PR #5188.

📝 Suggested documentation
+// multiStageTestNameForbiddenChars contains characters that cannot appear in
+// multi-stage test names because [brief reason - e.g., they conflict with step naming].
 const (
 	testStageUnknown testStage = iota
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/validation/test.go` around lines 46 - 48, Add a brief inline comment
above the constant multiStageTestNameForbiddenChars explaining why the character
"." is forbidden (for example: it conflicts with step naming conventions, is
reserved for system use, or causes parsing/namespace collisions) so future
maintainers can understand the rationale without tracing PR `#5188`; locate the
constant in pkg/validation/test.go and add one concise sentence referencing the
specific reason (e.g., conflicts with step names or reserved delimiter).
pkg/validation/test_test.go (1)

715-725: ⚡ Quick win

Expand test coverage for the forbidden character validation.

The test correctly validates the new rule for MultiStageTestConfiguration (steps), but is missing coverage for:

  1. MultiStageTestConfigurationLiteral (literal_steps) - should also reject dots
  2. Container tests with dots in names - should still be allowed
🧪 Suggested additional test cases
{
	id: `test name contains forbidden chars with literal_steps`,
	tests: []api.TestStepConfiguration{
		{
			As:                                 "e2e-release-4.22",
			MultiStageTestConfigurationLiteral: &api.MultiStageTestConfigurationLiteral{
				Test: []api.LiteralTestStep{{
					As:        "step",
					From:      "base",
					Commands:  "echo test",
					Resources: api.ResourceRequirements{Requests: api.ResourceList{"cpu": "1"}},
				}},
			},
		},
	},
	expectedError: errors.New("tests[0].as: 'e2e-release-4.22' is not a valid name, the following chars '.' are forbidden"),
},
{
	id: `container test name can contain forbidden chars`,
	tests: []api.TestStepConfiguration{
		{
			As:                         "e2e-release-4.22",
			Commands:                   "commands",
			ContainerTestConfiguration: &api.ContainerTestConfiguration{From: "base"},
		},
	},
	// No expected error - container tests are not restricted
},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/validation/test_test.go` around lines 715 - 725, Add two test cases to
the table in pkg/validation/test_test.go: one that exercises
MultiStageTestConfigurationLiteral by creating a TestStepConfiguration with As:
"e2e-release-4.22" and MultiStageTestConfigurationLiteral containing a
LiteralTestStep (use api.LiteralTestStep, api.ResourceRequirements and
api.ResourceList) and assert the same expectedError string about '.' being
forbidden; and another that creates a TestStepConfiguration with As:
"e2e-release-4.22" and ContainerTestConfiguration
(api.ContainerTestConfiguration{From: "base"}) and assert that no error is
returned (i.e., do not set expectedError) to verify container tests are allowed
to contain dots. Ensure the new cases follow the existing table structure and
use the same expectedError text as the existing MultiStageTestConfiguration
case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/validation/test_test.go`:
- Around line 715-725: Add two test cases to the table in
pkg/validation/test_test.go: one that exercises
MultiStageTestConfigurationLiteral by creating a TestStepConfiguration with As:
"e2e-release-4.22" and MultiStageTestConfigurationLiteral containing a
LiteralTestStep (use api.LiteralTestStep, api.ResourceRequirements and
api.ResourceList) and assert the same expectedError string about '.' being
forbidden; and another that creates a TestStepConfiguration with As:
"e2e-release-4.22" and ContainerTestConfiguration
(api.ContainerTestConfiguration{From: "base"}) and assert that no error is
returned (i.e., do not set expectedError) to verify container tests are allowed
to contain dots. Ensure the new cases follow the existing table structure and
use the same expectedError text as the existing MultiStageTestConfiguration
case.

In `@pkg/validation/test.go`:
- Around line 46-48: Add a brief inline comment above the constant
multiStageTestNameForbiddenChars explaining why the character "." is forbidden
(for example: it conflicts with step naming conventions, is reserved for system
use, or causes parsing/namespace collisions) so future maintainers can
understand the rationale without tracing PR `#5188`; locate the constant in
pkg/validation/test.go and add one concise sentence referencing the specific
reason (e.g., conflicts with step names or reserved delimiter).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 6a398faf-056a-4b9e-8d8b-b0ed9bf9a55f

📥 Commits

Reviewing files that changed from the base of the PR and between e3ac258 and 487cc37.

📒 Files selected for processing (2)
  • pkg/validation/test.go
  • pkg/validation/test_test.go

@danilo-gemoli
Copy link
Copy Markdown
Contributor Author

/test e2e

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 19, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danilo-gemoli, deepsm007

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:
  • OWNERS [danilo-gemoli,deepsm007]

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

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

@danilo-gemoli: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e 487cc37 link true /test e2e

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants