Skip to content

feat:improve backup database functionality via SQL and add related tests - #2198

Merged
robfrank merged 9 commits into
mainfrom
fix/2116-backup-database
May 10, 2025
Merged

feat:improve backup database functionality via SQL and add related tests#2198
robfrank merged 9 commits into
mainfrom
fix/2116-backup-database

Conversation

@robfrank

@robfrank robfrank commented May 9, 2025

Copy link
Copy Markdown
Collaborator

refs to #2116

This pull request introduces several changes aimed at improving database backup functionality, enhancing test coverage, and refining code quality. The most critical updates include adding a new backup feature, improving error handling during backups, and expanding test cases to ensure the robustness of the backup functionality. Additionally, there are various code cleanups and structural improvements across the codebase.

Database Backup Enhancements:

  • Backup Command Handling: Enhanced the BackupDatabaseStatement class to include improved error handling during database backups. It now logs errors and returns detailed results, including success or failure status and error messages when applicable.
  • Backup Settings Improvements: Refactored BackupSettings to use modern Java constructs (e.g., switch expressions) and simplified logic for assigning default filenames.
  • New Backup Test: Added BackupDatabaseTest to test the backup functionality, ensuring the command produces the expected results and file outputs.

Test Coverage Improvements:

  • E2E Tests: Added a new test (testBackupDatabase) in JdbcQueriesTest and RemoteDatabaseJavaApiTest to validate backup functionality. [1] [2]
  • Global Configuration Reset: Updated TestHelper to reset global configuration after each test to ensure test isolation.

Code Quality and Refactoring:

  • Code Cleanup: Removed unused imports and improved readability in multiple files, such as ArcadeContainerTemplate, BackupSettings, and FullBackupFormat. [1] [2] [3]
  • Improved SQL Query Engine: Made the parse method non-static in SQLQueryEngine to align with object-oriented principles.

Packaging and Deployment Updates:

  • Empty Directories for Backups: Updated assembly files (full.xml, headless.xml, minimal.xml) to include empty directories for backups and replication. [1] [2] [3]
  • Dockerfile Updates: Added volumes for backups and replication to the Docker image to support the new backup functionality.

Postgres Integration:

  • Command Context for SQL Execution: Updated PostgresNetworkExecutor to use BasicCommandContext for executing SQL statements, enabling better configuration management. [1] [2]## What does this PR do?

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

@robfrank robfrank added this to the 25.5.1 milestone May 9, 2025
@robfrank
robfrank requested review from Copilot, gramian and lvca May 9, 2025 11:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a new backup database functionality with enhancements on error handling and test coverage while cleaning up and modernizing several parts of the codebase.

  • Introduces a backup feature with detailed error reporting in the backup command handler.
  • Expands test coverage for backup functionality across various test suites.
  • Updates packaging and configuration files to support backup, replication, and improved test isolation.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/src/main/java/com/arcadedb/server/http/handler/PostCommandHandler.java Removed stray semicolon for cleaner code.
server/src/main/java/com/arcadedb/server/ArcadeDBServer.java Added a createDirectories method to ensure necessary directories (databases and backups) are present.
postgresw/src/test/java/com/arcadedb/postgres/PostgresWJdbcTest.java Added a basic backup database test using a "BACKUP DATABASE" SQL command.
postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkListener.java Reformatted constructor parameters across multiple lines for improved readability.
postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java Updated SQL command execution to use a BasicCommandContext and pass the server configuration.
package/src/main/docker/Dockerfile Added new volumes for configuration, backups, and replication support.
package/src/main/assembly/*.xml Created new file sets to generate empty directories for backups and replication in the distributions.
integration/src/test/java/com/arcadedb/integration/backup/BackupDatabaseTest.java Introduced an integration test validating backup command output.
integration/src/test/java/com/arcadedb/integration/backup/format/FullBackupFormat.java Updated import statements for clarity and maintainability.
integration/src/test/java/com/arcadedb/integration/backup/BackupSettings.java Refactored to use switch expressions and modern imports to assign backup settings.
engine/src/test/java/com/arcadedb/TestHelper.java Improved test isolation by resetting global configuration after each test.
engine/src/main/java/com/arcadedb/query/sql/parser/BackupDatabaseStatement.java Enhanced error handling in backup execution by wrapping the call in a try-catch with detailed error logging.
engine/src/main/java/com/arcadedb/query/sql/executor/BasicCommandContext.java Updated class comments to match the current interface naming.
engine/src/main/java/com/arcadedb/query/sql/SQLQueryEngine.java Converted the parse method from static to an instance method to improve API design.
e2e/src/test/java/com/arcadedb/e2e/RemoteDatabaseJavaApiTest.java & JdbcQueriesTest.java Expanded tests to cover backup command behavior via both SQL and SQLScript interfaces.
e2e/src/test/java/com/arcadedb/e2e/ArcadeContainerTemplate.java Updated the container initialization using generics and a more modern formatting style.

Comment thread server/src/main/java/com/arcadedb/server/ArcadeDBServer.java Outdated
Comment thread postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java Outdated
Comment thread engine/src/main/java/com/arcadedb/query/sql/parser/BackupDatabaseStatement.java Outdated
robfrank and others added 6 commits May 9, 2025 04:27
@codacy-production

codacy-production Bot commented May 9, 2025

Copy link
Copy Markdown

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.13% 57.14%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a7bfd27) 69903 44780 64.06%
Head commit (7bd9d55) 69930 (+27) 44885 (+105) 64.19% (+0.13%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2198) 42 24 57.14%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@gramian

gramian commented May 9, 2025

Copy link
Copy Markdown
Collaborator

@robfrank will this affect #2177 ?

It seems such a test could be easily added here https://github.com/ArcadeData/arcadedb/pull/2198/files#diff-d24951ee7936b3abd0aa8458f0fa2e97b6fc7758de35f5f1fda114929eaff7b0 fir sqlscript, right?

@robfrank

robfrank commented May 9, 2025

Copy link
Copy Markdown
Collaborator Author

@gramian added and tested locally, it fails. But I think it is expected to fail

@gramian

gramian commented May 9, 2025

Copy link
Copy Markdown
Collaborator

What is the replications folder for? Is this a thing for HA (see Dockerfile https://github.com/ArcadeData/arcadedb/pull/2198/files#diff-ee5bdd6fd6551ebaddc404ecef351b661fd0c9b8547819d718feb8b6b5729ae6 )? This folder does not appear in the docs.

@robfrank

robfrank commented May 9, 2025

Copy link
Copy Markdown
Collaborator Author

Yes, is for HA, but was missing as the backups one, so I added both

@robfrank
robfrank merged commit 540ecc9 into main May 10, 2025
@robfrank robfrank changed the title feat: implement backup database functionality and add related tests feat:improve backup database functionality via SQL and add related tests May 30, 2025
@robfrank
robfrank deleted the fix/2116-backup-database branch June 20, 2025 07:44
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants