-
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 8 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
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||
|
|
||||||
| import java.util.HashMap; | ||||||
|
|
||||||
| import com.falkordb.test.BaseTestContainerTestIT; | ||||||
drr00t marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| import org.junit.jupiter.api.AfterEach; | ||||||
| import org.junit.jupiter.api.Assertions; | ||||||
| import org.junit.jupiter.api.BeforeEach; | ||||||
|
|
@@ -14,13 +15,13 @@ | |||||
| import com.falkordb.GraphContext; | ||||||
| import com.falkordb.GraphContextGenerator; | ||||||
|
|
||||||
| public class GraphErrorTest { | ||||||
| public class GraphErrorTest extends BaseTestContainerTestIT { | ||||||
drr00t marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| private GraphContextGenerator api; | ||||||
|
|
||||||
| @BeforeEach | ||||||
| public void createApi() { | ||||||
| api = FalkorDB.driver().graph("social"); | ||||||
| api = FalkorDB.driver(getFalkordbHost(),getFalkordbPort()).graph("social"); | ||||||
|
||||||
| api = FalkorDB.driver(getFalkordbHost(),getFalkordbPort()).graph("social"); | |
| api = FalkorDB.driver(getFalkordbHost(), getFalkordbPort()).graph("social_" + System.nanoTime()); |
🤖 Prompt for AI Agents
In src/test/java/com/falkordb/exceptions/GraphErrorTest.java around line 24, the
test uses a fixed graph name "social" which can cause cross-test collisions;
change the graph creation to use a unique name per test run (for example append
a random UUID or the current timestamp or the test method/class name) so each
test uses its own isolated graph; update the line to build the graph name
dynamically (e.g., "social-" + UUID.randomUUID() or similar) when calling
FalkorDB.driver(...).graph(...).
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||
| 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.containers.wait.strategy.Wait; | ||||
| import org.testcontainers.junit.jupiter.Container; | ||||
| import org.testcontainers.utility.DockerImageName; | ||||
|
|
||||
| import java.time.Duration; | ||||
|
|
||||
| public class BaseTestContainerTestIT { | ||||
| private static final Logger log = LoggerFactory.getLogger(BaseTestContainerTestIT.class); | ||||
| public static final DockerImageName FALKORDB_IMAGE = DockerImageName.parse("falkordb/falkordb:latest"); | ||||
| public static final int FALKORDB_PORT = 6379; | ||||
|
|
||||
| @Container | ||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| private static GenericContainer<?> containerFalkorDB; | ||||
| private static final int falkordbPort = 6379; // Default port for Falkordb, adjust if necessary | ||||
|
|
||||
|
Comment on lines
+20
to
+21
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. 🛠️ Refactor suggestion Remove unused duplicate port constant The private static falkordbPort (Line 22) duplicates FALKORDB_PORT and is unused. - private static final int falkordbPort = 6379; // Default port for Falkordb, adjust if necessary📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||
| @BeforeAll | ||||
| public static void setUpContainer() { | ||||
| // allow overriding image via -Dfalkordb.image=repo/image:tag | ||||
| DockerImageName image = DockerImageName.parse( | ||||
| System.getProperty("falkordb.image", FALKORDB_IMAGE.asCanonicalNameString()) | ||||
| ); | ||||
| containerFalkorDB = new GenericContainer<>(image) | ||||
| .withExposedPorts(FALKORDB_PORT) | ||||
| .withLogConsumer(new Slf4jLogConsumer(log)) | ||||
| .waitingFor(Wait.forListeningPort()) | ||||
| .withStartupTimeout(Duration.ofSeconds(90)); | ||||
| containerFalkorDB.start(); | ||||
| } | ||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
|
||||
| @AfterAll | ||||
| public static void tearDownContainer() { | ||||
| if (containerFalkorDB != null) { | ||||
| containerFalkorDB.stop(); | ||||
| } | ||||
| } | ||||
|
|
||||
| protected int getFalkordbPort() { | ||||
| return containerFalkorDB.getFirstMappedPort(); | ||||
| } | ||||
|
|
||||
| protected String getFalkordbHost() { | ||||
| return containerFalkorDB.getHost(); | ||||
| } | ||||
| } | ||||
Uh oh!
There was an error while loading. Please reload this page.