@@ -1212,13 +1212,13 @@ class has both implementation and abstract methods, only for methods which
1212
1212
1213
1213
def __init__ (self , * args , ** kwargs ) -> None :
1214
1214
super ().__init__ (* args , ** kwargs )
1215
- # Now ensure that this base is part of the right type of object.
1216
- # For these checks to work, this __init__ method should appear in
1217
- # the MRO after all the __init__ methods that would set these properties
1218
- self ._check_attr ("context" , TestContext )
1219
- self ._check_attr ("logger" , Logger )
1220
1215
self ._usage_stats = UsageStats ()
1221
1216
1217
+ @property
1218
+ @abstractmethod
1219
+ def logger (self ) -> Logger :
1220
+ pass
1221
+
1222
1222
@property
1223
1223
def usage_stats (self ) -> UsageStats :
1224
1224
"""
@@ -1248,6 +1248,9 @@ def kafka_client_security(self) -> KafkaClientSecurity:
1248
1248
on this broker."""
1249
1249
pass
1250
1250
1251
+ def export_cluster_config (self ) -> None :
1252
+ self .logger .debug ("export_cluster_config not implemented for this service" )
1253
+
1251
1254
def wait_until (
1252
1255
self ,
1253
1256
fn : Callable [[], Any ],
@@ -1331,16 +1334,6 @@ def wrapped():
1331
1334
logger = logger ,
1332
1335
)
1333
1336
1334
- def _check_attr (self , name : str , t : Type ) -> None :
1335
- v = getattr (self , name , None )
1336
- mro = self .__class__ .__mro__
1337
- assert v is not None , (
1338
- f"RedpandaServiceABC was missing attribute { name } after __init__: { mro } \n "
1339
- )
1340
- assert isinstance (v , t ), (
1341
- f"{ name } had wrong type, expected { t } but was { type (v )} "
1342
- )
1343
-
1344
1337
def _extract_samples (
1345
1338
self , metrics : Generator [Metric , Any , None ], sample_pattern : str , node : Any
1346
1339
) -> list [MetricSample ]:
@@ -1582,7 +1575,6 @@ def __init__(
1582
1575
# we save the test context under both names since RedpandaService and Service
1583
1576
# save them under these two names, respetively
1584
1577
self .context = self ._context = context
1585
- self .logger = context .logger
1586
1578
1587
1579
super ().__init__ ()
1588
1580
@@ -1667,6 +1659,10 @@ def __init__(
1667
1659
f"Not enough brokers: test needs { self ._min_brokers } but cluster has { node_count } "
1668
1660
)
1669
1661
1662
+ @property
1663
+ def logger (self ) -> Logger :
1664
+ return self ._context .logger
1665
+
1670
1666
@property
1671
1667
def kubectl (self ) -> KubectlTool :
1672
1668
assert self .__kubectl , "kubectl accessed before cluster was started?"
@@ -2379,7 +2375,7 @@ def copy_from_pod(params):
2379
2375
return {}
2380
2376
2381
2377
2382
- class RedpandaService (RedpandaServiceABC , Service ):
2378
+ class RedpandaService (Service , RedpandaServiceABC ):
2383
2379
PERSISTENT_ROOT = "/var/lib/redpanda"
2384
2380
TRIM_LOGS_KEY = "trim_logs"
2385
2381
DATA_DIR = os .path .join (PERSISTENT_ROOT , "data" )
@@ -4449,11 +4445,11 @@ def get_version_if_not_head(self, node):
4449
4445
return self .get_version (node )
4450
4446
return None
4451
4447
4452
- def stop (self , ** kwargs : Any ) -> None :
4448
+ def export_cluster_config (self ) -> None :
4453
4449
"""
4454
- Override default stop() to execude stop_node in parallel
4450
+ Export the cluster configuration of all nodes to the ducktape log
4451
+ directory for later inspection.
4455
4452
"""
4456
- self ._stop_time = time .time () # The last time stop is invoked
4457
4453
self .logger .info ("%s: exporting cluster config" % self .who_am_i ())
4458
4454
4459
4455
service_dir = os .path .join (
@@ -4477,6 +4473,12 @@ def stop(self, **kwargs: Any) -> None:
4477
4473
# will not be able to get it from the admin API
4478
4474
self .logger .info (f"{ self .who_am_i ()} : error getting config: { e } " )
4479
4475
4476
+ def stop (self , ** kwargs : Any ) -> None :
4477
+ """
4478
+ Override default stop() to execude stop_node in parallel
4479
+ """
4480
+ self ._stop_time = time .time () # The last time stop is invoked
4481
+
4480
4482
self .logger .info ("%s: stopping service" % self .who_am_i ())
4481
4483
4482
4484
self .for_nodes (self .nodes , lambda n : self .stop_node (n , ** kwargs ))
0 commit comments