Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified test cases by QOS DB reference format remove #3824

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions ansible/library/sonic_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/python
import subprocess
from ansible.module_utils.basic import *

DOCUMENTATION = '''
---
module: sonic_release
version_added: "0.1"
author: Ashok Daparthi ([email protected])
short_description: Retrive os release facts from device
description:
- Retrieve sonic release facts for a device, the facts will be
inserted to the ansible_facts key.
'''

EXAMPLES = '''
# Gather sonic release facts
- name: Gather sonic release
sonic_release:

'''
def main():

module = AnsibleModule(argument_spec=dict())
"""
Gets the SONiC OS version that is running on this device.
"""
sonic_release = None
sonic_qos_db_fv_reference_with_table = false
try:
process = subprocess.Popen(['sonic-cfggen', '-y', '/etc/sonic/sonic_version.yml', '-v', 'release'],
stdout=subprocess.PIPE, stdin=subprocess.PIPE)
self.stdout, stderr = process.communicate()
ret_code = process.returncode
except Exception as e:
module.fail_json(msg=str(e))
else:
if ret_code != 0:
module.fail_json(msg=stderr)
else:
sonic_release = self.stdout.split('.')[0].strip()
"""
Check for QOS DB format for Field Value refered with tables or not.
"""
old_format_release_list = ["201811", "201911", "202012", "202106"]
if any(release == sonic_release for release in old_format_release_list):
sonic_qos_db_fv_reference_with_table = true

module.exit_json(ansible_facts={'sonic_release': sonic_release, 'sonic_qos_db_fv_reference_with_table': sonic_qos_db_fv_reference_with_table})

if __name__ == '__main__':
main()
82 changes: 80 additions & 2 deletions ansible/roles/fanout/templates/sonic_deploy_arista_7060.j2
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"FLEX_COUNTER_STATUS": "enable"
}
},

"QUEUE": {
{% if sonic_qos_db_fv_reference_with_table == 'true' %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}|0": {
"scheduler": "[SCHEDULER|scheduler.0]"
Expand All @@ -90,9 +90,37 @@
"scheduler": "[SCHEDULER|scheduler.0]"
}{% if not loop.last %},{% endif %}
{% endfor %}
{% else %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}|0": {
"scheduler": "scheduler.0"
},
"{{ alias }}|1": {
"scheduler": "scheduler.0"
},
"{{ alias }}|2": {
"scheduler": "scheduler.0"
},
"{{ alias }}|3": {
"wred_profile": "AZURE_LOSSLESS",
"scheduler": "scheduler.1"
},
"{{ alias }}|4": {
"wred_profile": "AZURE_LOSSLESS",
"scheduler": "scheduler.1"
},
"{{ alias }}|5": {
"scheduler": "scheduler.0"
},
"{{ alias }}|6": {
"scheduler": "scheduler.0"
}{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
},

"BUFFER_QUEUE": {
{% if sonic_qos_db_fv_reference_with_table == 'true' %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}|0-2": {
"profile": "[BUFFER_PROFILE|egress_lossy_profile]"
Expand All @@ -104,9 +132,23 @@
"profile": "[BUFFER_PROFILE|egress_lossy_profile]"
}{% if not loop.last %},{% endif %}
{% endfor %}
{% else %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}|0-2": {
"profile": "egress_lossy_profile"
},
"{{ alias }}|3-4": {
"profile": "egress_lossless_profile"
},
"{{ alias }}|5-6": {
"profile": "egress_lossy_profile"
}{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
},

"BUFFER_PG": {
{% if sonic_qos_db_fv_reference_with_table == 'true' %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}|0": {
"profile": "[BUFFER_PROFILE|ingress_lossy_profile]"
Expand All @@ -115,6 +157,16 @@
"profile": "[BUFFER_PROFILE|pg_lossless_100000_300m_profile]"
}{% if not loop.last %},{% endif %}
{% endfor %}
{% else %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}|0": {
"profile": "ingress_lossy_profile"
},
"{{ alias }}|3-4": {
"profile": "pg_lossless_100000_300m_profile"
}{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
},

"CABLE_LENGTH": {
Expand Down Expand Up @@ -186,6 +238,7 @@
},

