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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Status](https://img.shields.io/pypi/v/testit-python-commons?style=plastic)](http
- importRealtime=false is a default mode (previously true)

- **limitations**:
- The current 4.0.0 version is not compatible with `adapterMode=2` when using parallelization (e.g., `pytest --testit -n 4`). Please use `adapterMode=1`.
- Versions before 4.2.2 are not compatible with `adapterMode=2` when using parallelization (e.g., `pytest --testit -n 4`). Please use `adapterMode=1`or update to 4.2.2+ .

### How to run 4.0+ locally?

Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-behave/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.2.0"
VERSION = "4.2.2"

setup(
name='testit-adapter-behave',
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-nose/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = "4.2.0"
VERSION = "4.2.2"

setup(
name='testit-adapter-nose',
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-pytest/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.2.0"
VERSION = "4.2.2"

setup(
name='testit-adapter-pytest',
Expand Down
8 changes: 4 additions & 4 deletions testit-adapter-pytest/src/testit_adapter_pytest/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager, f
def pytest_configure(self, config):
self.__pytest_info = metadata("pytest")

if not hasattr(config, "workerinput") and not hasattr(self, "test_run_id"):
config.test_run_id = self.__adapter_manager.get_test_run_id()
else:
if hasattr(config, "workerinput"):
config.test_run_id = pickle.loads(config.workerinput["test_run_id"])
elif not hasattr(config, "test_run_id"):
config.test_run_id = self.__adapter_manager.get_test_run_id()

self.__adapter_manager.set_test_run_id(config.test_run_id)

@pytest.hookimpl
def pytest_configure_node(self, node):
if not hasattr(self, "test_run_id"):
if hasattr(node.config, "test_run_id"):
node.workerinput["test_run_id"] = pickle.dumps(node.config.test_run_id)

@adapter.hookimpl
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-robotframework/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.2.0"
VERSION = "4.2.2"

setup(
name='testit-adapter-robotframework',
Expand Down
2 changes: 1 addition & 1 deletion testit-python-commons/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.2.0"
VERSION = "4.2.2"

setup(
name='testit-python-commons',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,58 @@ def __init__(

def _initialize_sync_storage(self, client_configuration: ClientConfiguration):
"""Initialize Sync Storage runner if enabled."""
try:
# Get test run ID - create one if needed
test_run_id = self.__config.get_test_run_id()
if client_configuration.is_legacy_workflow():
return None

# If no test run ID, create one (as in Java implementation)
if not test_run_id:
test_run_id = self.__api_client.create_test_run(
self.__config.get_test_run_name()
)
self.__config.set_test_run_id(test_run_id)
self.__api_client.set_test_run_id(test_run_id)

# Extract configuration properties
url = client_configuration.get_url()
private_token = client_configuration.get_private_token()
port = client_configuration.get_sync_storage_port()
print(f'sync storage port: {port}')

# Create and start Sync Storage runner
if SYNC_STORAGE_AVAILABLE:
sync_storage_runner = SyncStorageRunner(
test_run_id=test_run_id,
port=port,
base_url=url,
private_token=private_token,
)
test_run_id = self.__config.get_test_run_id()
if not test_run_id and self.__config.get_mode() == AdapterMode.NEW_TEST_RUN:
return None

if not test_run_id:
logging.warning('Sync Storage requires test run ID; skipping initialization')
return None

return self._start_sync_storage(test_run_id, client_configuration)

if sync_storage_runner.start():
logging.info("Sync Storage started successfully")
return sync_storage_runner
else:
logging.warning("Failed to start Sync Storage")
def _start_sync_storage(
self,
test_run_id: str,
client_configuration: ClientConfiguration):
try:
if not SYNC_STORAGE_AVAILABLE:
return None

sync_storage_runner = SyncStorageRunner(
test_run_id=test_run_id,
port=client_configuration.get_sync_storage_port(),
base_url=client_configuration.get_url(),
private_token=client_configuration.get_private_token(),
)

if sync_storage_runner.start():
logging.info("Sync Storage started successfully")
return sync_storage_runner

logging.warning("Failed to start Sync Storage")
except Exception as e:
logging.warning(f"Failed to initialize SyncStorage: {e}", exc_info=True)

return None


@adapter_logger
def set_test_run_id(self, test_run_id: str) -> None:

self.__config.set_test_run_id(test_run_id)

self.__api_client.set_test_run_id(test_run_id)

# Update Sync Storage with test run ID if available
if self.__sync_storage_runner:
self.__sync_storage_runner.test_run_id = test_run_id
return

if SYNC_STORAGE_AVAILABLE and not self.__client_config.is_legacy_workflow():
self.__sync_storage_runner = self._start_sync_storage(
test_run_id, self.__client_config)

@adapter_logger
def get_test_run_id(self) -> str:
Expand Down
45 changes: 45 additions & 0 deletions testit-python-commons/tests/services/test_adapter_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,51 @@ def test_create_attachment_with_name(self, adapter_manager, mock_api_client_work
mock_os_remove.assert_called_once_with(expected_file_path)
assert attachment_id == expected_attachment_id

def test_init_does_not_create_test_run_for_new_test_run_mode_without_id(
self,
mocker,
mock_adapter_config,
mock_client_config,
mock_fixture_manager,
mock_api_client_worker):
mock_adapter_config.get_mode.return_value = AdapterMode.NEW_TEST_RUN
mock_adapter_config.get_test_run_id.return_value = None
mock_client_config.is_legacy_workflow.return_value = False
start_sync_storage = mocker.patch.object(
AdapterManager,
"_start_sync_storage",
return_value=None,
)

AdapterManager(
adapter_configuration=mock_adapter_config,
client_configuration=mock_client_config,
fixture_manager=mock_fixture_manager,
)

mock_api_client_worker.create_test_run.assert_not_called()
start_sync_storage.assert_not_called()

def test_set_test_run_id_starts_sync_storage_when_deferred(
self,
adapter_manager,
mock_client_config,
mocker):
test_run_id = str(uuid.uuid4())
sync_storage_runner = mocker.Mock()
start_sync_storage = mocker.patch.object(
adapter_manager,
"_start_sync_storage",
return_value=sync_storage_runner,
)
mock_client_config.is_legacy_workflow.return_value = False
adapter_manager._AdapterManager__sync_storage_runner = None

adapter_manager.set_test_run_id(test_run_id)

start_sync_storage.assert_called_once_with(test_run_id, mock_client_config)
assert adapter_manager._AdapterManager__sync_storage_runner is sync_storage_runner

def test_init_does_not_start_sync_storage_in_legacy_workflow(
self,
mocker,
Expand Down
2 changes: 1 addition & 1 deletion update_versions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

NEW_VERSION="4.2.0"
NEW_VERSION="4.2.2"
TESTIT_API_CLIENT_VERSION="7.5.6"

echo "Updating all adapters to version: $NEW_VERSION"
Expand Down
Loading