Skip to content

Conversation

@andrew-nowak
Copy link
Member

What does this change?

@Conalb97 raised that docker-testkit has some sort of incompatibility with M1 macs on certain JDKs. docker-testkit isn't receiving maintenance updates, and neither is the underlying docker client, so this is a good opportunity to replace it with a direct usage of testcontainers (mainly taking inspiration from Ophan https://github.com/guardian/ophan/blob/2ecb80da40915ce097e4a1de0e29b352b396323e/shared-lib/src/test/scala/app/BaseElasticTest.scala#L153 though we share the container between the tests, instead of a container per test, for a mild performance boost)

@github-actions
Copy link

github-actions bot commented Jan 26, 2024

@andrew-nowak andrew-nowak force-pushed the an/modern-testcontainers branch from 7ec35a1 to afc5fe0 Compare June 14, 2024 11:33
@andrew-nowak andrew-nowak marked this pull request as ready for review June 17, 2024 14:17
@andrew-nowak andrew-nowak requested a review from a team as a code owner June 17, 2024 14:17
@AndyKilmory
Copy link
Collaborator

I can see nothing that would present a problem for BBC devs. Thanks

Copy link
Contributor

@twrichards twrichards left a comment

Choose a reason for hiding this comment

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

LGTM - nice one @andrew-nowak 🙌

(note, I rebased #4287 on top to get it to build 🎉 - thank you)

Comment on lines 30 to 58
val esContainer: Option[ElasticsearchContainer] = if (useEsDocker) {
{
val container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.16.2")
.withExposedPorts(9200)
.withAccessToHost(true)
.withEnv(Map(
"cluster.name" -> "media-service",
"xpack.security.enabled" -> "false",
"discovery.type" -> "single-node",
"network.host" -> "0.0.0.0"
).asJava)
.waitingFor(Wait.forHttp("/")
.forPort(9200)
.forStatusCode(200)
.withStartupTimeout(180.seconds.toJava)
)
container.start()
Some(container)
}
} else None

val esPort = esContainer.map(_.getMappedPort(9200)).getOrElse(9200)
val es6TestUrl = Properties.envOrElse("ES6_TEST_URL", s"http://localhost:$esPort")

override protected def afterAll(): Unit = {
super.afterAll()

esContainer foreach { _.stop() }
}
Copy link
Contributor

@twrichards twrichards Jun 20, 2024

Choose a reason for hiding this comment

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

any chance we could DRY this out and have this and thrall equivalent extend something in common? (appreciate it's not rule of 3, but seems like a lot of code with various config options therein which presents scope for divergence).

@davidfurey
Copy link
Member

I had a similar issue with path-manager, which I fixed in guardian/path-manager#61 by adding an explicit dependency on a newer version of jnr-unixsocket

@andrew-nowak
Copy link
Member Author

I had a similar issue with path-manager, which I fixed in guardian/path-manager#61 by adding an explicit dependency on a newer version of jnr-unixsocket

Thanks that's a good find! However the docker lib is still unmaintained and these sorts of problems are gonna continue ramping up - so I think it's still worth replacing with the fresher/slimmer lib

Copy link
Contributor

@twrichards twrichards left a comment

Choose a reason for hiding this comment

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

nice, thanks for DRYing

@davidfurey
Copy link
Member

I had a similar issue with path-manager, which I fixed in guardian/path-manager#61 by adding an explicit dependency on a newer version of jnr-unixsocket

Thanks that's a good find! However the docker lib is still unmaintained and these sorts of problems are gonna continue ramping up - so I think it's still worth replacing with the fresher/slimmer lib

Seems reasonable. If you were feeling keen and wanted to apply the same approach to path-manager, I'd be very grateful.

@prout-bot
Copy link

Seen on auth, usage, metadata-editor, thrall, leases, cropper, collections, media-api, kahuna (merged by @andrew-nowak 9 minutes and 36 seconds ago) Please check your changes!

@prout-bot
Copy link

Seen on image-loader (merged by @andrew-nowak 9 minutes and 48 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants