@@ -43,21 +43,34 @@ def __init__(self, *args):
43
43
self .framework .observe (self .on .start , self ._on_start )
44
44
45
45
self .framework .observe (
46
- self .on .clear_continuous_writes_action , self ._on_clear_continuous_writes_action
46
+ getattr (self .on , "clear_continuous_writes_action" ),
47
+ self ._on_clear_continuous_writes_action ,
47
48
)
48
49
self .framework .observe (
49
- self .on .start_continuous_writes_action , self ._on_start_continuous_writes_action
50
+ getattr (self .on , "start_continuous_writes_action" ),
51
+ self ._on_start_continuous_writes_action ,
50
52
)
51
53
self .framework .observe (
52
- self .on .stop_continuous_writes_action , self ._on_stop_continuous_writes_action
54
+ getattr (self .on , "stop_continuous_writes_action" ),
55
+ self ._on_stop_continuous_writes_action ,
53
56
)
54
57
55
- self .framework .observe (self .on .get_inserted_data_action , self ._get_inserted_data )
58
+ self .framework .observe (
59
+ getattr (self .on , "get_inserted_data_action" ), self ._get_inserted_data
60
+ )
61
+
62
+ self .framework .observe (
63
+ getattr (self .on , "get_session_ssl_cipher_action" ), self ._get_session_ssl_cipher
64
+ )
56
65
57
66
# Database related events
58
67
self .database = DatabaseRequires (self , "database" , DATABASE_NAME )
59
- self .framework .observe (self .database .on .database_created , self ._on_database_created )
60
- self .framework .observe (self .database .on .endpoints_changed , self ._on_endpoints_changed )
68
+ self .framework .observe (
69
+ getattr (self .database .on , "database_created" ), self ._on_database_created
70
+ )
71
+ self .framework .observe (
72
+ getattr (self .database .on , "endpoints_changed" ), self ._on_endpoints_changed
73
+ )
61
74
self .framework .observe (
62
75
self .on [DATABASE_RELATION ].relation_broken , self ._on_relation_broken
63
76
)
@@ -276,6 +289,17 @@ def _get_inserted_data(self, event: ActionEvent) -> None:
276
289
"""Get random value inserted into the database."""
277
290
event .set_results ({"data" : self .app_peer_data .get (RANDOM_VALUE_KEY , "empty" )})
278
291
292
+ def _get_session_ssl_cipher (self , event : ActionEvent ) -> None :
293
+ """Get the SSL cipher used by the session."""
294
+ if not self ._database_config :
295
+ return event .set_results ({"cipher" : "empty" })
296
+
297
+ with MySQLConnector (self ._database_config ) as cursor :
298
+ cursor .execute ("SHOW SESSION STATUS LIKE 'Ssl_cipher'" )
299
+ cipher = cursor .fetchone ()[1 ]
300
+
301
+ event .set_results ({"cipher" : cipher })
302
+
279
303
280
304
if __name__ == "__main__" :
281
305
main (MySQLTestApplication )
0 commit comments