Skip to content

Commit 4d17ea1

Browse files
committed
Minor fixes to RemoteBigQueryHelper
- Remove RemoteBigQueryHelper.create(String, String) - Add javadoc to RemoteBigQueryHelper to document retry options - Add global timeout of 5minutes to each of the BigQuery ITs - Remove print from BigQueryImplTest and other nits
1 parent ba8acf1 commit 4d17ea1

File tree

4 files changed

+13
-44
lines changed

4 files changed

+13
-44
lines changed

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/testing/RemoteBigQueryHelper.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@
3131
import java.util.logging.Logger;
3232

3333
/**
34-
* Utility to create a remote BigQuery configuration for testing.
34+
* Utility to create a remote BigQuery configuration for testing. BigQuery options can be obtained
35+
* via the {@link #options()} method. Returned options have custom
36+
* {@link BigQueryOptions#retryParams()}: {@link RetryParams#retryMaxAttempts()} is {@code 10},
37+
* {@link RetryParams#retryMinAttempts()} is {@code 6}, {@link RetryParams#maxRetryDelayMillis()} is
38+
* {@code 30000}, {@link RetryParams#totalRetryPeriodMillis()} is {@code 120000} and
39+
* {@link RetryParams#initialRetryDelayMillis()} is {@code 250}.
40+
* {@link BigQueryOptions#connectTimeout()} and {@link BigQueryOptions#readTimeout()} are both set
41+
* to {@code 60000}.
3542
*/
3643
public class RemoteBigQueryHelper {
3744

@@ -97,27 +104,6 @@ public static RemoteBigQueryHelper create(String projectId, InputStream keyStrea
97104
}
98105
}
99106

100-
/**
101-
* Creates a {@code RemoteBigQueryHelper} object for the given project id and JSON key path.
102-
*
103-
* @param projectId id of the project to be used for running the tests
104-
* @param keyPath path to the JSON key to be used for running the tests
105-
* @return A {@code RemoteBigQueryHelper} object for the provided options.
106-
* @throws BigQueryHelperException if the file pointed by {@code keyPath} does not exist
107-
*/
108-
public static RemoteBigQueryHelper create(String projectId, String keyPath)
109-
throws BigQueryHelperException {
110-
try {
111-
InputStream keyFileStream = new FileInputStream(keyPath);
112-
return create(projectId, keyFileStream);
113-
} catch (FileNotFoundException ex) {
114-
if (log.isLoggable(Level.WARNING)) {
115-
log.log(Level.WARNING, ex.getMessage());
116-
}
117-
throw BigQueryHelperException.translate(ex);
118-
}
119-
}
120-
121107
/**
122108
* Creates a {@code RemoteBigQueryHelper} object using default project id and authentication
123109
* credentials.

gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ public Job apply(JobInfo jobInfo) {
859859
assertEquals(cursor, page.nextPageCursor());
860860
assertArrayEquals(jobList.toArray(), Iterables.toArray(page.values(), JobInfo.class));
861861
String selector = (String) capturedOptions.getValue().get(JOB_OPTION_FIELDS.rpcOption());
862-
System.out.println(selector);
863862
assertTrue(selector.contains("etag,jobs("));
864863
assertTrue(selector.contains("configuration"));
865864
assertTrue(selector.contains("jobReference"));

gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/ITBigQueryTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737

3838
import org.junit.AfterClass;
3939
import org.junit.BeforeClass;
40+
import org.junit.Rule;
4041
import org.junit.Test;
42+
import org.junit.rules.Timeout;
4143

4244
import java.io.IOException;
4345
import java.nio.charset.StandardCharsets;
@@ -128,6 +130,9 @@ public class ITBigQueryTest {
128130
private static BigQuery bigquery;
129131
private static Storage storage;
130132

133+
@Rule
134+
public Timeout globalTimeout = Timeout.seconds(300);
135+
131136
@BeforeClass
132137
public static void beforeClass() throws IOException, InterruptedException {
133138
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
@@ -732,7 +737,6 @@ public void testQueryJob() throws InterruptedException {
732737
assertTrue(bigquery.delete(DATASET, tableName));
733738
}
734739

735-
736740
@Test
737741
public void testExtract() throws InterruptedException {
738742
String tableName = "test_export_job_table";

gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/RemoteBigQueryHelperTest.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@
2323
import com.google.gcloud.bigquery.testing.RemoteBigQueryHelper;
2424

2525
import org.easymock.EasyMock;
26-
import org.junit.BeforeClass;
2726
import org.junit.Rule;
2827
import org.junit.Test;
2928
import org.junit.rules.ExpectedException;
3029

3130
import java.io.ByteArrayInputStream;
3231
import java.io.InputStream;
33-
import java.nio.file.Files;
34-
import java.nio.file.Paths;
35-
import java.util.UUID;
3632
import java.util.concurrent.ExecutionException;
3733

3834
public class RemoteBigQueryHelperTest {
@@ -66,18 +62,9 @@ public class RemoteBigQueryHelperTest {
6662
+ " \"type\": \"service_account\"\n"
6763
+ "}";
6864
private static final InputStream JSON_KEY_STREAM = new ByteArrayInputStream(JSON_KEY.getBytes());
69-
private static String keyPath = "/does/not/exist/key." + UUID.randomUUID().toString() + ".json";
7065

7166
@Rule
7267
public ExpectedException thrown = ExpectedException.none();
73-
74-
@BeforeClass
75-
public static void beforeClass() {
76-
while (Files.exists(Paths.get(JSON_KEY))) {
77-
keyPath = "/does/not/exist/key." + UUID.randomUUID().toString() + ".json";
78-
}
79-
}
80-
8168
@Test
8269
public void testForceDelete() throws InterruptedException, ExecutionException {
8370
BigQuery bigqueryMock = EasyMock.createMock(BigQuery.class);
@@ -101,11 +88,4 @@ public void testCreateFromStream() {
10188
assertEquals(120000, options.retryParams().totalRetryPeriodMillis());
10289
assertEquals(250, options.retryParams().initialRetryDelayMillis());
10390
}
104-
105-
@Test
106-
public void testCreateNoKey() {
107-
thrown.expect(RemoteBigQueryHelper.BigQueryHelperException.class);
108-
thrown.expectMessage(keyPath + " (No such file or directory)");
109-
RemoteBigQueryHelper.create(PROJECT_ID, keyPath);
110-
}
11191
}

0 commit comments

Comments
 (0)