Skip to content

Remove any null characters before parsing string in test_snmp_phy_entity#14596

Merged
bingwang-ms merged 1 commit intosonic-net:masterfrom
Janetxxx:user/jc/modify-snmp-phy-entity-test
Sep 18, 2024
Merged

Remove any null characters before parsing string in test_snmp_phy_entity#14596
bingwang-ms merged 1 commit intosonic-net:masterfrom
Janetxxx:user/jc/modify-snmp-phy-entity-test

Conversation

@Janetxxx
Copy link
Copy Markdown
Contributor

@Janetxxx Janetxxx commented Sep 16, 2024

Description of PR

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405

Approach

What is the motivation for this PR?

Solve ValueError when parsing a string that contains null bytes (\x00). ast.literal_eval is essentially trying to compile a string into an Abstract Syntax Tree node, but it can't handle null bytes in the string. e,g., node_or_string = '{\'ext_identifier\': \'Power Class 8 (16.0W Max)\', \'media_lane_count\': \'N/A\', \'ma: \'2024-05-23 \x00\x00\', \'active_apsel_hostlane7\': \'N/A\'}'

This happens due to how the output is captured by the shell command execution cmd = 'sonic-db-cli {} HGETALL \"{}\"'.format(db_id, key) output = duthost.shell(cmd)The output is being captured as a string with escaped single quotes and some null characters.

How did you do it?

Remove any null characters before parsing string.

How did you verify/test it?

In snmp/test_snmp_phy_entity.py:

======================================================================================== short test summary info ========================================================================================

SKIPPED [1] snmp/test_snmp_phy_entity.py:367: Not supported on non supervisor node

SKIPPED [1] platform_tests/thermal_control_test_helper.py:123: No mocker defined for this platform x86_64-arista_7060x6_64pe

SKIPPED [1] snmp/test_snmp_phy_entity.py:636: psu_controller is None, skipping this test

========================================================================== 4 passed, 3 skipped, 1 warning in 853.68s (0:14:13) ==========================================================================

Any platform specific information?

str3-7060x6-64pe-1

Supported testbed topology if it's a new test case?

t0-standalone-32

Documentation

Signed-off-by: Janetxxx <janet970527@gmail.com>
@bingwang-ms bingwang-ms merged commit 701e39e into sonic-net:master Sep 18, 2024
Janetxxx added a commit to Janetxxx/sonic-mgmt that referenced this pull request Sep 19, 2024
hdwhdw pushed a commit to hdwhdw/sonic-mgmt that referenced this pull request Sep 20, 2024
wangxin pushed a commit that referenced this pull request Sep 23, 2024
…hy_entity (#14596)" (#14659)

What is the motivation for this PR?
Revert #14596 as it was temporary optics

How did you do it?
How did you verify/test it?
Validate it in internal setup, TRANSCEIVER_INFO|Ethernet302 in STATE_DB is empty at the moment.

Any platform specific information?
str3-7060x6-64pe-1

Supported testbed topology if it's a new test case?
t0-standalone-32
arista-hpandya pushed a commit to arista-hpandya/sonic-mgmt that referenced this pull request Oct 2, 2024
arista-hpandya pushed a commit to arista-hpandya/sonic-mgmt that referenced this pull request Oct 2, 2024
…hy_entity (sonic-net#14596)" (sonic-net#14659)

What is the motivation for this PR?
Revert sonic-net#14596 as it was temporary optics

How did you do it?
How did you verify/test it?
Validate it in internal setup, TRANSCEIVER_INFO|Ethernet302 in STATE_DB is empty at the moment.

Any platform specific information?
str3-7060x6-64pe-1

Supported testbed topology if it's a new test case?
t0-standalone-32
hdwhdw pushed a commit to hdwhdw/sonic-mgmt that referenced this pull request Oct 10, 2024
…hy_entity (sonic-net#14596)" (sonic-net#14659)

What is the motivation for this PR?
Revert sonic-net#14596 as it was temporary optics

How did you do it?
How did you verify/test it?
Validate it in internal setup, TRANSCEIVER_INFO|Ethernet302 in STATE_DB is empty at the moment.

Any platform specific information?
str3-7060x6-64pe-1

Supported testbed topology if it's a new test case?
t0-standalone-32
vikshaw-Nokia pushed a commit to vikshaw-Nokia/sonic-mgmt that referenced this pull request Oct 23, 2024
vikshaw-Nokia pushed a commit to vikshaw-Nokia/sonic-mgmt that referenced this pull request Oct 23, 2024
…hy_entity (sonic-net#14596)" (sonic-net#14659)

What is the motivation for this PR?
Revert sonic-net#14596 as it was temporary optics

How did you do it?
How did you verify/test it?
Validate it in internal setup, TRANSCEIVER_INFO|Ethernet302 in STATE_DB is empty at the moment.

Any platform specific information?
str3-7060x6-64pe-1

Supported testbed topology if it's a new test case?
t0-standalone-32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants