Пример #1
0
def test_serial_console_login(test_microvm_with_api):
    """
    Test serial console login.

    @type: functional
    """
    microvm = test_microvm_with_api
    microvm.jailer.daemonize = False
    microvm.spawn()

    # We don't need to monitor the memory for this test because we are
    # just rebooting and the process dies before pmap gets the RSS.
    microvm.memory_monitor = None

    # Set up the microVM with 1 vCPU and a serial console.
    microvm.basic_config(vcpu_count=1,
                         boot_args='console=ttyS0 reboot=k panic=1 pci=off')

    microvm.start()

    serial = Serial(microvm)
    serial.open()
    current_state = WaitTerminal("ubuntu-fc-uvm:")

    while not isinstance(current_state, TestFinished):
        output_char = serial.rx_char()
        current_state = current_state.handle_input(serial, output_char)
Пример #2
0
def test_serial_console_login(test_microvm_with_ssh):
    """Test serial console login."""
    microvm = test_microvm_with_ssh
    microvm.jailer.daemonize = False
    microvm.spawn()

    # We don't need to monitor the memory for this test because we are
    # just rebooting and the process dies before pmap gets the RSS.
    microvm.memory_events_queue = None

    # Set up the microVM with 1 vCPU and a serial console.
    microvm.basic_config(vcpu_count=1,
                         boot_args='console=ttyS0 reboot=k panic=1 pci=off')

    microvm.start()

    serial = Serial(microvm)
    serial.open()

    # Set initial state - wait for 'login:' prompt
    current_state = WaitLogin("login:")

    while not isinstance(current_state, TestFinished):
        output_char = serial.rx_char()
        current_state = current_state.handle_input(
            serial, output_char)
def test_init_params(test_microvm_with_api):
    """Correct propagation of boot args to the kernel's command line.

    Test that init's parameters (the ones present after "--") do not get
    altered or misplaced.

    @type: negative
    """
    vm = test_microvm_with_api
    vm.jailer.daemonize = False
    vm.spawn()
    vm.memory_monitor = None

    # We will override the init with /bin/cat so that we try to read the
    # Ubuntu version from the /etc/issue file.
    vm.basic_config(
        vcpu_count=1,
        boot_args="console=ttyS0 reboot=k panic=1 pci=off"
        " init=/bin/cat -- /etc/issue",
    )

    vm.start()
    serial = Serial(vm)
    serial.open()
    # If the string does not show up, the test will fail.
    serial.rx(token="Ubuntu 18.04.5 LTS")
Пример #4
0
def test_serial_after_snapshot(bin_cloner_path):
    """
    Serial I/O after restoring from a snapshot.

    @type: functional
    """
    vm_builder = MicrovmBuilder(bin_cloner_path)
    vm_instance = vm_builder.build_vm_nano(
        diff_snapshots=False,
        daemonize=False,
    )
    microvm = vm_instance.vm
    root_disk = vm_instance.disks[0]
    ssh_key = vm_instance.ssh_key

    microvm.start()
    serial = Serial(microvm)
    serial.open()
    # Image used for tests on aarch64 has autologon
    if platform.machine() == "x86_64":
        serial.rx(token='login: ')
        serial.tx("root")
        serial.rx("Password: "******"root")

    snapshot_builder = SnapshotBuilder(microvm)
    disks = [root_disk.local_path()]
    # Create diff snapshot.
    snapshot = snapshot_builder.create(disks,
                                       ssh_key,
                                       SnapshotType.FULL)
    # Kill base microVM.
    microvm.kill()

    # Load microVM clone from snapshot.
    test_microvm, _ = vm_builder.build_from_snapshot(snapshot,
                                                     resume=True,
                                                     diff_snapshots=False,
                                                     daemonize=False)
    serial = Serial(test_microvm)
    serial.open()
    serial.rx("#")
    serial.tx("pwd")
    res = serial.rx("#")
    assert "/root" in res
Пример #5
0
def test_microvm_initrd_with_serial(
        test_microvm_with_initrd):
    """Check microvm started with an inird has / mounted as rootfs."""
    vm = test_microvm_with_initrd
    vm.jailer.daemonize = False
    vm.spawn()
    vm.memory_monitor = None

    vm.basic_config(
        add_root_device=False,
        vcpu_count=1,
        boot_args='console=ttyS0 reboot=k panic=1 pci=off',
        use_initrd=True
    )

    vm.start()
    serial = Serial(vm)
    serial.open()
    serial.rx(token='login: '******'Password: '******'# ')

    serial.tx("findmnt /")
    serial.rx(
        token=f"/      {INITRD_FILESYSTEM} {INITRD_FILESYSTEM}")
Пример #6
0
def test_microvm_initrd_with_serial(test_microvm_with_initrd):
    """
    Test that a boot using initrd successfully loads the root filesystem.

    @type: functional
    """
    vm = test_microvm_with_initrd
    vm.jailer.daemonize = False
    vm.spawn()
    vm.memory_monitor = None

    vm.basic_config(add_root_device=False,
                    vcpu_count=1,
                    boot_args='console=ttyS0 reboot=k panic=1 pci=off',
                    use_initrd=True)

    vm.start()
    serial = Serial(vm)
    serial.open()
    serial.rx(token='login: '******'Password: '******'# ')

    serial.tx("findmnt /")
    serial.rx(token=f"/      {INITRD_FILESYSTEM} {INITRD_FILESYSTEM}")