mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-13 16:54:37 +02:00
enh(tests): make install_plugins function more robust for debian inst… (#5031)
Co-authored-by: omercier <omercier@centreon.com>
This commit is contained in:
parent
c942796acd
commit
1cdf992c47
25
.github/scripts/test-all-plugins.py
vendored
25
.github/scripts/test-all-plugins.py
vendored
@ -51,13 +51,26 @@ def launch_snmp_sim():
|
|||||||
snmpsim_cmd = "snmpsim-command-responder --logging-method=null --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp --data-dir='./tests/robot' &"
|
snmpsim_cmd = "snmpsim-command-responder --logging-method=null --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp --data-dir='./tests/robot' &"
|
||||||
try_command(cmd=snmpsim_cmd, error="can't launch snmp sim daemon.")
|
try_command(cmd=snmpsim_cmd, error="can't launch snmp sim daemon.")
|
||||||
|
|
||||||
|
def refresh_packet_manager(archi):
|
||||||
|
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
||||||
|
if archi == "deb":
|
||||||
|
outfile.write("apt-get update\n")
|
||||||
|
output_status = (subprocess.run(
|
||||||
|
"apt-get update",
|
||||||
|
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||||
|
elif archi == "rpm":
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
|
||||||
|
exit(1)
|
||||||
|
return output_status
|
||||||
|
|
||||||
def install_plugin(plugin, archi):
|
def install_plugin(plugin, archi):
|
||||||
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
||||||
if archi == "deb":
|
if archi == "deb":
|
||||||
outfile.write("apt install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb\n")
|
outfile.write("apt-get install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb\n")
|
||||||
output_status = (subprocess.run(
|
output_status = (subprocess.run(
|
||||||
"apt install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb",
|
"apt-get install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb",
|
||||||
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||||
elif archi == "rpm":
|
elif archi == "rpm":
|
||||||
outfile.write("dnf install -y ./" + plugin + "*.rpm\n")
|
outfile.write("dnf install -y ./" + plugin + "*.rpm\n")
|
||||||
@ -72,9 +85,9 @@ def install_plugin(plugin, archi):
|
|||||||
def remove_plugin(plugin, archi):
|
def remove_plugin(plugin, archi):
|
||||||
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
||||||
if archi == "deb":
|
if archi == "deb":
|
||||||
outfile.write("apt -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower() + "\n")
|
outfile.write("apt-get -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower() + "\n")
|
||||||
output_status = (subprocess.run(
|
output_status = (subprocess.run(
|
||||||
"apt -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower(),
|
"apt-get -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower(),
|
||||||
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||||
# -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' is an option to force apt to keep the package in
|
# -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' is an option to force apt to keep the package in
|
||||||
# /var/cache/apt/archives, so it do not re download them for every installation.
|
# /var/cache/apt/archives, so it do not re download them for every installation.
|
||||||
@ -106,6 +119,10 @@ if __name__ == '__main__':
|
|||||||
error_purge = 0
|
error_purge = 0
|
||||||
nb_plugins = 0
|
nb_plugins = 0
|
||||||
list_plugin_error = []
|
list_plugin_error = []
|
||||||
|
|
||||||
|
# call apt update (or maybe dnf clean all if needed)
|
||||||
|
refresh_packet_manager(archi)
|
||||||
|
|
||||||
for plugin in sys.argv:
|
for plugin in sys.argv:
|
||||||
print("plugin : ", plugin)
|
print("plugin : ", plugin)
|
||||||
nb_plugins += 1
|
nb_plugins += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user