Repository navigation
Testing: rationalize / normalize VPCSC environment detection in systests #9580
Copy link
Copy link
Closed
Labels
api: automlIssues related to the AutoML API.Issues related to the AutoML API.api: cloudassetIssues related to the Cloud Asset Inventory API.Issues related to the Cloud Asset Inventory API.api: cloudtraceIssues related to the Cloud Trace API.Issues related to the Cloud Trace API.api: dlpIssues related to the Sensitive Data Protection API.Issues related to the Sensitive Data Protection API.api: monitoringIssues related to the Cloud Monitoring API.Issues related to the Cloud Monitoring API.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.api: translationIssues related to the Cloud Translation API API.Issues related to the Cloud Translation API API.api: videointelligenceIssues related to the Video Intelligence API API.Issues related to the Video Intelligence API API.api: visionIssues related to the Cloud Vision API.Issues related to the Cloud Vision API.testingtype: processA process-related concern. May include testing, release, or the like.A process-related concern. May include testing, release, or the like.
Description
We need a clear pattern for how to test whether the appropriate environment variables are set for VPCSC, and ways to skip tests when they are missing. I believe the constraints should be:
- Never set the environment variables in
noxfile.py. - If the inside / outside project variables are missing, skip the affected testcases cleanly.
I'm proposing to create a new module, test_utils/test_utils/vpcsc_config.py, which centralizes all this policy. Usage from systests would look like:
from test_utils.vpcsc_config import vpcsc_config
@vpcsc_config.skip_unless_inside_project
def test_requiring_inside_project():
do_something_with(vpcsc_config.project_inside)
@vpcsc_config.skip_unless_outside_project
def test_requiring_outside_project():
do_something_with(vpcsc_config.project_outside)
@vpcsc_config.skip_unless_outside_bucket
def test_requiring_outside_bucket():
do_something_with(vpcsc_config.bucket_outside)
@vpcsc_config.skip_unless_inside_project
@vpcsc_config.skip_unless_outside_project
def test_requiring_inside_and_outside_projects():
if vpcsc_config.inside_vpcsc:
do_something_with(vpcsc_config.project_inside, vpcsc_config.project_outside)
@vpcsc_config.skip_if_inside_vpcsc
def test_incompatible_with_vpcsc():
...
@vpcsc_config.skip_unless_inside_vpcsc
def test_requiring_requires_vpcsc():
...Steps:
- Add 'test_utils/test_utils/vpcsc_config.py`, with the indicated 'VPCSCConfig' class and singleton (tests: add centralized VPCSC config detection #9581)
- Apply in
asset/tests/system/test_vpcsc.py.(tests(asset): normalize VPCSC configuration in systests #9614) - Apply in
automl/tests/system/gapic/v1beta1/test_system_tables_client_v1.py. (tests(automl): normalize VPCSC configuration in systests #9607) - Apply in
dlp/tests/system/gapic/v2/test_system_dlp_service_v2_vpcsc.py. (tests(dlp): normalize VPCSC configuration in systests #9608) - Apply in
monitoring/tests/system/test_vpcsc_v3.py. (tests(monitoring): normalize VPCSC configuration in systests #9615) - Apply in
storage/tests/system.py. (tests(storage): normalize VPCSC configuration in systests. #9616) - Apply in
trace/tests/system/gapic/v{1,3}/test_system_trace_service_v{1,2}_vpcsc.py. (tests(trace): normalize VPCSC configuration in systests #9618) - Appy lin
translate/tests/system/test_vpcsc.py. (tests(translate): normalize VPCSC configuration in systests #9619) - Appy lin
videointelligence/tests/system.py. (tests(videointelligence): normalize VPCSC configuration in systests #9776) - Appy lin
vision/tests/system.py. (tests(vision): normalize VPCSC configuration in systests #9620)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: automlIssues related to the AutoML API.Issues related to the AutoML API.api: cloudassetIssues related to the Cloud Asset Inventory API.Issues related to the Cloud Asset Inventory API.api: cloudtraceIssues related to the Cloud Trace API.Issues related to the Cloud Trace API.api: dlpIssues related to the Sensitive Data Protection API.Issues related to the Sensitive Data Protection API.api: monitoringIssues related to the Cloud Monitoring API.Issues related to the Cloud Monitoring API.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.api: translationIssues related to the Cloud Translation API API.Issues related to the Cloud Translation API API.api: videointelligenceIssues related to the Video Intelligence API API.Issues related to the Video Intelligence API API.api: visionIssues related to the Cloud Vision API.Issues related to the Cloud Vision API.testingtype: processA process-related concern. May include testing, release, or the like.A process-related concern. May include testing, release, or the like.
Activity
tseaver commentedon Oct 31, 2019
Ugh, I've just found out that different test suites differ as to how the
GOOGLE_CLOUD_TESTS_IN_VPCSCenv var should be handled if not set:assetdefaultsIS_INSIDE_VPCSCto True; it also forcibly sets the envvars innoxfile.py.automldefaultsRUNNING_IN_VPCSCto False if the env var is missing.dlpdefaultsIS_INSIDE_VPCSCto False if the env var is missing; if False, itsnoxfile.pyalso scribbles on the other env vars.monitoringdefaultsIS_INSIDE_VPCSCto False if the env var is missing.; if False, itsnoxfile.pyalso scribbles on the other env vars.storagedefaultsRUNNING_IN_VPCSCto False if the env var is missing. If True, skips tests which use public buckets.tracedoesn't useGOOGLE_CLOUD_TESTS_IN_VPCSCat all: it just tests forPROJECT_IDandGOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT. Itsnoxfile.pyforcibly sets both of those variables.translatesetsIS_INSIDE_VPCSCto True if theGOOGLE_CLOUD_TESTS_IN_VPCSCis present in the environment, without testing its value!videointelligencesetsIS_INSIDE_VPCSCto None if the env var is missing, and uses it as a boolean value (no test for"true"or"false"). It has separate tests for "inside" and "outside" buckets, which use separate env vars: those env vars aren't set bynoxfile.py, also it does set the (seemingly unused)GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_IPandGOOGLE_CLOUD_TESTS_VPCSC_INSIDE_IPvariables.visiondoesn't use theGOOGLE_CLOUD_TESTS_IN_VPCSCenv var at all: it uses two custom ones,GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECTandGOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_BUCKET.busunkim96 commentedon Oct 31, 2019
👋 Ack, that is definitely a mess.
I wrote up this doc to clarify with VPCSC and backend folks as to what they need.
Tests should run only when the environment variable
GOOGLE_CLOUD_TESTS_IN_VPCSCis set. This is set only in the VPC-SC team's test environment.We can get rid of env var setup in the noxfile and run the tests depending on
GOOGLE_CLOUD_TESTS_IN_VPCSC.crwilcox commentedon Nov 1, 2019
Thanks for working towards this @tseaver. As @busunkim96 said, this is a bit of a mess right now, but I think the approach you are taking makes sense.
Do you have sufficient information to move forward on this work?
Also, in the PRs I see edits to noxfiles. Would it make sense to make those edits, at least eventually, in https://github.com/googleapis/synthtool/blob/master/synthtool/gcp/templates/python_library/noxfile.py.j2 ?
tseaver commentedon Nov 5, 2019
@crwilcox I intend to add one PR per API which currently has any VPCSC-specific tests, and will remove any VPCSC-specific envvar-setting in those PRs.
Trying to get the noxfiles back to "pristine / as generated" is outside the scope of this issue.
tests: add centralized VPCSC config detection (#9581)
tseaver commentedon Nov 6, 2019
The VPCSC stuff in the videointelligence systests is a mess: it actually removed a real systest and replaced with bits which use
requeststo make raw HTTP requests, rather than testing the client.I've asked to revert PR #9193 and #8607, and work on building in proper VPCSC support.
tests(automl): normalize VPCSC configuration in systests (#9607)
tests(trace): normalize VPCSC configuration in systests (#9618)
tests(dlp): normalize VPCSC configuration in systests (#9608)
tests(asset): normalize VPCSC configuration in systests (#9614)
tests(monitoring): normalize VPCSC configuration in systests (#9615)
tseaver commentedon Feb 13, 2020
The last PR for this issue is now open in the new
python-videointelligencerepo. Closing here, as bugs against the libraries aren't being managed here any longer.tests(dlp): normalize VPCSC configuration in systests (#9608)
tests(asset): normalize VPCSC configuration in systests (#9614)
tests(monitoring): normalize VPCSC configuration in systests (#9615)
tests(automl): normalize VPCSC configuration in systests (#9607)
tests(trace): normalize VPCSC configuration in systests (#9618)