Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ python:
- 3.5
- 3.6
before_install:
- sh scripts/setup_arangodb.sh
- bash scripts/setup_arangodb.sh
install:
- pip install coverage
- pip install pytest
Expand Down
14 changes: 13 additions & 1 deletion arango/collections/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ def properties(self):
:raises arango.exceptions.CollectionPropertiesError: If the
collection properties cannot be retrieved.
"""
_cluster_parameters = {
'numberOfShards': 'number_of_shards',
'shardKeys': 'shard_keys',
'replicationFactor': 'replication_factor',
}

request = Request(
method='get',
endpoint='/_api/collection/{}/properties'.format(self._name)
Expand All @@ -235,7 +241,7 @@ def handler(res):

key_options = res.body.get('keyOptions', {})

return {
properties = {
'id': res.body.get('id'),
'name': res.body.get('name'),
'edge': res.body.get('type') == 3,
Expand All @@ -251,6 +257,12 @@ def handler(res):
'key_offset': key_options.get('offset')
}

for parameter, alt_name in _cluster_parameters.items():
if parameter in res.body:
properties[alt_name] = res.body.get(parameter)

return properties

return request, handler

@api_method
Expand Down
57 changes: 51 additions & 6 deletions scripts/setup_arangodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,50 @@ ARANGODB_DIR="$DIR/$NAME"
ARANGOD="${ARANGODB_DIR}/bin/arangod_x86_64"

# create database directory
mkdir ${TMP_DIR}
mkdir -p ${TMP_DIR}/agency
mkdir -p ${TMP_DIR}/primary
mkdir -p ${TMP_DIR}/coordinator

echo "Starting ArangoDB Coordinator '${ARANGOD}'"

echo "Starting ArangoDB '${ARANGOD}'"

${ARANGOD} \
--database.directory ${TMP_DIR} \
--database.directory ${TMP_DIR}/agency \
--configuration none \
--server.endpoint tcp://127.0.0.1:8531 \
--javascript.app-path ${ARANGODB_DIR}/js/apps \
--javascript.startup-directory ${ARANGODB_DIR}/js \
--server.jwt-secret=secret_password \
--database.maximal-journal-size 1048576 \
--agency.my-address=tcp://127.0.0.1:8531 \
--agency.endpoint=tcp://127.0.0.1:8531 \
--agency.activate=true \
--agency.size=1 \
--agency.supervision=true &

${ARANGOD} \
--database.directory ${TMP_DIR}/primary \
--configuration none \
--server.endpoint tcp://127.0.0.1:8530 \
--javascript.app-path ${ARANGODB_DIR}/js/apps \
--javascript.startup-directory ${ARANGODB_DIR}/js \
--server.jwt-secret=secret_password \
--database.maximal-journal-size 1048576 \
--cluster.agency-endpoint=tcp://127.0.0.1:8531 \
--cluster.my-role=PRIMARY \
--cluster.my-address=tcp://127.0.0.1:8530 &

${ARANGOD} \
--database.directory ${TMP_DIR}/coordinator \
--configuration none \
--server.endpoint tcp://127.0.0.1:8529 \
--javascript.app-path ${ARANGODB_DIR}/js/apps \
--javascript.startup-directory ${ARANGODB_DIR}/js \
--database.maximal-journal-size 1048576 &
--server.jwt-secret=secret_password \
--database.maximal-journal-size 1048576 \
--cluster.agency-endpoint=tcp://127.0.0.1:8531 \
--cluster.my-role=COORDINATOR \
--cluster.my-address=tcp://127.0.0.1:8529 &

sleep 2

Expand All @@ -45,7 +78,19 @@ if [ "x$process" == "x" ]; then
exit 1
fi

echo "Waiting until ArangoDB is ready on port 8529"
sleep 10
echo "Waiting until ArangoDB Coordinator is ready on port 8529"
timeout=120
n=0
while [[ (-z `curl -k --basic --user "root:" -s "http://127.0.0.1:8529/_api/version" `) && (n -lt timeout) ]] ; do
echo -n "."
sleep 1s
n=$[$n+1]
done

if [[ n -eq timeout ]];
then
echo "Could not start ArangoDB. Timeout reached."
exit 1
fi

echo "ArangoDB is up"
3 changes: 3 additions & 0 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def test_properties():
assert isinstance(properties['compact'], bool)
assert isinstance(properties['volatile'], bool)
assert isinstance(properties['journal_size'], int)
assert isinstance(properties['replication_factor'], int)
assert isinstance(properties['number_of_shards'], int)
assert isinstance(properties['shard_keys'], list)
assert properties['keygen'] in ('autoincrement', 'traditional')
assert isinstance(properties['user_keys'], bool)
if properties['key_increment'] is not None:
Expand Down