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

Testcontainers #589

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Testcontainers #589

merged 1 commit into from
Oct 15, 2024

Conversation

ok2c
Copy link
Member

@ok2c ok2c commented Oct 15, 2024

Apache HTTPD / Squid compatibility tests have been migrated to TestContainers.

This also ensures that more complex authentication scenarios that are difficult to create with our own integration test framework (various scenarios involving a proxy) will now be run along with the rest of integration tests on a regular basis.

This will especially be important for #577 and this would also provide an opportunity to create integration test cases for Kerberos auth in the future.

@arturobernalg Please take a look.

EntityUtils.consume(response.getEntity());
}

Thread.sleep(2000);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this waiting for? Is there something we could check using something like awaitility instead of hardcoding a sleep which can lead to unpredictable test behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

What's this waiting for? Is there something we could check using something like awaitility instead of hardcoding a sleep which can lead to unpredictable test behaviour.

@massdosage It is waiting for a cache entry to become stale and trigger its re-validation. I am not sure this can be done without a sleep given this is an integration test. I can however try to reduce it.

I must admit I do not know what awaitility is and whether it can be applied here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's https://github.com/awaitility/awaitility, so in this case you could do something like (pseudo code):

await().atMost(2, SECONDS).until(cacheIsStale())

It's nice for turning these kind of unpredictable sleep calls into something that effectively is "keep trying for something to happen, and if it doesn't happen within some timeout, then fail the test".

I see that this sleep was copied over from a previous version of this test so I also understand if you'd rather keep the behaviour like this for now and push out the refactoring the sleep for another day if this hasn't caused any issues with flaky tests up to now.

Copy link
Member Author

Choose a reason for hiding this comment

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

@massdosage Have mercy on me.I just discovered TestContainers no so long ago and one throws awaitility at me on top of it.

Seriously our test cases are full of CountDownLatch based synchronization code and other ugliness. I would prefer to take a look at awaitility as a way of improving our async testing code overall and not just to replace an occasional Thread#sleep

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, sounds better to take the approach where you fix more things at once than just this one :) So just leave this "as is" for now. If you want to create an issue summarising where you think something like awaitility could improve the tests I might be able to take a look at it.

I'm a big fan of TestContainers, have used it successfully on a number of projects to bring the "Docker Tests" alongside the rest of the Java tests so I'm happy to see it being used here. One just has to be careful to limit the number of these tests as they are slowly and more resource hungry.

Copy link
Member

@arturobernalg arturobernalg left a comment

Choose a reason for hiding this comment

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

@ok2c The changes look reasonable to me, even though I don't have prior experience with TestContainers.

@ok2c
Copy link
Member Author

ok2c commented Oct 15, 2024

@ok2c The changes look reasonable to me, even though I don't have prior experience with TestContainers.

@arturobernalg Honestly, nether do it. It is a learning process for me as well. But it is good to have an extra pair of eye balls looking at a big change to the project.

@ok2c ok2c merged commit 0335839 into apache:master Oct 15, 2024
10 checks passed
@ok2c ok2c deleted the testcontainers branch October 15, 2024 20:17
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.

3 participants