Skip to content

Commit

Permalink
separate properties for bigtable.project and bigtable.instance (#4346)
Browse files Browse the repository at this point in the history
  • Loading branch information
elisheva-qlogic authored and igorbernstein2 committed Jan 16, 2019
1 parent 8ce9aef commit 821bf93
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.junit.Assert.assertTrue;

import com.google.api.gax.rpc.NotFoundException;
import com.google.bigtable.admin.v2.InstanceName;
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient;
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminSettings;
import com.google.cloud.bigtable.admin.v2.models.Cluster;
Expand All @@ -42,25 +41,24 @@
/** Integration tests for {@link InstanceAdminExample} */
public class ITInstanceAdminExample {

private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance";
private static final String PROJECT_PROPERTY_NAME = "bigtable.project";
private static final String ID_PREFIX = "instanceadmin";
private static final String CLUSTER = "cluster";
private static String projectName;
private static String projectId;
private static BigtableInstanceAdminClient adminClient;
private String clusterId;
private String instanceId;
private InstanceAdminExample instanceAdmin;

@BeforeClass
public static void beforeClass() throws IOException {
String targetProject = System.getProperty(INSTANCE_PROPERTY_NAME);
if (targetProject == null) {
projectId = System.getProperty(PROJECT_PROPERTY_NAME);
if (projectId == null) {
adminClient = null;
return;
}
projectName = InstanceName.parse(targetProject).getProject();
BigtableInstanceAdminSettings instanceAdminSettings =
BigtableInstanceAdminSettings.newBuilder().setProjectId(projectName).build();
BigtableInstanceAdminSettings.newBuilder().setProjectId(projectId).build();
adminClient = BigtableInstanceAdminClient.create(instanceAdminSettings);
}

Expand All @@ -74,11 +72,11 @@ public static void afterClass() {
public void setup() throws IOException {
if (adminClient == null) {
throw new AssumptionViolatedException(
INSTANCE_PROPERTY_NAME + " property is not set, skipping integration tests.");
PROJECT_PROPERTY_NAME + " property is not set, skipping integration tests.");
}
instanceId = generateId();
clusterId = generateId();
instanceAdmin = new InstanceAdminExample(projectName, instanceId, clusterId);
instanceAdmin = new InstanceAdminExample(projectId, instanceId, clusterId);
adminClient.createInstance(
CreateInstanceRequest.of(instanceId)
.addCluster(clusterId, "us-central1-f", 3, StorageType.SSD)
Expand All @@ -99,7 +97,7 @@ public void testCreateAndDeleteInstance() throws IOException {
String testInstance = generateId();
String testCluster = generateId();
InstanceAdminExample testInstanceAdmin =
new InstanceAdminExample(projectName, testInstance, testCluster);
new InstanceAdminExample(projectId, testInstance, testCluster);
testInstanceAdmin.createProdInstance();
assertTrue(adminClient.exists(testInstance));

Expand Down

0 comments on commit 821bf93

Please sign in to comment.