<commit_before>/*
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.spanner.it;

import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;

import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.Page;
import com.google.cloud.spanner.Database;
import com.google.cloud.spanner.DatabaseAdminClient;
import com.google.cloud.spanner.DatabaseClient;
import com.google.cloud.spanner.DatabaseId;
import com.google.cloud.spanner.ErrorCode;
import com.google.cloud.spanner.IntegrationTestEnv;
import com.google.cloud.spanner.ParallelIntegrationTest;
import com.google.cloud.spanner.ResultSet;
import com.google.cloud.spanner.SpannerException;
import com.google.cloud.spanner.Statement;
import com.google.cloud.spanner.testing.RemoteSpannerHelper;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.threeten.bp.Duration;

@Category(ParallelIntegrationTest.class)
@RunWith(JUnit4.class)
public class ITPitrUpdateDatabaseTest {

  private static final Duration OPERATION_TIMEOUT = Duration.ofMinutes(2);
  private static final String VERSION_RETENTION_PERIOD = "7d";

  @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
  private static DatabaseAdminClient dbAdminClient;
  private static DatabaseClient dbClient;
  private static String instanceId;
  private static String databaseId;
  private static UpdateDatabaseDdlMetadata metadata;

  @BeforeClass
  public static void setUp() throws Exception {
    assumeFalse("PITR-lite features are not supported by the emulator", isUsingEmulator());

    final RemoteSpannerHelper testHelper = env.getTestHelper();
    final String projectId = testHelper.getOptions().getProjectId();
    instanceId = testHelper.getInstanceId().getInstance();
    databaseId = testHelper.getUniqueDatabaseId();
    dbAdminClient = testHelper.getClient().getDatabaseAdminClient();

    createDatabase(dbAdminClient, instanceId, databaseId, Collections.emptyList());
    metadata =
        updateVersionRetentionPeriod(
            dbAdminClient, instanceId, databaseId, VERSION_RETENTION_PERIOD);

    dbClient =
        testHelper.getClient().getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));<commit_msg>test: increase operation timeout to prevent flaky failures (#1195)<commit_after>/*
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.spanner.it;

import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;

import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.Page;
import com.google.cloud.spanner.Database;
import com.google.cloud.spanner.DatabaseAdminClient;
import com.google.cloud.spanner.DatabaseClient;
import com.google.cloud.spanner.DatabaseId;
import com.google.cloud.spanner.ErrorCode;
import com.google.cloud.spanner.IntegrationTestEnv;
import com.google.cloud.spanner.ParallelIntegrationTest;
import com.google.cloud.spanner.ResultSet;
import com.google.cloud.spanner.SpannerException;
import com.google.cloud.spanner.Statement;
import com.google.cloud.spanner.testing.RemoteSpannerHelper;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.threeten.bp.Duration;

@Category(ParallelIntegrationTest.class)
@RunWith(JUnit4.class)
public class ITPitrUpdateDatabaseTest {

  private static final Duration OPERATION_TIMEOUT = Duration.ofMinutes(5);
  private static final String VERSION_RETENTION_PERIOD = "7d";

  @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
  private static DatabaseAdminClient dbAdminClient;
  private static DatabaseClient dbClient;
  private static String instanceId;
  private static String databaseId;
  private static UpdateDatabaseDdlMetadata metadata;

  @BeforeClass
  public static void setUp() throws Exception {
    assumeFalse("PITR-lite features are not supported by the emulator", isUsingEmulator());

    final RemoteSpannerHelper testHelper = env.getTestHelper();
    final String projectId = testHelper.getOptions().getProjectId();
    instanceId = testHelper.getInstanceId().getInstance();
    databaseId = testHelper.getUniqueDatabaseId();
    dbAdminClient = testHelper.getClient().getDatabaseAdminClient();

    createDatabase(dbAdminClient, instanceId, databaseId, Collections.emptyList());
    metadata =
        updateVersionRetentionPeriod(
            dbAdminClient, instanceId, databaseId, VERSION_RETENTION_PERIOD);

    dbClient =
        testHelper.getClient().getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));
{'fraction_non_alphanumeric': 0.08770603357024044, 'fraction_numerical': 0.004536518977771057, 'mean_word_length': 5.37801350048216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2375703', 'n_tokens_mistral': 1847, 'n_tokens_neox': 1820, 'n_words': 477}