diff mbox series

[5/7] Acceptance Tests: set machine type

Message ID 20181004151429.7232-6-crosa@redhat.com
State New
Headers show
Series Acceptance Tests: basic architecture support | expand

Commit Message

Cleber Rosa Oct. 4, 2018, 3:14 p.m. UTC
By setting the machine type, even if it's the one that will be picked
based on the arch, it's possible to run the same tests with targets
that require a machine type (in addition to those that don't).

Given that only boot_linux_console.py contains code specific to x86_64
(an explicit reference to the kernel image that will be used) the
other tests can be used to test different targets:

  $ avocado run -p arch=aarch64 --filter-by-tags='-x86_64' -- tests/acceptance/

Eventually, to reduce boiler plate code, the idea is to concentrate
the basic configuration (arch, machine, console) in either another
utility method, or make that happen by default.  This is of course the
subject of a future discussion.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/boot_linux_console.py | 3 ++-
 tests/acceptance/version.py            | 2 ++
 tests/acceptance/vnc.py                | 5 +++++
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Oct. 5, 2018, 3:42 p.m. UTC | #1
On 04/10/2018 17:14, Cleber Rosa wrote:
> By setting the machine type, even if it's the one that will be picked
> based on the arch, it's possible to run the same tests with targets
> that require a machine type (in addition to those that don't).
> 
> Given that only boot_linux_console.py contains code specific to x86_64
> (an explicit reference to the kernel image that will be used) the
> other tests can be used to test different targets:
> 
>   $ avocado run -p arch=aarch64 --filter-by-tags='-x86_64' -- tests/acceptance/
> 
> Eventually, to reduce boiler plate code, the idea is to concentrate
> the basic configuration (arch, machine, console) in either another
> utility method, or make that happen by default.  This is of course the
> subject of a future discussion.
> 
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>  tests/acceptance/boot_linux_console.py | 3 ++-
>  tests/acceptance/version.py            | 2 ++
>  tests/acceptance/vnc.py                | 5 +++++
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index 98324f7591..58032f971c 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -30,7 +30,8 @@ class BootLinuxConsole(Test):
>          kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a'
>          kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>  
> -        self.vm.set_machine('pc')
> +        self.vm.set_arch(self.arch)
> +        self.vm.set_machine()
>          self.vm.set_console()
>          kernel_command_line = 'console=ttyS0'
>          self.vm.add_args('-kernel', kernel_path,
> diff --git a/tests/acceptance/version.py b/tests/acceptance/version.py
> index 13b0a7440d..7a3a20945f 100644
> --- a/tests/acceptance/version.py
> +++ b/tests/acceptance/version.py
> @@ -18,6 +18,8 @@ class Version(Test):
>      :avocado: tags=quick
>      """
>      def test_qmp_human_info_version(self):
> +        self.vm.set_arch(self.arch)
> +        self.vm.set_machine()
>          self.vm.launch()
>          res = self.vm.command('human-monitor-command',
>                                command_line='info version')
> diff --git a/tests/acceptance/vnc.py b/tests/acceptance/vnc.py
> index b1ef9d71b1..4a8a83025f 100644
> --- a/tests/acceptance/vnc.py
> +++ b/tests/acceptance/vnc.py
> @@ -16,6 +16,11 @@ class Vnc(Test):
>      :avocado: enable
>      :avocado: tags=vnc,quick
>      """
> +    def setUp(self):
> +        super(Vnc, self).setUp()
> +        self.vm.set_arch(self.arch)
> +        self.vm.set_machine()
> +
>      def test_no_vnc(self):
>          self.vm.add_args('-nodefaults', '-S')
>          self.vm.launch()
> 

$ uname -m
aarch64
$ avocado --show=app run
--json-variants-load=tests/acceptance/variants/arch.json
tests/acceptance/vnc.py
JOB ID     : 06f38999b7386afbd66023e7c1daee84d7991060
JOB LOG    :
/home/phil/avocado/job-results/job-2018-10-05T15.40-06f3899/job.log
 (01/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;aarch64: PASS (0.34 s)
 (02/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;ppc: PASS (0.31 s)
 (03/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;ppc64: PASS (0.35 s)
 (04/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;s390x: PASS (0.24 s)
 (05/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;x86_64: PASS (0.34 s)
 (06/20)
tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;aarch64: PASS
(0.34 s)
 (07/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;ppc:
PASS (0.27 s)
 (08/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;ppc64:
PASS (0.34 s)
 (09/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;s390x:
PASS (0.24 s)
 (10/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;x86_64:
PASS (0.35 s)
 (11/20)
tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;aarch64:
PASS (0.33 s)
 (12/20)
tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;ppc:
PASS (0.28 s)
 (13/20)
tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;ppc64:
PASS (0.38 s)
 (14/20)
tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;s390x:
PASS (0.26 s)
 (15/20)
tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;x86_64:
PASS (0.35 s)
 (16/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;aarch64:
PASS (0.35 s)
 (17/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;ppc: PASS
(0.28 s)
 (18/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;ppc64:
PASS (0.36 s)
 (19/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;s390x:
PASS (0.26 s)
 (20/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;x86_64:
PASS (0.34 s)
RESULTS    : PASS 20 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0
| CANCEL 0
JOB TIME   : 8.30 s

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Cleber Rosa Oct. 9, 2018, 11:08 p.m. UTC | #2
On 10/5/18 11:42 AM, Philippe Mathieu-Daudé wrote:
> On 04/10/2018 17:14, Cleber Rosa wrote:
>> By setting the machine type, even if it's the one that will be picked
>> based on the arch, it's possible to run the same tests with targets
>> that require a machine type (in addition to those that don't).
>>
>> Given that only boot_linux_console.py contains code specific to x86_64
>> (an explicit reference to the kernel image that will be used) the
>> other tests can be used to test different targets:
>>
>>   $ avocado run -p arch=aarch64 --filter-by-tags='-x86_64' -- tests/acceptance/
>>
>> Eventually, to reduce boiler plate code, the idea is to concentrate
>> the basic configuration (arch, machine, console) in either another
>> utility method, or make that happen by default.  This is of course the
>> subject of a future discussion.
>>
>> Signed-off-by: Cleber Rosa <crosa@redhat.com>
>> ---
>>  tests/acceptance/boot_linux_console.py | 3 ++-
>>  tests/acceptance/version.py            | 2 ++
>>  tests/acceptance/vnc.py                | 5 +++++
>>  3 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>> index 98324f7591..58032f971c 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -30,7 +30,8 @@ class BootLinuxConsole(Test):
>>          kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a'
>>          kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>>  
>> -        self.vm.set_machine('pc')
>> +        self.vm.set_arch(self.arch)
>> +        self.vm.set_machine()
>>          self.vm.set_console()
>>          kernel_command_line = 'console=ttyS0'
>>          self.vm.add_args('-kernel', kernel_path,
>> diff --git a/tests/acceptance/version.py b/tests/acceptance/version.py
>> index 13b0a7440d..7a3a20945f 100644
>> --- a/tests/acceptance/version.py
>> +++ b/tests/acceptance/version.py
>> @@ -18,6 +18,8 @@ class Version(Test):
>>      :avocado: tags=quick
>>      """
>>      def test_qmp_human_info_version(self):
>> +        self.vm.set_arch(self.arch)
>> +        self.vm.set_machine()
>>          self.vm.launch()
>>          res = self.vm.command('human-monitor-command',
>>                                command_line='info version')
>> diff --git a/tests/acceptance/vnc.py b/tests/acceptance/vnc.py
>> index b1ef9d71b1..4a8a83025f 100644
>> --- a/tests/acceptance/vnc.py
>> +++ b/tests/acceptance/vnc.py
>> @@ -16,6 +16,11 @@ class Vnc(Test):
>>      :avocado: enable
>>      :avocado: tags=vnc,quick
>>      """
>> +    def setUp(self):
>> +        super(Vnc, self).setUp()
>> +        self.vm.set_arch(self.arch)
>> +        self.vm.set_machine()
>> +
>>      def test_no_vnc(self):
>>          self.vm.add_args('-nodefaults', '-S')
>>          self.vm.launch()
>>
> 
> $ uname -m
> aarch64
> $ avocado --show=app run
> --json-variants-load=tests/acceptance/variants/arch.json
> tests/acceptance/vnc.py
> JOB ID     : 06f38999b7386afbd66023e7c1daee84d7991060
> JOB LOG    :
> /home/phil/avocado/job-results/job-2018-10-05T15.40-06f3899/job.log
>  (01/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;aarch64: PASS (0.34 s)
>  (02/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;ppc: PASS (0.31 s)
>  (03/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;ppc64: PASS (0.35 s)
>  (04/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;s390x: PASS (0.24 s)
>  (05/20) tests/acceptance/vnc.py:Vnc.test_no_vnc;x86_64: PASS (0.34 s)
>  (06/20)
> tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;aarch64: PASS
> (0.34 s)
>  (07/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;ppc:
> PASS (0.27 s)
>  (08/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;ppc64:
> PASS (0.34 s)
>  (09/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;s390x:
> PASS (0.24 s)
>  (10/20) tests/acceptance/vnc.py:Vnc.test_no_vnc_change_password;x86_64:
> PASS (0.35 s)
>  (11/20)
> tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;aarch64:
> PASS (0.33 s)
>  (12/20)
> tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;ppc:
> PASS (0.28 s)
>  (13/20)
> tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;ppc64:
> PASS (0.38 s)
>  (14/20)
> tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;s390x:
> PASS (0.26 s)
>  (15/20)
> tests/acceptance/vnc.py:Vnc.test_vnc_change_password_requires_a_password;x86_64:
> PASS (0.35 s)
>  (16/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;aarch64:
> PASS (0.35 s)
>  (17/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;ppc: PASS
> (0.28 s)
>  (18/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;ppc64:
> PASS (0.36 s)
>  (19/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;s390x:
> PASS (0.26 s)
>  (20/20) tests/acceptance/vnc.py:Vnc.test_vnc_change_password;x86_64:
> PASS (0.34 s)
> RESULTS    : PASS 20 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0
> | CANCEL 0
> JOB TIME   : 8.30 s
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 

I think this is a "tested by" for the next commit (the one that adds the
JSON file), right?

Thanks for testing it!
- Cleber.
diff mbox series

Patch

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 98324f7591..58032f971c 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -30,7 +30,8 @@  class BootLinuxConsole(Test):
         kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('pc')
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine()
         self.vm.set_console()
         kernel_command_line = 'console=ttyS0'
         self.vm.add_args('-kernel', kernel_path,
diff --git a/tests/acceptance/version.py b/tests/acceptance/version.py
index 13b0a7440d..7a3a20945f 100644
--- a/tests/acceptance/version.py
+++ b/tests/acceptance/version.py
@@ -18,6 +18,8 @@  class Version(Test):
     :avocado: tags=quick
     """
     def test_qmp_human_info_version(self):
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine()
         self.vm.launch()
         res = self.vm.command('human-monitor-command',
                               command_line='info version')
diff --git a/tests/acceptance/vnc.py b/tests/acceptance/vnc.py
index b1ef9d71b1..4a8a83025f 100644
--- a/tests/acceptance/vnc.py
+++ b/tests/acceptance/vnc.py
@@ -16,6 +16,11 @@  class Vnc(Test):
     :avocado: enable
     :avocado: tags=vnc,quick
     """
+    def setUp(self):
+        super(Vnc, self).setUp()
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine()
+
     def test_no_vnc(self):
         self.vm.add_args('-nodefaults', '-S')
         self.vm.launch()