def check_breakage(app_name, current_release_version): """Checks if there is any major breakage for test server deployment and asks the user to file an issue if that is the case. Args: app_name: str. The name of the app to deploy. current_release_version: str. The version of the current release. Raises: Exception. There is major breakage found through test server logs. """ # If this is a test server deployment and the current release version is # already serving, open the GAE error logs. test_server_error_logs_url = ( 'https://console.cloud.google.com/logs/viewer?' 'project=%s&key1=default&minLogLevel=500') % app_name currently_served_version = ( gcloud_adapter.get_currently_served_version(app_name)) if (app_name == APP_NAME_OPPIATESTSERVER or 'migration' in app_name) and (currently_served_version == current_release_version): major_breakage = check_errors_in_a_page(test_server_error_logs_url, 'Is anything major broken?') if major_breakage: common.open_new_tab_in_browser_if_possible( release_constants.RELEASE_DRIVE_URL) common.open_new_tab_in_browser_if_possible( release_constants.ISSUE_FILING_URL) raise Exception( 'Please note the issue in the release journal for this month, ' 'file a blocking bug and switch to the last known good ' 'version.')
def test_get_currently_served_version(self): def mock_check_output(unused_cmd_tokens): return ( 'SERVICE VERSION TRAFFIC_SPLIT LAST_DEPLOYED SERVING_STATUS\n' 'default 2-1-1 1.00 SERVING\n') check_output_swap = self.swap( subprocess, 'check_output', mock_check_output) with check_output_swap: self.assertEqual( gcloud_adapter.get_currently_served_version('app name'), '2-1-1')