def switch_version(app_name, current_release_version): """Switches version if library page loads correctly. Args: app_name: str. The name of the app to deploy. current_release_version: str. The version of the current release. Raises: Exception. The library page does not load correctly. """ release_version_library_url = ( 'https://%s-dot-%s.appspot.com/community-library' % (current_release_version, app_name)) library_page_loads_correctly = check_errors_in_a_page( release_version_library_url, 'Library page is loading correctly?') if not library_page_loads_correctly: raise Exception( 'Aborting version switch due to issues in library page ' 'loading.') version_switch = release_constants.AFFIRMATIVE_CONFIRMATIONS[0] if common.is_current_branch_a_hotfix_branch(): python_utils.PRINT('Do you want to switch version?') version_switch = python_utils.INPUT() if version_switch in release_constants.AFFIRMATIVE_CONFIRMATIONS: gcloud_adapter.switch_version(app_name, current_release_version) python_utils.PRINT('Successfully migrated traffic to release version!')
def test_switch_version(self): def mock_get_latest_deployed_version(unused_app_name, unused_service_name): return 'test-version' latest_version_swap = self.swap(gcloud_adapter, 'get_latest_deployed_version', mock_get_latest_deployed_version) with self.check_output_swap, latest_version_swap: gcloud_adapter.switch_version('app name', '2.1.1') self.assertEqual(self.check_function_calls, self.expected_check_function_calls)
def switch_version(app_name, current_release_version): """Switches version if library page loads correctly. Args: app_name: str. The name of the app to deploy. current_release_version: str. The version of the current release. Raises: Exception. The library page does not load correctly. """ release_version_library_url = ('https://%s-dot-%s.appspot.com/library' % (current_release_version, app_name)) library_page_loads_correctly = check_errors_in_a_page( release_version_library_url, 'Library page is loading correctly?') if library_page_loads_correctly: gcloud_adapter.switch_version(app_name, current_release_version) python_utils.PRINT('Successfully migrated traffic to release version!') else: raise Exception( 'Aborting version switch due to issues in library page ' 'loading.')
def test_switch_version(self): with self.check_output_swap: gcloud_adapter.switch_version('app name', '2.1.1') self.assertEqual( self.check_function_calls, self.expected_check_function_calls)