diff mbox series

[19/22] Acceptance Tests: add port redirection for ssh by default

Message ID 20210203172357.1422425-20-crosa@redhat.com (mailing list archive)
State New, archived
Headers show
Series Acceptance Test: introduce base class for Linux based tests | expand

Commit Message

Cleber Rosa Feb. 3, 2021, 5:23 p.m. UTC
For users of the LinuxTest class, let's set up the VM with the port
redirection for SSH, instead of requiring each test to set the same
arguments.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 2 ++
 tests/acceptance/virtiofs_submounts.py    | 4 ----
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Philippe Mathieu-Daudé Feb. 3, 2021, 5:46 p.m. UTC | #1
On 2/3/21 6:23 PM, Cleber Rosa wrote:
> For users of the LinuxTest class, let's set up the VM with the port
> redirection for SSH, instead of requiring each test to set the same
> arguments.
> 
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>  tests/acceptance/avocado_qemu/__init__.py | 2 ++
>  tests/acceptance/virtiofs_submounts.py    | 4 ----
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index 5f4dd6b9ec..89669cc604 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -301,6 +301,8 @@ class LinuxTest(Test, LinuxSSHMixIn):
>          super(LinuxTest, self).setUp()
>          self.vm.add_args('-smp', '2')
>          self.vm.add_args('-m', '1024')
> +        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
> +                         '-device', 'virtio-net,netdev=vnet')

You need a machine with a virtio-bus to be able to plug a virtio device,
not all provide one.
Philippe Mathieu-Daudé Feb. 3, 2021, 5:51 p.m. UTC | #2
On 2/3/21 6:46 PM, Philippe Mathieu-Daudé wrote:
> On 2/3/21 6:23 PM, Cleber Rosa wrote:
>> For users of the LinuxTest class, let's set up the VM with the port
>> redirection for SSH, instead of requiring each test to set the same
>> arguments.
>>
>> Signed-off-by: Cleber Rosa <crosa@redhat.com>
>> ---
>>  tests/acceptance/avocado_qemu/__init__.py | 2 ++
>>  tests/acceptance/virtiofs_submounts.py    | 4 ----
>>  2 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
>> index 5f4dd6b9ec..89669cc604 100644
>> --- a/tests/acceptance/avocado_qemu/__init__.py
>> +++ b/tests/acceptance/avocado_qemu/__init__.py
>> @@ -301,6 +301,8 @@ class LinuxTest(Test, LinuxSSHMixIn):
>>          super(LinuxTest, self).setUp()
>>          self.vm.add_args('-smp', '2')
>>          self.vm.add_args('-m', '1024')
>> +        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
>> +                         '-device', 'virtio-net,netdev=vnet')
> 
> You need a machine with a virtio-bus to be able to plug a virtio device,
> not all provide one.

Alternatively you could provide a network_device_type argument to
setUp() which has to be explicitly set (since the tests would be
pointless without network access).
Cleber Rosa March 23, 2021, 5:56 p.m. UTC | #3
On Wed, Feb 03, 2021 at 06:51:42PM +0100, Philippe Mathieu-Daudé wrote:
> On 2/3/21 6:46 PM, Philippe Mathieu-Daudé wrote:
> > On 2/3/21 6:23 PM, Cleber Rosa wrote:
> >> For users of the LinuxTest class, let's set up the VM with the port
> >> redirection for SSH, instead of requiring each test to set the same
> >> arguments.
> >>
> >> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> >> ---
> >>  tests/acceptance/avocado_qemu/__init__.py | 2 ++
> >>  tests/acceptance/virtiofs_submounts.py    | 4 ----
> >>  2 files changed, 2 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> >> index 5f4dd6b9ec..89669cc604 100644
> >> --- a/tests/acceptance/avocado_qemu/__init__.py
> >> +++ b/tests/acceptance/avocado_qemu/__init__.py
> >> @@ -301,6 +301,8 @@ class LinuxTest(Test, LinuxSSHMixIn):
> >>          super(LinuxTest, self).setUp()
> >>          self.vm.add_args('-smp', '2')
> >>          self.vm.add_args('-m', '1024')
> >> +        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
> >> +                         '-device', 'virtio-net,netdev=vnet')
> > 
> > You need a machine with a virtio-bus to be able to plug a virtio device,
> > not all provide one.
>

Very true.

> Alternatively you could provide a network_device_type argument to
> setUp() which has to be explicitly set (since the tests would be
> pointless without network access).
>

Sure, I'll add the capability to configure the device type on v2.

Thanks!
- Cleber.
diff mbox series

Patch

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 5f4dd6b9ec..89669cc604 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -301,6 +301,8 @@  class LinuxTest(Test, LinuxSSHMixIn):
         super(LinuxTest, self).setUp()
         self.vm.add_args('-smp', '2')
         self.vm.add_args('-m', '1024')
+        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
+                         '-device', 'virtio-net,netdev=vnet')
         self.set_up_boot()
         if ssh_pubkey is None:
             ssh_pubkey, self.ssh_key = self.set_up_existing_ssh_keys()
diff --git a/tests/acceptance/virtiofs_submounts.py b/tests/acceptance/virtiofs_submounts.py
index 0298807e5c..94b59edd6d 100644
--- a/tests/acceptance/virtiofs_submounts.py
+++ b/tests/acceptance/virtiofs_submounts.py
@@ -195,10 +195,6 @@  class VirtiofsSubmountsTest(LinuxTest):
             self.vm.add_args('-kernel', vmlinuz,
                              '-append', 'console=ttyS0 root=/dev/sda1')
 
-        # Allow us to connect to SSH
-        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
-                         '-device', 'virtio-net,netdev=vnet')
-
         self.require_accelerator("kvm")
         self.vm.add_args('-accel', 'kvm')