def update_and_check_indexes(app_name): """Updates indexes and checks if all indexes are serving. Args: app_name: str. The name of the app to deploy. Raises: Exception. All indexes are not serving on the indexes page. """ # Update indexes, then prompt for a check that they are all serving # before continuing with the deployment. # NOTE: This assumes that the build process does not modify the # index.yaml file or create a different version of it to use in # production. indexes_page_url = ( 'https://console.cloud.google.com/datastore/indexes' '?project=%s') % app_name gcloud_adapter.update_indexes(INDEX_YAML_PATH, app_name) counter = 1 while not gcloud_adapter.check_all_indexes_are_serving(app_name): if counter == 1: common.open_new_tab_in_browser_if_possible(indexes_page_url) python_utils.PRINT('Waiting for all indexes to serve...') counter += 1 time.sleep(30)
def test_check_all_indexes_are_serving_with_all_indexes_serving(self): def mock_get_all_index_descriptions(unused_app_name): return [{ 'state': 'READY', 'indexId': 'index1' }, { 'state': 'READY', 'indexId': 'index2' }] get_all_index_descriptions_swap = self.swap( gcloud_adapter, 'get_all_index_descriptions', mock_get_all_index_descriptions) with get_all_index_descriptions_swap: self.assertTrue( gcloud_adapter.check_all_indexes_are_serving('app name'))
def update_and_check_indexes(app_name): """Updates indexes and checks if all indexes are serving. Args: app_name: str. The name of the app to deploy. Raises: Exception. All indexes are not serving on the indexes page. """ # Update indexes, then prompt for a check that they are all serving # before continuing with the deployment. # NOTE: This assumes that the build process does not modify the # index.yaml file or create a different version of it to use in # production. indexes_page_url = ('https://console.cloud.google.com/datastore/indexes' '?project=%s') % app_name gcloud_adapter.update_indexes(INDEX_YAML_PATH, app_name) if not gcloud_adapter.check_all_indexes_are_serving(app_name): common.open_new_tab_in_browser_if_possible(indexes_page_url) raise Exception( 'Please wait for all indexes to serve, then run this ' 'script again to complete the deployment. For details, ' 'visit the indexes page. Exiting.')