Skip to content

Commit 821bf93

Browse files
elisheva-qlogicigorbernstein2
authored andcommitted
separate properties for bigtable.project and bigtable.instance (#4346)
1 parent 8ce9aef commit 821bf93

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

google-cloud-examples/src/test/java/com/google/cloud/examples/bigtable/ITInstanceAdminExample.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.junit.Assert.assertTrue;
2121

2222
import com.google.api.gax.rpc.NotFoundException;
23-
import com.google.bigtable.admin.v2.InstanceName;
2423
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient;
2524
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminSettings;
2625
import com.google.cloud.bigtable.admin.v2.models.Cluster;
@@ -42,25 +41,24 @@
4241
/** Integration tests for {@link InstanceAdminExample} */
4342
public class ITInstanceAdminExample {
4443

45-
private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance";
44+
private static final String PROJECT_PROPERTY_NAME = "bigtable.project";
4645
private static final String ID_PREFIX = "instanceadmin";
4746
private static final String CLUSTER = "cluster";
48-
private static String projectName;
47+
private static String projectId;
4948
private static BigtableInstanceAdminClient adminClient;
5049
private String clusterId;
5150
private String instanceId;
5251
private InstanceAdminExample instanceAdmin;
5352

5453
@BeforeClass
5554
public static void beforeClass() throws IOException {
56-
String targetProject = System.getProperty(INSTANCE_PROPERTY_NAME);
57-
if (targetProject == null) {
55+
projectId = System.getProperty(PROJECT_PROPERTY_NAME);
56+
if (projectId == null) {
5857
adminClient = null;
5958
return;
6059
}
61-
projectName = InstanceName.parse(targetProject).getProject();
6260
BigtableInstanceAdminSettings instanceAdminSettings =
63-
BigtableInstanceAdminSettings.newBuilder().setProjectId(projectName).build();
61+
BigtableInstanceAdminSettings.newBuilder().setProjectId(projectId).build();
6462
adminClient = BigtableInstanceAdminClient.create(instanceAdminSettings);
6563
}
6664

@@ -74,11 +72,11 @@ public static void afterClass() {
7472
public void setup() throws IOException {
7573
if (adminClient == null) {
7674
throw new AssumptionViolatedException(
77-
INSTANCE_PROPERTY_NAME + " property is not set, skipping integration tests.");
75+
PROJECT_PROPERTY_NAME + " property is not set, skipping integration tests.");
7876
}
7977
instanceId = generateId();
8078
clusterId = generateId();
81-
instanceAdmin = new InstanceAdminExample(projectName, instanceId, clusterId);
79+
instanceAdmin = new InstanceAdminExample(projectId, instanceId, clusterId);
8280
adminClient.createInstance(
8381
CreateInstanceRequest.of(instanceId)
8482
.addCluster(clusterId, "us-central1-f", 3, StorageType.SSD)
@@ -99,7 +97,7 @@ public void testCreateAndDeleteInstance() throws IOException {
9997
String testInstance = generateId();
10098
String testCluster = generateId();
10199
InstanceAdminExample testInstanceAdmin =
102-
new InstanceAdminExample(projectName, testInstance, testCluster);
100+
new InstanceAdminExample(projectId, testInstance, testCluster);
103101
testInstanceAdmin.createProdInstance();
104102
assertTrue(adminClient.exists(testInstance));
105103

0 commit comments

Comments
 (0)