Skip to content

Testing: rationalize / normalize VPCSC environment detection in systests #9580

@tseaver

Description

@tseaver

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:

Metadata

Metadata

Assignees

Labels

api: automlIssues related to the AutoML API.api: cloudassetIssues related to the Cloud Asset Inventory API.api: cloudtraceIssues related to the Cloud Trace API.api: dlpIssues related to the Sensitive Data Protection API.api: monitoringIssues related to the Cloud Monitoring API.api: storageIssues related to the Cloud Storage API.api: translationIssues related to the Cloud Translation API API.api: videointelligenceIssues related to the Video Intelligence API API.api: visionIssues related to the Cloud Vision API.testingtype: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions