Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit e859f3b

Browse files
chore: merge main into generate-libraries-main
2 parents 886f0b8 + 1bfb763 commit e859f3b

6 files changed

Lines changed: 61 additions & 11 deletions

File tree

google-cloud-bigtable/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@
204204
<groupId>io.grpc</groupId>
205205
<artifactId>grpc-netty-shaded</artifactId>
206206
</dependency>
207+
<dependency>
208+
<groupId>io.grpc</groupId>
209+
<artifactId>grpc-alts</artifactId>
210+
</dependency>
207211
<dependency>
208212
<groupId>io.grpc</groupId>
209213
<artifactId>grpc-protobuf</artifactId>

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,8 +2091,7 @@ public List<String> apply(List<com.google.bigtable.admin.v2.SchemaBundle> protos
20912091
}
20922092

20932093
/**
2094-
* Deletes an schema bundle with the specified schema bundle ID in the specified table. Note that
2095-
* the deletion is prohibited if the schema bundle has deletion_protection field set to true.
2094+
* Deletes an schema bundle with the specified schema bundle ID in the specified table.
20962095
*
20972096
* <p>Sample code:
20982097
*
@@ -2106,8 +2105,7 @@ public void deleteSchemaBundle(String tableId, String schemaBundleId) {
21062105

21072106
/**
21082107
* Asynchronously deletes an schema bundle with the specified schema bundle ID in the specified
2109-
* table. Note that the deletion is prohibited if the schema bundle has deletion_protection field
2110-
* set to true.
2108+
* table.
21112109
*
21122110
* <p>Sample code:
21132111
*

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateSchemaBundleRequest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ public CreateSchemaBundleRequest setProtoSchemaFile(@Nonnull String protoSchemaF
6868
}
6969

7070
/** Sets the proto schema for this schema bundle. */
71-
public CreateSchemaBundleRequest setProtoSchema(@Nonnull ByteString protoSchema)
72-
throws IOException {
71+
public CreateSchemaBundleRequest setProtoSchema(@Nonnull ByteString protoSchema) {
7372
Preconditions.checkNotNull(protoSchema, "protoSchema must be set");
7473
requestBuilder.setSchemaBundle(
7574
com.google.bigtable.admin.v2.SchemaBundle.newBuilder()

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/grpc/BigtableChannelPool.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.grpc.Metadata;
3131
import io.grpc.MethodDescriptor;
3232
import io.grpc.Status;
33+
import io.grpc.alts.AltsContextUtil;
3334
import java.io.IOException;
3435
import java.time.Clock;
3536
import java.util.ArrayList;
@@ -565,9 +566,8 @@ static class Entry implements BigtableChannelObserver {
565566
}
566567

567568
void checkAndSetIsAlts(ClientCall<?, ?> call) {
568-
// TODO(populate ALTS holder)
569-
boolean result = false;
570-
isAltsHolder.compareAndSet(null, result);
569+
boolean currentIsAlts = AltsContextUtil.check(call);
570+
isAltsHolder.set(currentIsAlts);
571571
}
572572

573573
ManagedChannel getManagedChannel() {

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/ExecuteQueryIT.java

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

2222
import com.google.cloud.Date;
23+
import com.google.cloud.bigtable.admin.v2.models.CreateSchemaBundleRequest;
2324
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
2425
import com.google.cloud.bigtable.data.v2.models.RowMutation;
2526
import com.google.cloud.bigtable.data.v2.models.TableId;
@@ -28,10 +29,14 @@
2829
import com.google.cloud.bigtable.data.v2.models.sql.ResultSet;
2930
import com.google.cloud.bigtable.data.v2.models.sql.SqlType;
3031
import com.google.cloud.bigtable.data.v2.models.sql.Struct;
32+
import com.google.cloud.bigtable.data.v2.test.AlbumProto.Album;
33+
import com.google.cloud.bigtable.data.v2.test.SingerProto.Genre;
34+
import com.google.cloud.bigtable.data.v2.test.SingerProto.Singer;
3135
import com.google.cloud.bigtable.test_helpers.env.AbstractTestEnv;
3236
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv;
3337
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule;
3438
import com.google.protobuf.ByteString;
39+
import com.google.protobuf.DescriptorProtos.FileDescriptorSet;
3540
import java.io.IOException;
3641
import java.time.Instant;
3742
import java.util.Arrays;
@@ -48,6 +53,8 @@
4853
@RunWith(JUnit4.class)
4954
public class ExecuteQueryIT {
5055

56+
public static String SCHEMA_BUNDLE_ID = "my_bundle";
57+
5158
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule();
5259
private static BigtableDataClient dataClient;
5360
private static String tableId;
@@ -155,14 +162,21 @@ public void withHistoryQuery() {
155162
@SuppressWarnings("DoubleBraceInitialization")
156163
@Test
157164
public void allTypes() {
165+
createTestSchemaBundle();
166+
Album album = Album.newBuilder().setTitle("Lover").build();
158167
PreparedStatement preparedStatement =
159168
dataClient.prepareStatement(
160169
"SELECT 'stringVal' AS strCol, b'foo' as bytesCol, 1 AS intCol, CAST(1.2 AS FLOAT32) as"
161170
+ " f32Col, CAST(1.3 AS FLOAT64) as f64Col, true as boolCol,"
162171
+ " TIMESTAMP_FROM_UNIX_MILLIS(1000) AS tsCol, DATE(2024, 06, 01) as dateCol,"
163172
+ " STRUCT(1 as a, \"foo\" as b) AS structCol, [1,2,3] AS arrCol, "
164173
+ cf
165-
+ " as mapCol FROM `"
174+
+ " as mapCol, "
175+
+ " CAST(b'\022\005Lover' AS "
176+
+ SCHEMA_BUNDLE_ID
177+
+ ".com.google.cloud.bigtable.data.v2.test.Album) as protoCol, CAST('JAZZ' AS "
178+
+ SCHEMA_BUNDLE_ID
179+
+ ".com.google.cloud.bigtable.data.v2.test.Genre) as enumCol FROM `"
166180
+ tableId
167181
+ "` WHERE _key='"
168182
+ uniquePrefix
@@ -213,9 +227,13 @@ public void allTypes() {
213227
put(ByteString.copyFromUtf8("qual3"), ByteString.copyFromUtf8("val3"));
214228
}
215229
});
216-
230+
assertThat(rs.getProtoMessage("protoCol", Album.getDefaultInstance())).isEqualTo(album);
231+
assertThat(rs.getProtoMessage(11, Album.getDefaultInstance())).isEqualTo(album);
232+
assertThat(rs.getProtoEnum("enumCol", Genre::forNumber)).isEqualTo(Genre.JAZZ);
233+
assertThat(rs.getProtoEnum(12, Genre::forNumber)).isEqualTo(Genre.JAZZ);
217234
assertThat(rs.next()).isFalse();
218235
}
236+
deleteTestSchemaBundle();
219237
}
220238

221239
@Test
@@ -380,4 +398,20 @@ public void testNullColumns() {
380398
assertThat(rs.next()).isFalse();
381399
}
382400
}
401+
402+
private static void deleteTestSchemaBundle() {
403+
testEnvRule.env().getTableAdminClient().deleteSchemaBundle(tableId, SCHEMA_BUNDLE_ID);
404+
}
405+
406+
private static void createTestSchemaBundle() {
407+
FileDescriptorSet fileDescriptorSet =
408+
FileDescriptorSet.newBuilder()
409+
.addFile(Singer.getDescriptor().getFile().toProto())
410+
.addFile(Album.getDescriptor().getFile().toProto())
411+
.build();
412+
CreateSchemaBundleRequest request =
413+
CreateSchemaBundleRequest.of(tableId, SCHEMA_BUNDLE_ID)
414+
.setProtoSchema(fileDescriptorSet.toByteString());
415+
testEnvRule.env().getTableAdminClient().createSchemaBundle(request);
416+
}
383417
}

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/gaxx/grpc/BigtableChannelPoolTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.google.api.gax.grpc.ChannelFactory;
2323
import com.google.common.collect.Iterables;
24+
import io.grpc.Attributes;
2425
import io.grpc.CallOptions;
2526
import io.grpc.ClientCall;
2627
import io.grpc.ManagedChannel;
@@ -112,6 +113,8 @@ public void setUp() throws IOException {
112113
// Capture the listener when start is called
113114
// Configure mockClientCall.start to capture the listener
114115
doNothing().when(mockClientCall).start(listenerCaptor.capture(), any(Metadata.class));
116+
// Default to no ALTS context
117+
when(mockClientCall.getAttributes()).thenReturn(Attributes.EMPTY);
115118
}
116119

117120
private BigtableChannelPool.Entry getSingleEntry() {
@@ -233,4 +236,16 @@ public void testMixedRpcs() {
233236
assertThat(entry.getAndResetErrorCount()).isEqualTo(1); // The last failure
234237
assertThat(entry.totalOutstandingRpcs()).isEqualTo(0);
235238
}
239+
240+
@Test
241+
public void testNonAltsChannelReturnsFalse() {
242+
// empty attributes
243+
// cannot test true value as logic is complicated.
244+
// alts check looks at attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY);
245+
when(mockClientCall.getAttributes()).thenReturn(Attributes.EMPTY);
246+
BigtableChannelPool.Entry entry = getSingleEntry();
247+
assertThat(entry.isAltsHolder.get()).isNull();
248+
startCall(unaryMethodDescriptor);
249+
assertThat(entry.isAltsChannel()).isFalse();
250+
}
236251
}

0 commit comments

Comments
 (0)