"BUFFER_PROFILE": {
{% if sonic_qos_db_fv_reference_with_table == 'true' %}
"egress_lossless_profile": {
"static_th": "15982720",
"pool": "[BUFFER_POOL|egress_lossless_pool]",
Expand All @@ -209,6 +262,31 @@
"pool": "[BUFFER_POOL|ingress_lossless_pool]",
"size": "1248"
}
{% else %}
"egress_lossless_profile": {
"static_th": "15982720",
"pool": "egress_lossless_pool",
"size": "1518"
},
"egress_lossy_profile": {
"dynamic_th": "3",
"pool": "egress_lossy_pool",
"size": "1518"
},
"ingress_lossy_profile": {
"dynamic_th": "3",
"pool": "ingress_lossless_pool",
"size": "0"
},
"pg_lossless_100000_300m_profile": {
"xon_offset": "2288",
"dynamic_th": "0",
"xon": "2288",
"xoff": "268736",
"pool": "ingress_lossless_pool",
"size": "1248"
}
{% endif %}
}

}
}
66 changes: 55 additions & 11 deletions ansible/roles/test/tasks/qos_get_max_buff_size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
- debug:
msg="Get {{target_port_name}} port {{target_buffer_profile_type}} MAX buffer size"

- name: gather sonic release if not available
sonic_release:
when: sonic_release is not defined

- fail:
msg: "Unable to get sonic release and qos db format information"
when: sonic_qos_db_fv_reference_with_table is not defined

- name: Get {{target_buffer_profile_type}} buffer profile table for {{target_port_name}} port
shell: redis-cli -n 4 KEYS "{{target_table}}|{{target_port_name}}|{{target_pg}}"
register: buffer_profile_table


- fail:
msg: "Unable to get {{target_buffer_profile_type}} buffer profile table for {{target_port_name}}"
when: buffer_profile_table.stdout == ""
Expand All @@ -26,30 +33,50 @@
msg: "Unable to get {{target_buffer_profile_type}} buffer profile for {{target_port_name}}"
when: buffer_profile.stdout == ""

- name: Parse buffer profile name
set_fact:
buffer_profile="{{buffer_profile.stdout}}"
when: sonic_qos_db_fv_reference_with_table|bool == false

- name: Parse buffer profile name
set_fact:
buffer_profile="{{buffer_profile.stdout|replace('[','')|replace(']','')}}"
when: sonic_qos_db_fv_reference_with_table|bool == true

- name: set buffer_profile table key with new db format
set_fact:
buffer_profile_key="BUFFER_PROFILE|{{buffer_profile}}"
when: sonic_qos_db_fv_reference_with_table|bool == false

- name: set buffer_profile table key with old db format
set_fact:
buffer_profile_key="{{buffer_profile}}"
when: sonic_qos_db_fv_reference_with_table|bool == true

- name: Get {{target_buffer_profile_type}} buffer headroom size for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_profile}}" size
shell: redis-cli -n 4 HGET "{{buffer_profile_key}}" size
register: buffer_headroom

- fail:
msg: "Unable to get headroom size for {{target_port_name}}"
when: buffer_headroom.stdout == ""


- name: Get {{target_buffer_profile_type}} buffer pool profile for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_profile}}" pool
shell: redis-cli -n 4 HGET "{{buffer_profile_key}}" pool
register: buffer_pool_id

- name: Parse {{target_buffer_profile_type}} buffer pool profile name
set_fact:
buffer_pool_id="{{buffer_pool_id.stdout}}"
when: sonic_qos_db_fv_reference_with_table|bool == false

- name: Parse {{target_buffer_profile_type}} buffer pool profile name
set_fact:
buffer_pool_id="{{buffer_pool_id.stdout|replace('[','')|replace(']','')}}"
when: sonic_qos_db_fv_reference_with_table|bool == true

- name: Get {{target_buffer_profile_type}} buffer alpha ID for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_profile}}" dynamic_th
shell: redis-cli -n 4 HGET "{{buffer_profile_key}}" dynamic_th
register: buffer_alpha_raw

# static threshold
Expand All @@ -60,7 +87,7 @@
"{{target_buffer_profile_type}} buffer uses static threshold"
- name: Get {{target_buffer_profile_type}} buffer alpha ID for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_profile}}" static_th
shell: redis-cli -n 4 HGET "{{buffer_profile_key}}" static_th
register: buffer_static_th

- fail:
Expand All @@ -77,8 +104,18 @@
set_fact:
buffer_alpha="{{2|pow(buffer_alpha_raw.stdout|int)}}"

- name: Set buffer pool key with new db format
set_fact:
buffer_pool_id_key="BUFFER_POOL|{{buffer_pool_id}}"
when: sonic_qos_db_fv_reference_with_table|bool == false

