Commit f0a9a5ff authored by Georgios P. Katsikas's avatar Georgios P. Katsikas
Browse files

test: new automation example

parent 6df5f305
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.

########################################################################################################################
# Define your deployment settings here
########################################################################################################################

# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

########################################################################################################################
# Automated steps start here
########################################################################################################################

kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/policyservice
+109 −0
Original line number Diff line number Diff line
# Tests for the TFS Automation Service

This test invokes a closed loop example using the TFS Automation service.
For Automation to have proper context, we use the p4-fabric-tna test to provision an example topology, forwarding service, and telemetry service.
On top of this setup, Automation on the one hand employs an Analyzer to ingest telemetry data stemming from the dataplane, process this data, and define a target KPI of interest, while on the other hand employs Policy to define what action needs to happen in the dataplane if an alarm is raised on this KPI.

## Steps to setup and run a TFS program atop Stratum

To conduct this test, follow the steps below.

### Setup pyenv

Setup the Python virtual environment as follows:

```shell
python3 -m venv venv && source venv/bin/activate
```

### Deploy TFS

Deploy TFS as follows:

```shell
cd ~/tfs-ctrl/
source my_deploy.sh && source tfs_runtime_env_vars.sh
./deploy/all.sh
```

### Path setup

Ensure that `PATH` variable contains the parent project directory, e.g., "home/$USER/tfs-ctrl".

Ensure that `PYTHONPATH` variable contains the source code directory of TFS, e.g., "home/$USER/tfs-ctrl/src"

## Test

### Provision test

First deploy the TFS topology, connectivity, and telemetry services as follows:

```shell
cd ~/tfs-ctrl/
source my_deploy.sh && source tfs_runtime_env_vars.sh
bash src/tests/p4-fabric-tna/setup.sh
bash src/tests/p4-fabric-tna/run_test_01_bootstrap.sh
bash src/tests/p4-fabric-tna/run_test_03a_service_provision_l2.sh
bash src/tests/p4-fabric-tna/run_test_04a_service_provision_l3.sh
bash src/tests/p4-fabric-tna/run_test_06a_service_provision_int.sh
```

Once this is done, login on the WebUI to observe the example topology and verify that there are 2 services in ACTIVE state:

- A P4 L2 forwarding that establishes connectivity between the hosts of the topology
- A P4 INT service that invokes the INT Telemetry Collector as a service

```
http://<tfs-ip>/webui
```

Then, login on Grafana to observe the `Latency` Dashboard already created for you.

```
http://<tfs-ip>/grafana
```

Finally, login on Prometheus to check the KPI ID of interest.

```
http://<tfs-ip>:30090/
```

Example KPI of interest could be `KPISAMPLETYPE_INT_HOP_LAT`.

#### Fill-in input JSON file for Automation

Open the `automation.json` file located in `descriptors/`. and fill in the following critical fattrbutes:

- Under `target_service_id.service_uuid.uuid`, add the service uuid of the L2 forwarding service that you saw on the WebUI (Service tab)
- Under `target_service_id.context_id.context_uuid.uuid`, add the context uuid that you saw on the WebUI (Service tab, open any service)
- Under `telemetry_service_id.service_uuid.uuid`, add the service uuid of the INT forwarding service that you saw on the WebUI (Service tab)
- Under `telemetry_service_id.context_id.context_uuid.uuid`, add the context uuid that you saw on the WebUI (same as above)
- Under `input_kpi_ids.kpi_id.uuid`, add the KPI ID you saw when you queried the `KPISAMPLETYPE_INT_HOP_LAT` KPI on Prometheus
- In case you want to tweak the KPI thresholds, modify `analyzer.parameters.thresholds`

Now, you are ready to fire the test:

```shell
cd ~/tfs-ctrl/
bash 
```

To observe the logs of Automation, do:

```shell
cd ~/tfs-ctrl/
bash src/tests/automation/run_test_automation.sh
```

### Deprovision test

To deprovision the test, follow the steps below:

```shell

bash src/tests/p4-fabric-tna/run_test_03b_service_deprovision_l2.sh
bash src/tests/p4-fabric-tna/run_test_04b_service_deprovision_l3.sh
bash src/tests/p4-fabric-tna/run_test_06b_service_deprovision_int.sh
bash src/tests/p4-fabric-tna/run_test_07_cleanup.sh
```
+13 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.
+38 −0
Original line number Diff line number Diff line
{
    "target_service_id": {
        "service_uuid": {"uuid": "66d498ad-5d94-5d90-8cb4-861e30689c64"},
        "context_id": {"context_uuid": {"uuid": "43813baf-195e-5da6-af20-b3d0922e71a7"}}
    },
    "telemetry_service_id": {
        "service_uuid": {"uuid": "db73d789-4abc-5514-88bb-e21f7e31d36a"},
        "context_id": {"context_uuid": {"uuid": "43813baf-195e-5da6-af20-b3d0922e71a7"}}
    },
    "analyzer":{
        "operation_mode": "ANALYZEROPERATIONMODE_STREAMING",
        "parameters": {
            "thresholds": "{\"task_type\": \"AggregationHandler\",\"task_parameter\": [ {\"avg\": [0, 2500]}]}"
        },
        "input_kpi_ids": [
            {"kpi_id": { "uuid": "b9f915e2-402d-4788-9e7d-6bd1055b5e8b"}}
        ],
        "output_kpi_ids": [
            {"kpi_id": { "uuid": "c45b09d8-c84a-45d8-b4c2-9fa9902d157d"}}
        ],
        "batch_min_duration_s": 10,
        "batch_min_size": 5
    },
     "policy":{
        "serviceId": {
            "context_id": {"context_uuid": {"uuid": "43813baf-195e-5da6-af20-b3d0922e71a7"}},
            "service_uuid": {"uuid": "66d498ad-5d94-5d90-8cb4-861e30689c64"}
        },
        "policyRuleBasic": {
            "actionList": [
                {
                    "action": "POLICY_RULE_ACTION_RECALCULATE_PATH",
                    "action_config": []
                }
            ]
        }
    }
}
+17 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.

source tfs_runtime_env_vars.sh
python3 -m pytest --verbose src/tests/automation/test_functional_automation.py
Loading