Commit 45473164 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

chore: Remove old test scripts and topology import functionality from...

chore: Remove old test scripts and topology import functionality from TransportApiDriver, and add `create_request` import to IetfL3VpnDriver.
parent d34a1c29
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ from .handlers.SubscriptionHandler import (
from .Constants import SPECIAL_RESOURCE_MAPPINGS
from .TfsApiClient import TfsApiClient
from .Tools import compose_resource_endpoint

from .templates.tools import create_request

LOGGER = logging.getLogger(__name__)

+0 −25
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ from typing import Any, Iterator, List, Optional, Tuple, Union
from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method
from common.type_checkers.Checkers import chk_string, chk_type
from device.service.driver_api._Driver import _Driver
from device.service.driver_api.ImportTopologyEnum import ImportTopologyEnum, get_import_topology
from . import ALL_RESOURCE_KEYS
from .Tools import create_connectivity_service, find_key, config_getter, delete_connectivity_service, tapi_tequest

@@ -39,17 +38,6 @@ class TransportApiDriver(_Driver):
        scheme = self.settings.get('scheme', 'http')
        self.__tapi_root = '{:s}://{:s}:{:d}'.format(scheme, self.address, int(self.port))
        self.__timeout = int(self.settings.get('timeout', 120))
        self.__import_topology = get_import_topology(self.settings, default=ImportTopologyEnum.DISABLED)
        self.__skip_tapi_queries = self.__import_topology != ImportTopologyEnum.DISABLED

        if self.__skip_tapi_queries:
            self.tac = TfsApiClient(address, port, scheme=scheme, username=username, password=password, timeout=self.__timeout)
            LOGGER.info('TransportApiDriver initialized for {:s}:{:s} with import_topology={:s}'.format(
                address, str(port), str(self.__import_topology)))
        else:
            self.tac = None
            LOGGER.info('TransportApiDriver initialized for {:s}:{:s} as real OLS device'.format(
                address, str(port)))

    def Connect(self) -> bool:
        url = self.__tapi_root + '/restconf/data/tapi-common:context'
@@ -82,19 +70,6 @@ class TransportApiDriver(_Driver):
        chk_type('resources', resource_keys, list)
        results = []
        with self.__lock:
            if self.__skip_tapi_queries:
                LOGGER.info('Importing topology from NBI for teraflowsdn device')
                if len(resource_keys) == 0: resource_keys = ALL_RESOURCE_KEYS
                for resource_key in resource_keys:
                    if resource_key == RESOURCE_ENDPOINTS or resource_key == RESOURCE_SERVICES:
                        try:
                            results.extend(self.tac.get_devices_endpoints(self.__import_topology))
                            LOGGER.info('Imported {:d} resources from NBI'.format(len(results)))
                        except Exception as e:
                            LOGGER.exception('Failed to import topology from NBI: {:s}'.format(str(e)))
                            results.append((resource_key, e))
                return results

            if len(resource_keys) == 0: resource_keys = ALL_RESOURCE_KEYS
            for i, resource_key in enumerate(resource_keys):
                str_resource_name = 'resource_key[#{:d}]'.format(i)

src/tests/ipowdm_test.sh

deleted100755 → 0
+0 −68
Original line number Diff line number Diff line
#!/bin/bash

# Test IPoWDM service creation and deletion via NBI

set -e

NBI_URL="${NBI_URL:-http://10.95.86.58}"

echo "=========================================="
echo "IPoWDM NBI Test"
echo "=========================================="
echo ""

# Test 1: Create IPoWDM Service
echo ">>> Test 1: POST /restconf/ipowdm/v1/service/test-ipowdm-001"
echo ""

IPOWDM_DATA='{
  "src": [{
    "uuid": "Phoenix-1",
    "ip_address": "10.10.1.1",
    "ip_mask": "/24",
    "vlan_id": 100,
    "power": 0.0,
    "frequency": 194700.0
  }],
  "dst": [{
    "uuid": "Phoenix-2",
    "ip_address": "10.10.2.1",
    "ip_mask": "/24",
    "vlan_id": 100,
    "power": 0.0,
    "frequency": 194700.0
  }],
  "bw": 100,
  "uuid": "test-ipowdm-001",
  "device_id": "TFS-PACKET"
}'

curl -v -X POST \
  "$NBI_URL/restconf/ipowdm/v1/service/test-ipowdm-001" \
  -H "Content-Type: application/json" \
  -d "$IPOWDM_DATA"

