|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# |
| 3 | +# Copyright (C) 2025 VyOS maintainers and contributors |
| 4 | +# |
| 5 | +# This program is free software; you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License version 2 or later as |
| 7 | +# published by the Free Software Foundation. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +# |
| 17 | +# |
| 18 | +# This script is used to test execution of the commit algorithm by vyos-commitd |
| 19 | + |
| 20 | +from pathlib import Path |
| 21 | +from argparse import ArgumentParser |
| 22 | +from datetime import datetime |
| 23 | + |
| 24 | +from vyos.configtree import ConfigTree |
| 25 | +from vyos.configtree import test_commit |
| 26 | + |
| 27 | + |
| 28 | +parser = ArgumentParser( |
| 29 | + description='Execute commit priority queue' |
| 30 | +) |
| 31 | +parser.add_argument( |
| 32 | + '--active-config', help='Path to the active configuration file', required=True |
| 33 | +) |
| 34 | +parser.add_argument( |
| 35 | + '--proposed-config', help='Path to the proposed configuration file', required=True |
| 36 | +) |
| 37 | +args = parser.parse_args() |
| 38 | + |
| 39 | +active_arg = args.active_config |
| 40 | +proposed_arg = args.proposed_config |
| 41 | + |
| 42 | +active = ConfigTree(Path(active_arg).read_text()) |
| 43 | +proposed = ConfigTree(Path(proposed_arg).read_text()) |
| 44 | + |
| 45 | + |
| 46 | +time_begin_commit = datetime.now() |
| 47 | +test_commit(active, proposed) |
| 48 | +time_end_commit = datetime.now() |
| 49 | +print(f'commit time: {time_end_commit - time_begin_commit}') |
0 commit comments