Open
Conversation
Add test coverage for the core status command including: - Status output with installed/not installed state - Maintenance mode detection and output - Exit code functionality for normal and maintenance modes - JSON output format verification These tests provide a foundation for proper testing of the OCC status command functionality. Signed-off-by: Matthias Sauer <sauerm@strato.de>
Enhance the OCC status command to differentiate between database connection states and provide proper error handling: - Add database connection testing for installed instances - Introduce new exit code 3 for database connection failures - Add database status and error message to JSON output - Include friendly error messages for different failure states - Update tests to cover database connection scenarios This change allows monitoring tools to distinguish between: - Exit code 0: Normal operation - Exit code 1: Maintenance mode - Exit code 2: Upgrade needed - Exit code 3: Database connection failed Co-authored-by: GitHub Copilot Signed-off-by: Matthias Sauer <sauerm@strato.de>
There was a problem hiding this comment.
Pull request overview
This PR enhances the occ status command to include database connectivity checks, allowing it to differentiate between non-existent databases and connection errors through a new exit code (3) when using the --exit-code flag.
Changes:
- Added database connectivity testing using
SELECT 1query when Nextcloud is installed - Introduced new exit code 3 for database connection failures in exit-code mode
- Added user-friendly status messages for not installed, maintenance mode, and database connection failure states
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| core/Command/Status.php | Implements database connectivity check, adds new exit code 3 for connection failures, and includes friendly status messages in output |
| tests/Core/Command/StatusTest.php | Comprehensive test suite covering database connection scenarios, exit codes, and output formatting |
| try { | ||
| $this->connection->executeQuery('SELECT 1'); | ||
| $databaseStatus = 'connected'; | ||
| } catch (\Exception $e) { |
There was a problem hiding this comment.
Catching the generic \Exception is too broad. Consider catching more specific database-related exceptions (e.g., \Doctrine\DBAL\Exception) to avoid masking unexpected errors.
Suggested change
| } catch (\Exception $e) { | |
| } catch (\Doctrine\DBAL\Exception $e) { |
7 tasks
7 tasks
7 tasks
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Matthias Sauer <151215545+matsaur@users.noreply.github.com>
Co-authored-by: matsaur <151215545+matsaur@users.noreply.github.com>
Co-authored-by: matsaur <151215545+matsaur@users.noreply.github.com>
Co-authored-by: matsaur <151215545+matsaur@users.noreply.github.com>
Remove trailing whitespace from Status.php blank line
Remove trailing whitespace from Status.php
…other-one Remove trailing whitespace from Status.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To differentiate between non-existant database and connection errors,
occ statuswill fail with a new error code