-
Notifications
You must be signed in to change notification settings - Fork 7
Add testing it testcontainer #162
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
418f669
5de5b5e
938a88f
c56badb
2afb0f9
ea52e0a
e425fe0
eed6b72
74dbba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,25 @@ | |
| <version>3.19.4</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers</artifactId> | ||
| <version>1.21.3</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>1.21.3</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.redis</groupId> | ||
| <artifactId>testcontainers-redis</artifactId> | ||
| <version>2.2.4</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
Comment on lines
+116
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainConfirm whether com.redis:testcontainers-redis is actually used I don’t see usages in the provided diff; if unused, drop it to keep the test classpath lean. Run this to check for usage: 🏁 Script executed: #!/bin/bash
# Look for classes from com.redis.testcontainers or typical container names
rg -n -A2 -i $'package com\\.redis\\.testcontainers|Redis(Container|StackContainer)|com\\.redis\\.testcontainers' src/test || trueLength of output: 126 We'll broaden the search for any Redis-related usage in tests and code: 🏁 Script executed: #!/bin/bash
# Search for any mention of 'redis' in test sources
rg -n -i 'redis' -A2 src/test || true
# Search for RedisContainer instantiations anywhere in the repo
rg -n -i 'RedisContainer' -A2 src || trueLength of output: 6297 Unused • In 🤖 Prompt for AI Agents |
||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.falkordb.test; | ||
|
|
||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.testcontainers.containers.GenericContainer; | ||
| import org.testcontainers.containers.output.Slf4jLogConsumer; | ||
| import org.testcontainers.junit.jupiter.Container; | ||
| import org.testcontainers.utility.DockerImageName; | ||
|
|
||
| public class BaseTestIT { | ||
| private static final Logger log = LoggerFactory.getLogger(BaseTestIT.class); | ||
| public static final DockerImageName FALOKRDB_IMAGE = DockerImageName.parse("falkordb/falkordb:latest"); | ||
|
|
||
drr00t marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @Container | ||
| protected static GenericContainer<?> continerFalkordb; | ||
| private static final int falkordbPort = 6379; // Default port for Falkordb, adjust if necessary | ||
|
|
||
| @BeforeAll | ||
| public static void setUpContainer() { | ||
| continerFalkordb = new GenericContainer<>(FALOKRDB_IMAGE) | ||
| .withExposedPorts(falkordbPort) | ||
| .withLogConsumer(new Slf4jLogConsumer(log)); // Replace 6379 with Falkordb's default port if different | ||
| continerFalkordb.start(); | ||
| } | ||
|
|
||
| @AfterAll | ||
| public static void tearDownContainer() { | ||
| if (continerFalkordb != null) { | ||
| continerFalkordb.stop(); | ||
| } | ||
| } | ||
|
|
||
| protected int getFalkordbPort() { | ||
| return continerFalkordb.getFirstMappedPort(); | ||
| } | ||
|
|
||
| protected String getFalkordbHost() { | ||
| return continerFalkordb.getHost(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Manage Testcontainers versions via a property/BOM for consistency
Define a single testcontainers.version and import the Testcontainers BOM so all modules stay aligned. This avoids accidental version drift across artifacts.
Apply these diffs:
Add a property (Lines 69-72):
<properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> + <testcontainers.version>1.21.3</testcontainers.version> </properties>Import the BOM (add after properties; new block):
Drop explicit versions for Testcontainers artifacts (Lines 104-114):
<dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers</artifactId> - <version>1.21.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.testcontainers</groupId> <artifactId>junit-jupiter</artifactId> - <version>1.21.3</version> <scope>test</scope> </dependency>Note: keep the version for com.redis:testcontainers-redis; it’s not governed by the Testcontainers BOM.
🤖 Prompt for AI Agents