Skip to content

Commit

Permalink
Merge branch 'main' into server-maintenance-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna committed Jan 26, 2024
2 parents 261a89e + 805425d commit b519261
Show file tree
Hide file tree
Showing 16 changed files with 447 additions and 31 deletions.
17 changes: 8 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
version: 2.1

# orbs:
# coveralls: coveralls/[email protected]
orbs:
codecov: codecov/[email protected]

workflows:
ci:
jobs:
- lint
- test:
name: Python (<< matrix.python_version >>) - ArangoDB (<< matrix.arangodb_license >>, << matrix.arangodb_version >> << matrix.arangodb_config >>)
matrix:
parameters:
# TODO: Revisit why pyenv doesn't recognize 3.12
Expand Down Expand Up @@ -82,6 +83,8 @@ jobs:

- run: docker ps -a

- run: docker logs arango

- run:
name: "Run pytest"
command: |
Expand All @@ -97,17 +100,13 @@ jobs:
fi
echo "Running pytest with args: ${args[@]}"
pytest --cov=arango --cov-report=xml "${args[@]}"
pytest --cov=arango --cov-report=xml --cov-report term-missing --color=yes --code-highlight=yes "${args[@]}"
- store_artifacts:
path: test-results

- store_test_results:
path: test-results

# - run:
# name: Upload to Coveralls
# command: |
# if [ "<< parameters.python_version >>" = "3.11" && "<< parameters.arangodb_config >>" = "single" && "<< parameters.arangodb_license >>" = "community" && "<< parameters.arangodb_version >>" = "latest" ]; then
# coveralls/upload
# fi
- codecov/upload:
file: coverage.xml
15 changes: 13 additions & 2 deletions arango/aql.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def execute(
fill_block_cache: Optional[bool] = None,
allow_dirty_read: bool = False,
allow_retry: bool = False,
force_one_shard_attribute_value: Optional[str] = None,
) -> Result[Cursor]:
"""Execute the query and return the result cursor.
Expand Down Expand Up @@ -373,6 +374,16 @@ def execute(
:param allow_retry: Make it possible to retry fetching the latest batch
from a cursor.
:type allow_retry: bool
:param force_one_shard_attribute_value: (Enterprise Only) Explicitly set
a shard key value that will be used during query snippet distribution
to limit the query to a specific server in the cluster. This query option
can be used in complex queries in case the query optimizer cannot
automatically detect that the query can be limited to only a single
server (e.g. in a disjoint smart graph case). If the option is set
incorrectly, i.e. to a wrong shard key value, then the query may be
shipped to a wrong DB server and may not return results
(i.e. empty result set). Use at your own risk.
:param force_one_shard_attribute_value: str | None
:return: Result cursor.
:rtype: arango.cursor.Cursor
:raise arango.exceptions.AQLQueryExecuteError: If execute fails.
Expand Down Expand Up @@ -418,10 +429,10 @@ def execute(
options["skipInaccessibleCollections"] = skip_inaccessible_cols
if max_runtime is not None:
options["maxRuntime"] = max_runtime

# New in 3.11
if allow_retry is not None:
options["allowRetry"] = allow_retry
if force_one_shard_attribute_value is not None:
options["forceOneShardAttributeValue"] = force_one_shard_attribute_value

if options:
data["options"] = options
Expand Down
22 changes: 22 additions & 0 deletions arango/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ClusterServerCountError,
ClusterServerEngineError,
ClusterServerIDError,
ClusterServerModeError,
ClusterServerRoleError,
ClusterServerStatisticsError,
ClusterServerVersionError,
Expand Down Expand Up @@ -57,6 +58,27 @@ def response_handler(resp: Response) -> str:

return self._execute(request, response_handler)

def server_mode(self) -> Result[str]:
"""Return the server mode.
In a read-only server, all write operations will fail
with an error code of 1004 (ERROR_READ_ONLY). Creating or dropping
databases and collections will also fail with error code 11 (ERROR_FORBIDDEN).
:return: Server mode. Possible values are "default" or "readonly".
:rtype: str
:raise arango.exceptions.ClusterServerModeError: If retrieval fails.
"""
request = Request(method="get", endpoint="/_admin/server/mode")

def response_handler(resp: Response) -> str:
if resp.is_success:
return str(resp.body["mode"])

raise ClusterServerModeError(resp, request)

return self._execute(request, response_handler)

def server_version(self, server_id: str) -> Result[Json]:
"""Return the version of the given server.
Expand Down
Loading

0 comments on commit b519261

Please sign in to comment.