Skip to content

Commit 8a25165

Browse files
authored
build: fix auth library native tests and flaky test (#12881)
The `google-auth-library-java` migration to the monorepo inadvertently enabled GraalVM native testing for the credentials module because the generic `graalvm-single` job type runs tests on all modules in the subdirectory. In the original repository, this job was scoped to only test the `oauth2_http` module. This change adds `<skipNativeTests>true</skipNativeTests>` to the credentials and appengine module POMs to skip native tests, resolving the failure when the plugin cannot find test configuration files. It also stabilizes a flaky concurrent test in cab-token-generator. Fixes #12859
1 parent 26fe0f9 commit 8a25165

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

.kokoro/presubmit/google-auth-library-java-graalvm-native-presubmit.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ env_vars: {
5050
key: "BUILD_SUBDIR"
5151
value: "google-auth-library-java"
5252
}
53+
54+
env_vars: {
55+
key: "INTEGRATION_TEST_ARGS"
56+
value: "-Pslf4j2x"
57+
}
58+

google-auth-library-java/appengine/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
</archive>
4343
</configuration>
4444
</plugin>
45+
<plugin>
46+
<groupId>org.graalvm.buildtools</groupId>
47+
<artifactId>native-maven-plugin</artifactId>
48+
<configuration>
49+
<skipNativeTests>true</skipNativeTests>
50+
</configuration>
51+
</plugin>
52+
4553
</plugins>
4654
</build>
4755

google-auth-library-java/cab-token-generator/javatests/com/google/auth/credentialaccessboundary/ClientSideCredentialAccessBoundaryFactoryTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,22 +614,28 @@ private Clock createMockClock(RefreshType refreshType, GoogleCredentials sourceC
614614
// Set mocked time so that the token is fresh and no refresh is needed (before the refresh
615615
// margin).
616616
mockedTimeInMillis = expirationTimeInMillis - refreshMarginInMillis - 60000;
617+
when(mockClock.currentTimeMillis()).thenReturn(mockedTimeInMillis);
617618
break;
618619
case ASYNC:
619620
// Set mocked time so that the token is nearing expiry and an async refresh is triggered
620621
// (within the refresh margin).
621622
mockedTimeInMillis = expirationTimeInMillis - refreshMarginInMillis + 60000;
623+
when(mockClock.currentTimeMillis())
624+
.thenReturn(
625+
mockedTimeInMillis, // First call: Stale (triggers the async refresh)
626+
currentTimeInMillis // Subsequent calls: Fresh (skips redundant refreshes)
627+
);
622628
break;
623629
case BLOCKING:
624630
// Set mocked time so that the token requires immediate refresh (just after the minimum
625631
// token lifetime).
626632
mockedTimeInMillis = expirationTimeInMillis - minimumTokenLifetimeMillis + 60000;
633+
when(mockClock.currentTimeMillis()).thenReturn(mockedTimeInMillis);
627634
break;
628635
default:
629636
throw new IllegalArgumentException("Unexpected RefreshType: " + refreshType);
630637
}
631638

632-
when(mockClock.currentTimeMillis()).thenReturn(mockedTimeInMillis);
633639
return mockClock;
634640
}
635641

google-auth-library-java/credentials/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
<sourceDirectory>java</sourceDirectory>
2323
<testSourceDirectory>javatests</testSourceDirectory>
2424
<plugins>
25+
<plugin>
26+
<groupId>org.graalvm.buildtools</groupId>
27+
<artifactId>native-maven-plugin</artifactId>
28+
<configuration>
29+
<skipNativeTests>true</skipNativeTests>
30+
</configuration>
31+
</plugin>
2532
<plugin>
2633
<groupId>org.apache.maven.plugins</groupId>
2734
<artifactId>maven-source-plugin</artifactId>

0 commit comments

Comments
 (0)