Skip to content

Use the mock clock to test the credential expiration. - #1114

Merged
tdas merged 4 commits into
unitycatalog:mainfrom
openinx:1113-mock-the-clock
Oct 17, 2025
Merged

tdas merged 4 commits into
unitycatalog:mainfrom
openinx:1113-mock-the-clock

Conversation

@openinx

@openinx openinx commented Oct 15, 2025

Copy link
Copy Markdown
Collaborator

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • 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: #1113

@openinx
openinx marked this pull request as draft October 15, 2025 19:46
@openinx
openinx force-pushed the 1113-mock-the-clock branch from 6a496e3 to 2fdbd22 Compare October 15, 2025 22:26
}

@Override
public synchronized void advance(Duration duration) {

@openinx openinx Oct 15, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@openinx
openinx marked this pull request as ready for review October 15, 2025 22:41
@openinx openinx closed this Oct 15, 2025
@openinx openinx reopened this Oct 15, 2025
void advance(Duration duration);

static Clock systemClock() {
return new SystemClock();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tdas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very clean! thank you for doing this. only minor comments to address.

public AbfsVendedTokenProvider() {
}

AbfsVendedTokenProvider(Clock clock, long renewalLeadTimeMillis) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this non-public constructor to create the provider with specified clock and renewalLeadTimeMillis.

initialize(conf);
}

AwsVendedTokenProvider(Configuration conf, Clock clock, long renewalLeadTimeMillis) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

this(Clock.systemClock(), DEFAULT_RENEWAL_LEAD_TIME_MILLIS);
}

GenericCredentialProvider(Clock clock, long renewalLeadTimeMillis) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it as non-public, since it's mainly for testing purposes.

}

// For testing purpose only.
void setRenewalLeadTimeMillis(long renewalLeadTimeMillis) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this for testing purpose setter, since we are passing it via the constuctor.

void advance(Duration duration);

static Clock systemClock() {
return SystemClock.SINGLETON;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use the SINGLETON of the SystemClock.

@openinx

openinx commented Oct 16, 2025

Copy link
Copy Markdown
Collaborator Author

The CI is timeout, seems unrelated.

Waiting for UC server... (41/48)
Waiting for UC server... (42/48)
Waiting for UC server... (43/48)
Waiting for UC server... (44/48)
Waiting for UC server... (45/48)
Waiting for UC server... (46/48)
Waiting for UC server... (47/48)
Waiting for UC server... (48/48)
ai/dev/start_unitycatalog.sh: line 36: kill: (2155) - No such process
UC server failed to start within 240 seconds
Error: Process completed with exit code 1.

Let's retry.

@openinx openinx closed this Oct 16, 2025
@openinx openinx reopened this Oct 16, 2025
@openinx openinx closed this Oct 17, 2025
@openinx openinx reopened this Oct 17, 2025
@openinx

openinx commented Oct 17, 2025

Copy link
Copy Markdown
Collaborator Author

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.

@openinx openinx closed this Oct 17, 2025
@openinx openinx reopened this Oct 17, 2025
@tdas
tdas merged commit 25c1342 into unitycatalog:main Oct 17, 2025
timothyw553 pushed a commit to timothyw553/unitycatalog that referenced this pull request Oct 24, 2025
)

**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]>
openinx added a commit to openinx/unitycatalog that referenced this pull request Nov 11, 2025
)

**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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants