From 246207fb3130d2d1e4dca093066005b56bb44d8d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 27 Oct 2024 16:55:41 +0100 Subject: [PATCH] integration: test_create_volume_invalid_driver allow either 400 or 404 The API currently returns a 404 error when trying to create a volume with an invalid (non-existing) driver. We are considering changing this status code to be a 400 (invalid parameter), as even though the _reason_ of the error may be that the plugin / driver is not found, the _cause_ of the error is that the user provided a plugin / driver that's invalid for the engine they're connected to. This patch updates the test to pass for either case. Signed-off-by: Sebastiaan van Stijn --- tests/integration/api_volume_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration/api_volume_test.py b/tests/integration/api_volume_test.py index ecd19da2d..fdf79d673 100644 --- a/tests/integration/api_volume_test.py +++ b/tests/integration/api_volume_test.py @@ -17,10 +17,16 @@ def test_create_volume(self): assert result['Driver'] == 'local' def test_create_volume_invalid_driver(self): - driver_name = 'invalid.driver' + # special name to avoid exponential timeout loop + # https://github.com/moby/moby/blob/9e00a63d65434cdedc444e79a2b33a7c202b10d8/pkg/plugins/client.go#L253-L254 + driver_name = 'this-plugin-does-not-exist' - with pytest.raises(docker.errors.NotFound): + with pytest.raises(docker.errors.APIError) as cm: self.client.create_volume('perfectcherryblossom', driver_name) + assert ( + cm.value.response.status_code == 404 or + cm.value.response.status_code == 400 + ) def test_list_volumes(self): name = 'imperishablenight'