open-traffic-generator / snappi

Open Traffic Generator SDK in Python and Go
MIT License
70 stars 7 forks source link

snappi is crashing while doing get config, if config contains TCP header #184

Closed biplamal closed 1 month ago

biplamal commented 2 years ago

E TypeError: property value shall be of type <class 'int'> at <class 'snappi.snappi.PatternFlowTcpSeqNum'> E got 0 of type <class 'str'> , expected min 0, expected max 4294967295

biplamal commented 2 years ago
import snappi
import pytest

@pytest.mark.sanity
def test_grpc_http_config(settings):
    """
    - config without port & with flow
    Validate,
    - should fail at set_config
    """
    size, fixed_packets = 1518, 50000

    http_api = snappi.api(location=settings.http_server)

    grpc_api = snappi.api(location=settings.grpc_server,
                          transport=snappi.Transport.GRPC)

    config = new_config(http_api, settings, size, fixed_packets)

    # gRPC setConfig
    res_grpc = grpc_api.set_config(config)
    if len(res_grpc.warnings) > 0:
        print("Warnings: {}".format(res_grpc.warnings))

    res_grpc = grpc_api.get_config()

    # HTTP setConfig
    res_http = http_api.set_config(config)
    if len(res_http.warnings) > 0:
        print("Warnings: {}".format(res_http.warnings))

    res_http = http_api.get_config()

    assert res_http.serialize(
        encoding='dict') == res_grpc.serialize(encoding='dict')

def new_config(api, settings, size, fixed_packets):
    config = api.config()
    tx = config.ports.port(name='tx', location=settings.ports[0])
    ly = config.layer1.layer1(name='l1')[0]

    ly.speed = settings.speed
    ly.promiscuous = settings.promiscuous
    ly.mtu = settings.mtu
    ly.port_names = [tx[0].name]

    flw = config.flows.flow(name='flw')[-1]

    flw.size.fixed = size
    flw.rate.percentage = settings.line_rate
    flw.duration.fixed_packets.packets = fixed_packets
    flw.tx_rx.port.tx_name = tx[0].name

    flw.packet.ethernet().ipv4().tcp()

    return config
biplamal commented 2 years ago

script to reproduce the issue

Rangababu-R commented 2 years ago

@biplamal Its issue with models. TCP.Seq.Num is being set to integer type and format is not set to int64. Why does the server returning in string? was it made to int64 type?

shramroy commented 2 years ago

Observation is - Whichever field having format: integer length: 32 this format causing this issue. The affected fields are TCP seq_num, ack_num, gtpv1 teid & gtpv2 teid.

apratimmukherjee commented 1 month ago

Its fixed by https://github.com/open-traffic-generator/openapiart/pull/362 as per linked issue so closing this.