canonical / testflinger

https://testflinger.readthedocs.io/en/latest/
GNU General Public License v3.0
9 stars 13 forks source link

[CERTTF-303] Handle case of file upload interrupted by the user #266

Closed boukeas closed 2 months ago

boukeas commented 2 months ago

Description

When file upload through the CLI was interrupted by the user, then the job was not automatically cancelled, causing it to appear indefinitely as waiting on the server.

Now KeyboardInterrupt is caught and raises an AttachmentError, which in turn causes the job to be cancelled.

Also included are a couple of very minor refinements, mostly relating to improved logging.

Tests

Submitted a job that involved a larger attachment and pressed Ctrl-C during the upload:

testflinger-cli --server https://testflinger-staging.canonical.com submit test-job-kernos.yaml 
^CJob 1736d348-32d0-48a3-a212-234060bb201d submitted and cancelled: failed to submit attachments

See result, verifying the job has been cancelled.

boukeas commented 2 months ago

Would it be possible to add some tests for submit_job_attachment including ones for catching AttachmentError?

@plars Were you thinking of something in addition to test_submit_attachments_retries, test_submit_attachments_no_retries and test_submit_attachments_timeout that are already included in the tests?

plars commented 2 months ago

@boukeas I saw those and they are ok. But I was thinking it would be good to do something that called submit_job_attachments and covered the error paths that can return AttachmentError if possible