mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Increase backup upload timeout (#132990)
This commit is contained in:
parent
77fb440ed4
commit
482ad6fbee
@ -7,7 +7,7 @@ from collections.abc import AsyncIterator, Callable, Coroutine
|
||||
import hashlib
|
||||
from typing import Any, Self
|
||||
|
||||
from aiohttp import ClientError, StreamReader
|
||||
from aiohttp import ClientError, ClientTimeout, StreamReader
|
||||
from hass_nabucasa import Cloud, CloudError
|
||||
from hass_nabucasa.cloud_api import (
|
||||
async_files_delete_file,
|
||||
@ -151,9 +151,10 @@ class CloudBackupAgent(BackupAgent):
|
||||
details["url"],
|
||||
data=await open_stream(),
|
||||
headers=details["headers"] | {"content-length": str(backup.size)},
|
||||
timeout=ClientTimeout(connect=10.0, total=43200.0), # 43200s == 12h
|
||||
)
|
||||
upload_status.raise_for_status()
|
||||
except ClientError as err:
|
||||
except (TimeoutError, ClientError) as err:
|
||||
raise BackupAgentError("Failed to upload backup") from err
|
||||
|
||||
async def async_delete_backup(
|
||||
|
@ -372,6 +372,7 @@ async def test_agents_upload(
|
||||
assert f"Uploading backup {backup_id}" in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("put_mock_kwargs", [{"status": 500}, {"exc": TimeoutError}])
|
||||
@pytest.mark.usefixtures("cloud_logged_in", "mock_list_files")
|
||||
async def test_agents_upload_fail_put(
|
||||
hass: HomeAssistant,
|
||||
@ -379,6 +380,7 @@ async def test_agents_upload_fail_put(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
mock_get_upload_details: Mock,
|
||||
put_mock_kwargs: dict[str, Any],
|
||||
) -> None:
|
||||
"""Test agent upload backup fails."""
|
||||
client = await hass_client()
|
||||
@ -395,7 +397,7 @@ async def test_agents_upload_fail_put(
|
||||
protected=True,
|
||||
size=0.0,
|
||||
)
|
||||
aioclient_mock.put(mock_get_upload_details.return_value["url"], status=500)
|
||||
aioclient_mock.put(mock_get_upload_details.return_value["url"], **put_mock_kwargs)
|
||||
|
||||
with (
|
||||
patch(
|
||||
|
Loading…
x
Reference in New Issue
Block a user