@@ -2173,3 +2173,69 @@ def foo(x):
2173
2173
cleanup_remote_function_assets (
2174
2174
session .bqclient , session .cloudfunctionsclient , foo
2175
2175
)
2176
+
2177
+
2178
+ @pytest .mark .parametrize (
2179
+ ("ingress_settings_args" , "effective_ingress_settings" ),
2180
+ [
2181
+ pytest .param (
2182
+ {}, functions_v2 .ServiceConfig .IngressSettings .ALLOW_ALL , id = "no-set"
2183
+ ),
2184
+ pytest .param (
2185
+ {"cloud_function_ingress_settings" : "all" },
2186
+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_ALL ,
2187
+ id = "set-all" ,
2188
+ ),
2189
+ pytest .param (
2190
+ {"cloud_function_ingress_settings" : "internal-only" },
2191
+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_INTERNAL_ONLY ,
2192
+ id = "set-internal-only" ,
2193
+ ),
2194
+ pytest .param (
2195
+ {"cloud_function_ingress_settings" : "internal-and-gclb" },
2196
+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_INTERNAL_AND_GCLB ,
2197
+ id = "set-internal-and-gclb" ,
2198
+ ),
2199
+ ],
2200
+ )
2201
+ @pytest .mark .flaky (retries = 2 , delay = 120 )
2202
+ def test_remote_function_ingress_settings (
2203
+ session , scalars_dfs , ingress_settings_args , effective_ingress_settings
2204
+ ):
2205
+ try :
2206
+
2207
+ def square (x : int ) -> int :
2208
+ return x * x
2209
+
2210
+ square_remote = session .remote_function (reuse = False , ** ingress_settings_args )(
2211
+ square
2212
+ )
2213
+
2214
+ # Assert that the GCF is created with the intended maximum timeout
2215
+ gcf = session .cloudfunctionsclient .get_function (
2216
+ name = square_remote .bigframes_cloud_function
2217
+ )
2218
+ assert gcf .service_config .ingress_settings == effective_ingress_settings
2219
+
2220
+ scalars_df , scalars_pandas_df = scalars_dfs
2221
+
2222
+ bf_result = scalars_df ["int64_too" ].apply (square_remote ).to_pandas ()
2223
+ pd_result = scalars_pandas_df ["int64_too" ].apply (square )
2224
+
2225
+ pandas .testing .assert_series_equal (bf_result , pd_result , check_dtype = False )
2226
+ finally :
2227
+ # clean up the gcp assets created for the remote function
2228
+ cleanup_remote_function_assets (
2229
+ session .bqclient , session .cloudfunctionsclient , square_remote
2230
+ )
2231
+
2232
+
2233
+ @pytest .mark .flaky (retries = 2 , delay = 120 )
2234
+ def test_remote_function_ingress_settings_unsupported (session ):
2235
+ with pytest .raises (
2236
+ ValueError , match = "'unknown' not one of the supported ingress settings values"
2237
+ ):
2238
+
2239
+ @session .remote_function (reuse = False , cloud_function_ingress_settings = "unknown" )
2240
+ def square (x : int ) -> int :
2241
+ return x * x
0 commit comments