Commit d649fe78 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context component:

- cleaned up script run tests locally
- temporarily added script to automate test & coverage reporting
- reorganized unitary tests
- migration in progress to use single-column primary-key for main entities
- intermediate backup ; work in progress
parent e719962b
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

#export TFS_K8S_HOSTNAME="tfs-vm"

########################################################################################################################
# Automated steps start here
########################################################################################################################
@@ -29,24 +27,14 @@ export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
PROJECTDIR=`pwd`

cd $PROJECTDIR/src
#RCFILE=$PROJECTDIR/coverage/.coveragerc

#kubectl --namespace $TFS_K8S_NAMESPACE expose deployment contextservice --name=redis-tests --port=6379 --type=NodePort
#export REDIS_SERVICE_HOST=$(kubectl --namespace $TFS_K8S_NAMESPACE get service redis-tests -o 'jsonpath={.spec.clusterIP}')
#export REDIS_SERVICE_HOST=$(kubectl get node $TFS_K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}')
#export REDIS_SERVICE_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service redis-tests -o 'jsonpath={.spec.ports[?(@.port==6379)].nodePort}')
RCFILE=$PROJECTDIR/coverage/.coveragerc

#export CRDB_URI="cockroachdb://tfs:tfs123@127.0.0.1:26257/tfs_test?sslmode=require"
export CRDB_URI="cockroachdb://tfs:tfs123@10.1.7.195:26257/tfs_test?sslmode=require"
export PYTHONPATH=/home/tfs/tfs-ctrl/src

# Run unitary tests and analyze coverage of code at same time
#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 --durations=0
pytest --verbose --maxfail=1 \
# helpful pytest flags: --log-level=INFO -o log_cli=true --verbose --maxfail=1 --durations=0
coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose --maxfail=1 \
    context/tests/test_unitary.py \
    context/tests/test_hasher.py

#kubectl --namespace $TFS_K8S_NAMESPACE delete service redis-tests
+0 −1
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
# 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
+3 −2
Original line number Diff line number Diff line
@@ -16,14 +16,15 @@ TOPIC_CONNECTION = 'connection'
TOPIC_CONTEXT    = 'context'
TOPIC_DEVICE     = 'device'
TOPIC_LINK       = 'link'
TOPIC_POLICY     = 'policy'
#TOPIC_POLICY     = 'policy'
TOPIC_SERVICE    = 'service'
TOPIC_SLICE      = 'slice'
TOPIC_TOPOLOGY   = 'topology'

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

CONSUME_TIMEOUT = 0.5 # seconds
+86 −281

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -28,13 +28,13 @@ class Engine:
        try:
            engine = sqlalchemy.create_engine(
                crdb_uri, connect_args={'application_name': APP_NAME}, echo=ECHO, future=True)
        except: # pylint: disable=bare-except
        except: # pylint: disable=bare-except # pragma: no cover
            LOGGER.exception('Failed to connect to database: {:s}'.format(crdb_uri))
            return None

        try:
            Engine.create_database(engine)
        except: # pylint: disable=bare-except
        except: # pylint: disable=bare-except # pragma: no cover
            LOGGER.exception('Failed to check/create to database: {:s}'.format(engine.url))
            return None

Loading