Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extensions for virtual time testing #19

Merged
merged 2 commits into from
Sep 30, 2021

Conversation

mickeelm
Copy link
Contributor

Came across some virtual time-testing scenarios in my own project and I felt that these were missing, wrote them and shared if you are interested in taking them in.

I'm of course open to discussion and perhaps I'm over-testing them, but I felt it was necessary to show that they actually use the methods that they are intended to bridge.

@mickeelm
Copy link
Contributor Author

So, this PR is turning four months today. Just a friendly ping...I realize the kotlin-extensions isn't super prio though.

@simonbasle
Copy link
Member

Damn @mickeelm I'm so sorry... Yeah I haven't looked at the PR list in a long time, looks like I was only subscribed to issues 😢

This PR makes total sense, but I have a comment on the tests.

@simonbasle simonbasle added this to the 1.1.5 milestone Sep 30, 2021
Copy link
Member

@simonbasle simonbasle left a comment

Choose a reason for hiding this comment

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

tests can be hardened against time-related bugs, otherwise LGTM

@@ -53,4 +58,49 @@ class StepVerifierExtensionsTests {
.verifyError<IllegalStateException>()
}

@Test
fun `testUsingVirtualTime()`() {
{ Mono.just("foo").delayElement(Duration.ofDays(1)) }
Copy link
Member

Choose a reason for hiding this comment

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

maybe, if anything goes wrong, use Duration.ofMinutes(10) or something long enough that vts is significant, but if somehow it ends up using realtime the CI won't get stuck for too long?

.testUsingVirtualTime()
.thenAwait(Duration.ofDays(1))
.expectNext("foo")
.verifyComplete()
Copy link
Member

Choose a reason for hiding this comment

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

alternatively, each of these tests could use the .expectComplete().verify(Duration.ofSeconds(1)) style here, which would put a timeout on the whole verification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's the better approach, so I decided to go with that one. As a bonus, the code is now indented in the same style as Sergei's tests above :)

@mickeelm
Copy link
Contributor Author

No worries, I forgot the PR existed even :)

I'll have a look and make some changes.

…l time, in order to not accidentally keep a build going for days.
Copy link
Member

@simonbasle simonbasle left a comment

Choose a reason for hiding this comment

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

thanks for the PR 👍

@simonbasle simonbasle merged commit bf62063 into reactor:main Sep 30, 2021
@mickeelm mickeelm deleted the virtual_time branch September 30, 2021 20:02
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.

None yet

2 participants