<commit_before>package com.google.cloud.hadoop.gcsio.integration;

import static com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.assertByteArrayEquals;
import static com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.assertObjectContent;
import static com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.writeObject;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

import com.google.cloud.hadoop.gcsio.GoogleCloudStorage;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageItemInfo;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions.MetricsSink;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions.Fadvise;
import com.google.cloud.hadoop.gcsio.StorageResourceId;
import com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.TestBucketHelper;
import com.google.cloud.hadoop.util.AsyncWriteChannelOptions;
import com.google.common.flogger.GoogleLogger;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SeekableByteChannel;
import java.util.Arrays;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class GoogleCloudStorageGrpcIntegrationTest {

  private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

  // Prefix this name with the prefix used in other gcs io integrate tests once it's whitelisted by
  // GCS to access gRPC API.
  private static final String BUCKET_NAME_PREFIX = "gcs-grpc-team";

  private static final TestBucketHelper BUCKET_HELPER = new TestBucketHelper(BUCKET_NAME_PREFIX);

  private static final String BUCKET_NAME = BUCKET_HELPER.getUniqueBucketName("shared");

  private final boolean tdEnabled;

  @Parameters
  // We want to test this entire class with both gRPC-LB and Traffic Director
  public static Iterable<Boolean> tdEnabled() {
    return Arrays.asList(false, true);
  }

  public GoogleCloudStorageGrpcIntegrationTest(boolean tdEnabled) {
    this.tdEnabled = tdEnabled;
  }

  private static GoogleCloudStorageOptions.Builder configureDefaultOptions() {
    GoogleCloudStorageOptions.Builder optionsBuilder =
        GoogleCloudStorageTestHelper.getStandardOptionBuilder().setGrpcEnabled(true);
    String grpcServerAddress = System.getenv("GCS_TEST_GRPC_SERVER_ADDRESS_OVERRIDE");
    if (grpcServerAddress != null) {
      optionsBuilder.setGrpcServerAddress(grpcServerAddress);
      logger.atInfo().log("Overriding gRPC server address to %s", grpcServerAddress);
    }
    return optionsBuilder;
  }<commit_msg>Add env config for integ test to only run with TD enabled (#767)<commit_after>package com.google.cloud.hadoop.gcsio.integration;

import static com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.assertByteArrayEquals;
import static com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.assertObjectContent;
import static com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.writeObject;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

import com.google.cloud.hadoop.gcsio.GoogleCloudStorage;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageItemInfo;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions.MetricsSink;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions.Fadvise;
import com.google.cloud.hadoop.gcsio.StorageResourceId;
import com.google.cloud.hadoop.gcsio.integration.GoogleCloudStorageTestHelper.TestBucketHelper;
import com.google.cloud.hadoop.util.AsyncWriteChannelOptions;
import com.google.common.flogger.GoogleLogger;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SeekableByteChannel;
import java.util.Arrays;
import java.util.List;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class GoogleCloudStorageGrpcIntegrationTest {

  private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

  // Prefix this name with the prefix used in other gcs io integrate tests once it's whitelisted by
  // GCS to access gRPC API.
  private static final String BUCKET_NAME_PREFIX = "gcs-grpc-team";

  private static final TestBucketHelper BUCKET_HELPER = new TestBucketHelper(BUCKET_NAME_PREFIX);

  private static final String BUCKET_NAME = BUCKET_HELPER.getUniqueBucketName("shared");

  private final boolean tdEnabled;

  @Parameters
  // We want to test this entire class with both gRPC-LB and Traffic Director
  // Some of our internal endpoints only work with TD
  public static Iterable<Boolean> tdEnabled() {
    return Boolean.parseBoolean(System.getenv("GCS_TEST_ONLY_RUN_WITH_TD_ENABLED"))
        ? List.of(true)
        : List.of(false, true);
  }

  public GoogleCloudStorageGrpcIntegrationTest(boolean tdEnabled) {
    this.tdEnabled = tdEnabled;
  }

  private static GoogleCloudStorageOptions.Builder configureDefaultOptions() {
    GoogleCloudStorageOptions.Builder optionsBuilder =
        GoogleCloudStorageTestHelper.getStandardOptionBuilder().setGrpcEnabled(true);
    String grpcServerAddress = System.getenv("GCS_TEST_GRPC_SERVER_ADDRESS_OVERRIDE");
    if (grpcServerAddress != null) {
      optionsBuilder.setGrpcServerAddress(grpcServerAddress);
      logger.atInfo().log("Overriding gRPC server address to %s", grpcServerAddress);
    }
    return optionsBuilder;
  }
{'fraction_non_alphanumeric': 0.08373316824021049, 'fraction_numerical': 0.0004643244079863798, 'mean_word_length': 6.070021881838074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4945934', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1834, 'n_words': 367}