This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
874 additions
and
2 deletions.
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
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,23 @@ | ||
version: '3' | ||
services: | ||
# Neo4j service | ||
neo4j: | ||
build: | ||
context: . | ||
dockerfile: ./docker/neo4j/Dockerfile | ||
ports: | ||
- "7474:7474" | ||
- "7687:7687" | ||
volumes: | ||
- .:/source | ||
container_name: "fdw-neo4j" | ||
# Custom postgres from dokerfile | ||
postgres: | ||
build: | ||
context: . | ||
dockerfile: ./docker/postgres/Dockerfile | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- .:/source | ||
container_name: "fdw-pg" |
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,6 @@ | ||
FROM neo4j:3.5-enterprise AS fdwNeo4j | ||
|
||
ENV NEO4J_ACCEPT_LICENSE_AGREEMENT=yes | ||
ENV EXTENSION_SCRIPT=/source/docker/neo4j/init.sh | ||
|
||
RUN apk add --no-cache curl |
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,33 @@ | ||
#!/bin/bash | ||
echo "~~~" | ||
echo "~ Changing password" | ||
echo "~~~" | ||
su-exec neo4j bin/neo4j-admin set-initial-password admin | ||
|
||
echo "~~~" | ||
echo "~ Starting Neo4j" | ||
echo "~~~" | ||
su-exec neo4j bin/neo4j start | ||
|
||
# Wait until the database is up and ready | ||
echo "~~~" | ||
echo "~ Waiting Neo4j to be ready" | ||
echo "~~~" | ||
until $(curl --output /dev/null --silent --head --fail http://localhost:7474); do | ||
printf '.' | ||
sleep 1 | ||
done | ||
echo | ||
|
||
# Load the data with the cypher shell | ||
echo "~~~" | ||
echo "~ Init database" | ||
echo "~~~" | ||
su-exec neo4j bin/cypher-shell -u neo4j -p admin < /source/docker/neo4j/initdb.gql | ||
|
||
tail -f logs/* | ||
|
||
echo "~~~" | ||
echo "~ Stopping Neo4j" | ||
echo "~~~" | ||
su-exec neo4j bin/neo4j stop |
Large diffs are not rendered by default.
Oops, something went wrong.
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,25 @@ | ||
FROM postgres:10 AS fdwPostgres | ||
|
||
ENV POSTGRES_USER postgres | ||
ENV POSTGRES_PASSWORD postgres | ||
ENV POSTGRES_DB test | ||
|
||
RUN mkdir -p /neo4j-fdw | ||
COPY . /neo4j-fdw/source | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
postgresql-server-dev-10 \ | ||
python-dev \ | ||
python-setuptools \ | ||
python-dev \ | ||
python-pip \ | ||
postgresql-plpython-10 \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN ["chmod", "+x", "/neo4j-fdw/source/docker/postgres/init.sh"] | ||
RUN /neo4j-fdw/source/docker/postgres/init.sh | ||
|
||
ADD ./docker/postgres/initdb.sql /docker-entrypoint-initdb.d |
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,13 @@ | ||
#!/bin/bash | ||
|
||
# Install Multicorn | ||
echo "~~~~~~~~~~~~~ Installing multicorn" | ||
cd /neo4j-fdw/ | ||
git clone git://github.com/Kozea/Multicorn.git | ||
cd Multicorn | ||
make && make install | ||
|
||
# Install neo4j fdw | ||
echo "~~~~~~~~~~~~~ Installing Neo4j FDW" | ||
cd /neo4j-fdw/source/ | ||
python setup.py install |
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,35 @@ | ||
|
||
CREATE EXTENSION multicorn; | ||
|
||
CREATE SERVER multicorn_neo4j FOREIGN DATA WRAPPER multicorn | ||
OPTIONS ( | ||
wrapper 'neo4jPg.neo4jfdw.Neo4jForeignDataWrapper', | ||
url 'bolt://neo4j:7687', | ||
user 'neo4j', | ||
password 'admin' | ||
); | ||
|
||
CREATE FOREIGN TABLE movie ( | ||
id bigint NOT NULL, | ||
title varchar NOT NULL, | ||
released smallint, | ||
tagline varchar | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (n:Movie) RETURN id(n) AS id, n.title AS title, n.released AS released, n.tagline AS tagline' | ||
); | ||
|
||
CREATE FOREIGN TABLE person ( | ||
id bigint NOT NULL, | ||
name varchar NOT NULL, | ||
born smallint | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (n:Person) RETURN id(n) AS id, n.name AS name, n.born AS born' | ||
); | ||
|
||
CREATE FOREIGN TABLE actedIn ( | ||
id bigint NOT NULL, | ||
movie_id bigint NOT NULL, | ||
person_id bigint NOT NULL | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (p:Person)-[r:ACTED_IN]->(m:Movie) RETURN id(r) AS id, id(p) AS person_id, id(m) AS movie_id' | ||
); |
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
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,24 @@ | ||
#!/bin/bash | ||
|
||
rm -f /tmp/regression.diffs | ||
|
||
TEST_DIRECTORY=$1 | ||
|
||
TEST_SUITE="" | ||
for file in $TEST_DIRECTORY/sql/*.sql | ||
do | ||
NAME=`basename $file .sql` | ||
TEST_SUITE="$TEST_SUITE $NAME" | ||
done | ||
|
||
echo "$TEST_SUITE" | ||
su postgres <<EOF | ||
export PATH=$PATH:/usr/lib/postgresql/10/lib/pgxs/src/test/regress/ | ||
cd $TEST_DIRECTORY | ||
echo "pg_regress $TEST_SUITE" | ||
pg_regress --outputdir=/tmp $TEST_SUITE | ||
EOF | ||
|
||
if [ -f '/tmp/regression.diffs' ]; then | ||
exit 1 | ||
fi |
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,5 +1,4 @@ | ||
from setuptools import setup, find_packages | ||
|
||
import neo4jPg | ||
|
||
setup( | ||
|
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,30 @@ | ||
CREATE EXTENSION multicorn; | ||
CREATE SERVER multicorn_neo4j FOREIGN DATA WRAPPER multicorn | ||
OPTIONS ( | ||
wrapper 'neo4jPg.neo4jfdw.Neo4jForeignDataWrapper', | ||
url 'bolt://neo4j:7687', | ||
user 'neo4j', | ||
password 'admin' | ||
); | ||
CREATE FOREIGN TABLE movie ( | ||
id bigint NOT NULL, | ||
title varchar NOT NULL, | ||
released smallint, | ||
tagline varchar | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (n:Movie) RETURN id(n) AS id, n.title AS title, n.released AS released, n.tagline AS tagline' | ||
); | ||
CREATE FOREIGN TABLE person ( | ||
id bigint NOT NULL, | ||
name varchar NOT NULL, | ||
born smallint | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (n:Person) RETURN id(n) AS id, n.name AS name, n.born AS born' | ||
); | ||
CREATE FOREIGN TABLE actedIn ( | ||
id bigint NOT NULL, | ||
movie_id bigint NOT NULL, | ||
person_id bigint NOT NULL | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (p:Person)-[r:ACTED_IN]->(m:Movie) RETURN id(r) AS id, id(p) AS person_id, id(m) AS movie_id' | ||
); |
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,52 @@ | ||
SELECT * FROM movie LIMIT 10; | ||
id | title | released | tagline | ||
----+------------------------+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
0 | The Matrix | 1999 | Welcome to the Real World | ||
9 | The Matrix Reloaded | 2003 | Free your mind | ||
10 | The Matrix Revolutions | 2003 | Everything that has a beginning has an end | ||
11 | The Devil's Advocate | 1997 | Evil has its winning ways | ||
15 | A Few Good Men | 1992 | In the heart of the nation's capital, in a courthouse of the U.S. government, one man will stop at nothing to keep his honor, and one will stop at nothing to find the truth. | ||
29 | Top Gun | 1986 | I feel the need, the need for speed. | ||
37 | Jerry Maguire | 2000 | The rest of his life begins now. | ||
46 | Stand By Me | 1986 | For some, it's the last real taste of innocence, and the first real taste of life. But for everyone, it's the time that memories are made of. | ||
52 | As Good as It Gets | 1997 | A comedy from the heart that goes for the throat. | ||
56 | What Dreams May Come | 1998 | After life there is more. The end is just the beginning. | ||
(10 rows) | ||
|
||
SELECT * FROM movie m WHERE m.released > 2000 ORDER BY m.released DESC LIMIT 10; | ||
id | title | released | tagline | ||
-----+------------------------+----------+------------------------------------------------------------------------------------------------------- | ||
105 | Cloud Atlas | 2012 | Everything is connected | ||
128 | Ninja Assassin | 2009 | Prepare to enter a secret world of assassins | ||
137 | Frost/Nixon | 2008 | 400 million people were waiting for the truth. | ||
121 | Speed Racer | 2008 | Speed has no limits | ||
159 | Charlie Wilson's War | 2007 | A stiff drink. A little mascara. A lot of nerve. Who said they couldn't bring down the Soviet empire. | ||
111 | The Da Vinci Code | 2006 | Break The Codes | ||
116 | V for Vendetta | 2006 | Freedom! Forever! | ||
92 | RescueDawn | 2006 | Based on the extraordinary true story of one man's fight for freedom | ||
161 | The Polar Express | 2004 | This Holiday Season… Believe | ||
154 | Something's Gotta Give | 2003 | | ||
(10 rows) | ||
|
||
SELECT * FROM movie m WHERE m.title = 'The Matrix'; | ||
id | title | released | tagline | ||
----+------------+----------+--------------------------- | ||
0 | The Matrix | 1999 | Welcome to the Real World | ||
(1 row) | ||
|
||
SELECT * FROM movie m WHERE m.title LIKE '%Matrix%'; | ||
id | title | released | tagline | ||
----+------------------------+----------+-------------------------------------------- | ||
0 | The Matrix | 1999 | Welcome to the Real World | ||
9 | The Matrix Reloaded | 2003 | Free your mind | ||
10 | The Matrix Revolutions | 2003 | Everything that has a beginning has an end | ||
(3 rows) | ||
|
||
SELECT * FROM movie m WHERE m.title ILIKE '%matrix%'; | ||
id | title | released | tagline | ||
----+------------------------+----------+-------------------------------------------- | ||
0 | The Matrix | 1999 | Welcome to the Real World | ||
9 | The Matrix Reloaded | 2003 | Free your mind | ||
10 | The Matrix Revolutions | 2003 | Everything that has a beginning has an end | ||
(3 rows) | ||
|
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,35 @@ | ||
|
||
CREATE EXTENSION multicorn; | ||
|
||
CREATE SERVER multicorn_neo4j FOREIGN DATA WRAPPER multicorn | ||
OPTIONS ( | ||
wrapper 'neo4jPg.neo4jfdw.Neo4jForeignDataWrapper', | ||
url 'bolt://neo4j:7687', | ||
user 'neo4j', | ||
password 'admin' | ||
); | ||
|
||
CREATE FOREIGN TABLE movie ( | ||
id bigint NOT NULL, | ||
title varchar NOT NULL, | ||
released smallint, | ||
tagline varchar | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (n:Movie) RETURN id(n) AS id, n.title AS title, n.released AS released, n.tagline AS tagline' | ||
); | ||
|
||
CREATE FOREIGN TABLE person ( | ||
id bigint NOT NULL, | ||
name varchar NOT NULL, | ||
born smallint | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (n:Person) RETURN id(n) AS id, n.name AS name, n.born AS born' | ||
); | ||
|
||
CREATE FOREIGN TABLE actedIn ( | ||
id bigint NOT NULL, | ||
movie_id bigint NOT NULL, | ||
person_id bigint NOT NULL | ||
) SERVER multicorn_neo4j OPTIONS ( | ||
cypher 'MATCH (p:Person)-[r:ACTED_IN]->(m:Movie) RETURN id(r) AS id, id(p) AS person_id, id(m) AS movie_id' | ||
); |
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,5 @@ | ||
SELECT * FROM movie LIMIT 10; | ||
SELECT * FROM movie m WHERE m.released > 2000 ORDER BY m.released DESC LIMIT 10; | ||
SELECT * FROM movie m WHERE m.title = 'The Matrix'; | ||
SELECT * FROM movie m WHERE m.title LIKE '%Matrix%'; | ||
SELECT * FROM movie m WHERE m.title ILIKE '%matrix%'; |
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,10 @@ | ||
import unittest | ||
from neo4jPg import neo4jfdw | ||
|
||
class SimplisticTest(unittest.TestCase): | ||
|
||
def test(self): | ||
self.assertTrue(True) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,59 @@ | ||
#!/bin/bash | ||
|
||
|
||
#################################################################### | ||
# Before all tests | ||
#################################################################### | ||
echo "~~~" | ||
echo "~ Before all tests" | ||
echo "~~~" | ||
echo | ||
|
||
echo | ||
echo "~ Run docker compose" | ||
docker-compose rm -f | ||
docker-compose pull | ||
docker-compose up --build --detach | ||
sleep 10 | ||
|
||
#################################################################### | ||
# Run python unit test | ||
#################################################################### | ||
echo "~~~" | ||
echo "~ Running python tests" | ||
echo "~~~" | ||
echo | ||
|
||
py.test | ||
|
||
RESULT=$? | ||
if [ $RESULT -gt 0 ]; then | ||
echo "Some python tests failed" | ||
exit 1 | ||
fi | ||
|
||
#################################################################### | ||
# Running pg_regress tests | ||
#################################################################### | ||
echo "~~~" | ||
echo "~ Running pg_regress tests" | ||
echo "~~~" | ||
echo | ||
|
||
echo "~ Execute pg_regress tests" | ||
docker exec -it fdw-pg /source/pg_regress.sh /source/test | ||
if [ $? -gt 0 ]; then | ||
echo "Some regress test failed" | ||
exit 1 | ||
fi | ||
|
||
#################################################################### | ||
# After all tests | ||
#################################################################### | ||
echo "~~~" | ||
echo "~ After all tests" | ||
echo "~~~" | ||
echo | ||
|
||
echo "~ Stop docker containers" | ||
docker-compose down |