BigtableHBaseClassicSettings extends BigtableHBaseSettings { public BigtableOptions getBigtableOptions() { return bigtableOptions; } BigtableHBaseClassicSettings(Configuration configuration); @Override String getDataHost(); @Override String getAdminHost(); @Override int getPort(); @Override int getBulkMaxRowCount(); @Override long getBatchingMaxRequestSize(); @Override boolean isRetriesWithoutTimestampAllowed(); BigtableOptions getBigtableOptions();  }
@Test public void testDefaultRetryOptions() throws IOException { BigtableOptions options = ((BigtableHBaseClassicSettings) BigtableHBaseSettings.create(configuration)) .getBigtableOptions(); RetryOptions retryOptions = options.getRetryOptions(); assertEquals(RetryOptions.DEFAULT_ENABLE_GRPC_RETRIES, retryOptions.enableRetries()); assertEquals( RetryOptions.DEFAULT_MAX_ELAPSED_BACKOFF_MILLIS, retryOptions.getMaxElapsedBackoffMillis()); assertEquals( RetryOptions.DEFAULT_READ_PARTIAL_ROW_TIMEOUT_MS, retryOptions.getReadPartialRowTimeoutMillis()); assertEquals( RetryOptions.DEFAULT_MAX_SCAN_TIMEOUT_RETRIES, retryOptions.getMaxScanTimeoutRetries()); }
@Test public void testSettingRetryOptions() throws IOException { configuration.set(BigtableOptionsFactory.ENABLE_GRPC_RETRIES_KEY, "false"); configuration.set(BigtableOptionsFactory.ENABLE_GRPC_RETRY_DEADLINEEXCEEDED_KEY, "false"); configuration.set(BigtableOptionsFactory.MAX_ELAPSED_BACKOFF_MILLIS_KEY, "111"); configuration.set(BigtableOptionsFactory.READ_PARTIAL_ROW_TIMEOUT_MS, "123"); BigtableOptions options = ((BigtableHBaseClassicSettings) BigtableHBaseSettings.create(configuration)) .getBigtableOptions(); RetryOptions retryOptions = options.getRetryOptions(); assertFalse(retryOptions.enableRetries()); assertFalse(retryOptions.retryOnDeadlineExceeded()); assertEquals(111, retryOptions.getMaxElapsedBackoffMillis()); assertEquals(123, retryOptions.getReadPartialRowTimeoutMillis()); }
@Test public void testExplicitCredentials() throws IOException, GeneralSecurityException { Credentials credentials = Mockito.mock(Credentials.class); configuration = new Configuration(false); configuration.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, TEST_HOST); configuration.set(BigtableOptionsFactory.PROJECT_ID_KEY, TEST_PROJECT_ID); configuration.set(BigtableOptionsFactory.INSTANCE_ID_KEY, TEST_INSTANCE_ID); configuration = BigtableConfiguration.withCredentials(configuration, credentials); BigtableOptions options = ((BigtableHBaseClassicSettings) BigtableHBaseSettings.create(configuration)) .getBigtableOptions(); Credentials actualCreds = CredentialFactory.getCredentials(options.getCredentialOptions()); Assert.assertSame(credentials, actualCreds); }