def compose_multiple_apps(self): module_names = self.app.pargs.modules group = self.app.pargs.env_group_suffix or 'dev' nohang = self.app.pargs.nohang timeout = self.app.pargs.timeout root_dir = os.getcwd() version_labels = [] grouped_env_names = [] app_name = None for module in module_names: if not os.path.isdir(os.path.join(root_dir, module)): io.log_warning(strings['create.appdoesntexist'].replace( '{app_name}', module)) continue os.chdir(os.path.join(root_dir, module)) if not fileoperations.env_yaml_exists(): io.log_warning(strings['compose.noenvyaml'].replace( '{module}', module)) continue io.echo( '--- Creating application version for module: {0} ---'.format( module)) # Re-run hooks to get values from .elasticbeanstalk folders of modules hooks.set_region(None) hooks.set_ssl(None) hooks.set_profile(None) commonops.set_group_suffix_for_current_branch(group) if not app_name: app_name = self.get_app_name() process_app_version = fileoperations.env_yaml_exists() version_label = commonops.create_app_version( app_name, process=process_app_version) version_labels.append(version_label) environment_name = fileoperations.get_env_name_from_env_yaml() if environment_name is not None: commonops.set_environment_for_current_branch( environment_name.replace('+', '-{0}'.format(group))) grouped_env_names.append( environment_name.replace('+', '-{0}'.format(group))) os.chdir(root_dir) if len(version_labels) > 0: composeops.compose(app_name, version_labels, grouped_env_names, group, nohang, timeout) else: io.log_warning(strings['compose.novalidmodules'])
def test_compose__wait_for_processed_app_versions_was_unsuccessful( self, compose_apps_mock, wait_for_processed_app_versions_mock): wait_for_processed_app_versions_mock.return_value = False self.assertIsNone( composeops.compose('my-application', ['version-label-1', 'version-label-2'], ['environment-1', 'environment-2'], group_name='dev', timeout=6)) wait_for_processed_app_versions_mock.assert_called_once_with( 'my-application', ['version-label-1', 'version-label-2'], timeout=6) compose_apps_mock.assert_not_called()
def test_compose__nohang(self, compose_apps_mock, wait_for_compose_events_mock, wait_for_processed_app_versions_mock): wait_for_processed_app_versions_mock.return_value = True compose_apps_mock.return_value = 'request-id' self.assertIsNone( composeops.compose('my-application', ['version-label-1', 'version-label-2'], ['environment-1', 'environment-2'], group_name='dev', nohang=True)) wait_for_processed_app_versions_mock.assert_called_once_with( 'my-application', ['version-label-1', 'version-label-2'], timeout=10) compose_apps_mock.assert_called_once_with( 'my-application', ['version-label-1', 'version-label-2'], 'dev') wait_for_compose_events_mock.assert_not_called()