Skip to content

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #215

@vikumarks

Description

@vikumarks

Test Script: dentv2/acl/perf/test_acl_perf_json_fix.py::test_dentv2_acl_perf_json_fix

    async def test_dentv2_acl_perf_json_fix(testbed):
        """
        Test Name: test_dentv2_acl_perf_json_fix
        Test Suite: suite_acl_performance
        Test Overview: test if the json output bug for policer in tc is fixed
        Test Procedure:
        1. check the fix for json output when a rate limiter is added to the tc action
        """
    
        devices = await tb_get_all_devices(testbed)
        infra_devices = []
        for dd in devices:
            if dd.type in [DeviceType.INFRA_SWITCH]:
                infra_devices.append(dd)
        if not infra_devices:
            print("The testbed does not have enough dent")
            return
    
        for dd in infra_devices:
            for swp in [link[0] for link in dd.links]:
                await TcFilter.add(
                    input_data=[
                        {
                            dd.host_name: [
                                {
                                    "block": 1,
                                    "direction": "ingress",
                                    "protocol": "ip",
                                    "handle": 8314,
                                    "pref": 1,
                                    "filtertype": {
                                        "verbose": "",
                                        "skip_sw": "",
                                        "indev": swp,
                                        "ip_proto": "udp",
                                        "src_port": 53,
                                    },
                                    "action": {
                                        "police": {
                                            "rate": "1kbps",
                                            "burst": 100,
                                            "conform-exceed": "",
                                            "drop": "",
                                        }
                                    },
                                }
                            ]
                        }
                    ]
                )
                out = await TcFilter.show(
                    input_data=[{dd.host_name: [{"block": 1, "options": "-json"}]}]
                )
                try:
>                   json_output = json.loads(out[0][dd.host_name]["result"])

/usr/local/lib/python3.10/dist-packages/dent_os_testbed/test/test_suite/dentv2/acl/perf/test_acl_perf_json_fix.py:88: 
..
..
self = <json.decoder.JSONDecoder object at 0x7f143b35a020>, s = 'Cannot find block "1"\n', idx = 0

    def raw_decode(self, s, idx=0):
        """Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.
    
        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
    
        """
        try:
            obj, end = self.scan_once(s, idx)
        except StopIteration as err:
>           raise JSONDecodeError("Expecting value", s, err.value) from None
E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Metadata

Metadata

Assignees

Labels

DENT 3.0needed for DENT 3.0 releasebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions