Commit 79167bfd authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Several changes:

Common:
- implemented ServiceException class
- updated attributes in entities belonging to Database API
- implemented test method to populate database with example topology

Context service:
- updated genproto script
- implemented report_coverage_context script
- moved specific rest scripts to root folder
- minor arrangements in ContextClient
- updated proto python files
- implemented GetTopology RPC functionality
- implemented unitary testing for GetTopology

Device service:
- updated genproto script
parent e8ec7e2b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
#!/bin/bash

./report_coverage.sh | grep --color -E -i "^.*context.*$|$"
+7 −0
Original line number Diff line number Diff line
#!/bin/bash

## Make folder containing the script the root folder for its execution
#cd $(dirname $0)

#ENDPOINT=($(kubectl --namespace teraflow-development get service contextservice -o 'jsonpath={.spec.clusterIP} {.spec.ports[?(@.name=="grpc")].port}'))
#docker run -it --env TEST_TARGET_ADDRESS=${ENDPOINT[0]} --env TEST_TARGET_PORT=${ENDPOINT[1]} context_service:test
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ RCFILE=~/teraflow/controller/coverage/.coveragerc
# Run unitary tests and analyze coverage of code at same time
coverage run --rcfile=$RCFILE -m pytest --log-level=DEBUG --verbose \
    common/database/tests/test_unitary_inmemory.py \
    context/tests/test_unitary.py \
    device/tests/test_unitary.py

## Run integration tests and analyze coverage of code at same time
+2 −0
Original line number Diff line number Diff line
DEFAULT_CONTEXT_ID = 'admin'
DEFAULT_TOPOLOGY_ID = 'admin'
+7 −3
Original line number Diff line number Diff line
@@ -11,8 +11,7 @@ VALIDATORS = {}
class Context(_Entity):
    def __init__(self, context_uuid : str, database_engine : _DatabaseEngine):
        self._database_engine = database_engine
        super().__init__(parent=self)
        self._context_uuid = context_uuid
        super().__init__(context_uuid, parent=self)
        self._attributes = EntityAttributes(self, KEY_CONTEXT, validators=VALIDATORS)
        self._topologies = EntityCollection(self, KEY_TOPOLOGIES)

@@ -26,7 +25,7 @@ class Context(_Entity):
    def context(self) -> 'Context': return self

    @property
    def context_uuid(self) -> str: return self._context_uuid
    def context_uuid(self) -> str: return self._entity_uuid

    @property
    def attributes(self) -> EntityAttributes: return self._attributes
@@ -42,5 +41,10 @@ class Context(_Entity):
        for topology_uuid in self.topologies.get(): self.topology(topology_uuid).delete()
        self.attributes.delete()

    def dump_id(self) -> Dict:
        return {
            'contextUuid': {'uuid': self.context_uuid},
        }

    def dump(self) -> Dict:
        return {topology_uuid : self.topology(topology_uuid).dump() for topology_uuid in self.topologies.get()}
Loading