2014-11-04 20 views
1

我正在使用Neo4j和Node.js來構建REST API。如何在同一臺計算機上安裝2個Neo4j數據庫:dev和test

我想寫這個API的一些測試。如何在這些測試中使用「測試數據庫」?

使用MySQL或MongoDB,我會擺弄資源URL以使用不同的數據庫,如「app-test」vs「app」。

在neo4j中做這件事的智能方法是什麼?

謝謝!

解決方案:這是我做過什麼:

做了一個目錄DB /測試。在該目錄,把:

  • 2的bash腳本如下
  • 一個test.zip你想要的數據庫備份

install.sh

#!/bin/bash 

VERSION=neo4j-community-2.1.5 

# Download a copy of the server 
wget http://dist.neo4j.org/$VERSION-unix.tar.gz 
# Unpack it here 
tar -xvzf $VERSION-unix.tar.gz 
# Change the default port to http->7475 https->7476 
sed -i.bak s/7474/7475/g $VERSION/conf/neo4j-server.properties 
sed -i.bak s/7473/7476/g $VERSION/conf/neo4j-server.properties 

restart.sh

#!/bin/bash 

VERSION=neo4j-community-2.1.5 

echo === stop the server 
$VERSION/bin/neo4j stop 

echo --- replace the database 
rm -rf $VERSION/data/graph.db 
unzip -q test.zip -d $VERSION/data/graph.db 

echo --- start the server 
$VERSION/bin/neo4j start 

然後將它添加到g使用grunt-run運行的runtfile:

run: { 
    restartTestDb: { 
    exec: 'cd db/test && ./restart.sh', 
    } 
}, 

Works。

回答

2

你可以用neo4j做同樣的事情。只需在一個單獨的位置安裝neo4j的另一個副本,然後configure it to use a different port

每次測試後,您可以刪除graph.db文件以清除所有數據。

2

我目前正在忙於一個可以從命令行管理和切換數據庫的項目。

我忙於修復neo4j下載功能,這仍然在WIP中,但用戶越多,它就越穩定。

我應該在一兩個小時內推github。

編輯:庫這裏https://github.com/neoxygen/neo4j-toolkit

這裏http://recordit.co/YRVhOJKXdj

+0

視頻直播哎,我沒有嘗試這一點,但它看起來很酷。 – 2014-11-04 23:32:37

相關問題