Commit c7ae7e84 authored by Jérome Perrin's avatar Jérome Perrin

software/caddy-frontend/test: repair test

"bin/pythonwitheggs" no longer exist
parent 63679664
Pipeline #9038 failed with stage
in 0 seconds
...@@ -237,9 +237,22 @@ def getQUIC(url, ip, port): ...@@ -237,9 +237,22 @@ def getQUIC(url, ip, port):
def getPluginParameterDict(software_path, filepath): def getPluginParameterDict(software_path, filepath):
"""Load the slapos monitor plugin and returns the configuration used by this plugin.
This allow to check that monitoring plugin are using a proper config.
"""
# This is implemented by creating a wrapper script that loads the plugin wrapper
# script and returns its `extra_config_dict`. This might have to be adjusted if
# internals of slapos promise plugins change.
bin_file = os.path.join(software_path, 'bin', 'test-plugin-promise') bin_file = os.path.join(software_path, 'bin', 'test-plugin-promise')
monitor_python_with_eggs = os.path.join(software_path, 'bin', 'monitor-pythonwitheggs')
if not os.path.exists(monitor_python_with_eggs):
raise ValueError("Monitoring stack's python does not exist at %s" % monitor_python_with_eggs)
with open(bin_file, 'w') as f: with open(bin_file, 'w') as f:
f.write("""#!%s/bin/pythonwitheggs f.write("""#!%s
import os import os
import importlib import importlib
import sys import sys
...@@ -251,9 +264,9 @@ filename = os.path.basename(filepath) ...@@ -251,9 +264,9 @@ filename = os.path.basename(filepath)
module = importlib.import_module(os.path.splitext(filename)[0]) module = importlib.import_module(os.path.splitext(filename)[0])
print json.dumps(module.extra_config_dict) print json.dumps(module.extra_config_dict)
""" % software_path) """ % monitor_python_with_eggs)
os.chmod(bin_file, 0755) os.chmod(bin_file, 0o755)
result = subprocess_output([bin_file, filepath]).strip() result = subprocess_output([bin_file, filepath]).strip()
try: try:
return json.loads(result) return json.loads(result)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment