Skip to content

Commit

Permalink
Enable parallel test runs (#851)
Browse files Browse the repository at this point in the history
closes #710
  • Loading branch information
roman-khimov authored Sep 13, 2024
2 parents 3deb7be + 5f87d0e commit c44307a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
env:
ALLURE_RESULTS_DIR: ${{ env.ALLURE_RESULTS_DIR }}
run: |
source venv.pytest/bin/activate && pytest --log-cli-level error --alluredir=${GITHUB_WORKSPACE}/allure-results pytest_tests/tests
source venv.pytest/bin/activate && pytest -n 3 --log-cli-level error --alluredir=${GITHUB_WORKSPACE}/allure-results pytest_tests/tests
working-directory: neofs-testcases

################################################################
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ xunit_results.xml
# ignore work directories and setup files
.setup
.env
TemporaryDir/*
TemporaryDir-/*
artifacts/*
docs/*
venv.*/*
Expand Down
12 changes: 6 additions & 6 deletions pytest_tests/lib/helpers/aws_cli_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@


class AwsCliClient:
# Flags that we use for all S3 commands: disable SSL verification (as we use self-signed
# certificate in devenv) and disable automatic pagination in CLI output
common_flags = "--no-verify-ssl --no-paginate"
s3gate_endpoint: str

def __init__(self, s3gate_endpoint) -> None:
def __init__(self, s3gate_endpoint, profile="") -> None:
self.s3gate_endpoint = s3gate_endpoint
# Flags that we use for all S3 commands: disable SSL verification (as we use self-signed
# certificate in devenv) and disable automatic pagination in CLI output
self.common_flags = "--no-verify-ssl --no-paginate"
if profile != "":
self.common_flags += f" --profile {profile}"
os.environ["AWS_EC2_METADATA_DISABLED"] = "true"

def create_bucket(
Expand Down
3 changes: 2 additions & 1 deletion pytest_tests/lib/helpers/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import uuid

import yaml

Expand All @@ -22,7 +23,7 @@

NEOFS_CONTRACT = os.getenv("NEOFS_IR_CONTRACTS_NEOFS")

ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir")
ASSETS_DIR = f"TemporaryDir-{uuid.uuid4()}"
TEST_FILES_DIR = os.getenv("TEST_FILES_DIR", "TestFilesDir")
TEST_OBJECTS_DIR = os.getenv("TEST_OBJECTS_DIR", "TestObjectsDir")
DEVENV_PATH = os.getenv("DEVENV_PATH", os.path.join("..", "neofs-dev-env"))
Expand Down
4 changes: 1 addition & 3 deletions pytest_tests/lib/helpers/rest_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
import requests
from helpers.aws_cli_client import LONG_TIMEOUT
from helpers.cli_helpers import _cmd_run
from helpers.common import SIMPLE_OBJECT_SIZE
from helpers.common import ASSETS_DIR, SIMPLE_OBJECT_SIZE
from helpers.complex_object_actions import get_nodes_without_object
from helpers.file_helper import get_file_hash
from helpers.neofs_verbs import get_object
from neofs_testlib.shell import Shell

logger = logging.getLogger("NeoLogger")

ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/")


@allure.step("Get via REST Gate")
def get_via_rest_gate(
Expand Down
12 changes: 10 additions & 2 deletions pytest_tests/lib/s3/s3_gate_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json
import logging
import os
import random
import re
import string
import sys
import uuid
from typing import Any, Optional
Expand Down Expand Up @@ -201,8 +203,9 @@ def configure_boto3_client(access_key_id: str, secret_access_key: str, s3gate_en
@allure.step("Configure S3 client (aws cli)")
def configure_cli_client(access_key_id: str, secret_access_key: str, s3gate_endpoint: str):
try:
client = AwsCliClient(s3gate_endpoint)
_configure_aws_cli("aws configure", access_key_id, secret_access_key)
profile = _generate_random_profile()
client = AwsCliClient(s3gate_endpoint, profile)
_configure_aws_cli(f"aws configure --profile {profile}", access_key_id, secret_access_key)
_cmd_run(f"aws configure set max_attempts {MAX_REQUEST_ATTEMPTS}")
_cmd_run(f"aws configure set retry_mode {RETRY_MODE}")
return client
Expand All @@ -211,3 +214,8 @@ def configure_cli_client(access_key_id: str, secret_access_key: str, s3gate_endp
pytest.skip("AWS CLI was not found")
else:
raise RuntimeError("Error while configuring AwsCliClient") from err


def _generate_random_profile():
random_postfix = "".join(random.choice(string.ascii_letters + string.digits) for _ in range(10))
return f"profile__{random_postfix}"
3 changes: 1 addition & 2 deletions pytest_tests/lib/s3/s3_gate_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from botocore.exceptions import ClientError
from helpers.aws_cli_client import AwsCliClient
from helpers.cli_helpers import log_command_execution
from helpers.common import ASSETS_DIR
from s3.s3_gate_bucket import S3_SYNC_WAIT_TIME

##########################################################
Expand All @@ -28,8 +29,6 @@
"bucket-owner-full-control",
]

ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/")


@allure.step("List objects S3 v2")
def list_objects_s3_v2(s3_client, bucket: str, full_output: bool = False) -> list:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ requests==2.32.0
tenacity==8.2.3
ruff==0.4.2
urllib3==2.2.2
pytest-xdist==3.6.1

0 comments on commit c44307a

Please sign in to comment.