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

Fix flaky test mavenRootPomHandlerBaseDirIsCorrect #4452

Merged
merged 22 commits into from May 22, 2024

Conversation

vchikoti1998
Copy link
Contributor

@vchikoti1998 vchikoti1998 commented May 8, 2024

Types of changes

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

The test case mavenRootPomHandlerBaseDirIsCorrect() was updated to use runBlocking instead of runTestrunBlocking is a Kotlin coroutines function that helps bridge regular blocking code (code that stops the current thread) 
with coroutine based code (code that suspends execution and allows other tasks to run concurrently). 
Using runBlocking resolved the issue with uncaught exceptions that was occurring when using the more specialized 
runTest function.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vchikoti1998 vchikoti1998 changed the title Fix flaky tests [WIP] Fix flaky tests May 8, 2024
@vchikoti1998
Copy link
Contributor Author

vchikoti1998 commented May 9, 2024

/retryBuild

@vchikoti1998
Copy link
Contributor Author

/retryBuilds

@vchikoti1998 vchikoti1998 changed the title [WIP] Fix flaky tests Fix flaky test mavenRootPomHandlerBaseDirIsCorrect May 14, 2024
@vchikoti1998 vchikoti1998 marked this pull request as ready for review May 14, 2024 18:59
@vchikoti1998 vchikoti1998 requested a review from a team as a code owner May 14, 2024 18:59
@@ -61,7 +61,7 @@ class JavaLambdaBuilderTest {
}

@Test
fun mavenRootPomHandlerBaseDirIsCorrect() = runTest {
fun mavenRootPomHandlerBaseDirIsCorrect(): Unit = runBlocking {
Copy link
Contributor

Choose a reason for hiding this comment

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

tests should use runTest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will revert it

Copy link
Contributor

Choose a reason for hiding this comment

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

discussed offline, the issue is with runTest and the fix is in a later version of coroutines-test

@@ -17,7 +17,7 @@ junit5 = "5.10.2"
# https://kotlinlang.org/docs/releases.html#release-details
kotlin = "1.9.23"
# set in <root>/settings.gradle.kts
kotlinCoroutines = "1.7.3"
kotlinCoroutines = "1.8.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@@ -61,7 +61,7 @@ class JavaLambdaBuilderTest {
}

@Test
fun mavenRootPomHandlerBaseDirIsCorrect() = runTest {
fun mavenRootPomHandlerBaseDirIsCorrect(): Unit = runBlocking {
Copy link
Contributor

Choose a reason for hiding this comment

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

it would also be good to add a comment in the source code explaining why we're using runBlocking

Suggested change
fun mavenRootPomHandlerBaseDirIsCorrect(): Unit = runBlocking {
fun mavenRootPomHandlerBaseDirIsCorrect() = runBlocking {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure Definitely, will add a comment.
mavenRootPomHandlerBaseDirIsCorrect() method signature can't be removed its not taking Unit as default

Copy link

sonarcloud bot commented May 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@vchikoti1998 vchikoti1998 merged commit bd0261a into main May 22, 2024
12 of 14 checks passed
@vchikoti1998 vchikoti1998 deleted the vchikoti/fix_flaky_tests_on_mac branch May 22, 2024 01:42
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