Skip to content

Commit

Permalink
test: integrationtest with pg mysql and mssql
Browse files Browse the repository at this point in the history
- use tests according to konserve-jdbc with mssql and mysql
  • Loading branch information
TimoKramer committed Jan 22, 2023
1 parent 7369dd4 commit 6903e1b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workflows:
context: dockerhub-deploy
requires:
- tools/setup
- tools/integrationtest-postgresql-mariadb:
- tools/integrationtest-postgresql-mysql-mssql:
context: dockerhub-deploy
requires:
- tools/setup
Expand All @@ -33,7 +33,7 @@ workflows:
requires:
- tools/setup
- tools/format
- tools/integrationtest-postgresql-mariadb
- tools/integrationtest-postgresql-mysql-mssql
- tools/build
- tools/deploy-release:
jarname: "datahike-jdbc"
Expand All @@ -46,5 +46,5 @@ workflows:
requires:
- tools/setup
- tools/format
- tools/integrationtest-postgresql-mariadb
- tools/integrationtest-postgresql-mysql-mssql
- tools/build
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pom.xml
pom.xml.asc
*.jar
*.class
Expand Down
16 changes: 12 additions & 4 deletions bin/run-integrationtests
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@ function setup_PG() {
fi
}

function setup_MARIA() {
function setup_MYSQL() {
if [ -z ${CIRCLECI} ]; then
echo $(docker run --detach --publish 3306:3306 --env MYSQL_RANDOM_ROOT_PASSWORD=true --env MYSQL_DATABASE=config-test --env MYSQL_USER=alice --env MYSQL_PASSWORD=foo docker.io/mariadb:10)
echo $(docker run --detach --publish 3306:3306 --env MYSQL_RANDOM_ROOT_PASSWORD=true --env MYSQL_DATABASE=config-test --env MYSQL_USER=alice --env MYSQL_PASSWORD=foo docker.io/mysql:8)
fi
}

function setup_MSSQL() {
if [ -z ${CIRCLECI} ]; then
echo $(docker run --detach --publish 1433:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD=passwordA1! --env MSSQL_PID=Developer --env MSSQL_TCP_PORT=1433 mcr.microsoft.com/mssql/server:2019-latest)
fi
}

function teardown() {
if [ -z ${CIRCLECI} ]; then
docker rm -f ${PG_NAME}
docker rm -f ${MARIA_NAME}
docker rm -f ${MYSQL_NAME}
docker rm -f ${MSSQL_NAME}
fi
}

PG_NAME=$(setup_PG)
MARIA_NAME=$(setup_MARIA)
MYSQL_NAME=$(setup_MYSQL)
MSSQL_NAME=$(setup_MSSQL)

sleep 5

Expand Down
48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.replikativ</groupId>
<artifactId>datahike-jdbc</artifactId>
<packaging>jar</packaging>
<name>datahike-jdbc</name>
<description>A JDBC backend for Datahike</description>
<version>0.1.2-SNAPSHOT</version>
<url>https://datahike.io</url>
<licenses>
<license>
<name>Eclipse</name>
<url>http://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>
<scm>
<connection>scm:git:[email protected]:replikativ/datahike-jdbc.git</connection>
<developerConnection>scm:git:[email protected]/replikativ/datahike-jdbc.git</developerConnection>
<url>https://github.com/replikativ/datahike-jdbc</url>
</scm>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.10.3</version>
</dependency>
<dependency>
<groupId>io.replikativ</groupId>
<artifactId>konserve-jdbc</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>io.replikativ</groupId>
<artifactId>superv.async</artifactId>
<version>0.2.11</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
<repositories>
<repository>
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
</project>
30 changes: 30 additions & 0 deletions test/datahike_jdbc/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@
(d/delete-database config)
(is (not (d/database-exists? config))))))

(deftest ^:integration test-mssql
(let [config {:store {:backend :jdbc
:dbtype "sqlserver"
:user "sa"
:password "passwordA1!"
:dbname "tempdb"}
:schema-flexibility :write
:keep-history? false}
_ (d/delete-database config)]
(is (not (d/database-exists? config)))
(let [_ (d/create-database config)
conn (d/connect config)]
(d/transact conn [{:db/ident :name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}
{:db/ident :age
:db/valueType :db.type/long
:db/cardinality :db.cardinality/one}])
(d/transact conn [{:db/id 1, :name "Ivan", :age 15}
{:db/id 2, :name "Petr", :age 37}
{:db/id 3, :name "Ivan", :age 37}
{:db/id 4, :age 15}])
(is (= (d/q '[:find ?e :where [?e :name]] @conn)
#{[3] [2] [1]}))

(d/release conn)
(is (d/database-exists? config))
(d/delete-database config)
(is (not (d/database-exists? config))))))

(deftest ^:integration test-h2
(let [config {:store {:backend :jdbc
:dbtype "h2"
Expand Down

0 comments on commit 6903e1b

Please sign in to comment.