-
Notifications
You must be signed in to change notification settings - Fork 164
Integration Tests for Borg #1716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
23ccbde
Initial nox configuration file
jetchirag 70a9db9
Formatting
jetchirag 2a46274
Added several tests for test_archives
jetchirag 6cd2658
added more tests to archives tests
jetchirag 077f993
Archive more supported file types
jetchirag 5b3b6c6
Revert "Archive more supported file types"
jetchirag e243f68
Archive more supported file types
jetchirag 14cab4a
Added test for creating / adding repo
jetchirag 05ecaf2
Push changes for conftest.py
jetchirag 0ca5613
Added tests for borg info
jetchirag c6418e8
Test configuration improvements and bug fixes
jetchirag a68cb65
conftest.py cleanup
jetchirag e456f10
Test for creating new archive
jetchirag 6c769e8
Merge branch 'master' into borg-live-tests
jetchirag 854ee60
Fixed prune test
jetchirag 72215dc
Group common fixtures of conftest.py
jetchirag ce94213
Added nox to dev requirements and adjusted Makefile for nox and unit/…
jetchirag 9067939
Added docstrings to test_archive.py
jetchirag d19b834
Added coverage to pytests
jetchirag bb7c2f6
Added all supported versions to nox
jetchirag a9c3da3
Changed GH action flow to install all required py versions
jetchirag 7f8d1a3
Completed borg diff testing
jetchirag 56827da
Removed unnecessary code from diff test
jetchirag 3e4a462
Added a min borg version fixture
jetchirag d12dd08
Added libfuse3-dev to linux requirement for fuse3
jetchirag 725b6b0
Added various compatibility check for platform and borg versions
jetchirag 9a0c1c9
GH CI temp speedup
jetchirag ce33f9e
Solve borg_json_output not found error on archive rename test
jetchirag 4a6c778
Fixed test_borg_repo_info error with invalid repo path
jetchirag db5d6bb
Macos does not use tmp for tmpdir, fix
jetchirag 6ecdec4
Require pkgconfig to install borg 1.2.0 and above using pip
jetchirag da05507
pkg-config -> pkgconfig
jetchirag a1c7190
tmpdir appends integer to generate unique directory for diff tests ru…
jetchirag 914a35a
Always install pre-commit
jetchirag 79d247e
Install libxxhash-dev for linux
jetchirag 9a19d90
Set PKG_CONFIG_PATH for macos
jetchirag ec87104
Remove python parameterization from nox
jetchirag 282c119
Trial | Restore nox python parameterization with increased timeout
jetchirag 1bc222a
Borg 2 have compact message case change
jetchirag 83695fd
Added docstrings to tests
jetchirag ede422c
Added docstrings to tests_2
jetchirag 86da9e9
Added pkg config path to env for macos
jetchirag b95d245
Macos install macfuse
jetchirag 101c709
Attempt at installing borg via github test
jetchirag 6e1c70c
Nox config to use env specified borg version when set
jetchirag 23ce04c
Skip borg mount test on macos (atleast for now)
jetchirag cd77362
Merge branch 'master' into borg-live-tests
jetchirag 1db9d4b
Cleanup | remove main.show() statements
jetchirag cf0dfaa
Run unit test seperately
jetchirag 770ecbf
Unit job as include
jetchirag 71f1ef6
Revert unit test config
jetchirag cd02371
Revert "Revert unit test config"
jetchirag 1e484f1
Revert "Unit job as include"
jetchirag ba61d9e
Revert "Run unit test seperately"
jetchirag 94bdc97
Merge remote-tracking branch 'upstream/master' into borg-live-tests
jetchirag 26772e5
Restore unit test job
jetchirag 2c51435
New composite action for installation
jetchirag 1b33e37
Composite action require shell property
jetchirag 48afd4b
Unit tests as another job
jetchirag f1302f4
Fixed breaking of some tests due to introduction of repo name
jetchirag c0ca616
Minor bug fix, incorrect variable used in asssertion
jetchirag 211dec1
Use llfuse for borg 1.1.18, minor GH action changes
jetchirag 4152103
Debug mount error
jetchirag 55c8a84
Debug mount error 2
jetchirag 99a3c11
raise exception if not mounted
jetchirag f64d7d3
Revert exception
jetchirag c8757f2
Minor changes; removed a comment
jetchirag 0cdb4f8
Minor changes; removed a comment
jetchirag 14ce5d4
Merge branch 'master' into borg-live-tests
jetchirag 956eebd
Check for chrdev support
jetchirag 8cc3bc7
Merge branch 'borg-live-tests' of github.com:jetchirag/vorta into bor…
jetchirag 37f91ea
Update to Borg 2.0.0b6
jetchirag ff0f32a
Merge remote-tracking branch 'upstream/master' into borg-live-tests
jetchirag 1b2f272
Merge Master
jetchirag 0532cd9
Switch to new password widget for test_init
jetchirag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Install Dependencies | ||
description: Installs system dependencies | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install system dependencies (Linux) | ||
if: runner.os == 'Linux' | ||
shell: bash | ||
run: | | ||
sudo apt update && sudo apt install -y \ | ||
xvfb libssl-dev openssl libacl1-dev libacl1 fuse3 build-essential \ | ||
libxkbcommon-x11-0 dbus-x11 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \ | ||
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 libxcb-shape0 \ | ||
libegl1 libxcb-cursor0 libfuse-dev libsqlite3-dev libfuse3-dev pkg-config \ | ||
python3-pkgconfig libxxhash-dev borgbackup | ||
|
||
- name: Install system dependencies (macOS) | ||
if: runner.os == 'macOS' | ||
shell: bash | ||
run: | | ||
brew install openssl readline xz xxhash pkg-config borgbackup |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import re | ||
import sys | ||
|
||
import nox | ||
|
||
borg_version = os.getenv("BORG_VERSION") | ||
|
||
if borg_version: | ||
# Use specified borg version | ||
supported_borgbackup_versions = [borg_version] | ||
else: | ||
# Generate a list of borg versions compatible with system installed python version | ||
system_python_version = tuple(sys.version_info[:3]) | ||
|
||
supported_borgbackup_versions = [ | ||
borgbackup | ||
for borgbackup in ("1.1.18", "1.2.2", "1.2.4", "2.0.0b6") | ||
# Python version requirements for borgbackup versions | ||
if (borgbackup == "1.1.18" and system_python_version >= (3, 5, 0)) | ||
or (borgbackup == "1.2.2" and system_python_version >= (3, 8, 0)) | ||
or (borgbackup == "1.2.4" and system_python_version >= (3, 8, 0)) | ||
or (borgbackup == "2.0.0b6" and system_python_version >= (3, 9, 0)) | ||
] | ||
|
||
|
||
@nox.session | ||
@nox.parametrize("borgbackup", supported_borgbackup_versions) | ||
def run_tests(session, borgbackup): | ||
# install borgbackup | ||
if (sys.platform == 'darwin'): | ||
# in macOS there's currently no fuse package which works with borgbackup directly | ||
session.install(f"borgbackup=={borgbackup}") | ||
elif (borgbackup == "1.1.18"): | ||
# borgbackup 1.1.18 doesn't support pyfuse3 | ||
session.install("llfuse") | ||
session.install(f"borgbackup[llfuse]=={borgbackup}") | ||
else: | ||
session.install(f"borgbackup[pyfuse3]=={borgbackup}") | ||
|
||
# install dependencies | ||
session.install("-r", "requirements.d/dev.txt") | ||
session.install("-e", ".") | ||
|
||
# check versions | ||
cli_version = session.run("borg", "--version", silent=True).strip() | ||
cli_version = re.search(r"borg (\S+)", cli_version).group(1) | ||
python_version = session.run("python", "-c", "import borg; print(borg.__version__)", silent=True).strip() | ||
|
||
session.log(f"Borg CLI version: {cli_version}") | ||
session.log(f"Borg Python version: {python_version}") | ||
|
||
assert cli_version == borgbackup | ||
assert python_version == borgbackup | ||
|
||
session.run("pytest", *session.posargs, env={"BORG_VERSION": borgbackup}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ black==22.* | |
coverage | ||
flake8 | ||
macholib | ||
nox | ||
pkgconfig | ||
pre-commit | ||
pyinstaller | ||
pylint | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
import os | ||
import sys | ||
from datetime import datetime as dt | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
import vorta | ||
import vorta.application | ||
import vorta.borg.jobs_manager | ||
from peewee import SqliteDatabase | ||
from vorta.store.models import ( | ||
ArchiveModel, | ||
BackupProfileModel, | ||
EventLogModel, | ||
RepoModel, | ||
RepoPassword, | ||
SchemaVersion, | ||
SettingsModel, | ||
SourceFileModel, | ||
WifiSettingModel, | ||
) | ||
from vorta.views.main_window import MainWindow | ||
|
||
models = [ | ||
RepoModel, | ||
RepoPassword, | ||
BackupProfileModel, | ||
SourceFileModel, | ||
SettingsModel, | ||
ArchiveModel, | ||
WifiSettingModel, | ||
EventLogModel, | ||
SchemaVersion, | ||
] | ||
|
||
|
||
def pytest_configure(config): | ||
|
@@ -55,86 +29,8 @@ def qapp(tmpdir_factory): | |
|
||
from vorta.application import VortaApp | ||
|
||
VortaApp.set_borg_details_action = MagicMock() # Can't use pytest-mock in session scope | ||
VortaApp.scheduler = MagicMock() | ||
|
||
qapp = VortaApp([]) # Only init QApplication once to avoid segfaults while testing. | ||
|
||
yield qapp | ||
mock_db.close() | ||
qapp.quit() | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=True) | ||
def init_db(qapp, qtbot, tmpdir_factory): | ||
tmp_db = tmpdir_factory.mktemp('Vorta').join('settings.sqlite') | ||
mock_db = SqliteDatabase( | ||
str(tmp_db), | ||
pragmas={ | ||
'journal_mode': 'wal', | ||
}, | ||
) | ||
vorta.store.connection.init_db(mock_db) | ||
|
||
default_profile = BackupProfileModel(name='Default') | ||
default_profile.save() | ||
|
||
new_repo = RepoModel(url='[email protected]:repo') | ||
new_repo.encryption = 'none' | ||
new_repo.save() | ||
|
||
default_profile.repo = new_repo.id | ||
default_profile.dont_run_on_metered_networks = False | ||
default_profile.validation_on = False | ||
default_profile.save() | ||
|
||
test_archive = ArchiveModel(snapshot_id='99999', name='test-archive', time=dt(2000, 1, 1, 0, 0), repo=1) | ||
test_archive.save() | ||
|
||
test_archive1 = ArchiveModel(snapshot_id='99998', name='test-archive1', time=dt(2000, 1, 1, 0, 0), repo=1) | ||
test_archive1.save() | ||
|
||
source_dir = SourceFileModel(dir='/tmp/another', repo=new_repo, dir_size=100, dir_files_count=18, path_isdir=True) | ||
source_dir.save() | ||
|
||
qapp.main_window.deleteLater() | ||
del qapp.main_window | ||
qapp.main_window = MainWindow(qapp) # Re-open main window to apply mock data in UI | ||
|
||
yield | ||
|
||
qapp.jobs_manager.cancel_all_jobs() | ||
qapp.backup_finished_event.disconnect() | ||
qapp.scheduler.schedule_changed.disconnect() | ||
qtbot.waitUntil(lambda: not qapp.jobs_manager.is_worker_running(), **pytest._wait_defaults) | ||
mock_db.close() | ||
|
||
|
||
@pytest.fixture | ||
def choose_file_dialog(*args): | ||
class MockFileDialog: | ||
def __init__(self, *args, **kwargs): | ||
pass | ||
|
||
def open(self, func): | ||
func() | ||
|
||
def selectedFiles(self): | ||
return ['/tmp'] | ||
|
||
return MockFileDialog | ||
|
||
|
||
@pytest.fixture | ||
def borg_json_output(): | ||
def _read_json(subcommand): | ||
stdout = open(f'tests/borg_json_output/{subcommand}_stdout.json') | ||
stderr = open(f'tests/borg_json_output/{subcommand}_stderr.json') | ||
return stdout, stderr | ||
|
||
return _read_json | ||
|
||
|
||
@pytest.fixture | ||
def rootdir(): | ||
return os.path.dirname(os.path.abspath(__file__)) |
File renamed without changes.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.