Skip to content

Add test to cerberus/setup.py#1033

Open
iting0321 wants to merge 4 commits intokrkn-chaos:mainfrom
iting0321:setup.py
Open

Add test to cerberus/setup.py#1033
iting0321 wants to merge 4 commits intokrkn-chaos:mainfrom
iting0321:setup.py

Conversation

@iting0321
Copy link
Contributor

Type of change

  • Refactor
  • New feature
  • Bug fix
  • Optimization

Description

Name                     Stmts   Miss  Cover   Missing
------------------------------------------------------
krkn/cerberus/setup.py      62      1    98%   127
------------------------------------------------------
TOTAL                       62      1    98%

Related Tickets & Documents

Documentation

  • Is documentation needed for this update?

If checked, a documentation PR must be created and merged in the website repository.

Related Documentation PR (if applicable)

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Copilot AI review requested due to automatic review settings December 31, 2025 08:41
@iting0321 iting0321 mentioned this pull request Dec 31, 2025
35 tasks
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive test coverage for the krkn/cerberus/setup.py module, improving code coverage from the current 98% to potentially 100%. The tests focus on three main functions: get_status, publish_kraken_status, and application_status, which handle Cerberus health monitoring and status reporting.

  • Adds 338 lines of unit tests covering various scenarios for Cerberus integration
  • Creates test package structure with proper initialization
  • Tests cover both healthy and unhealthy states, error conditions, and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tests/cerberus/test_setup.py New comprehensive test suite for cerberus setup module with 3 test classes covering all major functions and edge cases
tests/cerberus/init.py New package initialization file for cerberus test module

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"cerberus": {
"cerberus_enabled": True,
"cerberus_url": "http://cerberus:8080",
"check_applicaton_routes": False
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Spelling error: "applicaton" should be "application". This typo is consistent with the actual implementation code (line 17 in setup.py uses "check_applicaton_routes"), but it's still incorrect spelling.

Copilot uses AI. Check for mistakes.
"cerberus": {
"cerberus_enabled": True,
"cerberus_url": "http://cerberus:8080",
"check_applicaton_routes": True
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Spelling error: "applicaton" should be "application". This typo is consistent with the actual implementation code (line 17 in setup.py uses "check_applicaton_routes"), but it's still incorrect spelling.

Copilot uses AI. Check for mistakes.
@tsebastiani
Copy link
Collaborator

@iting0321 Thank you very much for your contributions, could you please solve the issues identified by copilot? Thanks a lot!

Copilot AI review requested due to automatic review settings January 3, 2026 06:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"cerberus": {
"cerberus_enabled": True,
"cerberus_url": "http://cerberus:8080",
"check_application_routes": True
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The config dictionary uses check_application_routes but the actual source code uses check_applicaton_routes (with a typo - missing 'i'). This test will not accurately test the code path that checks application routes since the key doesn't match what the implementation looks for.

Copilot uses AI. Check for mistakes.
Comment on lines +315 to +317
application_status("http://cerberus:8080", 0, 6000)

mock_exit.assert_called_once_with(1)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This test doesn't properly verify the behavior when sys.exit is called. The test should raise SystemExit but doesn't set up the mock to do so. Without mock_exit.side_effect = SystemExit(1), the test won't raise SystemExit and will just continue execution, making the assertion less meaningful.

Copilot uses AI. Check for mistakes.
Comment on lines +327 to +329
application_status("http://cerberus:8080", 0, 6000)

mock_exit.assert_called_once_with(1)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This test doesn't properly verify the behavior when sys.exit is called. The test should raise SystemExit but doesn't set up the mock to do so. Without mock_exit.side_effect = SystemExit(1), the test won't raise SystemExit and will just continue execution, making the assertion less meaningful.

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +151
with patch('krkn.cerberus.setup.sys.exit') as mock_exit:
publish_kraken_status(config, ["failed_scenario"], 0, 100)
mock_exit.assert_called_once_with(1)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This test doesn't properly verify the sys.exit behavior. Without setting mock_exit.side_effect = SystemExit(1), the mock will prevent the actual SystemExit from being raised, making the test less meaningful. The test should either verify that exit was called or properly simulate the SystemExit exception.

Copilot uses AI. Check for mistakes.
Comment on lines +179 to +181
with patch('krkn.cerberus.setup.sys.exit') as mock_exit:
publish_kraken_status(config, ["failed_scenario"], 0, 100)
mock_exit.assert_called_once_with(1)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This test doesn't properly verify the sys.exit behavior. Without setting mock_exit.side_effect = SystemExit(1), the mock will prevent the actual SystemExit from being raised, making the test less meaningful. The test should either verify that exit was called or properly simulate the SystemExit exception.

Copilot uses AI. Check for mistakes.
"cerberus": {
"cerberus_enabled": True,
"cerberus_url": "http://cerberus:8080",
"check_application_routes": False
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The config dictionary uses check_application_routes but the actual source code uses check_applicaton_routes (with a typo - missing 'i'). This test will not accurately test the code path that checks application routes since the key doesn't match what the implementation looks for.

Copilot uses AI. Check for mistakes.
"cerberus": {
"cerberus_enabled": True,
"cerberus_url": "http://cerberus:8080",
"check_application_routes": True
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The config dictionary uses check_application_routes but the actual source code uses check_applicaton_routes (with a typo - missing 'i'). This test will not accurately test the code path that checks application routes since the key doesn't match what the implementation looks for.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +90
get_status(config, 0, 100)

mock_exit.assert_called_once_with(1)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This test doesn't properly verify the behavior when sys.exit is called. The test should raise SystemExit but doesn't set up the mock to do so. Without mock_exit.side_effect = SystemExit(1), the test won't raise SystemExit and will just continue execution, making the assertion meaningless.

Copilot uses AI. Check for mistakes.
Comment on lines +130 to +132
get_status(config, 0, 100)

mock_exit.assert_called_once_with(1)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

This test doesn't properly verify the behavior when sys.exit is called. The test should raise SystemExit but doesn't set up the mock to do so. Without mock_exit.side_effect = SystemExit(1), the test won't raise SystemExit and will just continue execution, making the assertion less meaningful.

Copilot uses AI. Check for mistakes.
"cerberus": {
"cerberus_enabled": True,
"cerberus_url": "http://cerberus:8080",
"check_application_routes": False
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The config dictionary uses check_application_routes but the actual source code uses check_applicaton_routes (with a typo - missing 'i'). This test will not accurately test the code path that checks application routes since the key doesn't match what the implementation looks for.

Copilot uses AI. Check for mistakes.
@iting0321
Copy link
Contributor Author

Because “application” was misspelled as “applicaton” at line 17 in krkn/cerberus/setup.py, I opened pull request #1043.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants