11import time
2+ import paramiko
23from utils .onboarding .weblog_interface import make_get_request , warmup_weblog , make_internal_get_request
34from utils .onboarding .backend_interface import wait_backend_trace_id
45from utils .onboarding .wait_for_tcp_port import wait_for_port
1011
1112class AutoInjectBaseTest :
1213 def _test_install (
13- self , virtual_machine , * , profile : bool = False , appsec : bool = False , origin_detection : bool = False
14+ self ,
15+ virtual_machine : _VirtualMachine ,
16+ * ,
17+ profile : bool = False ,
18+ appsec : bool = False ,
19+ origin_detection : bool = False ,
1420 ):
1521 """If there is a multicontainer app, we need to make a request to each app"""
1622
@@ -32,7 +38,7 @@ def _test_install(
3238 def _check_install (
3339 self ,
3440 virtual_machine : _VirtualMachine ,
35- vm_context_url ,
41+ vm_context_url : str ,
3642 * ,
3743 profile : bool = False ,
3844 appsec : bool = False ,
@@ -75,7 +81,7 @@ def _check_install(
7581 self ._log_trace_debug_message (e , request_uuid )
7682 raise
7783
78- def _appsec_validator (self , _ , trace_data ):
84+ def _appsec_validator (self , _ : str , trace_data : dict ):
7985 """Validator for Appsec traces that checks if the trace contains an Appsec event."""
8086 root_id = trace_data ["trace" ]["root_id" ]
8187 root_span = trace_data ["trace" ]["spans" ][root_id ]
@@ -102,7 +108,7 @@ def _appsec_validator(self, _, trace_data):
102108 logger .error ("expected 'appsec.event' to be true in trace meta or at least one rule triggered" )
103109 return False
104110
105- def _container_tags_validator (self , _ , trace_data ):
111+ def _container_tags_validator (self , _ : str , trace_data : dict ):
106112 root_id = trace_data ["trace" ]["root_id" ]
107113 root_span = trace_data ["trace" ]["spans" ][root_id ]
108114
@@ -127,14 +133,14 @@ def _log_trace_debug_message(self, exc: Exception, request_uuid: str) -> None:
127133 f"- A problem processing the intake in the backend (manually locate the trace id [{ request_uuid } ] in the DD console, using the system-tests organization)\n "
128134 )
129135
130- def close_channel (self , channel ) -> None :
136+ def close_channel (self , channel : paramiko . Channel ) -> None :
131137 try :
132138 if not channel .eof_received :
133139 channel .close ()
134140 except Exception as e :
135141 logger .error (f"Error closing the channel: { e } " )
136142
137- def execute_command (self , virtual_machine , command ) -> str :
143+ def execute_command (self , virtual_machine : _VirtualMachine , command : str ) -> str :
138144 # Env for the command
139145 prefix_env = ""
140146 for key , value in virtual_machine .get_command_environment ().items ():
@@ -165,7 +171,12 @@ def execute_command(self, virtual_machine, command) -> str:
165171 return command_output
166172
167173 def _test_uninstall_commands (
168- self , virtual_machine , stop_weblog_command , start_weblog_command , uninstall_command , install_command
174+ self ,
175+ virtual_machine : _VirtualMachine ,
176+ stop_weblog_command : str ,
177+ start_weblog_command : str ,
178+ uninstall_command : str ,
179+ install_command : str ,
169180 ):
170181 """We can unistall the auto injection software. We can start the app again
171182 The weblog app should work but no sending traces to the backend.
@@ -228,7 +239,7 @@ def _test_uninstall_commands(
228239 self ._test_install (virtual_machine )
229240 logger .info (f"Success _test_uninstall for : [{ virtual_machine .name } ]" )
230241
231- def _test_uninstall (self , virtual_machine ):
242+ def _test_uninstall (self , virtual_machine : _VirtualMachine ):
232243 header = "----------------------------------------------------------------------"
233244 vm_logger (context .scenario .host_log_folder , virtual_machine .name ).info (
234245 f"{ header } \n { header } \n Launching the uninstall for VM: { virtual_machine .name } \n { header } \n { header } "
@@ -250,7 +261,7 @@ def _test_uninstall(self, virtual_machine):
250261 virtual_machine , stop_weblog_command , start_weblog_command , uninstall_command , install_command
251262 )
252263
253- def _test_no_world_writeable (self , virtual_machine ):
264+ def _test_no_world_writeable (self , virtual_machine : _VirtualMachine ):
254265 """Checks that there are no world writeable files in /opt/datadog-packages/datadog-apm*"""
255266 logger = vm_logger (context .scenario .host_log_folder , virtual_machine .name )
256267 logger .info (
0 commit comments