summaryrefslogtreecommitdiff
path: root/src/helpers/test_commit.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2025-03-18 15:48:30 +0000
committerGitHub <noreply@github.com>2025-03-18 15:48:30 +0000
commit78a3ba7039e8ad9be8ca1960ecc5dac9a985fb0e (patch)
tree2fdef8540f26e4e03dbea232a09a26360fd7ada7 /src/helpers/test_commit.py
parent62ebdb827b1b3097b345aae0cf13b636ca055537 (diff)
parentd8a6295a13a6eb8faf127639ae15fa76608e7351 (diff)
downloadvyos-1x-78a3ba7039e8ad9be8ca1960ecc5dac9a985fb0e.tar.gz
vyos-1x-78a3ba7039e8ad9be8ca1960ecc5dac9a985fb0e.zip
Merge pull request #4398 from jestabro/commitd
T7121: Set up communication vyconfd to vyos-commitd
Diffstat (limited to 'src/helpers/test_commit.py')
-rwxr-xr-xsrc/helpers/test_commit.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/helpers/test_commit.py b/src/helpers/test_commit.py
new file mode 100755
index 000000000..00a413687
--- /dev/null
+++ b/src/helpers/test_commit.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2025 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#
+# This script is used to test execution of the commit algorithm by vyos-commitd
+
+from pathlib import Path
+from argparse import ArgumentParser
+from datetime import datetime
+
+from vyos.configtree import ConfigTree
+from vyos.configtree import test_commit
+
+
+parser = ArgumentParser(
+ description='Execute commit priority queue'
+)
+parser.add_argument(
+ '--active-config', help='Path to the active configuration file', required=True
+)
+parser.add_argument(
+ '--proposed-config', help='Path to the proposed configuration file', required=True
+)
+args = parser.parse_args()
+
+active_arg = args.active_config
+proposed_arg = args.proposed_config
+
+active = ConfigTree(Path(active_arg).read_text())
+proposed = ConfigTree(Path(proposed_arg).read_text())
+
+
+time_begin_commit = datetime.now()
+test_commit(active, proposed)
+time_end_commit = datetime.now()
+print(f'commit time: {time_end_commit - time_begin_commit}')