Commit 22d86182 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context component:

- reorganized code spliting database models, enumerations, and operation methods
- separated unitary tests per entity and defined order between them
- separated unitary test for fasthasher
- modev old code to separate folder
parent bd291c64
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -44,8 +44,9 @@ export PYTHONPATH=/home/tfs/tfs-ctrl/src
#coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose --maxfail=1 \
#    context/tests/test_unitary.py

# --log-level=INFO -o log_cli=true
pytest --verbose --maxfail=1 --durations=0 \
    context/tests/test_unitary.py
# --log-level=INFO -o log_cli=true --durations=0
pytest --verbose --maxfail=1 \
    context/tests/test_unitary.py \
    context/tests/test_hasher.py

#kubectl --namespace $TFS_K8S_NAMESPACE delete service redis-tests
+2 −0
Original line number Diff line number Diff line
Flask==2.1.3
Flask-RESTful==0.3.9
psycopg2-binary==2.9.3
pytest-depends==1.0.1
redis==4.1.2
requests==2.27.1
SQLAlchemy==1.4.40
sqlalchemy-cockroachdb==1.4.3
SQLAlchemy-Utils==0.38.3
prettytable==3.5.0
+34 −0
Original line number Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


    @safe_and_metered_rpc_method(METRICS, LOGGER)
    def GetContextEvents(self, request : Empty, context : grpc.ServicerContext) -> Iterator[ContextEvent]:
        pass
        #for message in self.messagebroker.consume({TOPIC_CONTEXT}, consume_timeout=CONSUME_TIMEOUT):
        #    yield ContextEvent(**json.loads(message.content))
        #cf = ChangeFeedClient()
        #ready = cf.initialize()
        #if not ready: raise OperationFailedException('Initialize ChangeFeed')
        #for timestamp, _, primary_key, is_delete, after in cf.get_changes('context'):
        #    if is_delete:
        #        event_type = EventTypeEnum.EVENTTYPE_REMOVE
        #    else:
        #        is_create = (timestamp - after.get('created_at')) < 1.0
        #        event_type = EventTypeEnum.EVENTTYPE_CREATE if is_create else EventTypeEnum.EVENTTYPE_UPDATE
        #    event = {
        #        'event': {'timestamp': {'timestamp': timestamp}, 'event_type': event_type},
        #        'context_id': json_context_id(primary_key[0]),
        #    }
        #    yield ContextEvent(**event)
+6 −2
Original line number Diff line number Diff line
@@ -14,12 +14,16 @@

TOPIC_CONNECTION = 'connection'
TOPIC_CONTEXT    = 'context'
TOPIC_TOPOLOGY   = 'topology'
TOPIC_DEVICE     = 'device'
TOPIC_LINK       = 'link'
TOPIC_POLICY     = 'policy'
TOPIC_SERVICE    = 'service'
TOPIC_SLICE      = 'slice'
TOPIC_TOPOLOGY   = 'topology'

TOPICS = {TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_TOPOLOGY, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE}
TOPICS = {
    TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK,
    TOPIC_POLICY, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY
}

CONSUME_TIMEOUT = 0.5 # seconds
+96 −453

File changed.

Preview size limit exceeded, changes collapsed.

Loading