Beispiel #1
0
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)
Beispiel #2
0
    def test_update_indexes_with_missing_indexes_file(self):
        def mock_isfile(unused_path):
            return False

        isfile_swap = self.swap(os.path, 'isfile', mock_isfile)
        with isfile_swap, self.assertRaises(AssertionError):
            gcloud_adapter.update_indexes('yaml path', 'app name')
Beispiel #3
0
    def test_update_indexes_with_available_indexes_file(self):
        def mock_isfile(unused_path):
            return True

        isfile_swap = self.swap(os.path, 'isfile', mock_isfile)
        with isfile_swap, self.check_output_swap:
            gcloud_adapter.update_indexes('yaml path', 'app name')
        self.assertEqual(self.check_function_calls,
                         self.expected_check_function_calls)
Beispiel #4
0
def update_indexes():
    """Updates production indexes after doing the prerequisite checks."""
    parsed_args = _PARSER.parse_args()
    if parsed_args.app_name:
        app_name = parsed_args.app_name
    else:
        raise Exception('No app name specified.')

    # Do prerequisite checks.
    common.require_cwd_to_be_oppia()
    gcloud_adapter.require_gcloud_to_be_available()
    if not common.is_current_branch_a_release_branch():
        raise Exception(
            'Indexes should only be updated from a release branch.')

    # Update the indexes.
    gcloud_adapter.update_indexes(INDEX_YAML_PATH, app_name)
Beispiel #5
0
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.')