summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/integration_tests/modules/test_combined.py20
-rw-r--r--tests/integration_tests/modules/test_runcmd.py25
2 files changed, 20 insertions, 25 deletions
diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py
index 97b59558..27f3c074 100644
--- a/tests/integration_tests/modules/test_combined.py
+++ b/tests/integration_tests/modules/test_combined.py
@@ -15,6 +15,7 @@ from tests.integration_tests.instances import IntegrationInstance
from tests.integration_tests.util import verify_ordered_items_in_text
USER_DATA = """\
+## template: jinja
#cloud-config
apt:
primary:
@@ -31,6 +32,9 @@ locale: en_GB.UTF-8
locale_configfile: /etc/default/locale
ntp:
servers: ['ntp.ubuntu.com']
+runcmd:
+ - echo {{ds.meta_data.local_hostname}} > /var/tmp/runcmd_output
+ - echo {{merged_cfg.def_log_file}} >> /var/tmp/runcmd_output
"""
@@ -92,6 +96,22 @@ class TestCombined:
'en_US.UTF-8'
], locale_gen)
+ def test_runcmd_with_variable_substitution(
+ self, class_client: IntegrationInstance
+ ):
+ """Test runcmd, while including jinja substitution.
+
+ Ensure we can also substitue variables from instance-data-sensitive
+ LP: #1931392
+ """
+ client = class_client
+ expected = [
+ client.execute('hostname').stdout.strip(),
+ '/var/log/cloud-init.log',
+ ]
+ output = client.read_from_file('/var/tmp/runcmd_output')
+ verify_ordered_items_in_text(expected, output)
+
def test_no_problems(self, class_client: IntegrationInstance):
"""Test no errors, warnings, or tracebacks"""
client = class_client
diff --git a/tests/integration_tests/modules/test_runcmd.py b/tests/integration_tests/modules/test_runcmd.py
deleted file mode 100644
index 50d1851e..00000000
--- a/tests/integration_tests/modules/test_runcmd.py
+++ /dev/null
@@ -1,25 +0,0 @@
-"""Integration test for the runcmd module.
-
-This test specifies a command to be executed by the ``runcmd`` module
-and then checks if that command was executed during boot.
-
-(This is ported from
-``tests/cloud_tests/testcases/modules/runcmd.yaml``.)"""
-
-import pytest
-
-
-USER_DATA = """\
-#cloud-config
-runcmd:
- - echo cloud-init run cmd test > /var/tmp/run_cmd
-"""
-
-
-@pytest.mark.ci
-class TestRuncmd:
-
- @pytest.mark.user_data(USER_DATA)
- def test_runcmd(self, client):
- runcmd_output = client.read_from_file("/var/tmp/run_cmd")
- assert runcmd_output.strip() == "cloud-init run cmd test"