avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
345 stars 343 forks source link

avocado jobs command is broken #6067

Open richtja opened 2 weeks ago

richtja commented 2 weeks ago

Describe the bug The avocado jobs command makes avocado crash. Bout avocado jobs list and avocado jobs show is broken.

Steps to reproduce Just run avocado jobs list or avocado jobs show latest

Expected behavior Avocado will provide useful information, and it won't crash.

Current behavior

$ avocado jobs list
...
abb1d9a7875e6dde3ad96fd4976a4c4bedb246bb 2024-10-30 10:44:49.229156   1 (0/0/1/0)
dc68076acdaa2ceb7a1f5b2a06164863f02abb91 2024-10-30 10:44:00.593955   1 (0/0/0/0)
64ca178a72bef056fc859b07fb5b648e49f8d60e 2024-10-30 10:43:51.515882   1 (0/0/0/0)
d34143063b6fb1611609e794154d7514beaa5c23 2024-10-29 16:19:51.930934   2 (2/0/0/0)
Avocado crashed unexpectedly: 'start'
Traceback (most recent call last):
  File "/home/janrichter/.pyenv/versions/avocado/bin/avocado", line 33, in <module>
    sys.exit(load_entry_point('avocado-framework', 'console_scripts', 'avocado')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 189, in run
    return self.handle_list_command(results)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 122, in handle_list_command
    job["start"],
    ~~~^^^^^^^^^
KeyError: 'start'

You can also find details in /home/janrichter/avocado/data/crashes/avocado-traceback-2024-11-08_11:11:50-45p8yhss.log
$ avocado jobs show latest
JOB ID      : latest
JOB LOG     : /home/janrichter/avocado/job-results/job-2024-11-07T14.26-c5f4066/job.log

Avocado crashed unexpectedly: 'NoneType' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/janrichter/.pyenv/versions/avocado/bin/avocado", line 33, in <module>
    sys.exit(load_entry_point('avocado-framework', 'console_scripts', 'avocado')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 191, in run
    return self.handle_show_command(config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 157, in handle_show_command
    self._print_job_tests(results_data.get("tests"))
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 60, in _print_job_tests
    end = datetime.fromtimestamp(test.get("actual_end", test.get("end")))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

You can also find details in /home/janrichter/avocado/data/crashes/avocado-traceback-2024-11-08_11:14:57-cj90psur.log

System information (please complete the following information):

clebergnu commented 1 week ago

The avocado jobs list breakage can be seen only when "job results" content is created across multiple versions of Avocado. Example:

$ python3 -m pip install avocado-framework=92.3
...
$ avocado run /bin/true
...
$ python3 -m pip install avocado-framework==108.0
$ avocado jobs list
avocado jobs list
Avocado crashed unexpectedly: 'start'
Traceback (most recent call last):
  File "/usr/local/bin/avocado", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 189, in run
    return self.handle_list_command(results)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 122, in handle_list_command
    job["start"],
    ~~~^^^^^^^^^
KeyError: 'start'

You can also find details in /root/avocado/data/crashes/avocado-traceback-2024-11-12_12:32:41-9yvth7dc.log

The expected behavior here is to not crash, possibly skipping the info that was not obtained.

Now, even with a single version of Avocado generating job results, there's a possible crash with:

$ python3 -m pip install avocado-framework==108.0
$ avocado run /bin/true 
JOB ID     : 1849848b22a44828889c6b0f2648107fc55264b1
JOB LOG    : /root/avocado/job-results/job-2024-11-12T18.14-1849848/job.log
 (1/1) /bin/true: STARTED
 (1/1) /bin/true: PASS (0.01 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 0.51 s

Followed by:

$ avocado jobs show latest
JOB ID      : latest
JOB LOG     : /root/avocado/job-results/job-2024-11-12T18.14-1849848/job.log

Avocado crashed unexpectedly: 'NoneType' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/usr/local/bin/avocado", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 191, in run
    return self.handle_show_command(config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 157, in handle_show_command
    self._print_job_tests(results_data.get("tests"))
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 60, in _print_job_tests
    end = datetime.fromtimestamp(test.get("actual_end", test.get("end")))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

You can also find details in /root/avocado/data/crashes/avocado-traceback-2024-11-12_18:14:42-6o_shh4c.log
richtja commented 1 week ago

Hi @clebergnu, thanks for the testing. So IIUIC the avocado jobs show latest is not some corner case with corrupted test results, it just simply doesn't work on avocado 108. Therefore, I will move this into current milestone as any other normal bug.