From dd222f3d4cacb10af0cf2608d6142a941f185a4f Mon Sep 17 00:00:00 2001 From: Lluis Campos Date: Mon, 25 Nov 2024 20:30:07 +0100 Subject: [PATCH] test: Install `script` module for the tests that need it and enable them Ticket: QA-817 Signed-off-by: Lluis Campos --- tests/helpers.py | 7 +++++++ tests/tests/test_deployment_retry.py | 5 ++++- tests/tests/test_inventory.py | 9 +++++++-- tests/tests/test_mender_gateway.py | 6 ++++-- tests/tests/test_mtls.py | 5 ++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index 893136a75..e8cd1145e 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -96,3 +96,10 @@ def check_log_is_unauthenticated(device, since=None): Helpers._check_log_for_message( device, "Failed to authorize with the server", since ) + + @staticmethod + def install_community_update_module(device, module): + url = f"https://raw.githubusercontent.com/mendersoftware/mender-update-modules/master/{module}/module/{module}" + device.run("mkdir -p /usr/share/mender/modules/v3") + device.run(f"wget -P /usr/share/mender/modules/v3 {url}") + device.run(f"chmod +x /usr/share/mender/modules/v3/{module}") diff --git a/tests/tests/test_deployment_retry.py b/tests/tests/test_deployment_retry.py index 8edaa8afd..6ae148e8a 100644 --- a/tests/tests/test_deployment_retry.py +++ b/tests/tests/test_deployment_retry.py @@ -21,6 +21,7 @@ from .. import conftest from ..common_setup import enterprise_no_client from ..MenderAPI import logger, Authentication, DeviceAuthV2, Deployments +from ..helpers import Helpers from testutils.infra.cli import CliTenantadm from testutils.common import Tenant, User, new_tenant_client from .common_artifact import get_script_artifact @@ -53,7 +54,6 @@ def make_script_artifact(artifact_name, device_type, output_path): return get_script_artifact(script, artifact_name, device_type, output_path) -@pytest.mark.skip(reason="FIXME: QA-817") @pytest.mark.usefixtures("enterprise_no_client") class TestDeploymentRetryEnterprise(MenderTesting): """Tests the retry deployment functionality""" @@ -100,6 +100,9 @@ def test_deployment_retry_failed_update(self, enterprise_no_client): ) devauth.accept_devices(1) + # Install the script update module required for this test + Helpers.install_community_update_module(device, "script") + with tempfile.NamedTemporaryFile() as tf: artifact = make_script_artifact( diff --git a/tests/tests/test_inventory.py b/tests/tests/test_inventory.py index 036b1997d..d148af58b 100644 --- a/tests/tests/test_inventory.py +++ b/tests/tests/test_inventory.py @@ -23,6 +23,7 @@ enterprise_one_client_bootstrapped, ) from ..MenderAPI import DeviceAuthV2, Deployments, Inventory, logger +from ..helpers import Helpers from .common_artifact import get_script_artifact from .mendertesting import MenderTesting @@ -47,6 +48,9 @@ def do_test_inventory(self, env): deploy = Deployments(env.auth, devauth) inv = Inventory(env.auth) + # Install the script update module required for this test + Helpers.install_community_update_module(env.device, "script") + def deploy_simple_artifact(artifact_name, extra_args): # create a simple artifact (script) which doesn't do anything with tempfile.NamedTemporaryFile() as tf: @@ -227,6 +231,9 @@ def do_test_inventory_update_after_successful_deployment(self, env): mender_device.run(sedcmd) mender_device.run("systemctl restart mender-updated") + # Install the script update module required for this test + Helpers.install_community_update_module(mender_device, "script") + # Get the inventory sent after first boot initial_inv_json = inv.get_devices() assert len(initial_inv_json) > 0 @@ -271,7 +278,6 @@ def deploy_simple_artifact(artifact_name, extra_args): ), "The device has not updated the inventory after the update" -@pytest.mark.skip(reason="FIXME: QA-817") class TestInventoryOpenSource(BaseTestInventory): @MenderTesting.fast def test_inventory(self, standard_setup_one_client_bootstrapped): @@ -286,7 +292,6 @@ def test_inventory_update_after_successful_deployment( ) -@pytest.mark.skip(reason="FIXME: QA-817") class TestInventoryEnterprise(BaseTestInventory): @MenderTesting.fast def test_inventory(self, enterprise_one_client_bootstrapped): diff --git a/tests/tests/test_mender_gateway.py b/tests/tests/test_mender_gateway.py index 8b65eb9c9..374cb72a2 100644 --- a/tests/tests/test_mender_gateway.py +++ b/tests/tests/test_mender_gateway.py @@ -368,6 +368,10 @@ def do_test_deployment_two_devices_parallel_updates_multiple_deployments( devauth = DeviceAuthV2(env.auth) deploy = Deployments(env.auth, devauth) + # Install the script update module required for this test + Helpers.install_community_update_module(mender_device_1, "script") + Helpers.install_community_update_module(mender_device_2, "script") + host_ip = env.get_virtual_network_host_ip() mender_conf = mender_device_1.run("cat /etc/mender/mender.conf") valid_image = valid_image_with_mender_conf(mender_conf) @@ -514,7 +518,6 @@ def test_deployment_two_devices_parallel_updates_one_aborted( valid_image_with_mender_conf, ) - @pytest.mark.skip(reason="FIXME: QA-817") @flaky(max_runs=3) @MenderTesting.fast def test_deployment_two_devices_parallel_updates_multiple_deployments( @@ -619,7 +622,6 @@ def test_deployment_two_devices_parallel_updates_one_aborted( valid_image_with_mender_conf, ) - @pytest.mark.skip(reason="FIXME: QA-817") @flaky(max_runs=3) @MenderTesting.fast def test_deployment_two_devices_parallel_updates_multiple_deployments( diff --git a/tests/tests/test_mtls.py b/tests/tests/test_mtls.py index bfb69215c..d8455e97e 100644 --- a/tests/tests/test_mtls.py +++ b/tests/tests/test_mtls.py @@ -28,6 +28,7 @@ from .. import conftest from ..MenderAPI import reset_mender_api, auth, deploy, devauth, logger +from ..helpers import Helpers from .common_artifact import get_script_artifact from .mendertesting import MenderTesting @@ -85,7 +86,6 @@ def make_script_artifact(artifact_name, device_type, output_path): return get_script_artifact(script, artifact_name, device_type, output_path) -@pytest.mark.skip(reason="FIXME: QA-817") @pytest.mark.skipif( isK8S(), reason="not relevant in a staging or production environment" ) @@ -200,6 +200,9 @@ def common_test_mtls_enterprise( self.hsm_setup(pin, ssl_engine_id, env.device) key_uri = self.hsm_get_key_uri(pin, ssl_engine_id, env.device) + # Install the script update module required for this test + Helpers.install_community_update_module(env.device, "script") + try: # retrieve the original configuration file output = env.device.run("cat /etc/mender/mender.conf")