From f7976e3ccce2f57e9a542b7030247d19ee618252 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 29 Jan 2022 22:54:29 +0100 Subject: [PATCH] tests: Add test `test_exec_inside_application_pod_finds_mounted_file` --- test/test_transports_kubernetes_transports.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_transports_kubernetes_transports.py b/test/test_transports_kubernetes_transports.py index 3e51fa5..1017a3d 100644 --- a/test/test_transports_kubernetes_transports.py +++ b/test/test_transports_kubernetes_transports.py @@ -52,6 +52,27 @@ def test_backup_side_pod_operates_on_same_volumes_as_original_application(self, self.assertTrue(run_transport(definition, transport)) self.assertIn("I have never read Marx Capital, but I have the marks of capital all over me.", io.get_value()) + @patch('bahub.transports.kubernetes_podexec.create_backup_maker_command') + def test_exec_inside_application_pod_finds_mounted_file(self, create_backup_maker_command): + """ + We do a `kubectl exec` into a running POD and execute a command, grab result + """ + + io = BufferedSystemIO() + io.set_log_level('debug') + transport = PodExecTransport( + spec={ + 'selector': "app=nginx", # see: test/env/kubernetes/nginx + 'namespace': 'default', + }, + io=io + ) + definition = create_example_fs_definition(transport) + + create_backup_maker_command.return_value = ["cat", "/var/www/msg.html"] + self.assertTrue(run_transport(definition, transport)) + self.assertIn("I have never read Marx Capital, but I have the marks of capital all over me.", io.get_value()) + @classmethod def setUpClass(cls) -> None: super(TestKubernetesTransport, cls).setUpClass()