Skip to content

Commit 203d74b

Browse files
bigtable: fix hardcoded admin test integration target (#3471)
1 parent d57efcf commit 203d74b

File tree

1 file changed

+35
-11
lines changed
  • google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it

1 file changed

+35
-11
lines changed

google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
import static org.junit.Assert.assertFalse;
2121
import static org.junit.Assert.assertNotNull;
2222
import static org.junit.Assert.assertTrue;
23-
import java.io.IOException;
24-
import java.util.List;
25-
import org.junit.AfterClass;
26-
import org.junit.BeforeClass;
27-
import org.junit.Test;
28-
import org.threeten.bp.Duration;
2923
import com.google.bigtable.admin.v2.InstanceName;
3024
import com.google.bigtable.admin.v2.TableName;
3125
import com.google.cloud.bigtable.admin.v2.TableAdminClient;
@@ -39,22 +33,52 @@
3933
import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.ConsistencyToken;
4034
import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.Table;
4135
import com.google.protobuf.ByteString;
36+
import java.io.IOException;
37+
import java.util.List;
38+
import org.junit.AfterClass;
39+
import org.junit.AssumptionViolatedException;
40+
import org.junit.Before;
41+
import org.junit.BeforeClass;
42+
import org.junit.Test;
43+
import org.threeten.bp.Duration;
4244

4345
public class TableAdminClientIT {
46+
// TODO(igorbernstein2): remove these properties once admin is split from data client
47+
private static final String ENV_PROPERTY = "bigtable.env";
48+
private static final String TABLE_PROPERTY_NAME = "bigtable.table";
49+
4450
static TableAdminClient tableAdmin;
4551

4652
@BeforeClass
4753
public static void createClient() throws IOException {
48-
tableAdmin = TableAdminClient.create(InstanceName.of("sduskis-hello-shakespear", "beam-test"));
54+
if (!"prod".equals(System.getProperty(ENV_PROPERTY))) {
55+
tableAdmin = null;
56+
return;
57+
}
58+
59+
TableName tableName = TableName.parse(System.getProperty(TABLE_PROPERTY_NAME));
60+
InstanceName instanceName = InstanceName.of(tableName.getProject(), tableName.getInstance());
61+
62+
tableAdmin = TableAdminClient.create(instanceName);
4963
}
5064

5165
@AfterClass
52-
public static void closeClient() throws Exception {
53-
tableAdmin.close();
66+
public static void closeClient() {
67+
if (tableAdmin != null) {
68+
tableAdmin.close();
69+
}
70+
}
71+
72+
@Before
73+
public void setup() {
74+
// TODO(igorbernstein2): remove this check once admin is split
75+
if (tableAdmin == null) {
76+
throw new AssumptionViolatedException("Tests can only run against prod environment");
77+
}
5478
}
5579

5680
@Test
57-
public void createTable() throws Exception {
81+
public void createTable() {
5882
String tableId = "adminCreateTest";
5983
CreateTable createTableReq =
6084
TableAdminRequests.createTable(tableId)
@@ -83,7 +107,7 @@ public void createTable() throws Exception {
83107
public void modifyFamilies() {
84108
String tableId = "adminModifyFamTest";
85109
ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId);
86-
Duration.ofSeconds(1000);
110+
87111
modifyFamiliesReq
88112
.addFamily("mf1")
89113
.addFamily("mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))

0 commit comments

Comments
 (0)