@@ -1336,17 +1336,27 @@ def test_remote_function_via_session_custom_sa(scalars_dfs):
13361336
13371337 try :
13381338
1339+ # TODO(shobs): Figure out why the default ingress setting
1340+ # (internal-only) does not work here
13391341 @rf_session .remote_function (
13401342 input_types = [int ],
13411343 output_type = int ,
13421344 reuse = False ,
13431345 cloud_function_service_account = gcf_service_account ,
1346+ cloud_function_ingress_settings = "all" ,
13441347 )
13451348 def square_num (x ):
13461349 if x is None :
13471350 return x
13481351 return x * x
13491352
1353+ # assert that the GCF is created with the intended SA
1354+ gcf = rf_session .cloudfunctionsclient .get_function (
1355+ name = square_num .bigframes_cloud_function
1356+ )
1357+ assert gcf .service_config .service_account_email == gcf_service_account
1358+
1359+ # assert that the function works as expected on data
13501360 scalars_df , scalars_pandas_df = scalars_dfs
13511361
13521362 bf_int64_col = scalars_df ["int64_col" ]
@@ -1358,12 +1368,6 @@ def square_num(x):
13581368 pd_result = pd_int64_col .to_frame ().assign (result = pd_result_col )
13591369
13601370 assert_pandas_df_equal (bf_result , pd_result , check_dtype = False )
1361-
1362- # Assert that the GCF is created with the intended SA
1363- gcf = rf_session .cloudfunctionsclient .get_function (
1364- name = square_num .bigframes_cloud_function
1365- )
1366- assert gcf .service_config .service_account_email == gcf_service_account
13671371 finally :
13681372 # clean up the gcp assets created for the remote function
13691373 cleanup_function_assets (
@@ -1476,14 +1480,24 @@ def square_num(x):
14761480 return x
14771481 return x * x
14781482
1483+ # TODO(shobs): See if the test vpc can be configured to make this flow
1484+ # work with the default ingress setting (internal-only)
14791485 square_num_remote = rf_session .remote_function (
14801486 input_types = [int ],
14811487 output_type = int ,
14821488 reuse = False ,
14831489 cloud_function_service_account = "default" ,
14841490 cloud_function_vpc_connector = gcf_vpc_connector ,
1491+ cloud_function_ingress_settings = "all" ,
14851492 )(square_num )
14861493
1494+ # assert that the GCF is created with the intended vpc connector
1495+ gcf = rf_session .cloudfunctionsclient .get_function (
1496+ name = square_num_remote .bigframes_cloud_function
1497+ )
1498+ assert gcf .service_config .vpc_connector == gcf_vpc_connector
1499+
1500+ # assert that the function works as expected on data
14871501 scalars_df , scalars_pandas_df = scalars_dfs
14881502
14891503 bf_int64_col = scalars_df ["int64_col" ]
@@ -1495,12 +1509,6 @@ def square_num(x):
14951509 pd_result = pd_int64_col .to_frame ().assign (result = pd_result_col )
14961510
14971511 assert_pandas_df_equal (bf_result , pd_result , check_dtype = False )
1498-
1499- # Assert that the GCF is created with the intended vpc connector
1500- gcf = rf_session .cloudfunctionsclient .get_function (
1501- name = square_num_remote .bigframes_cloud_function
1502- )
1503- assert gcf .service_config .vpc_connector == gcf_vpc_connector
15041512 finally :
15051513 # clean up the gcp assets created for the remote function
15061514 cleanup_function_assets (
@@ -2439,13 +2447,13 @@ def generate_stats(row: pandas.Series) -> list[int]:
24392447 [
24402448 pytest .param (
24412449 {},
2442- functions_v2 .ServiceConfig .IngressSettings .ALLOW_ALL ,
2443- True ,
2450+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_INTERNAL_ONLY ,
2451+ False ,
24442452 id = "no-set" ,
24452453 ),
24462454 pytest .param (
24472455 {"cloud_function_ingress_settings" : None },
2448- functions_v2 .ServiceConfig .IngressSettings .ALLOW_ALL ,
2456+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_INTERNAL_ONLY ,
24492457 True ,
24502458 id = "set-none" ,
24512459 ),
@@ -2493,11 +2501,8 @@ def square(x: int) -> int:
24932501 default_ingress_setting_warnings = [
24942502 warn
24952503 for warn in record
2496- if isinstance (warn .message , FutureWarning )
2497- and "`cloud_function_ingress_settings` are set to 'all' by default"
2498- in warn .message .args [0 ]
2499- and "will change to 'internal-only' for enhanced security in future"
2500- in warn .message .args [0 ]
2504+ if isinstance (warn .message , UserWarning )
2505+ and "The `cloud_function_ingress_settings` is being set to 'internal-only' by default."
25012506 ]
25022507 assert len (default_ingress_setting_warnings ) == (
25032508 1 if expect_default_ingress_setting_warning else 0
0 commit comments