2
2
# Copyright 2021 Canonical Ltd.
3
3
# See LICENSE file for licensing details.
4
4
5
- import asyncio
6
5
import logging
7
6
8
7
import pytest
@@ -43,10 +42,10 @@ async def test_app_force_removal(ops_test: OpsTest, charm: str):
43
42
num_units = 1 ,
44
43
base = CHARM_BASE ,
45
44
storage = {
46
- "archive" : {"pool" : "lxd-btrfs" , "size" : 8046 },
47
- "data" : {"pool" : "lxd-btrfs" , "size" : 8046 },
48
- "logs" : {"pool" : "lxd-btrfs" , "size" : 8046 },
49
- "temp" : {"pool" : "lxd-btrfs" , "size" : 8046 },
45
+ "archive" : {"pool" : "lxd-btrfs" , "size" : 2048 },
46
+ "data" : {"pool" : "lxd-btrfs" , "size" : 2048 },
47
+ "logs" : {"pool" : "lxd-btrfs" , "size" : 2048 },
48
+ "temp" : {"pool" : "lxd-btrfs" , "size" : 2048 },
50
49
},
51
50
config = {"profile" : "testing" },
52
51
)
@@ -66,7 +65,7 @@ async def test_app_force_removal(ops_test: OpsTest, charm: str):
66
65
storage_ids = get_storage_ids (ops_test , primary_name )
67
66
68
67
# Check if storage exists after application deployed
69
- logger .info ("werifing is storage exists" )
68
+ logger .info ("verifying that storage exists" )
70
69
for storage_id in storage_ids :
71
70
for attempt in Retrying (
72
71
stop = stop_after_delay (15 * 3 ), wait = wait_fixed (3 ), reraise = True
@@ -89,7 +88,7 @@ async def test_app_force_removal(ops_test: OpsTest, charm: str):
89
88
)
90
89
91
90
# Storage should remain
92
- logger .info ("werifing is storage exists" )
91
+ logger .info ("verifying that storage exists" )
93
92
for storage_id in storage_ids :
94
93
for attempt in Retrying (
95
94
stop = stop_after_delay (15 * 3 ), wait = wait_fixed (3 ), reraise = True
@@ -107,6 +106,8 @@ async def test_charm_garbage_ignorance(ops_test: OpsTest, charm: str):
107
106
for attempt in Retrying (stop = stop_after_delay (30 * 3 ), wait = wait_fixed (3 ), reraise = True ):
108
107
with attempt :
109
108
garbage_storages = await get_detached_storages (ops_test )
109
+ assert len (garbage_storages ) == 4
110
+ logger .info (f"Collected storages: { garbage_storages } " )
110
111
111
112
logger .info ("add unit with attached storage" )
112
113
await add_unit_with_storage (ops_test , APPLICATION_NAME , garbage_storages )
@@ -146,31 +147,29 @@ async def test_app_resources_conflicts_v3(ops_test: OpsTest, charm: str):
146
147
"""Test application deploy in dirty environment with garbage storage from another application."""
147
148
async with ops_test .fast_forward ():
148
149
logger .info ("checking garbage storage" )
149
- garbage_storage = None
150
+ garbage_storages = None
150
151
for attempt in Retrying (stop = stop_after_delay (30 * 3 ), wait = wait_fixed (3 ), reraise = True ):
151
152
with attempt :
152
- garbage_storage = await get_detached_storages (ops_test )
153
+ garbage_storages = await get_detached_storages (ops_test )
154
+ assert len (garbage_storages ) == 4
155
+ logger .info (f"Collected storages: { garbage_storages } " )
153
156
154
157
logger .info ("deploying duplicate application with attached storage" )
155
158
await ops_test .model .deploy (
156
159
charm ,
157
160
application_name = DUP_APPLICATION_NAME ,
158
161
num_units = 1 ,
159
162
base = CHARM_BASE ,
160
- attach_storage = [tag .storage (storage ) for storage in garbage_storage ],
163
+ attach_storage = [tag .storage (storage ) for storage in garbage_storages ],
161
164
config = {"profile" : "testing" },
162
165
)
163
166
164
167
# Reducing the update status frequency to speed up the triggering of deferred events.
165
- await ops_test .model .set_config ({"update-status-hook-interval" : "10s" })
166
-
167
- logger .info ("waiting for duplicate application to be blocked" )
168
- try :
168
+ async with ops_test .fast_forward ("60s" ):
169
+ logger .info ("waiting for duplicate application to be waiting" )
169
170
await ops_test .model .wait_for_idle (
170
- apps = [DUP_APPLICATION_NAME ], timeout = 1000 , status = "blocked"
171
+ apps = [DUP_APPLICATION_NAME ], timeout = 1000 , status = "waiting" , idle_period = 30
171
172
)
172
- except asyncio .TimeoutError :
173
- logger .info ("Application is not in blocked state. Checking logs..." )
174
173
175
174
# Since application have postgresql db in storage from external application it should not be able to connect due to new password
176
175
logger .info ("checking operator password auth" )
0 commit comments