echo ""
echo ""
echo "Waiting 2 seconds..."
sleep 2
echo ""

# Test 2: Delete IPoWDM Service
echo ">>> Test 2: DELETE /restconf/ipowdm/v1/service/test-ipowdm-001"
echo ""
sleep 4
DELETE_DATA='{
  "device_id": "TFS-PACKET"
}'

curl -v -X DELETE \
  "$NBI_URL/restconf/ipowdm/v1/service/test-ipowdm-001" \
  -H "Content-Type: application/json" \
  -d "$DELETE_DATA"

echo ""
echo ""
echo "==========================================="
echo "Test completed - Check NBI logs"
echo "==========================================="
+0 −188
Original line number Diff line number Diff line
#!/bin/bash

# Comprehensive test for both Media Channel and Optical Slice services
# Tests creation and deletion of services via NBI

set -e

NBI_URL="${NBI_URL:-http://10.95.86.58}"

echo "=========================================="
echo "TFS NBI Integration Test - Full Suite"
echo "=========================================="
echo ""

# Test counters
TESTS_RUN=0
TESTS_PASSED=0
TESTS_FAILED=0

# Function to run a test
run_test() {
    local test_name="$1"
    local method="$2"
    local endpoint="$3"
    local data="$4"
    local expected_status="$5"
    
    TESTS_RUN=$((TESTS_RUN + 1))
    echo ">>> Test $TESTS_RUN: $test_name"
    echo ""
    
    if [ -n "$data" ]; then
        response=$(curl -v -X "$method" \
            "$NBI_URL$endpoint" \
            -H "Content-Type: application/json" \
            -d "$data" \
            2>&1)
    else
        response=$(curl -v -X "$method" \
            "$NBI_URL$endpoint" \
            -H "Content-Type: application/json" \
            2>&1)
    fi
    
    echo "$response"
    echo ""
    
    # Check if expected status is in response
    if echo "$response" | grep -q "HTTP.*$expected_status"; then
        echo "✓ PASSED: Got expected status $expected_status"
        TESTS_PASSED=$((TESTS_PASSED + 1))
    else
        echo "✗ FAILED: Expected status $expected_status"
        TESTS_FAILED=$((TESTS_FAILED + 1))
    fi
    
    echo ""
    echo "Waiting 2 seconds..."
    sleep 2
    echo ""
}

# ==========================================
# MEDIA CHANNEL TESTS
# ==========================================
echo "==========================================
MEDIA CHANNEL SERVICE TESTS
==========================================
"

# Test 1: Create Media Channel Service
MEDIA_CHANNEL_DATA='{
  "input_sip": "e7444187-119b-5b2e-8a60-ee26b30c441a",
  "output_sip": "b32b1623-1f64-59d2-8148-b035a8f77625",
  "uuid": "test-mc-001",
  "bw": "100",
  "tenant_uuid": "502311db-2724-4d86-a711-c9502d8d749f",
  "direction": "BIDIRECTIONAL",
  "layer_protocol_name": "PHOTONIC_MEDIA",
  "layer_protocol_qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_MC",
  "lower_frequency_mhz": "194700000",
  "upper_frequency_mhz": "194800000",
  "link_uuid_path": ["3beef785-bb26-5741-af10-c5e1838c1701"],
  "granularity": "G_6_25GHZ",
  "grid_type": "FLEX",
  "device_id": "TFS-TAPI",
  "url": "http://11.1.1.101:4900/502311db-2724-4d86-a711-c9502d8d749f/restconf/data"
}'

run_test \
    "Create Media Channel Service" \
    "POST" \
    "/restconf/media-channel/v1/service/test-mc-001" \
    "$MEDIA_CHANNEL_DATA" \
    "201"

# Test 2: Delete Media Channel Service
MEDIA_CHANNEL_DELETE_DATA='{
  "device_id": "TFS-TAPI"
}'

run_test \
    "Delete Media Channel Service" \
    "DELETE" \
    "/restconf/media-channel/v1/service/test-mc-001" \
    "$MEDIA_CHANNEL_DELETE_DATA" \
    "200"

# ==========================================
# OPTICAL SLICE TESTS
# ==========================================
echo "==========================================
OPTICAL SLICE SERVICE TESTS
==========================================
"

