File: test_cloud_config_archive.py

package info (click to toggle)
cloud-init 25.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,412 kB
  • sloc: python: 135,894; sh: 3,883; makefile: 141; javascript: 30; xml: 22
file content (31 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pytest

from tests.integration_tests.instances import IntegrationInstance
from tests.integration_tests.util import verify_clean_boot, verify_clean_log

USER_DATA = """\
#cloud-config-archive
- type: "text/cloud-boothook"
  content: |
    #!/bin/sh
    echo "this is from a boothook." > /var/tmp/boothook.txt
- type: "text/cloud-config"
  content: |
    bootcmd:
    - echo "this is from a cloud-config." > /var/tmp/bootcmd.txt
"""


@pytest.mark.ci
@pytest.mark.user_data(USER_DATA)
def test_cloud_config_archive(client: IntegrationInstance):
    """Basic correctness test for #cloud-config-archive."""
    log = client.read_from_file("/var/log/cloud-init.log")
    assert "this is from a boothook." in client.read_from_file(
        "/var/tmp/boothook.txt"
    )
    assert "this is from a cloud-config." in client.read_from_file(
        "/var/tmp/bootcmd.txt"
    )
    verify_clean_log(log)
    verify_clean_boot(client)