Skip to content

Commit

Permalink
chore: Fix flaky InstantiatingGrpcChannelProviderTest on Mac (#3010)
Browse files Browse the repository at this point in the history
  • Loading branch information
lqiu96 authored Jul 3, 2024
1 parent aad24f6 commit 554329e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public static void setupClass() {

@BeforeEach
public void setup() throws IOException {
System.setProperty("os.name", "Linux");
computeEngineCredentials = Mockito.mock(ComputeEngineCredentials.class);
}

Expand Down Expand Up @@ -686,6 +685,7 @@ void testLogDirectPathMisconfigNotOnGCE() throws Exception {

@Test
public void canUseDirectPath_happyPath() {
System.setProperty("os.name", "Linux");
EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class);
Mockito.when(
envProvider.getenv(
Expand All @@ -704,6 +704,7 @@ public void canUseDirectPath_happyPath() {

@Test
public void canUseDirectPath_directPathEnvVarDisabled() {
System.setProperty("os.name", "Linux");
EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class);
Mockito.when(
envProvider.getenv(
Expand All @@ -722,6 +723,7 @@ public void canUseDirectPath_directPathEnvVarDisabled() {

@Test
public void canUseDirectPath_directPathEnvVarNotSet_attemptDirectPathIsTrue() {
System.setProperty("os.name", "Linux");
InstantiatingGrpcChannelProvider.Builder builder =
InstantiatingGrpcChannelProvider.newBuilder()
.setAttemptDirectPath(true)
Expand All @@ -734,6 +736,7 @@ public void canUseDirectPath_directPathEnvVarNotSet_attemptDirectPathIsTrue() {

@Test
public void canUseDirectPath_directPathEnvVarNotSet_attemptDirectPathIsFalse() {
System.setProperty("os.name", "Linux");
InstantiatingGrpcChannelProvider.Builder builder =
InstantiatingGrpcChannelProvider.newBuilder()
.setAttemptDirectPath(false)
Expand All @@ -746,6 +749,7 @@ public void canUseDirectPath_directPathEnvVarNotSet_attemptDirectPathIsFalse() {

@Test
public void canUseDirectPath_nonComputeCredentials() {
System.setProperty("os.name", "Linux");
Credentials credentials = Mockito.mock(Credentials.class);
EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class);
Mockito.when(
Expand Down Expand Up @@ -784,6 +788,7 @@ public void canUseDirectPath_isNotOnComputeEngine_invalidOsNameSystemProperty()

@Test
public void canUseDirectPath_isNotOnComputeEngine_invalidSystemProductName() {
System.setProperty("os.name", "Linux");
EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class);
Mockito.when(
envProvider.getenv(
Expand All @@ -802,6 +807,7 @@ public void canUseDirectPath_isNotOnComputeEngine_invalidSystemProductName() {

@Test
public void canUseDirectPath_isNotOnComputeEngine_unableToGetSystemProductName() {
System.setProperty("os.name", "Linux");
EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class);
Mockito.when(
envProvider.getenv(
Expand All @@ -819,6 +825,7 @@ public void canUseDirectPath_isNotOnComputeEngine_unableToGetSystemProductName()

@Test
public void canUseDirectPath_nonGDUUniverseDomain() {
System.setProperty("os.name", "Linux");
EnvironmentProvider envProvider = Mockito.mock(EnvironmentProvider.class);
Mockito.when(
envProvider.getenv(
Expand Down

0 comments on commit 554329e

Please sign in to comment.