Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces environment-based test skipping capabilities by adding support for CI, Librarian, and local environments. It defines new environment variable constants, helper methods to detect these environments, and corresponding skip methods. The feedback suggests ensuring that these new skip methods respect the MUST_NOT_SKIP_TESTS environment variable so developers can force-run tests when debugging. Additionally, the helper method IsEnvironmentVariableSet should be updated to check for an explicit 'true' value case-insensitively, preventing unexpected behavior when variables are set to 'false'.
c8793f1 to
4e361cb
Compare
|
/gemini |
3f9fcb5 to
a97fb92
Compare
45156e5 to
7e4b6ee
Compare
Add IsCiEnvironment, IsLibrarianEnvironment, IsLocalEnvironment, and corresponding SkipOn* methods to TestEnvironment so tests can distinguish between Kokoro CI, Librarian, and local runs. Also default GOOGLE_CLOUD_DOTNET_TEST_ENV=librarian for build-library and integration-test-library in pipeline-config.json so tests running inside Librarian containers can detect the Librarian environment.
7e4b6ee to
ddff971
Compare
| { | ||
| "name": "GOOGLE_CLOUD_DOTNET_TEST_ENV", | ||
| "defaultValue": "librarian" | ||
| } |
There was a problem hiding this comment.
I don't think this is right, there's no guarantee that something using this file is running in librarian. For the jobs that run in librarian, we should inject the environment variables on those jobs.
| public const string GoogleCloudTestsInVpcScEnvironmentVariable = "GOOGLE_CLOUD_TESTS_IN_VPCSC"; | ||
| public const string GoogleCloudTestEnvEnvironmentVariable = "GOOGLE_CLOUD_DOTNET_TEST_ENV"; | ||
| public const string LibrarianRepositoryEnvironmentVariable = "LIBRARIAN_REPOSITORY"; | ||
| public const string CiEnvironment = "ci"; |
There was a problem hiding this comment.
| public const string CiEnvironment = "ci"; | |
| public const string CIEnvironment = "ci"; |
There was a problem hiding this comment.
And maybe, let's talk about these values more. Maybe instead of librarian, ci and dev we have values for what's actually restricted on each, e.g. no-service-account. Let's discuss internally in the bug, which are all the ways in which we are restricted?
| /// Returns true if the tests are running in a CI environment | ||
| /// (detected by the <c>GOOGLE_CLOUD_DOTNET_TEST_ENV</c> environment variable value <c>ci</c>). | ||
| /// </summary> | ||
| public static bool IsCiEnvironment() => |
There was a problem hiding this comment.
| public static bool IsCiEnvironment() => | |
| public static bool IsCIEnvironment() => |
|
|
||
| /// <summary> | ||
| /// Returns true if the tests are running in a local environment | ||
| /// (detected as not being in CI or Librarian environments). |
There was a problem hiding this comment.
Let's have a specific value for this.
| @@ -77,6 +81,33 @@ public static string GetProjectLocationId() | |||
| /// </summary> | |||
| public static bool IsRestrictedEnvironment() => string.IsNullOrEmpty(Environment.GetEnvironmentVariable(GoogleApplicationCredentialsEnvironmentVariable)); | |||
There was a problem hiding this comment.
Can we maybe remove this one now, or after?
b/580033155