Skip to content

Commit

Permalink
Merge pull request #781 from arenadata/develop
Browse files Browse the repository at this point in the history
Release 2021.03.10
  • Loading branch information
acmnu2nd authored Mar 10, 2021
2 parents b7634e1 + 7188860 commit 7a3ce9f
Show file tree
Hide file tree
Showing 10 changed files with 657 additions and 213 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ pytest: ## Run functional tests
-e SELENOID_HOST="${SELENOID_HOST}" -e SELENOID_PORT="${SELENOID_PORT}" \
ci.arenadata.io/functest:3.8.6.slim.buster-x64 /bin/sh -e ./pytest.sh

pytest_release: ## Run functional tests on release
docker pull ci.arenadata.io/functest:3.8.6.slim.buster.firefox-x64
docker run -i --rm --shm-size=4g -v /var/run/docker.sock:/var/run/docker.sock --network=host -v $(CURDIR)/:/adcm -w /adcm/ \
-e BUILD_TAG=${BUILD_TAG} -e ADCM_TAG=$(subst /,_,$(BRANCH_NAME)) -e ADCMPATH=/adcm/ -e PYTHONPATH=${PYTHONPATH}:python/ \
-e SELENOID_HOST="${SELENOID_HOST}" -e SELENOID_PORT="${SELENOID_PORT}" \
ci.arenadata.io/functest:3.8.6.slim.buster.firefox-x64 /bin/sh -e ./pytest.sh --firefox

ng_tests: ## Run Angular tests
docker pull ci.arenadata.io/functest:3.8.6.slim.buster-x64
docker run -i --rm -v $(CURDIR)/:/adcm -w /adcm/web/src ci.arenadata.io/functest:3.8.6.slim.buster-x64 /bin/sh -c "export CHROME_BIN=/usr/bin/google-chrome; npm install && ng test --watch=false"
Expand Down
2 changes: 1 addition & 1 deletion pytest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find . -name "__pycache__" -type d -delete
{ # try
pytest tests/ui_tests tests/functional -s -v -n auto --maxfail 30 \
--showlocals --alluredir ./allure-results/ --durations=20 \
--reruns 2 --remote-executor-host "$SELENOID_HOST" --timeout=360 &&
--reruns 2 --remote-executor-host "$SELENOID_HOST" --timeout=360 "$@" &&
chmod -R o+xw allure-results
} || { # catch
chmod -R o+xw allure-results
Expand Down
1 change: 1 addition & 0 deletions python/api/cluster_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ def get_kwargs(self, obj):
prototype_id = serializers.SerializerMethodField()
display_name = serializers.CharField(read_only=True)
description = serializers.CharField(read_only=True)
state = serializers.CharField(read_only=True)
url = MyUrlField(read_only=True, view_name='cluster-service-component-details')

def get_prototype_id(self, obj):
Expand Down
2 changes: 1 addition & 1 deletion python/cm/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def check_component_req(service, component):
for shc in get_components_with_requires():
for r in shc[2].prototype.requires:
if not check_component_req(r['service'], r['component']):
ref = f'component "{shc[2].component.name}" of service "{shc[0].prototype.name}"'
ref = f'component "{shc[2].prototype.name}" of service "{shc[0].prototype.name}"'
msg = 'no required component "{}" of service "{}" for {}'
err('COMPONENT_CONSTRAINT_ERROR', msg.format(r['component'], r['service'], ref))

Expand Down
41 changes: 41 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=W0621
from typing import Optional

import allure
import json
Expand All @@ -18,6 +19,9 @@
import sys
import tempfile

from _pytest.python import Function
from allure_commons.model2 import TestResult, Parameter
from allure_pytest.listener import AllureListener
from selenium.common.exceptions import WebDriverException

from adcm_client.wrappers.docker import ADCM
Expand Down Expand Up @@ -65,6 +69,43 @@ def pytest_generate_tests(metafunc):
metafunc.parametrize('browser', browsers, scope='session')


@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_setup(item: Function):
"""
Pytest hook that overrides test parameters
In case of adss tests, parameters in allure report don't make sense unlike test ID
So, we remove all parameters in allure report but add one parameter with test ID
"""
yield
_override_allure_test_parameters(item)


def _override_allure_test_parameters(item: Function):
"""
Overrides all pytest parameters in allure report with test ID
"""
listener = _get_listener_by_item_if_present(item)
if listener:
test_result: TestResult = listener.allure_logger.get_test(None)
test_result.parameters = [Parameter(name="ID", value=item.callspec.id)]


def _get_listener_by_item_if_present(item: Function) -> Optional[AllureListener]:
"""
Find AllureListener instance in pytest pluginmanager
"""
if hasattr(item, "callspec"):
listener: AllureListener = next(
filter(
lambda x: isinstance(x, AllureListener),
item.config.pluginmanager._name2plugin.values(), # pylint: disable=protected-access
),
None,
)
return listener
return None


@pytest.fixture(scope="session")
def web_driver(browser):
"""
Expand Down
Loading

0 comments on commit 7a3ce9f

Please sign in to comment.