diff options
author | Justin Cook <justin.cook@linaro.org> | 2020-11-02 12:12:38 -0600 |
---|---|---|
committer | Justin Cook <justin.cook@linaro.org> | 2020-11-02 12:12:38 -0600 |
commit | a01958347436794df1e06fa997deb2ef853deabf (patch) | |
tree | a3397c4c743d9581d9e2099ccf81b1e7642fc924 | |
parent | 86ef61df7761d71fcf9f15883688b8d4a35c989e (diff) |
Gracefully handle some tuxbuild json config errors
-rw-r--r-- | squad_client/commands/submit.py | 6 | ||||
-rw-r--r-- | tests/data/submit/tuxbuild/empty_kconfig.json | 21 | ||||
-rw-r--r-- | tests/data/submit/tuxbuild/missing_kconfig.json | 19 | ||||
-rw-r--r-- | tests/test_submit.py | 10 |
4 files changed, 56 insertions, 0 deletions
diff --git a/squad_client/commands/submit.py b/squad_client/commands/submit.py index b2cc9dd..d0aa3f0 100644 --- a/squad_client/commands/submit.py +++ b/squad_client/commands/submit.py @@ -111,6 +111,12 @@ class SubmitCommand(SquadClientCommand): data = tb + except IndexError as ie: + logger.error("Failed to load tuxbuild json due to a missing kconfig value: %s", ie) + + except KeyError as ke: + logger.error("Failed to load tuxbuild json due to a missing variable: %s", ke) + except json.JSONDecodeError as jde: logger.error("Failed to load json: %s", jde) diff --git a/tests/data/submit/tuxbuild/empty_kconfig.json b/tests/data/submit/tuxbuild/empty_kconfig.json new file mode 100644 index 0000000..20caf01 --- /dev/null +++ b/tests/data/submit/tuxbuild/empty_kconfig.json @@ -0,0 +1,21 @@ +[ + { + "build_key": "t8NSUfTBZiSPbBVaXLH7kw", + "build_status": "pass", + "client_token": "3cffcab5-aaf8-446d-8dec-861da6814788", + "download_url": "https://builds.tuxbuild.com/t8NSUfTBZiSPbBVaXLH7kw/", + "errors_count": 0, + "git_describe": "next-20201021", + "git_repo": "https://gitlab.com/Linaro/lkft/mirrors/next/linux-next", + "git_sha": "5302568121ba345f5c22528aefd72d775f25221e", + "git_short_log": "5302568121ba (\"Add linux-next specific files for 20201021\")", + "kconfig": [ + ], + "kernel_version": "5.9.0", + "status_message": "build completed", + "target_arch": "x86", + "toolchain": "gcc-9", + "tuxbuild_status": "complete", + "warnings_count": 1 + } +] diff --git a/tests/data/submit/tuxbuild/missing_kconfig.json b/tests/data/submit/tuxbuild/missing_kconfig.json new file mode 100644 index 0000000..ac6cbd0 --- /dev/null +++ b/tests/data/submit/tuxbuild/missing_kconfig.json @@ -0,0 +1,19 @@ +[ + { + "build_key": "t8NSUfTBZiSPbBVaXLH7kw", + "build_status": "pass", + "client_token": "3cffcab5-aaf8-446d-8dec-861da6814788", + "download_url": "https://builds.tuxbuild.com/t8NSUfTBZiSPbBVaXLH7kw/", + "errors_count": 0, + "git_describe": "next-20201021", + "git_repo": "https://gitlab.com/Linaro/lkft/mirrors/next/linux-next", + "git_sha": "5302568121ba345f5c22528aefd72d775f25221e", + "git_short_log": "5302568121ba (\"Add linux-next specific files for 20201021\")", + "kernel_version": "5.9.0", + "status_message": "build completed", + "target_arch": "x86", + "toolchain": "gcc-9", + "tuxbuild_status": "complete", + "warnings_count": 1 + } +] diff --git a/tests/test_submit.py b/tests/test_submit.py index 9740fca..6cafae7 100644 --- a/tests/test_submit.py +++ b/tests/test_submit.py @@ -195,6 +195,16 @@ class SubmitCommandTest(unittest.TestCase): self.assertFalse(proc.ok) self.assertIn("argument --results-layout: invalid choice: 'bad_layout'", proc.err) + def test_submit_results_tuxbuild_json_empty_kconfig(self): + proc = self.manage_submit(results="tests/data/submit/tuxbuild/empty_kconfig.json", results_layout="tuxbuild_json") + self.assertFalse(proc.ok) + self.assertIn("Failed to load tuxbuild json due to a missing kconfig value: list index out of range", proc.err) + + def test_submit_results_tuxbuild_json_missing_kconfig(self): + proc = self.manage_submit(results="tests/data/submit/tuxbuild/missing_kconfig.json", results_layout="tuxbuild_json") + self.assertFalse(proc.ok) + self.assertIn("Failed to load tuxbuild json due to a missing variable: 'kconfig'", proc.err) + def test_submit_results_yaml(self): proc = self.manage_submit(results='tests/submit_results/sample_results.yaml') self.assertTrue(proc.ok) |