Commit b238e50a authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Initial implementation of the scenario tests.

parent 57603757
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -169,16 +169,18 @@ kubectl create secret generic qdb-data --namespace ${TFS_K8S_NAMESPACE} --type='
    --from-literal=METRICSDB_PASSWORD=${QDB_PASSWORD}
printf "\n"

echo "Create Redis secret..."
REDIS_PASSWORD=`uuidgen`
kubectl create secret generic redis-secrets --namespace=$TFS_K8S_NAMESPACE \
    --from-literal=REDIS_PASSWORD=$REDIS_PASSWORD

echo "Deploying components and collecting environment variables..."
ENV_VARS_SCRIPT=tfs_runtime_env_vars.sh
echo "# Environment variables for TeraFlowSDN deployment" > $ENV_VARS_SCRIPT
PYTHONPATH=$(pwd)/src
echo "export PYTHONPATH=${PYTHONPATH}" >> $ENV_VARS_SCRIPT

echo "Create Redis secret..."
# first try to delete an old one if exists
kubectl delete secret redis-secrets --namespace=$TFS_K8S_NAMESPACE
REDIS_PASSWORD=`uuidgen`
kubectl create secret generic redis-secrets --namespace=$TFS_K8S_NAMESPACE \
    --from-literal=REDIS_PASSWORD=$REDIS_PASSWORD
echo "export REDIS_PASSWORD=${REDIS_PASSWORD}" >> $ENV_VARS_SCRIPT

for COMPONENT in $TFS_COMPONENTS; do
+7 −0
Original line number Diff line number Diff line
@@ -42,6 +42,13 @@ spec:
        args:
        - --requirepass
        - $(REDIS_PASSWORD)
        resources:
          requests:
            cpu: 50m
            memory: 64Mi
          limits:
            cpu: 500m
            memory: 512Mi
---
apiVersion: v1
kind: Service
+2 −2
Original line number Diff line number Diff line
@@ -76,11 +76,11 @@ spec:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: opticalattackdetectorservice-hpa
  name: opticalattackmanagerservice-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: opticalattackdetectorservice
    name: opticalattackmanagerservice
  minReplicas: 1
  maxReplicas: 1
+2 −1
Original line number Diff line number Diff line
@@ -66,10 +66,11 @@ attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorCl
redis_host = get_service_host(ServiceNameEnum.CACHING)
r = None
if redis_host is not None:
    redis_port = int(get_setting("CACHINGSERVICE_SERVICE_PORT_REDIS"))
    redis_port = int(get_setting("CACHINGSERVICE_SERVICE_PORT_REDIS", default=6379))
    redis_password = get_setting("REDIS_PASSWORD")

    r = redis.Redis(host=redis_host, port=redis_port, password=redis_password)
    r.ping()

# detecting preloading of the stats
path = get_setting("PATH_OPM_INFORMATION_SUMMARY", default=None)
+3 −1
Original line number Diff line number Diff line
@@ -482,13 +482,15 @@ def main():

    redis_host = get_service_host(ServiceNameEnum.CACHING)
    if redis_host is not None:
        redis_port = int(get_setting("CACHINGSERVICE_SERVICE_PORT_REDIS"))
        redis_port = int(get_setting("CACHINGSERVICE_SERVICE_PORT_REDIS", default=6379))
        redis_password = get_setting("REDIS_PASSWORD")
        LOGGER.debug(f"Redis password: {redis_password}")

    service_list = None
    cache = None
    if SERVICE_LIST_MODE == LIST_REDIS_MODE:
        cache = redis.Redis(host=redis_host, port=redis_port, password=redis_password)
        cache.ping()

        # clean the existing list that will be populated later on in this function
        cache.delete(SERVICE_LIST_KEY)
Loading