pytest-dev / pytest-testinfra

Testinfra test your infrastructures
https://testinfra.readthedocs.io
Apache License 2.0
2.37k stars 355 forks source link

Some commands require further input after sending remote commands. #780

Open chengxiang1997 opened 1 week ago

chengxiang1997 commented 1 week ago

Some commands require further input after sending remote commands. What can I do if I'm using TestInfra? For example, when I input mkfs.ext4 /dev/sdb, it prompts the following content:

[root@localhost ~]# mkfs.ext4 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n)

If I want to further input y through a Python script, how can I do that?"

narmaku commented 1 week ago

This is not an issue with this project itself, but with the fact that you are trying to run a command that requires interaction with the end user to confirm next steps.

This is a common situation when you try to run commands remotely (such as pytest-testinfra does) since they use non-interactive shell (as everything is run programmatically).

To solve this, you may need to explore ways to force the command to be executed without asking you for confirmation. E.g. some commands provide the -y option to auto-approve operations.

You may consult the man page of mkfs to see which option suites your needs: https://linux.die.net/man/8/mkfs.ext4 (maybe the -F opt)