8000 bigtable: fix hardcoded admin test integration target by igorbernstein2 · Pull Request #3471 · googleapis/google-cloud-java · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.threeten.bp.Duration;
import com.google.bigtable.admin.v2.InstanceName;
import com.google.bigtable.admin.v2.TableName;
import com.google.cloud.bigtable.admin.v2.TableAdminClient;
Expand All @@ -39,22 +33,52 @@
import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.ConsistencyToken;
import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.Table;
import com.google.protobuf.ByteString;
import java.io.IOException;
import java.util.List;
import org.junit.AfterClass;
import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.threeten.bp.Duration;

public class TableAdminClientIT {
// TODO(igorbernstein2): remove these properties once admin is split from data client
private static final String ENV_PROPERTY = "bigtable.env";
private static final String TABLE_PROPERTY_NAME = "bigtable.table";

static TableAdminClient tableAdmin;

@BeforeClass
public static void createClient() throws IOException {
tableAdmin = TableAdminClient.create(InstanceName.of("sduskis-hello-shakespear", "beam-test"));
if (!"prod".equals(System.getProperty(ENV_PROPERTY))) {
tableAdmin = null;
return;
}

TableName tableName = TableName.parse(System.getProperty(TABLE_PROPERTY_NAME));
InstanceName instanceName = InstanceName.of(tableName.getProject(), tableName.getInstance());

tableAdmin = TableAdminClient.create(instanceName);
}

@AfterClass
public static void closeClient() throws Exception {
tableAdmin.close();
public static void closeClient() {
if (tableAdmin != null) {
tableAdmin.close();
}
}

@Before
public void setup() {
// TODO(igorbernstein2): remove this check once admin is split
if (tableAdmin == null) {
throw new AssumptionViolatedException("Tests can only run against prod environment");
}
}

@Test
public void createTable() throws Exception {
public void createTable() {
String tableId = "adminCreateTest";
CreateTable createTableReq =
TableAdminRequests.createTable(tableId)
Expand Down Expand Up @@ -83,7 +107,7 @@ public void createTable() throws Exception {
public void modifyFamilies() {
String tableId = "adminModifyFamTest";
ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId);
Duration.ofSeconds(1000);

modifyFamiliesReq
.addFamily("mf1")
.addFamily("mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
Expand Down
0