forked from testcontainers/testcontainers-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make pgvector available with JDBC syntax (testcontainers#8633)
- Loading branch information
1 parent
18ea976
commit 58072a7
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...les/postgresql/src/main/java/org/testcontainers/containers/PgVectorContainerProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.testcontainers.containers; | ||
|
||
import org.testcontainers.jdbc.ConnectionUrl; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
/** | ||
* Factory for PgVector containers. | ||
* | ||
* @see <a href="https://github.com/pgvector/pgvector">https://github.com/pgvector/pgvector</a> | ||
*/ | ||
public class PgVectorContainerProvider extends JdbcDatabaseContainerProvider { | ||
|
||
private static final String NAME = "pgvector"; | ||
|
||
private static final String DEFAULT_TAG = "pg16"; | ||
|
||
private static final DockerImageName DEFAULT_IMAGE = DockerImageName | ||
.parse("pgvector/pgvector") | ||
.asCompatibleSubstituteFor("postgres"); | ||
|
||
public static final String USER_PARAM = "user"; | ||
|
||
public static final String PASSWORD_PARAM = "password"; | ||
|
||
@Override | ||
public boolean supports(String databaseType) { | ||
return databaseType.equals(NAME); | ||
} | ||
|
||
@Override | ||
public JdbcDatabaseContainer newInstance() { | ||
return newInstance(DEFAULT_TAG); | ||
} | ||
|
||
@Override | ||
public JdbcDatabaseContainer newInstance(String tag) { | ||
return new PostgreSQLContainer(DEFAULT_IMAGE.withTag(tag)); | ||
} | ||
|
||
@Override | ||
public JdbcDatabaseContainer newInstance(ConnectionUrl connectionUrl) { | ||
return newInstanceFromConnectionUrl(connectionUrl, USER_PARAM, PASSWORD_PARAM); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...n/resources/META-INF/services/org.testcontainers.containers.JdbcDatabaseContainerProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
org.testcontainers.containers.PostgreSQLContainerProvider | ||
org.testcontainers.containers.PostgisContainerProvider | ||
org.testcontainers.containers.TimescaleDBContainerProvider | ||
org.testcontainers.containers.PgVectorContainerProvider |
28 changes: 28 additions & 0 deletions
28
...les/postgresql/src/test/java/org/testcontainers/jdbc/pgvector/PgVectorJDBCDriverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.testcontainers.jdbc.pgvector; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.testcontainers.jdbc.AbstractJDBCDriverTest; | ||
|
||
import java.util.Arrays; | ||
import java.util.EnumSet; | ||
|
||
@RunWith(Parameterized.class) | ||
public class PgVectorJDBCDriverTest extends AbstractJDBCDriverTest { | ||
|
||
@Parameterized.Parameters(name = "{index} - {0}") | ||
public static Iterable<Object[]> data() { | ||
return Arrays.asList( | ||
new Object[][] { | ||
{ | ||
"jdbc:tc:pgvector://hostname/databasename?user=someuser&password=somepwd", | ||
EnumSet.of(Options.JDBCParams), | ||
}, | ||
{ | ||
"jdbc:tc:pgvector:pg14://hostname/databasename?user=someuser&password=somepwd", | ||
EnumSet.of(Options.JDBCParams), | ||
}, | ||
} | ||
); | ||
} | ||
} |