Skip to content
Merged
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
5 changes: 5 additions & 0 deletions arango/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ def format_collection(body: Json) -> Json:
if "internalValidatorType" in body:
result["internal_validator_type"] = body["internalValidatorType"]

if "deleted" in body:
result["deleted"] = body["deleted"]
if "supportsRBAC" in body:
result["supportsRBAC"] = body["supportsRBAC"]

return verify_format(body, result)


Expand Down
43 changes: 42 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import pytest

from arango.cursor import Cursor
from arango.exceptions import AsyncExecuteError, TransactionInitError
from arango.exceptions import (
AsyncExecuteError,
ReplicationClusterInventoryError,
TransactionInitError,
)


def generate_db_name():
Expand Down Expand Up @@ -190,3 +194,40 @@ def assert_raises(*exc):
:type: exc
"""
return pytest.raises(exc + (AsyncExecuteError, TransactionInitError))


def wait_for_cluster_resilient(sys_db):
collections_in_sync = False
max_attempts = 100

while not collections_in_sync and max_attempts > 0:
count_in_sync = 0
count_still_waiting = 0

try:
inventory = sys_db.replication.cluster_inventory(include_system=True)
except ReplicationClusterInventoryError:
print("Failed to get cluster inventory, retrying...")
time.sleep(1)
max_attempts -= 1
continue

collections_in_sync = True
for col in inventory["collections"]:
if not col["all_in_sync"]:
count_still_waiting += 1
collections_in_sync = False
else:
count_in_sync += 1

if not collections_in_sync:
if max_attempts % 50 == 0:
print(inventory)
print(f"In sync: {count_in_sync}")
print(f"Still not in sync: {count_still_waiting}")
time.sleep(1)

max_attempts -= 1

if not collections_in_sync:
raise Exception("Collections didn't come in sync!")
4 changes: 4 additions & 0 deletions tests/static/cluster-3.12.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ all.database.extended-names = true
all.log.api-enabled = true
all.javascript.allow-admin-execute = true
all.server.options-api = admin
all.javascript.files-allowlist = ".*";
all.javascript.environment-variables-allowlist = ".*";
all.javascript.endpoints-allowlist = ".*";
all.javascript.startup-options-allowlist = ".*";
4 changes: 4 additions & 0 deletions tests/static/single-3.12.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ all.database.password = passwd
all.database.extended-names = true
all.javascript.allow-admin-execute = true
all.server.options-api = admin
all.javascript.files-allowlist = ".*";
all.javascript.environment-variables-allowlist = ".*";
all.javascript.endpoints-allowlist = ".*";
all.javascript.startup-options-allowlist = ".*";
42 changes: 1 addition & 41 deletions tests/test_backup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import time

import pytest
from packaging import version

Expand All @@ -11,46 +9,8 @@
BackupGetError,
BackupRestoreError,
BackupUploadError,
ReplicationClusterInventoryError,
)
from tests.helpers import assert_raises


def wait_for_cluster_resilient(sys_db):
collections_in_sync = False
max_attempts = 100

while not collections_in_sync and max_attempts > 0:
count_in_sync = 0
count_still_waiting = 0

try:
inventory = sys_db.replication.cluster_inventory(include_system=True)
except ReplicationClusterInventoryError:
print("Failed to get cluster inventory, retrying...")
time.sleep(1)
max_attempts -= 1
continue

collections_in_sync = True
for col in inventory["collections"]:
if not col["all_in_sync"]:
count_still_waiting += 1
collections_in_sync = False
else:
count_in_sync += 1

if not collections_in_sync:
if max_attempts % 50 == 0:
print(inventory)
print(f"In sync: {count_in_sync}")
print(f"Still not in sync: {count_still_waiting}")
time.sleep(1)

max_attempts -= 1

if not collections_in_sync:
raise Exception("Collections didn't come in sync!")
from tests.helpers import assert_raises, wait_for_cluster_resilient


def test_backup_management(sys_db, bad_db, cluster, skip_tests, db_version):
Expand Down
50 changes: 31 additions & 19 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
generate_col_name,
generate_string,
generate_username,
wait_for_cluster_resilient,
)


Expand Down Expand Up @@ -170,7 +171,10 @@ def test_collection_misc_methods(col, bad_col, cluster):
assert result == info


def test_collection_management(db, bad_db, cluster):
def test_collection_management(sys_db, db, bad_db, cluster):
if cluster:
wait_for_cluster_resilient(sys_db)

# Test create collection
col_name = generate_col_name()
assert db.has_collection(col_name) is False
Expand Down Expand Up @@ -249,25 +253,33 @@ def test_collection_management(db, bad_db, cluster):
# schema must not be empty
db.create_collection(name=col_name, schema={})

col = db.create_collection(
name=col_name,
sync=True,
system=False,
key_generator="traditional",
user_keys=False,
edge=True,
shard_count=2,
shard_fields=["test_attr:"],
replication_factor=1,
sync_replication=False,
enforce_replication_factor=False,
sharding_strategy="community-compat",
smart_join_attribute="test_attr",
write_concern=1,
schema=schema,
computedValues=computed_values,
)
for _ in range(10):
try:
col = db.create_collection(
name=col_name,
sync=True,
system=False,
key_generator="traditional",
user_keys=False,
edge=True,
shard_count=2,
shard_fields=["test_attr:"],
replication_factor=1,
sync_replication=False,
enforce_replication_factor=False,
sharding_strategy="community-compat",
smart_join_attribute="test_attr",
write_concern=1,
schema=schema,
computedValues=computed_values,
)
except CollectionCreateError as err:
if err.error_code != DUPLICATE_NAME or not db.has_collection(col_name):
print(f"Failed to create collection with name {col_name}: {err}")
time.sleep(3)
continue
assert db.has_collection(col_name) is True
col = db.collection(col_name)

if cluster:
for details in (False, True):
Expand Down
Loading