-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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,44 @@ | ||
#!/usr/bin/env python | ||
# flake8: noqa: E402 | ||
import argparse | ||
import logging | ||
import sys | ||
|
||
from pathlib import Path | ||
|
||
from irrd.storage.preload import send_reload_signal | ||
|
||
""" | ||
Load an RPSL file into the database. | ||
""" | ||
|
||
logger = logging.getLogger(__name__) | ||
sys.path.append(str(Path(__file__).resolve().parents[2])) | ||
|
||
from irrd.conf import config_init, CONFIG_PATH_DEFAULT | ||
from irrd.storage.database_handler import DatabaseHandler | ||
|
||
|
||
def set_force_reload(source) -> None: | ||
dh = DatabaseHandler(enable_preload_update=False) | ||
dh.set_force_reload(source) | ||
dh.commit() | ||
dh.close() | ||
|
||
|
||
def main(): # pragma: no cover | ||
description = """Force a full reload for a mirror.""" | ||
parser = argparse.ArgumentParser(description=description) | ||
parser.add_argument('--config', dest='config_file_path', type=str, | ||
help=f'use a different IRRd config file (default: {CONFIG_PATH_DEFAULT})') | ||
parser.add_argument('source', type=str, | ||
help='the name of the source to reload') | ||
args = parser.parse_args() | ||
|
||
config_init(args.config_file_path) | ||
|
||
set_force_reload(args.source) | ||
|
||
|
||
if __name__ == '__main__': # pragma: no cover | ||
main() |
This file contains 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,18 @@ | ||
from unittest.mock import Mock | ||
|
||
from irrd.utils.test_utils import flatten_mock_calls | ||
from ..mirror_force_reload import set_force_reload | ||
|
||
|
||
def test_set_force_reload(capsys, monkeypatch): | ||
mock_dh = Mock() | ||
monkeypatch.setattr('irrd.scripts.mirror_force_reload.DatabaseHandler', | ||
lambda enable_preload_update: mock_dh) | ||
|
||
set_force_reload('TEST') | ||
assert flatten_mock_calls(mock_dh) == [ | ||
['set_force_reload', ('TEST', ), {}], | ||
['commit', (), {}], | ||
['close', (), {}] | ||
] | ||
assert not capsys.readouterr().out |
This file contains 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 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 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