Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 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 .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest]
python-version: ['3.9']
package: [
testit-adapter-behave,
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
TEMP_FILE: tmp/output.txt
TMS_ADAPTER_MODE: 1
TMS_CERT_VALIDATION: false
TMS_IMPORT_REALTIME: false
TMS_PRIVATE_TOKEN: ${{ secrets.TESTIT_PRIVATE_TOKEN }}
TMS_URL: ${{ secrets.TESTIT_URL }}
jobs:
Expand Down Expand Up @@ -92,10 +93,27 @@ jobs:
pip3 install -r python-examples/${{ matrix.project_name }}/requirements_ci.txt
pip3 install ./testit-python-commons
pip3 install ./${{ matrix.adapter_name }}

- name: Test
run: |
chmod +x ./scripts/get_sync_storage_version.sh
chmod +x ./scripts/get_sync_storage.sh

export SYNC_STORAGE_VERSION=$(./scripts/get_sync_storage_version.sh)
cd python-examples/${{ matrix.project_name }}
eval "${{ matrix.test_command }}" || exit 0

# enabled starting of sync storage before all
../../scripts/get_sync_storage.sh $SYNC_STORAGE_VERSION
nohup .caches/syncstorage-linux-amd64 --testRunId ${{ env.TMS_TEST_RUN_ID }} --port 49152 \
--baseURL ${{ env.TMS_URL }} --privateToken ${{ env.TMS_PRIVATE_TOKEN }} > service.log 2>&1 &
curl -v http://127.0.0.1:49152/health || true

eval "${{ matrix.test_command }}" || true #ignore error code

sleep 1
curl -v http://127.0.0.1:49152/wait-completion?testRunId=${{ env.TMS_TEST_RUN_ID }} || true
# cat service.log

- name: Validate
run: |
dotnet test --configuration Debug --no-build --logger:"console;verbosity=detailed" api-validator-dotnet
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "testit-adapter-nose/**"
- "testit-adapter-pytest/**"
- "testit-adapter-robotframework/**"
- "testit-python-commons/**"
#- "testit-python-commons/**"
- "requirements.txt"
- ".github/workflows/validate.yml"
push:
Expand All @@ -26,7 +26,7 @@ jobs:
testit-adapter-nose,
testit-adapter-pytest,
testit-adapter-robotframework,
testit-python-commons
#testit-python-commons # temporarily disabled
]
steps:
- name: Checkout repository
Expand Down
264 changes: 0 additions & 264 deletions docs/01_appproperties__.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

299 changes: 0 additions & 299 deletions docs/06_менеджер_адаптера__adaptermanager__.md

This file was deleted.

268 changes: 0 additions & 268 deletions docs/07_менеджер_плагинов_tms__tmspluginmanager__.md

This file was deleted.

224 changes: 0 additions & 224 deletions docs/08_клиент_api__apiclientworker__.md

This file was deleted.

66 changes: 0 additions & 66 deletions docs/index.md

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/get_sync_storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SYNC_STORAGE_VERSION=$1

mkdir -p .caches

wget -O .caches/syncstorage-linux-amd64 \
"https://github.com/testit-tms/sync-storage-public/releases/download/${SYNC_STORAGE_VERSION}/syncstorage-${SYNC_STORAGE_VERSION}-linux_amd64"
chmod +x .caches/syncstorage-linux-amd64
2 changes: 2 additions & 0 deletions scripts/get_sync_storage_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo $(grep -o 'SYNC_STORAGE_VERSION = "[^"]*"' testit-python-commons/src/testit_python_commons/services/sync_storage/sync_storage_runner.py | cut -d'"' -f2)

