Repository navigation
Use the mock clock to test the credential expiration. - #1114
Conversation
Signed-off-by: Zheng Hu <[email protected]>
Signed-off-by: Zheng Hu <[email protected]>
6a496e3 to
2fdbd22
Compare
| } | ||
|
|
||
| @Override | ||
| public synchronized void advance(Duration duration) { |
There was a problem hiding this comment.
Need to add the synchronized here, since it's possible for us to advance the same now at the same time via different threads. Since Instant is immutable, we always need to assign the updated instant to now.
Signed-off-by: Zheng Hu <[email protected]>
| void advance(Duration duration); | ||
|
|
||
| static Clock systemClock() { | ||
| return new SystemClock(); |
There was a problem hiding this comment.
minor: this does not need to return new object every time. this can be a singleton.
|
|
||
| // For testing purpose only. | ||
| void setClock(Clock clock) { | ||
| this.clock = clock; |
There was a problem hiding this comment.
minor: why not take this in the constructor, an overloaded constructor that takes a clock?
then createTestProvider can always set it and you dont have to keep calling this method in every test.
tdas
left a comment
There was a problem hiding this comment.
this is very clean! thank you for doing this. only minor comments to address.
Signed-off-by: Zheng Hu <[email protected]>
| public AbfsVendedTokenProvider() { | ||
| } | ||
|
|
||
| AbfsVendedTokenProvider(Clock clock, long renewalLeadTimeMillis) { |
There was a problem hiding this comment.
We need this non-public constructor to create the provider with specified clock and renewalLeadTimeMillis.
| initialize(conf); | ||
| } | ||
|
|
||
| AwsVendedTokenProvider(Configuration conf, Clock clock, long renewalLeadTimeMillis) { |
| this(Clock.systemClock(), DEFAULT_RENEWAL_LEAD_TIME_MILLIS); | ||
| } | ||
|
|
||
| GenericCredentialProvider(Clock clock, long renewalLeadTimeMillis) { |
There was a problem hiding this comment.
Make it as non-public, since it's mainly for testing purposes.
| } | ||
|
|
||
| // For testing purpose only. | ||
| void setRenewalLeadTimeMillis(long renewalLeadTimeMillis) { |
There was a problem hiding this comment.
Removed this for testing purpose setter, since we are passing it via the constuctor.
| void advance(Duration duration); | ||
|
|
||
| static Clock systemClock() { | ||
| return SystemClock.SINGLETON; |
There was a problem hiding this comment.
Always use the SINGLETON of the SystemClock.
|
The CI is timeout, seems unrelated. Let's retry. |
|
the unit test failed because of the following ( ref: https://github.com/unitycatalog/unitycatalog/actions/runs/18581618758/job/52977634603?pr=1114 ) Downloaded https://repo1.maven.org/maven2/org/ow2/asm/asm/9.3/asm-9.3.jar
Downloaded https://repo1.maven.org/maven2/io/micrometer/micrometer-commons/1.12.4/micrometer-commons-1.12.4.pom.asc.sha512
Downloaded https://repo1.maven.org/maven2/org/ow2/asm/asm/9.3/asm-9.3.pom.asc.sha512
Downloaded https://repo1.maven.org/maven2/org/ow2/asm/asm/9.3/asm-9.3.pom.sha512
Downloaded https://repo1.maven.org/maven2/io/micrometer/micrometer-commons/1.12.4/micrometer-commons-1.12.4.jar.sha512
[error] lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] https://repo1.maven.org/maven2/org/scala-lang/scala2-sbt-bridge/2.13.16/scala2-sbt-bridge-2.13.16.jar: download error: Caught java.nio.channels.OverlappingFileLockException while downloading https://repo1.maven.org/maven2/org/scala-lang/scala2-sbt-bridge/2.13.16/scala2-sbt-bridge-2.13.16.jar
[error]
[error] at lmcoursier.internal.shaded.coursier.Artifacts$.$anonfun$fetchArtifacts$9(Artifacts.scala:365)
[error] at lmcoursier.internal.shaded.coursier.util.Task$.$anonfun$flatMap$extension$1(Task.scala:14)
[error] at lmcoursier.internal.shaded.coursier.util.Task$.$anonfun$flatMap$extension$1$adapted(Task.scala:14)
[error] at lmcoursier.internal.shaded.coursier.util.Task$.wrap(Task.scala:82)
[error] at lmcoursier.internal.shaded.coursier.util.Task$.$anonfun$flatMap$2(Task.scala:14)
[error] at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
[error] at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
[error] at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] at java.base/java.lang.Thread.run(Thread.java:840)
[error] Caused by: lmcoursier.internal.shaded.coursier.cache.ArtifactError$DownloadError: download error: Caught java.nio.channels.OverlappingFileLockException while downloading https://repo1.maven.org/maven2/org/scala-lang/scala2-sbt-bridge/2.13.16/scala2-sbt-bridge-2.13.16.jar
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$.helper$2(Downloader.scala:793)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$.coursier$cache$internal$Downloader$$downloading(Downloader.scala:806)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$Blocking$.remote(Downloader.scala:415)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader.$anonfun$remote$6(Downloader.scala:533)
[error] at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
[error] at scala.util.Success.$anonfun$map$1(Try.scala:255)
[error] at scala.util.Success.map(Try.scala:213)
[error] at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
[error] at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
[error] at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
[error] at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] at java.base/java.lang.Thread.run(Thread.java:840)
[error] Caused by: java.nio.channels.OverlappingFileLockException
[error] at java.base/sun.nio.ch.FileLockTable.checkList(FileLockTable.java:229)
[error] at java.base/sun.nio.ch.FileLockTable.add(FileLockTable.java:123)
[error] at java.base/sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1276)
[error] at java.base/java.nio.channels.FileChannel.lock(FileChannel.java:1089)
[error] at lmcoursier.internal.shaded.coursier.paths.CachePath.withStructureLock(CachePath.java:152)
[error] at lmcoursier.internal.shaded.coursier.cache.CacheLocks$.withStructureLock(CacheLocks.scala:20)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$Blocking$.doDownload(Downloader.scala:262)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$Blocking$.$anonfun$remote$2(Downloader.scala:410)
[error] at lmcoursier.internal.shaded.coursier.cache.CacheLocks$.loop$1(CacheLocks.scala:73)
[error] at lmcoursier.internal.shaded.coursier.cache.CacheLocks$.withLockOr(CacheLocks.scala:93)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$Blocking$.$anonfun$remote$1(Downloader.scala:413)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$.$anonfun$downloading$1(Downloader.scala:764)
[error] at lmcoursier.internal.shaded.coursier.cache.CacheLocks$.withUrlLock(CacheLocks.scala:112)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$.helper$2(Downloader.scala:764)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$.coursier$cache$internal$Downloader$$downloading(Downloader.scala:806)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$Blocking$.remote(Downloader.scala:415)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader.$anonfun$remote$6(Downloader.scala:533)
[error] at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
[error] at scala.util.Success.$anonfun$map$1(Try.scala:255)
[error] at scala.util.Success.map(Try.scala:213)
[error] at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
[error] at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
[error] at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
[error] at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] at java.base/java.lang.Thread.run(Thread.java:840)
[error] (spark / scalaCompilerBridgeBinaryJar) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] https://repo1.maven.org/maven2/org/scala-lang/scala2-sbt-bridge/2.13.16/scala2-sbt-bridge-2.13.16.jar: download error: Caught java.nio.channels.OverlappingFileLockException while downloading https://repo1.maven.org/maven2/org/scala-lang/scala2-sbt-bridge/2.13.16/scala2-sbt-bridge-2.13.16.jar
[error] Total time: 50 s, completed Oct 17, 2025, 3:40:07 AM
Error: Process completed with exit code 1.Let's retry it again. |
) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** The related issue is here: unitycatalog#1113 --------- Signed-off-by: Zheng Hu <[email protected]> Signed-off-by: TimothyW553 <[email protected]>
) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** The related issue is here: unitycatalog#1113 --------- Signed-off-by: Zheng Hu <[email protected]>
PR Checklist
docsis updatedDescription of changes
The related issue is here: #1113