Skip to content

CCXDEV-15561: Improve test coverage 4#1226

Merged
openshift-merge-bot[bot] merged 7 commits intoopenshift:masterfrom
katushiik11:CCXDEV-15561-test-coverage-4
Apr 13, 2026
Merged

CCXDEV-15561: Improve test coverage 4#1226
openshift-merge-bot[bot] merged 7 commits intoopenshift:masterfrom
katushiik11:CCXDEV-15561-test-coverage-4

Conversation

@katushiik11
Copy link
Copy Markdown
Contributor

@katushiik11 katushiik11 commented Feb 9, 2026

This PR implements tests to improve test coverage in directories, utils, utils/check, controller/periodic & cmd/obfuscate-archive.

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

  • None

Documentation

  • None

Unit Tests

  • pkg/utils/count_lines_test.go
  • pkg/utils/gatherers_test.go
  • pkg/utils/line_limit_reader_test.go
  • pkg/utils/check/has_container_in_crashloop_test.go
  • pkg/utils/check/is_healthy_pod_test.go
  • pkg/controller/periodic/datagather_informer_test.go
  • cmd/obfuscate-archive/main_test.go

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

No

Breaking Changes

No

References

https://issues.redhat.com/browse/CCXDEV-15561

Summary by CodeRabbit

  • Tests
    • Added extensive test suites covering archive obfuscation and extraction, event processing/filtering for periodic gatherers, container and pod health detection, line-counting and line-limit reading utilities, and periodic processing timing — improving reliability, edge-case coverage, and error-path validation across the system.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 9, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Feb 9, 2026

@katushiik11: This pull request references CCXDEV-15561 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

This PR implements tests to improve test coverage in directories, utils, utils/check, controller/periodic & cmd/obfuscate-archive.

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

  • None

Documentation

  • None

Unit Tests

  • pkg/utils/count_lines_test.go
  • pkg/utils/gatherers_test.go
  • pkg/utils/line_limit_reader_test.go
  • pkg/utils/check/has_container_in_crashloop_test.go
  • pkg/utils/check/is_healthy_pod_test.go
  • pkg/controller/periodic/datagather_informer_test.go
  • cmd/obfuscate-archive/main_test.go

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

No

Breaking Changes

No

References

https://issues.redhat.com/browse/CCXDEV-15561

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 requested review from ncaak and opokornyy February 9, 2026 12:41
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2026
@katushiik11
Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@BaiyangZhou
Copy link
Copy Markdown

/retest

@opokornyy
Copy link
Copy Markdown
Contributor

/retest

Comment thread pkg/utils/gatherers_test.go Outdated
Copy link
Copy Markdown
Contributor

@ncaak ncaak left a comment

Choose a reason for hiding this comment

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

Overall, it looks good.

I have a few minor concerns about some field names, such as "now" and "expected," which could be more specific. However, the tests are readable, so I won't push for a refactor.

I approve these changes, but I'll let @opokornyy give final approval and the "lgtm" label.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Feb 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: katushiik11, ncaak

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

@BaiyangZhou
Copy link
Copy Markdown

/test lint

1 similar comment
@BaiyangZhou
Copy link
Copy Markdown

/test lint

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: be9edacb-b765-48fd-beaf-09ff7e4cd40f

📥 Commits

Reviewing files that changed from the base of the PR and between 4db670e and c7d17a0.

📒 Files selected for processing (1)
  • cmd/obfuscate-archive/main_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/obfuscate-archive/main_test.go

📝 Walkthrough

Walkthrough

Adds seven new test files exercising archive obfuscation, periodic datagather informer, container/pod health checks, and several line-based utility functions; all changes are test-only with no production code modifications.

Changes

Cohort / File(s) Summary
Archive Obfuscation Tests
cmd/obfuscate-archive/main_test.go
Comprehensive tests for reading and obfuscating tar.gz archives, extracting infrastructure/ingress/metadata records, domain extraction logic, handling of invalid JSON, missing records, and error paths (including non-gzip and non-existent files).
Periodic Controller Tests
pkg/controller/periodic/datagather_informer_test.go
Tests for DataGather informer event handler: name-prefix filtering, correct name dispatch to channel, and ignoring invalid (non-DataGather) objects.
Container Crashloop Tests
pkg/utils/check/has_container_in_crashloop_test.go
Unit tests for crashloop detection functions covering terminated vs waiting states, restart counts, exit codes, init vs regular containers, and pod-level aggregation.
Pod Health Tests
pkg/utils/check/is_healthy_pod_test.go
Table-driven tests for IsHealthyPod covering phases, creation timestamps (age-based pending checks), container termination exit codes, restart counts, init container failures, and absence of statuses.
Line/Reader Utility Tests
pkg/utils/count_lines_test.go, pkg/utils/line_limit_reader_test.go
Tests for CountLines and LineLimitReader: empty/multi-line behavior, EOF handling, line-limit enforcement, total-line accounting, and edge cases (no-newline, zero limit).
Gatherer Timing Tests
pkg/utils/gatherers_test.go
Tests for ShouldBeProcessedNow validating scheduling decisions based on lastProcessingTime and period (past, not elapsed, future cases).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.3)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Mar 17, 2026

