@ -133,7 +133,7 @@ def generate_dependency_map(integration_targets): # type: (t.List[IntegrationTa
""" Analyze the given list of integration test targets and return a dictionary expressing target names and the targets on which they depend. """
""" Analyze the given list of integration test targets and return a dictionary expressing target names and the targets on which they depend. """
targets_dict = dict ( ( target . name , target ) for target in integration_targets )
targets_dict = dict ( ( target . name , target ) for target in integration_targets )
target_dependencies = analyze_integration_target_dependencies ( integration_targets )
target_dependencies = analyze_integration_target_dependencies ( integration_targets )
dependency_map = { }
dependency_map = { } # type: t.Dict[str, t.Set[IntegrationTarget]]
invalid_targets = set ( )
invalid_targets = set ( )
@ -158,7 +158,7 @@ def generate_dependency_map(integration_targets): # type: (t.List[IntegrationTa
def get_files_needed ( target_dependencies ) : # type: (t.List[IntegrationTarget]) -> t.List[str]
def get_files_needed ( target_dependencies ) : # type: (t.List[IntegrationTarget]) -> t.List[str]
""" Return a list of files needed by the given list of target dependencies. """
""" Return a list of files needed by the given list of target dependencies. """
files_needed = [ ]
files_needed = [ ] # type: t.List[str]
for target_dependency in target_dependencies :
for target_dependency in target_dependencies :
files_needed + = target_dependency . needs_file
files_needed + = target_dependency . needs_file
@ -228,7 +228,7 @@ def integration_test_environment(
args , # type: IntegrationConfig
args , # type: IntegrationConfig
target , # type: IntegrationTarget
target , # type: IntegrationTarget
inventory_path_src , # type: str
inventory_path_src , # type: str
) : # type: (...) -> t. ContextManage r[IntegrationEnvironment]
) : # type: (...) -> t. Iterato r[IntegrationEnvironment]
""" Context manager that prepares the integration test environment and cleans it up. """
""" Context manager that prepares the integration test environment and cleans it up. """
ansible_config_src = args . get_ansible_config ( )
ansible_config_src = args . get_ansible_config ( )
ansible_config_relative = os . path . join ( data_context ( ) . content . integration_path , ' %s .cfg ' % args . command )
ansible_config_relative = os . path . join ( data_context ( ) . content . integration_path , ' %s .cfg ' % args . command )
@ -311,8 +311,7 @@ def integration_test_environment(
display . info ( ' Copying %s / to %s / ' % ( dir_src , dir_dst ) , verbosity = 2 )
display . info ( ' Copying %s / to %s / ' % ( dir_src , dir_dst ) , verbosity = 2 )
if not args . explain :
if not args . explain :
# noinspection PyTypeChecker
shutil . copytree ( to_bytes ( dir_src ) , to_bytes ( dir_dst ) , symlinks = True ) # type: ignore[arg-type] # incorrect type stub omits bytes path support
shutil . copytree ( to_bytes ( dir_src ) , to_bytes ( dir_dst ) , symlinks = True )
for file_src , file_dst in file_copies :
for file_src , file_dst in file_copies :
display . info ( ' Copying %s to %s ' % ( file_src , file_dst ) , verbosity = 2 )
display . info ( ' Copying %s to %s ' % ( file_src , file_dst ) , verbosity = 2 )
@ -332,7 +331,7 @@ def integration_test_config_file(
args , # type: IntegrationConfig
args , # type: IntegrationConfig
env_config , # type: CloudEnvironmentConfig
env_config , # type: CloudEnvironmentConfig
integration_dir , # type: str
integration_dir , # type: str
) : # type: (...) -> t. ContextManage r[t.Optional[str]]
) : # type: (...) -> t. Iterato r[t.Optional[str]]
""" Context manager that provides a config file for integration tests, if needed. """
""" Context manager that provides a config file for integration tests, if needed. """
if not env_config :
if not env_config :
yield None
yield None
@ -349,7 +348,7 @@ def integration_test_config_file(
config_file = json . dumps ( config_vars , indent = 4 , sort_keys = True )
config_file = json . dumps ( config_vars , indent = 4 , sort_keys = True )
with named_temporary_file ( args , ' config-file- ' , ' .json ' , integration_dir , config_file ) as path :
with named_temporary_file ( args , ' config-file- ' , ' .json ' , integration_dir , config_file ) as path : # type: str
filename = os . path . relpath ( path , integration_dir )
filename = os . path . relpath ( path , integration_dir )
display . info ( ' >>> Config File: %s \n %s ' % ( filename , config_file ) , verbosity = 3 )
display . info ( ' >>> Config File: %s \n %s ' % ( filename , config_file ) , verbosity = 3 )
@ -386,8 +385,8 @@ def create_inventory(
def command_integration_filtered (
def command_integration_filtered (
args , # type: IntegrationConfig
args , # type: IntegrationConfig
host_state , # type: HostState
host_state , # type: HostState
targets , # type: t.Tuple[IntegrationTarget ]
targets , # type: t.Tuple[IntegrationTarget , ... ]
all_targets , # type: t.Tuple[IntegrationTarget ]
all_targets , # type: t.Tuple[IntegrationTarget , ... ]
inventory_path , # type: str
inventory_path , # type: str
pre_target = None , # type: t.Optional[t.Callable[[IntegrationTarget], None]]
pre_target = None , # type: t.Optional[t.Callable[[IntegrationTarget], None]]
post_target = None , # type: t.Optional[t.Callable[[IntegrationTarget], None]]
post_target = None , # type: t.Optional[t.Callable[[IntegrationTarget], None]]
@ -401,7 +400,7 @@ def command_integration_filtered(
all_targets_dict = dict ( ( target . name , target ) for target in all_targets )
all_targets_dict = dict ( ( target . name , target ) for target in all_targets )
setup_errors = [ ]
setup_errors = [ ]
setup_targets_executed = set ( )
setup_targets_executed = set ( ) # type: t.Set[str]
for target in all_targets :
for target in all_targets :
for setup_target in target . setup_once + target . setup_always :
for setup_target in target . setup_once + target . setup_always :
@ -526,7 +525,7 @@ def command_integration_filtered(
failed . append ( target )
failed . append ( target )
if args . continue_on_error :
if args . continue_on_error :
display . error ( ex )
display . error ( str ( ex ) )
continue
continue
display . notice ( ' To resume at this test target, use the option: --start-at %s ' % target . name )
display . notice ( ' To resume at this test target, use the option: --start-at %s ' % target . name )
@ -585,7 +584,7 @@ def command_integration_script(
module_defaults = env_config . module_defaults ,
module_defaults = env_config . module_defaults ,
) , indent = 4 , sort_keys = True ) , verbosity = 3 )
) , indent = 4 , sort_keys = True ) , verbosity = 3 )
with integration_test_environment ( args , target , inventory_path ) as test_env :
with integration_test_environment ( args , target , inventory_path ) as test_env : # type: IntegrationEnvironment
cmd = [ ' ./ %s ' % os . path . basename ( target . script_path ) ]
cmd = [ ' ./ %s ' % os . path . basename ( target . script_path ) ]
if args . verbosity :
if args . verbosity :
@ -602,7 +601,7 @@ def command_integration_script(
if env_config and env_config . env_vars :
if env_config and env_config . env_vars :
env . update ( env_config . env_vars )
env . update ( env_config . env_vars )
with integration_test_config_file ( args , env_config , test_env . integration_dir ) as config_path :
with integration_test_config_file ( args , env_config , test_env . integration_dir ) as config_path : # type: t.Optional[str]
if config_path :
if config_path :
cmd + = [ ' -e ' , ' @ %s ' % config_path ]
cmd + = [ ' -e ' , ' @ %s ' % config_path ]
@ -661,7 +660,7 @@ def command_integration_role(
module_defaults = env_config . module_defaults ,
module_defaults = env_config . module_defaults ,
) , indent = 4 , sort_keys = True ) , verbosity = 3 )
) , indent = 4 , sort_keys = True ) , verbosity = 3 )
with integration_test_environment ( args , target , inventory_path ) as test_env :
with integration_test_environment ( args , target , inventory_path ) as test_env : # type: IntegrationEnvironment
if os . path . exists ( test_env . vars_file ) :
if os . path . exists ( test_env . vars_file ) :
vars_files . append ( os . path . relpath ( test_env . vars_file , test_env . integration_dir ) )
vars_files . append ( os . path . relpath ( test_env . vars_file , test_env . integration_dir ) )
@ -733,7 +732,7 @@ def run_setup_targets(
args , # type: IntegrationConfig
args , # type: IntegrationConfig
host_state , # type: HostState
host_state , # type: HostState
test_dir , # type: str
test_dir , # type: str
target_names , # type: t. List [str]
target_names , # type: t. Sequence [str]
targets_dict , # type: t.Dict[str, IntegrationTarget]
targets_dict , # type: t.Dict[str, IntegrationTarget]
targets_executed , # type: t.Set[str]
targets_executed , # type: t.Set[str]
inventory_path , # type: str
inventory_path , # type: str