Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enable BYOSA test for remote_function cloud function #432

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions tests/system/large/test_remote_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,19 +1281,29 @@ def square(x):
)


@pytest.mark.skip("This requires additional project config.")
@pytest.mark.flaky(retries=2, delay=120)
def test_remote_function_via_session_custom_sa(scalars_dfs):
# Set these values to run the test locally
# TODO(shobs): Automate and enable this test
PROJECT = ""
GCF_SERVICE_ACCOUNT = ""
# TODO(shobs): Automate the following set-up during testing in the test project.
#
# For upfront convenience, the following set up has been statically created
# in the project bigfrmames-dev-perf via cloud console:
#
# 1. Create a service account as per
# https://cloud.google.com/iam/docs/service-accounts-create#iam-service-accounts-create-console
# 2. Give necessary roles as per
# https://cloud.google.com/functions/docs/reference/iam/roles#additional-configuration
#
project = "bigframes-dev-perf"
gcf_service_account = (
"[email protected]"
)

rf_session = bigframes.Session(context=bigframes.BigQueryOptions(project=PROJECT))
rf_session = bigframes.Session(context=bigframes.BigQueryOptions(project=project))

try:

@rf_session.remote_function(
[int], int, reuse=False, cloud_function_service_account=GCF_SERVICE_ACCOUNT
[int], int, reuse=False, cloud_function_service_account=gcf_service_account
)
def square_num(x):
if x is None:
Expand All @@ -1316,7 +1326,7 @@ def square_num(x):
gcf = rf_session.cloudfunctionsclient.get_function(
name=square_num.bigframes_cloud_function
)
assert gcf.service_config.service_account_email == GCF_SERVICE_ACCOUNT
assert gcf.service_config.service_account_email == gcf_service_account
finally:
# clean up the gcp assets created for the remote function
cleanup_remote_function_assets(
Expand Down