@katushiik11: This pull request references CCXDEV-15561 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

This PR implements tests to improve test coverage in directories, utils, utils/check, controller/periodic & cmd/obfuscate-archive.

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

  • None

Documentation

  • None

Unit Tests

  • pkg/utils/count_lines_test.go
  • pkg/utils/gatherers_test.go
  • pkg/utils/line_limit_reader_test.go
  • pkg/utils/check/has_container_in_crashloop_test.go
  • pkg/utils/check/is_healthy_pod_test.go
  • pkg/controller/periodic/datagather_informer_test.go
  • cmd/obfuscate-archive/main_test.go

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

No

Breaking Changes

No

References

https://issues.redhat.com/browse/CCXDEV-15561

Summary by CodeRabbit

  • Tests
  • Added comprehensive test suites for archive obfuscation and extraction operations, event processing and filtering mechanisms, container and pod health monitoring capabilities, line manipulation utilities, and periodic processing timing validation to enhance code reliability, improve error handling validation, and ensure correct behavior across various scenarios and edge cases throughout the system.

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.

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/utils/line_limit_reader_test.go (1)

67-80: expectEOF is misleading when using io.ReadAll.

io.ReadAll consumes EOF and typically returns err == nil, so this branch doesn’t actually validate EOF behavior. This weakens readability and test intent.

Proposed cleanup
-			n, err := io.ReadAll(limitedReader)
-
-			if tt.expectEOF {
-				// For limited reads, we expect some data followed by EOF
-				assert.Equal(t, tt.expectedOutput, string(n))
-			} else {
-				// For unlimited or empty reads
-				if err != nil && err != io.EOF {
-					t.Fatalf("unexpected error: %v", err)
-				}
-				if len(tt.input) > 0 {
-					assert.Equal(t, tt.expectedOutput, string(n))
-				}
-			}
+			n, err := io.ReadAll(limitedReader)
+			assert.NoError(t, err)
+			assert.Equal(t, tt.expectedOutput, string(n))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/utils/line_limit_reader_test.go` around lines 67 - 80, The test's use of
tt.expectEOF with io.ReadAll is misleading because io.ReadAll consumes EOF and
usually returns nil error; update the test around io.ReadAll(limitedReader) so
it no longer branches on tt.expectEOF: always assert the returned bytes match
tt.expectedOutput (using string(n)), and if you need to verify EOF behavior
explicitly use a different read strategy (e.g., call limitedReader.Read with a
buffer or io.ReadFull and check for io.EOF) to assert EOF semantics for the
limitedReader; adjust references to tt.expectEOF, io.ReadAll, and limitedReader
accordingly so the intent is clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/obfuscate-archive/main_test.go`:
- Around line 149-159: The test case labeled "invalid JSON returns nil error"
currently expects no error for malformed ingress JSON; change the test table
entry to set expectError: true (and keep expectedDomain empty) and update the
test assertion in the table-driven test (the test function that iterates over
the cases, e.g., Test... in main_test.go that uses the case fields
invalidJSON/expectError/expectedDomain) to assert an error is returned when
invalidJSON is true, ensuring the ingress JSON parsing path (the parser invoked
by the test) surfaces parse failures rather than treating malformed input as
success.

---

Nitpick comments:
In `@pkg/utils/line_limit_reader_test.go`:
- Around line 67-80: The test's use of tt.expectEOF with io.ReadAll is
misleading because io.ReadAll consumes EOF and usually returns nil error; update
the test around io.ReadAll(limitedReader) so it no longer branches on
tt.expectEOF: always assert the returned bytes match tt.expectedOutput (using
string(n)), and if you need to verify EOF behavior explicitly use a different
read strategy (e.g., call limitedReader.Read with a buffer or io.ReadFull and
check for io.EOF) to assert EOF semantics for the limitedReader; adjust
references to tt.expectEOF, io.ReadAll, and limitedReader accordingly so the
intent is clear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 3f078cd4-c43b-445a-82f5-32b64aae5d6f

