@@ -19,8 +19,10 @@ import (
19
19
"errors"
20
20
"fmt"
21
21
"maps"
22
+ "os"
22
23
"slices"
23
24
"sort"
25
+ "strconv"
24
26
"testing"
25
27
26
28
sppb "cloud.google.com/go/spanner/apiv1/spannerpb"
@@ -60,6 +62,11 @@ func (oi *ourInterceptor) interceptUnary(ctx context.Context, req any, usi *grpc
60
62
return handler (ctx , req )
61
63
}
62
64
65
+ func directPathEnabled () bool {
66
+ enabled , _ := strconv .ParseBool (os .Getenv ("GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS" ))
67
+ return enabled
68
+ }
69
+
63
70
// This is a regression test to assert that all the expected headers are propagated
64
71
// along to the final gRPC server avoiding scenarios where headers got dropped from a
65
72
// destructive context augmentation call.
@@ -138,36 +145,41 @@ func TestAllHeadersForwardedAppropriately(t *testing.T) {
138
145
WantHeaders []string
139
146
}
140
147
148
+ var dynamicHeaders []string
149
+ if directPathEnabled () {
150
+ dynamicHeaders = []string {"x-goog-spanner-enable-afe-server-timing" }
151
+ }
152
+
141
153
wantUnaryExpectations := []* headerExpectation {
142
154
{
143
155
"/google.spanner.v1.Spanner/BatchCreateSessions" ,
144
- []string {
156
+ append ( []string {
145
157
":authority" , "content-type" , "google-cloud-resource-prefix" ,
146
158
"grpc-accept-encoding" , "user-agent" , "x-goog-api-client" ,
147
159
"x-goog-request-params" , "x-goog-spanner-end-to-end-tracing" ,
148
160
"x-goog-spanner-request-id" , "x-goog-spanner-route-to-leader" ,
149
- },
161
+ }, dynamicHeaders ... ),
150
162
},
151
163
{
152
164
"/google.spanner.v1.Spanner/BeginTransaction" ,
153
- []string {
165
+ append ( []string {
154
166
":authority" , "content-type" , "google-cloud-resource-prefix" ,
155
167
"grpc-accept-encoding" , "user-agent" , "x-goog-api-client" ,
156
168
"x-goog-request-params" , "x-goog-spanner-end-to-end-tracing" ,
157
169
"x-goog-spanner-request-id" ,
158
- },
170
+ }, dynamicHeaders ... ),
159
171
},
160
172
}
161
173
162
174
wantStreamingExpectations := []* headerExpectation {
163
175
{
164
176
"/google.spanner.v1.Spanner/ExecuteStreamingSql" ,
165
- []string {
177
+ append ( []string {
166
178
":authority" , "content-type" , "google-cloud-resource-prefix" ,
167
179
"grpc-accept-encoding" , "user-agent" , "x-goog-api-client" ,
168
180
"x-goog-request-params" , "x-goog-spanner-end-to-end-tracing" ,
169
181
"x-goog-spanner-request-id" ,
170
- },
182
+ }, dynamicHeaders ... ),
171
183
},
172
184
}
173
185
0 commit comments