5 changes: 5 additions & 0 deletions testit-adapter-behave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ tmsCertValidation=CERT_VALIDATION -D tmsAutomaticCreationTestCases=AUTOMATIC_CRE
tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES -D tmsImportRealtime=IMPORT_REALTIME
```

Logging level:
```
$ behave ... --logging-level=DEBUG
```

If you want to enable debug mode then
see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)

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 = "3.12.4"
VERSION = "4.0.0"

setup(
name='testit-adapter-behave',
Expand Down
22 changes: 22 additions & 0 deletions testit-adapter-behave/src/testit_adapter_behave/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from .utils import (
convert_step_to_step_result_model,
convert_executable_test_to_test_result_model)
import logging

# on_block_completed must be called AFTER other actions
# on_running_started must be called BEFORE other actions

class AdapterListener(object):
__executable_test = None
Expand All @@ -23,24 +26,40 @@ def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager):
self.__step_manager = step_manager

def start_launch(self):
self.__adapter_manager.on_running_started()
test_run_id = self.__adapter_manager.get_test_run_id()

self.__adapter_manager.set_test_run_id(test_run_id)
logging.debug("start_launch")

def stop_launch(self):
logging.debug("BEHAVE stop_launch")
self.__adapter_manager.write_tests()
self.__adapter_manager.on_block_completed()


def get_tests_for_launch(self):
logging.debug("get_tests_for_launch")
self.__adapter_manager.on_running_started()
return self.__adapter_manager.get_autotests_for_launch()

def get_scenario(self, scenario):
logging.debug("get_scenario")
self.__adapter_manager.on_running_started()
self.__executable_test = parse_scenario(scenario)
self.__background_steps_count = len(scenario.background_steps)
self.__steps_count = len(scenario.steps)



def set_scenario(self):
logging.debug("BEHAVE set_scenario")
self.__adapter_manager.write_test(
convert_executable_test_to_test_result_model(self.__executable_test))
# must depend on the current adapter mode
# if it's realtime -> call
if self.__adapter_manager.is_realtime():
self.__adapter_manager.on_block_completed()

def get_step_parameters(self, match):
scope = self.get_scope()
Expand All @@ -55,6 +74,8 @@ def get_step_parameters(self, match):
self.__executable_test[scope].append(executable_step)

def get_step_result(self, result):
logging.debug("get_step_result")
self.__adapter_manager.on_running_started()
scope = self.get_scope()
outcome = parse_status(result.status)

Expand Down Expand Up @@ -90,6 +111,7 @@ def get_step_result(self, result):
self.set_scenario()

def get_scope(self):
self.__adapter_manager.on_running_started()
if self.__background_steps_count != 0:
return 'setUp'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
STATUS = {
'passed': OutcomeType.PASSED,
'failed': OutcomeType.FAILED,
'error': OutcomeType.FAILED,
'skipped': OutcomeType.SKIPPED,
'untested': OutcomeType.SKIPPED,
'undefined': OutcomeType.BLOCKED
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 = "3.12.4"
VERSION = "4.0.0"

setup(
name='testit-adapter-nose',
Expand Down
3 changes: 3 additions & 0 deletions testit-adapter-nose/src/testit_adapter_nose/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ def start_launch(self):
test_run_id = self.__adapter_manager.get_test_run_id()

self.__adapter_manager.set_test_run_id(test_run_id)
self.__adapter_manager.on_running_started()

def stop_launch(self):
self.__adapter_manager.on_block_completed()
self.__adapter_manager.write_tests()

def get_tests_for_launch(self):
self.__adapter_manager.on_running_started()
return self.__adapter_manager.get_autotests_for_launch()

def start_test(self, test):
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 = "3.12.4"
VERSION = "4.0.0"

setup(
name='testit-adapter-pytest',
Expand Down
2 changes: 2 additions & 0 deletions testit-adapter-pytest/src/testit_adapter_pytest/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def __check_external_id_in_resolved_autotests(external_id: str, resolved_autotes
@pytest.hookimpl(tryfirst=True)
def pytest_runtest_protocol(self, item):
self.__executable_test = utils.form_test(item)
self.__adapter_manager.on_running_started()

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_setup(self, item):
Expand Down Expand Up @@ -258,6 +259,7 @@ def pytest_runtest_logfinish(self):

@pytest.hookimpl
def pytest_sessionfinish(self, session):
self.__adapter_manager.on_block_completed()
self.__adapter_manager.write_tests()

@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 = "3.12.4"
VERSION = "4.0.0"

setup(
name='testit-adapter-robotframework',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
class AutotestAdapter:
ROBOT_LISTENER_API_VERSION = 2

# self.adapter_manager.on_block_completed()
# self.adapter_manager.on_running_started()

def __init__(self, adapter_manager):
self.adapter_manager = adapter_manager
self.active_test = None
Expand Down Expand Up @@ -37,6 +40,7 @@ def start_test(self, name, attributes):
self.active_test = Autotest(autoTestName=name)
self.active_test.add_attributes(attributes)
BuiltIn().remove_tags("testit*")
self.adapter_manager.on_running_started()

def start_keyword(self, name, attributes):
if self.active_test:
Expand Down Expand Up @@ -71,6 +75,7 @@ def end_test(self, name, attributes):
convert_executable_test_to_test_result_model(self.active_test.order()))

def close(self):
self.adapter_manager.on_block_completed()
self.adapter_manager.write_tests()


Expand Down
6 changes: 6 additions & 0 deletions testit-python-commons/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Sync Storage Integration

This library includes built-in support for Sync Storage, enabling coordinated test execution across multiple workers in distributed testing environments.

See [SYNC_STORAGE_INTEGRATION.md](SYNC_STORAGE_INTEGRATION.md) for detailed documentation on how the integration works.

# How to enable debug logging?
1. Add in **connection_config.ini** file from the root directory of the project:
```
Expand Down
Empty file.
9 changes: 8 additions & 1 deletion testit-python-commons/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest~=8.3.3
pytest-xdist
pytest-mock

flake8
flake8-builtins
Expand All @@ -11,4 +12,10 @@ mypy
attrs~=24.2.0
pluggy~=1.5.0
tomli~=2.2.1
setuptools~=75.6.0
setuptools~=75.6.0

# Sync Storage dependencies
requests~=2.31.0
urllib3~=2.0.4
psutil~=5.9.5

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate requirements

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 = "3.12.4"
VERSION = "4.0.0"

setup(
name='testit-python-commons',
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions testit-python-commons/src/api_client_syncstorage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# flake8: noqa

"""
Sync Storage Service API

This is a sync storage service for coordinating test workers. # noqa: E501

The version of the OpenAPI document: 1.0
Generated by: https://openapi-generator.tech
"""


__version__ = "1.0.0"

# import ApiClient
from api_client_syncstorage.api_client import ApiClient

# import Configuration
from api_client_syncstorage.configuration import Configuration

# import exceptions
from api_client_syncstorage.exceptions import OpenApiException
from api_client_syncstorage.exceptions import ApiAttributeError
from api_client_syncstorage.exceptions import ApiTypeError
from api_client_syncstorage.exceptions import ApiValueError
from api_client_syncstorage.exceptions import ApiKeyError
from api_client_syncstorage.exceptions import ApiException
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from api_client_syncstorage.apis import CompletionApi
Loading