-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt http and s3 tests to new dynamic env (#708)
- Loading branch information
Showing
22 changed files
with
2,813 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,12 +82,21 @@ jobs: | |
file: 'neofs-node-amd64' | ||
target: 'neofs-testcases/neofs-node' | ||
|
||
- name: Checkout neofs-s3-gw repository | ||
uses: actions/checkout@v4 | ||
- name: Download latest stable neofs-s3-gw | ||
uses: dsaltares/[email protected] | ||
with: | ||
repo: 'nspcc-dev/neofs-s3-gw' | ||
version: 'tags/v0.29.0' | ||
file: 'neofs-s3-gw-linux-amd64' | ||
target: 'neofs-testcases/neofs-s3-gw' | ||
|
||
- name: Download latest stable neofs-s3-gw-authmate | ||
uses: dsaltares/[email protected] | ||
with: | ||
repository: nspcc-dev/neofs-s3-gw | ||
ref: '014a5bf493d00b8cce478e2c96c84ad9de8fe617' | ||
path: neofs-s3-gw | ||
repo: 'nspcc-dev/neofs-s3-gw' | ||
version: 'tags/v0.29.0' | ||
file: 'neofs-s3-authmate-linux-amd64' | ||
target: 'neofs-testcases/neofs-s3-authmate' | ||
|
||
- name: Download latest stable neofs-rest-gw | ||
uses: dsaltares/[email protected] | ||
|
@@ -123,15 +132,10 @@ jobs: | |
sudo chmod a+x neofs-rest-gw | ||
sudo chmod a+x neofs-http-gw | ||
sudo chmod a+x neo-go | ||
sudo chmod a+x neofs-s3-authmate | ||
sudo chmod a+x neofs-s3-gw | ||
working-directory: neofs-testcases | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
cache: true | ||
go-version: '1.20' | ||
- run: go version | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
|
@@ -162,24 +166,11 @@ jobs: | |
sudo python ./tools/src/openssl_config_fix.py | ||
working-directory: neofs-testcases | ||
|
||
- name: Build neofs-s3-gw | ||
timeout-minutes: 5 | ||
run: | | ||
make all | ||
echo "$(pwd)/bin" >> $GITHUB_PATH | ||
working-directory: neofs-s3-gw | ||
|
||
- name: Copy binaries to testcases directory | ||
timeout-minutes: 30 | ||
run: | | ||
cp ${GITHUB_WORKSPACE}/neofs-s3-gw/bin/* . | ||
echo "$(pwd)" >> $GITHUB_PATH | ||
working-directory: neofs-testcases | ||
|
||
- name: Prepare venv | ||
timeout-minutes: 30 | ||
run: | | ||
make venv.no-dev-env-pytest | ||
echo "$(pwd)" >> $GITHUB_PATH | ||
working-directory: neofs-testcases | ||
|
||
- name: Log environment | ||
|
25 changes: 25 additions & 0 deletions
25
dynamic_env_pytest_tests/lib/helpers/storage_object_info.py
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 dataclasses import dataclass | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class ObjectRef: | ||
cid: str | ||
oid: str | ||
|
||
|
||
@dataclass | ||
class LockObjectInfo(ObjectRef): | ||
lifetime: Optional[int] = None | ||
expire_at: Optional[int] = None | ||
|
||
|
||
@dataclass | ||
class StorageObjectInfo(ObjectRef): | ||
size: Optional[int] = None | ||
wallet_file_path: Optional[str] = None | ||
file_path: Optional[str] = None | ||
file_hash: Optional[str] = None | ||
attributes: Optional[list[dict[str, str]]] = None | ||
tombstone: Optional[str] = None | ||
locks: Optional[list[LockObjectInfo]] = None |
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,78 @@ | ||
import random | ||
|
||
import allure | ||
import neofs_verbs | ||
from grpc_responses import OBJECT_NOT_FOUND, error_matches_status | ||
from neofs_testlib.env.env import StorageNode | ||
from neofs_testlib.shell import Shell | ||
from python_keywords.http_gate import assert_hashes_are_equal, get_via_http_gate | ||
from python_keywords.neofs_verbs import get_object | ||
|
||
|
||
def get_object_and_verify_hashes( | ||
oid: str, | ||
file_name: str, | ||
wallet: str, | ||
cid: str, | ||
shell: Shell, | ||
nodes: list[StorageNode], | ||
endpoint: str, | ||
object_getter=None, | ||
) -> None: | ||
nodes_list = get_nodes_without_object( | ||
wallet=wallet, | ||
cid=cid, | ||
oid=oid, | ||
shell=shell, | ||
nodes=nodes, | ||
) | ||
# for some reason we can face with case when nodes_list is empty due to object resides in all nodes | ||
if nodes_list: | ||
random_node = random.choice(nodes_list) | ||
else: | ||
random_node = random.choice(nodes) | ||
|
||
object_getter = object_getter or get_via_http_gate | ||
|
||
got_file_path = get_object( | ||
wallet=wallet, | ||
cid=cid, | ||
oid=oid, | ||
shell=shell, | ||
endpoint=random_node.endpoint, | ||
) | ||
got_file_path_http = object_getter(cid=cid, oid=oid, endpoint=endpoint) | ||
|
||
assert_hashes_are_equal(file_name, got_file_path, got_file_path_http) | ||
|
||
|
||
@allure.step("Get Nodes Without Object") | ||
def get_nodes_without_object( | ||
wallet: str, cid: str, oid: str, shell: Shell, nodes: list[StorageNode] | ||
) -> list[StorageNode]: | ||
""" | ||
The function returns list of nodes which do not store | ||
the given object. | ||
Args: | ||
wallet (str): the path to the wallet on whose behalf | ||
we request the nodes | ||
cid (str): ID of the container which store the object | ||
oid (str): object ID | ||
shell: executor for cli command | ||
Returns: | ||
(list): nodes which do not store the object | ||
""" | ||
nodes_list = [] | ||
for node in nodes: | ||
try: | ||
res = neofs_verbs.head_object( | ||
wallet, cid, oid, shell=shell, endpoint=node.endpoint, is_direct=True | ||
) | ||
if res is None: | ||
nodes_list.append(node) | ||
except Exception as err: | ||
if error_matches_status(err, OBJECT_NOT_FOUND): | ||
nodes_list.append(node) | ||
else: | ||
raise Exception(f"Got error {err} on head object command") from err | ||
return nodes_list |
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,41 @@ | ||
import logging | ||
|
||
import allure | ||
import neofs_verbs | ||
from neofs_testlib.env.env import StorageNode | ||
from neofs_testlib.shell import Shell | ||
|
||
logger = logging.getLogger("NeoLogger") | ||
|
||
|
||
@allure.step("Get Simple Object Copies") | ||
def get_simple_object_copies( | ||
wallet: str, cid: str, oid: str, shell: Shell, nodes: list[StorageNode] | ||
) -> int: | ||
""" | ||
To figure out the number of a simple object copies, only direct | ||
HEAD requests should be made to the every node of the container. | ||
We consider non-empty HEAD response as a stored object copy. | ||
Args: | ||
wallet (str): the path to the wallet on whose behalf the | ||
copies are got | ||
cid (str): ID of the container | ||
oid (str): ID of the Object | ||
shell: executor for cli command | ||
nodes: nodes to search on | ||
Returns: | ||
(int): the number of object copies in the container | ||
""" | ||
copies = 0 | ||
for node in nodes: | ||
try: | ||
response = neofs_verbs.head_object( | ||
wallet, cid, oid, shell=shell, endpoint=node.endpoint, is_direct=True | ||
) | ||
if response: | ||
logger.info(f"Found object {oid} on node {node}") | ||
copies += 1 | ||
except Exception: | ||
logger.info(f"No {oid} object copy found on {node}, continue") | ||
continue | ||
return copies |
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
Oops, something went wrong.