# Test 3: Create Optical Slice Service
OPTICAL_SLICE_DATA='{
  "url": "http://11.1.1.101:4900/502311db-2724-4d86-a711-c9502d8d749f/restconf/data",
  "data": {
    "tapi-common:context": {
      "name": [{"value": "test-optical-slice-001"}],
      "service-interface-point": [
        {"uuid": "e7444187-119b-5b2e-8a60-ee26b30c441a"},
        {"uuid": "b32b1623-1f64-59d2-8148-b035a8f77625"}
      ],
      "tapi-topology:topology-context": {
        "topology": [{
          "link": [{"uuid": "3beef785-bb26-5741-af10-c5e1838c1701"}],
          "node": [{
            "uuid": "68eb48ac-b686-5653-bdaf-7ccaeecd0709",
            "owned-node-edge-point": [{
              "uuid": "7fd74b80-2b5a-55e2-8ef7-82bf589c9591",
              "tapi-photonic-media:media-channel-node-edge-point-spec": {
                "mc-pool": {
                  "supportable-spectrum": [{
                    "lower-frequency": "191325000",
                    "upper-frequency": "192225000"
                  }]
                }
              }
            }]
          }]
        }]
      },
      "uuid": "502311db-2724-4d86-a711-c9502d8d749f"
    }
  }
}'

run_test \
    "Create Optical Slice Service" \
    "POST" \
    "/restconf/optical-slice/v1/service/test-optical-001" \
    "$OPTICAL_SLICE_DATA" \
    "201"

# Test 4: Delete Optical Slice Service
OPTICAL_SLICE_DELETE_DATA='{
  "context_uuid": "502311db-2724-4d86-a711-c9502d8d749f",
  "device_id": "TFS-TAPI"
}'

run_test \
    "Delete Optical Slice Service" \
    "DELETE" \
    "/restconf/optical-slice/v1/service/test-optical-001" \
    "$OPTICAL_SLICE_DELETE_DATA" \
    "200"

# ==========================================
# TEST SUMMARY
# ==========================================
echo "=========================================="
echo "TEST SUMMARY"
echo "=========================================="
echo "Total Tests Run:    $TESTS_RUN"
echo "Tests Passed:       $TESTS_PASSED"
echo "Tests Failed:       $TESTS_FAILED"
echo "=========================================="

if [ $TESTS_FAILED -eq 0 ]; then
    echo "✓ ALL TESTS PASSED"
    exit 0
else
    echo "✗ SOME TESTS FAILED"
    exit 1
fi
+0 −54
Original line number Diff line number Diff line
#!/bin/bash
# Test Media Channel NBI - Simple version

set -e

NBI_URL="http://10.95.86.58"

echo "=========================================="
echo "Media Channel NBI Test - Simple"
echo "=========================================="
echo ""

# Test 1: Create media channel
echo ">>> Test 1: POST /restconf/media-channel/v1/service/test-001"
echo ""

curl -v -X POST "$NBI_URL/restconf/media-channel/v1/service/test-001" \
  -H "Content-Type: application/json" \
  -d '{
    "input_sip": "e7444187-119b-5b2e-8a60-ee26b30c441a",
    "output_sip": "b32b1623-1f64-59d2-8148-b035a8f77625",
    "uuid": "test-001",
    "bw": "100",
    "tenant_uuid": "7c10521f-dcdf-4b83-823b-08c8f56933bc",
    "direction": "BIDIRECTIONAL",
    "layer_protocol_name": "PHOTONIC_MEDIA",
    "layer_protocol_qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_MC",
    "lower_frequency_mhz": "194700000",
    "upper_frequency_mhz": "194800000",
    "link_uuid_path": ["3beef785-bb26-5741-af10-c5e1838c1701"],
    "granularity": "G_6_25GHZ",
    "grid_type": "FLEX",
    "device_id": "TFS-TAPI"
  }'

echo ""
echo ""
echo "Waiting 2 seconds..."
sleep 2

# Test 2: Delete media channel
echo ""
echo ">>> Test 2: DELETE /restconf/media-channel/v1/service/test-001"
echo ""

curl -v -X DELETE "$NBI_URL/restconf/media-channel/v1/service/test-001" \
  -H "Content-Type: application/json" \
  -d '{"uuid": "test-001", "device_id": "TFS-TAPI"}'

echo ""
echo ""
echo "==========================================="
echo "Test completed - Check NBI logs"
echo "==========================================="