📥 Commits

Reviewing files that changed from the base of the PR and between dfa9ec1 and 4db670e.

📒 Files selected for processing (7)
  • cmd/obfuscate-archive/main_test.go
  • pkg/controller/periodic/datagather_informer_test.go
  • pkg/utils/check/has_container_in_crashloop_test.go
  • pkg/utils/check/is_healthy_pod_test.go
  • pkg/utils/count_lines_test.go
  • pkg/utils/gatherers_test.go
  • pkg/utils/line_limit_reader_test.go

Comment on lines +149 to +159
name: "invalid JSON returns nil error",
ingress: &configv1.Ingress{
Spec: configv1.IngressSpec{
Domain: "test.example.com",
},
},
includeRecord: true,
invalidJSON: true,
expectError: false,
expectedDomain: "",
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don’t treat malformed ingress JSON as a successful parse.

Expecting nil error for invalid JSON can hide corrupted archive input and weakens failure signaling in this path.

Suggested test expectation adjustment
-		{
-			name: "invalid JSON returns nil error",
+		{
+			name: "error - invalid JSON",
 			ingress: &configv1.Ingress{
 				Spec: configv1.IngressSpec{
 					Domain: "test.example.com",
 				},
 			},
 			includeRecord:  true,
 			invalidJSON:    true,
-			expectError:    false,
-			expectedDomain: "",
+			expectError:    true,
+			errorContains:  "invalid character",
+			expectedDomain: "",
 		},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: "invalid JSON returns nil error",
ingress: &configv1.Ingress{
Spec: configv1.IngressSpec{
Domain: "test.example.com",
},
},
includeRecord: true,
invalidJSON: true,
expectError: false,
expectedDomain: "",
},
name: "error - invalid JSON",
ingress: &configv1.Ingress{
Spec: configv1.IngressSpec{
Domain: "test.example.com",
},
},
includeRecord: true,
invalidJSON: true,
expectError: true,
errorContains: "invalid character",
expectedDomain: "",
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/obfuscate-archive/main_test.go` around lines 149 - 159, The test case
labeled "invalid JSON returns nil error" currently expects no error for
malformed ingress JSON; change the test table entry to set expectError: true
(and keep expectedDomain empty) and update the test assertion in the
table-driven test (the test function that iterates over the cases, e.g., Test...
in main_test.go that uses the case fields
invalidJSON/expectError/expectedDomain) to assert an error is returned when
invalidJSON is true, ensuring the ingress JSON parsing path (the parser invoked
by the test) surfaces parse failures rather than treating malformed input as
success.

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Mar 17, 2026

@katushiik11: This pull request references CCXDEV-15561 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

This PR implements tests to improve test coverage in directories, utils, utils/check, controller/periodic & cmd/obfuscate-archive.

Categories

  • Bugfix
  • Data Enhancement
  • Feature
  • Backporting
  • Others (CI, Infrastructure, Documentation)

Sample Archive

  • None

Documentation

  • None

Unit Tests

  • pkg/utils/count_lines_test.go
  • pkg/utils/gatherers_test.go
  • pkg/utils/line_limit_reader_test.go
  • pkg/utils/check/has_container_in_crashloop_test.go
  • pkg/utils/check/is_healthy_pod_test.go
  • pkg/controller/periodic/datagather_informer_test.go
  • cmd/obfuscate-archive/main_test.go

Privacy

Yes. There are no sensitive data in the newly collected information.

Changelog

No

Breaking Changes

No

References

https://issues.redhat.com/browse/CCXDEV-15561

Summary by CodeRabbit

  • Tests
  • Added extensive test suites covering archive obfuscation and extraction, event processing/filtering for periodic gatherers, container and pod health detection, line-counting and line-limit reading utilities, and periodic processing timing — improving reliability, edge-case coverage, and error-path validation across the system.

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.

@opokornyy
Copy link
Copy Markdown
Contributor

/lgtm
/verified by @opokornyy

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 13, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@opokornyy: This PR has been marked as verified by @opokornyy.

Details

In response to this:

/lgtm
/verified by @opokornyy

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 lgtm Indicates that a PR is ready to be merged. label Apr 13, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 13, 2026

@katushiik11: 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 50525ba into openshift:master Apr 13, 2026
7 checks passed
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. 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. 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