Commit 78dd010b authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Several changes:

Common:
- Normalized report_coverage_*.sh scripts, and temporarily summarized results in device one for testing purposes.
- Adapted run_tests_locally.sh script for testing purposes
- Improved message synthesis of ServiceException

Context:
- Improved ConfigModel helper functions

Device (intermediate backup):
- Removed DataCache since it reduces readability of the code. Moved database one level up.
- Improved ServicerImpl and moved DataCache functionality over there.
- Added condition to prevent AddDevice request from carrying a configuration.
- Multiple pre-work required for processing configuration differences in DeviceServiceServicerImpl.
parent 59f08ade
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#!/bin/bash

./report_coverage_all.sh | grep -v -E "^(cent|comp|cont|devi|moni|serv|test)" | grep --color -E -i "^common/.*$|$"
./report_coverage_all.sh | grep --color -E -i "^common/.*$|$"
+1 −1
Original line number Diff line number Diff line
#!/bin/bash

./report_coverage_all.sh | grep -v -E "^(cent|com|devi|moni|serv|test)" | grep --color -E -i "^context/.*$|$"
./report_coverage_all.sh | grep --color -E -i "^context/.*$|$"
+1 −1
Original line number Diff line number Diff line
#!/bin/bash

./report_coverage_all.sh | grep --color -E -i "^device/.*$|$"
./report_coverage_all.sh | grep -v -E "^(cent|comm|comp|cont|moni|serv|test)" | grep --color -E -i "^device/.*$|$"
+11 −11
Original line number Diff line number Diff line
@@ -18,23 +18,23 @@ export REDIS_SERVICE_PORT=$(kubectl get service contextservice-public --namespac
# First destroy old coverage file
rm -f $COVERAGEFILE

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    common/orm/tests/test_unitary.py \
    common/message_broker/tests/test_unitary.py \
    common/rpc_method_wrapper/tests/test_unitary.py
#coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
#    common/orm/tests/test_unitary.py \
#    common/message_broker/tests/test_unitary.py \
#    common/rpc_method_wrapper/tests/test_unitary.py

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    centralizedattackdetector/tests/test_unitary.py
#coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
#    centralizedattackdetector/tests/test_unitary.py

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    context/tests/test_unitary.py
#coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
#    context/tests/test_unitary.py

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    device/tests/test_unitary_driverapi.py \
    device/tests/test_unitary.py
    #device/tests/test_unitary_driverapi.py \

#coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
#    service/tests/test_unitary.py

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    compute/tests/test_unitary.py
#coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
#    compute/tests/test_unitary.py
+18 −5
Original line number Diff line number Diff line
import grpc
from typing import Iterable
from typing import Iterable, Union

class ServiceException(Exception):
    def __init__(self, code : grpc.StatusCode, details : str, extra_details : Iterable[str] = []) -> None:
    def __init__(
        self, code : grpc.StatusCode, details : str, extra_details : Union[str, Iterable[str]] = []
        ) -> None:

        self.code = code
        if isinstance(extra_details, str): extra_details = [extra_details]
        self.details = '; '.join(map(str, [details] + extra_details))
        super().__init__(self.details)

class NotFoundException(ServiceException):
    def __init__(self, object_name : str, object_uuid: str, extra_details : Iterable[str] = []) -> None:
    def __init__(
        self, object_name : str, object_uuid: str, extra_details : Union[str, Iterable[str]] = []
        ) -> None:

        details = '{:s}({:s}) not found'.format(str(object_name), str(object_uuid))
        super().__init__(grpc.StatusCode.NOT_FOUND, details, extra_details=extra_details)

class AlreadyExistsException(ServiceException):
    def __init__(self, object_name : str, object_uuid: str, extra_details : Iterable[str] = None) -> None:
    def __init__(
        self, object_name : str, object_uuid: str, extra_details : Union[str, Iterable[str]] = None
        ) -> None:

        details = '{:s}({:s}) already exists'.format(str(object_name), str(object_uuid))
        super().__init__(grpc.StatusCode.ALREADY_EXISTS, details, extra_details=extra_details)

class InvalidArgumentException(ServiceException):
    def __init__(self, argument_name : str, argument_value: str, extra_details : Iterable[str] = None) -> None:
    def __init__(
        self, argument_name : str, argument_value: str, extra_details : Union[str, Iterable[str]] = None
        ) -> None:

        details = '{:s}({:s}) is invalid'.format(str(argument_name), str(argument_value))
        super().__init__(grpc.StatusCode.INVALID_ARGUMENT, details, extra_details=extra_details)
Loading