@@ -1336,17 +1336,27 @@ def test_remote_function_via_session_custom_sa(scalars_dfs):
1336
1336
1337
1337
try :
1338
1338
1339
+ # TODO(shobs): Figure out why the default ingress setting
1340
+ # (internal-only) does not work here
1339
1341
@rf_session .remote_function (
1340
1342
input_types = [int ],
1341
1343
output_type = int ,
1342
1344
reuse = False ,
1343
1345
cloud_function_service_account = gcf_service_account ,
1346
+ cloud_function_ingress_settings = "all" ,
1344
1347
)
1345
1348
def square_num (x ):
1346
1349
if x is None :
1347
1350
return x
1348
1351
return x * x
1349
1352
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
1350
1360
scalars_df , scalars_pandas_df = scalars_dfs
1351
1361
1352
1362
bf_int64_col = scalars_df ["int64_col" ]
@@ -1358,12 +1368,6 @@ def square_num(x):
1358
1368
pd_result = pd_int64_col .to_frame ().assign (result = pd_result_col )
1359
1369
1360
1370
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
1367
1371
finally :
1368
1372
# clean up the gcp assets created for the remote function
1369
1373
cleanup_function_assets (
@@ -1476,14 +1480,24 @@ def square_num(x):
1476
1480
return x
1477
1481
return x * x
1478
1482
1483
+ # TODO(shobs): See if the test vpc can be configured to make this flow
1484
+ # work with the default ingress setting (internal-only)
1479
1485
square_num_remote = rf_session .remote_function (
1480
1486
input_types = [int ],
1481
1487
output_type = int ,
1482
1488
reuse = False ,
1483
1489
cloud_function_service_account = "default" ,
1484
1490
cloud_function_vpc_connector = gcf_vpc_connector ,
1491
+ cloud_function_ingress_settings = "all" ,
1485
1492
)(square_num )
1486
1493
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
1487
1501
scalars_df , scalars_pandas_df = scalars_dfs
1488
1502
1489
1503
bf_int64_col = scalars_df ["int64_col" ]
@@ -1495,12 +1509,6 @@ def square_num(x):
1495
1509
pd_result = pd_int64_col .to_frame ().assign (result = pd_result_col )
1496
1510
1497
1511
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
1504
1512
finally :
1505
1513
# clean up the gcp assets created for the remote function
1506
1514
cleanup_function_assets (
@@ -2439,13 +2447,13 @@ def generate_stats(row: pandas.Series) -> list[int]:
2439
2447
[
2440
2448
pytest .param (
2441
2449
{},
2442
- functions_v2 .ServiceConfig .IngressSettings .ALLOW_ALL ,
2443
- True ,
2450
+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_INTERNAL_ONLY ,
2451
+ False ,
2444
2452
id = "no-set" ,
2445
2453
),
2446
2454
pytest .param (
2447
2455
{"cloud_function_ingress_settings" : None },
2448
- functions_v2 .ServiceConfig .IngressSettings .ALLOW_ALL ,
2456
+ functions_v2 .ServiceConfig .IngressSettings .ALLOW_INTERNAL_ONLY ,
2449
2457
True ,
2450
2458
id = "set-none" ,
2451
2459
),
@@ -2493,11 +2501,8 @@ def square(x: int) -> int:
2493
2501
default_ingress_setting_warnings = [
2494
2502
warn
2495
2503
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."
2501
2506
]
2502
2507
assert len (default_ingress_setting_warnings ) == (
2503
2508
1 if expect_default_ingress_setting_warning else 0
0 commit comments