mirror of
https://github.com/krkn-chaos/krkn.git
synced 2026-08-25 09:27:36 +00:00
Core Refactoring, Krkn Scenario Plugin API (#694)
* relocated shared libraries from `kraken` to `krkn` folder Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * AbstractScenarioPlugin and ScenarioPluginFactory Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * application_outage porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * arcaflow_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * managedcluster_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * network_chaos porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * node_actions porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * plugin_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * pvc_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * service_disruption porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * service_hijacking porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * cluster_shut_down_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * syn_flood porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * time_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * zone_outages porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * ScenarioPluginFactory tests Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * unit tests update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * pod_scenarios and post actions deprecated Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> scenarios post_actions Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * funtests and config update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * run_krkn.py update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * utils porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * API Documentation Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * container_scenarios porting Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> fix Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * funtest fix Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * document gif update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * Documentation + tests update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * removed example plugin Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * global renaming Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> test fix Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> test fix Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * config.yaml typos Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> typos Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * removed `plugin_scenarios` from NativScenarioPlugin class Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * pod_network_scenarios type added Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * documentation update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> * krkn-lib update Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> typo Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> --------- Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com>
This commit is contained in:
@@ -1,28 +1,37 @@
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from kraken.plugins import run_python_file
|
||||
from kraken.plugins.run_python_plugin import RunPythonFileInput
|
||||
from krkn.scenario_plugins.native.run_python_plugin import (
|
||||
RunPythonFileInput,
|
||||
run_python_file,
|
||||
)
|
||||
|
||||
|
||||
class RunPythonPluginTest(unittest.TestCase):
|
||||
def test_success_execution(self):
|
||||
tmp_file = tempfile.NamedTemporaryFile()
|
||||
tmp_file.write(bytes("print('Hello world!')", 'utf-8'))
|
||||
tmp_file.write(bytes("print('Hello world!')", "utf-8"))
|
||||
tmp_file.flush()
|
||||
output_id, output_data = run_python_file(params=RunPythonFileInput(tmp_file.name), run_id="test-python-plugin-success")
|
||||
output_id, output_data = run_python_file(
|
||||
params=RunPythonFileInput(tmp_file.name),
|
||||
run_id="test-python-plugin-success",
|
||||
)
|
||||
self.assertEqual("success", output_id)
|
||||
self.assertEqual("Hello world!\n", output_data.stdout)
|
||||
|
||||
def test_error_execution(self):
|
||||
tmp_file = tempfile.NamedTemporaryFile()
|
||||
tmp_file.write(bytes("import sys\nprint('Hello world!')\nsys.exit(42)\n", 'utf-8'))
|
||||
tmp_file.write(
|
||||
bytes("import sys\nprint('Hello world!')\nsys.exit(42)\n", "utf-8")
|
||||
)
|
||||
tmp_file.flush()
|
||||
output_id, output_data = run_python_file(params=RunPythonFileInput(tmp_file.name), run_id="test-python-plugin-error")
|
||||
output_id, output_data = run_python_file(
|
||||
params=RunPythonFileInput(tmp_file.name), run_id="test-python-plugin-error"
|
||||
)
|
||||
self.assertEqual("error", output_id)
|
||||
self.assertEqual(42, output_data.exit_code)
|
||||
self.assertEqual("Hello world!\n", output_data.stdout)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user