- name: Set buffer pool key with old db format
set_fact:
buffer_pool_id_key="{{buffer_pool_id}}"
when: sonic_qos_db_fv_reference_with_table|bool == true

- name: Get {{target_buffer_profile_type}} buffer pool size for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_pool_id}}" size
shell: redis-cli -n 4 HGET "{{buffer_pool_id_key}}" size
register: buffer_pool_size

- fail:
Expand All @@ -93,9 +130,9 @@

# ingress lossless specific
- name: Get XON for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_profile}}" xon
shell: redis-cli -n 4 HGET "{{buffer_profile_key}}" xon
register: buffer_xon
when: buffer_profile != "" and "pg_lossless" in buffer_profile
when: buffer_profile != "" and "pg_lossless" in buffer_profile

- fail:
msg: "Unable to get XON for {{target_port_name}}"
Expand All @@ -104,7 +141,7 @@

# ingress lossless specific
- name: Get XOFF for {{target_port_name}} port
shell: redis-cli -n 4 HGET "{{buffer_profile}}" xoff
shell: redis-cli -n 4 HGET "{{buffer_profile_key}}" xoff
register: buffer_xoff
when: buffer_profile != "" and 'pg_lossless' in buffer_profile

Expand All @@ -116,8 +153,15 @@
# Get buffer pool ROID
# This is perhaps the only useful section in this yaml play
- block:
- set_fact:
- name: Set buffer_pool_name with new db format
set_fact:
buffer_pool_name="{{buffer_pool_id}}"
when: sonic_qos_db_fv_reference_with_table|bool == false

- name: Set buffer_pool_name with old db format
set_fact:
buffer_pool_name="{{buffer_pool_id|replace('BUFFER_POOL|','')}}"
when: sonic_qos_db_fv_reference_with_table|bool == true

- name: Get {{buffer_pool_name}} VOID
shell: redis-cli -n 2 HGET COUNTERS_BUFFER_POOL_NAME_MAP "{{buffer_pool_name}}"
Expand Down
16 changes: 15 additions & 1 deletion ansible/roles/test/tasks/qos_sai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,21 @@
defined_asic_list: ['td2', 'th', 'th2', 'spc1', 'spc2', 'spc3']
speed_cablelen: "{{ lossless_buffer_profile }}"

- set_fact: speed_cablelen="{{speed_cablelen | regex_replace('BUFFER_PROFILE\|pg_lossless_(.*)_profile', '\\1')}}"
- name: gather sonic release if not available
sonic_release:
when: sonic_release is not defined

- fail:
msg: "Unable to get sonic release and qos db format information"
when: sonic_qos_db_fv_reference_with_table is not defined

- name: Set speed_cablelen with new db format
set_fact: speed_cablelen="{{speed_cablelen | regex_replace('pg_lossless_(.*)_profile', '\\1')}}"
when: sonic_qos_db_fv_reference_with_table|bool == false

- name: Set speed_cablelen with old db format
set_fact: speed_cablelen="{{speed_cablelen | regex_replace('BUFFER_PROFILE\|pg_lossless_(.*)_profile', '\\1')}}"
when: sonic_qos_db_fv_reference_with_table|bool == true

- name: Get asic type
set_fact: asic_type="{{ item }}"
Expand Down
12 changes: 12 additions & 0 deletions ansible/roles/test/templates/qos_lossy_profile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"BUFFER_PROFILE": {
"pg_lossy_TEST_profile": {
"dynamic_th": "-8",
{% if sonic_qos_db_fv_reference_with_table == 'true' %}
"pool": "[{{ buffer_pool_id }}]",
{% else %}
"pool": "{{ buffer_pool_id }}",
{% endif %}
{% if buffer_headroom.stdout != '0' %}
"size": "{{ buffer_headroom.stdout }}"
{% else %}
Expand All @@ -14,11 +18,19 @@
{% endif %}
"BUFFER_PG": {
"{{ dut_switch_ports[src_port_id|int] }}|0-1": {
{% if sonic_qos_db_fv_reference_with_table == 'true' %}
{% if pfc_generate_buffer_profile == 'True' %}
"profile": "[BUFFER_PROFILE|pg_lossy_TEST_profile]"
{% else %}
"profile": "[{{ buffer_profile }}]"
{% endif %}
{% else %}
{% if pfc_generate_buffer_profile == 'True' %}
"profile": "pg_lossy_TEST_profile"
{% else %}
"profile": "{{ buffer_profile }}"
{% endif %}
{% endif %}
}
}
}
Loading