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

[GCU] Update RDMA Platform Validator #2913

Merged
merged 12 commits into from
Jul 20, 2023
13 changes: 12 additions & 1 deletion generic_config_updater/field_operation_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ def get_asic_name():
hwsku = output.rstrip('\n')
if asic_type == 'mellanox' or asic_type == 'vs':
spc1_hwskus = asic_mapping["mellanox_asics"]["spc1"]
spc2_hwskus = asic_mapping["mellanox_asics"]["spc2"]
spc3_hwskus = asic_mapping["mellanox_asics"]["spc3"]
if hwsku.lower() in [spc1_hwsku.lower() for spc1_hwsku in spc1_hwskus]:
asic = "spc1"
return asic
if hwsku.lower() in [spc2_hwsku.lower() for spc2_hwsku in spc2_hwskus]:
asic = "spc2"
return asic
if hwsku.lower() in [spc3_hwsku.lower() for spc3_hwsku in spc3_hwskus]:
asic = "spc3"
return asic
if asic_type == 'broadcom' or asic_type == 'vs':
broadcom_asics = asic_mapping["broadcom_asics"]
for asic_shorthand, hwskus in broadcom_asics.items():
Expand Down Expand Up @@ -75,7 +83,10 @@ def _get_fields_in_patch():

if 'value' in patch_element.keys() and isinstance(patch_element['value'], dict):
for key in patch_element['value']:
cleaned_fields.append(cleaned_field+ '/' + key)
if len(cleaned_field) > 0:
cleaned_fields.append(cleaned_field + '/' + key)
else:
cleaned_fields.append(key)
else:
cleaned_fields.append(cleaned_field)

Expand Down
17 changes: 15 additions & 2 deletions generic_config_updater/gcu_field_operation_validators.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"helper_data": {
"rdma_config_update_validator": {
"mellanox_asics": {
"spc1": [ "ACS-MSN2700", "ACS-MSN2740", "ACS-MSN2100", "ACS-MSN2410", "ACS-MSN2010", "Mellanox-SN2700", "Mellanox-SN2700-D48C8" ]
"spc1": [ "ACS-MSN2700", "ACS-MSN2740", "ACS-MSN2100", "ACS-MSN2410", "ACS-MSN2010", "Mellanox-SN2700", "Mellanox-SN2700-D48C8" ],
"spc2": [ "ACS-MSN3800", "Mellanox-SN3800-D112C8" ],
"spc3": [ "ACS-MSN4700", "ACS-MSN4600", "ACS-MSN4600C", "ACS-MSN4410", "Mellanox-SN4600C-D112C8", "Mellanox-SN4600C-C64" ]
},
"broadcom_asics": {
"th": [ "Force10-S6100", "Arista-7060CX-32S-C32", "Arista-7060CX-32S-C32-T1", "Arista-7060CX-32S-D48C8", "Celestica-DX010-C32", "Seastone-DX010" ],
Expand All @@ -37,11 +39,14 @@
"restoration_time",
"detection_time",
"action",
"global/poll_interval"
"global/poll_interval",
""
],
"operations": ["remove", "add", "replace"],
"platforms": {
"spc1": "20181100",
"spc2": "20191100",
"spc3": "20220500",
"td2": "20181100",
"th": "20181100",
"th2": "20181100",
Expand All @@ -65,6 +70,8 @@
"operations": ["replace"],
"platforms": {
"spc1": "20191100",
"spc2": "20191100",
"spc3": "20220500",
"td2": "",
"th": "20221100",
"th2": "20221100",
Expand All @@ -86,6 +93,8 @@
"operations": ["replace"],
"platforms": {
"spc1": "20181100",
"spc2": "20191100",
"spc3": "20220500",
"td2": "20181100",
"th": "20181100",
"th2": "20181100",
Expand All @@ -100,6 +109,8 @@
"operations": ["replace"],
"platforms": {
"spc1": "20191100",
"spc2": "20191100",
"spc3": "20220500",
"td2": "",
"th": "20221100",
"th2": "20221100",
Expand All @@ -123,6 +134,8 @@
"operations": ["replace"],
"platforms": {
"spc1": "20181100",
isabelmsft marked this conversation as resolved.
Show resolved Hide resolved
"spc2": "20191100",
"spc3": "20220500",
"td2": "20181100",
"th": "20181100",
"th2": "20181100",
Expand Down
34 changes: 33 additions & 1 deletion tests/generic_config_updater/field_operation_validator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,26 @@ def test_rdma_config_update_validator_td3_asic_invalid_version(self):
@patch("generic_config_updater.field_operation_validators.get_asic_name", mock.Mock(return_value="spc1"))
@patch("os.path.exists", mock.Mock(return_value=True))
@patch("builtins.open", mock_open(read_data='{"tables": {"PFC_WD": {"validator_data": {"rdma_config_update_validator": {"PFCWD enable/disable": {"fields": ["detection_time", "action"], "operations": ["remove", "replace", "add"], "platforms": {"spc1": "20181100"}}}}}}}'))
def test_rdma_config_update_validator_spc_asic_valid_version(self):
def test_rdma_config_update_validator_spc_asic_valid_version_remove(self):
patch_element = {"path": "/PFC_WD/Ethernet8/detection_time", "op": "remove"}
assert generic_config_updater.field_operation_validators.rdma_config_update_validator(patch_element) == True

@patch("sonic_py_common.device_info.get_sonic_version_info", mock.Mock(return_value={"build_version": "SONiC.20220530"}))
@patch("generic_config_updater.field_operation_validators.get_asic_name", mock.Mock(return_value="spc1"))
@patch("os.path.exists", mock.Mock(return_value=True))
@patch("builtins.open", mock_open(read_data='{"tables": {"PFC_WD": {"validator_data": {"rdma_config_update_validator": {"PFCWD enable/disable": {"fields": ["detection_time", "restoration_time", "action"], "operations": ["remove", "replace", "add"], "platforms": {"spc1": "20181100"}}}}}}}'))
def test_rdma_config_update_validator_spc_asic_valid_version_add_pfcwd(self):
patch_element = {"path": "/PFC_WD/Ethernet8", "op": "add", "value": {"action": "drop", "detection_time": "300", "restoration_time": "200"}}
assert generic_config_updater.field_operation_validators.rdma_config_update_validator(patch_element) == True

@patch("sonic_py_common.device_info.get_sonic_version_info", mock.Mock(return_value={"build_version": "SONiC.20220530"}))
@patch("generic_config_updater.field_operation_validators.get_asic_name", mock.Mock(return_value="spc1"))
@patch("os.path.exists", mock.Mock(return_value=True))
@patch("builtins.open", mock_open(read_data='{"tables": {"PFC_WD": {"validator_data": {"rdma_config_update_validator": {"PFCWD enable/disable": {"fields": ["detection_time", "action", ""], "operations": ["remove", "replace", "add"], "platforms": {"spc1": "20181100"}}}}}}}'))
def test_rdma_config_update_validator_spc_asic_valid_version(self):
patch_element = {"path": "/PFC_WD/Ethernet8", "op": "remove"}
assert generic_config_updater.field_operation_validators.rdma_config_update_validator(patch_element) == True

@patch("sonic_py_common.device_info.get_sonic_version_info", mock.Mock(return_value={"build_version": "SONiC.20220530"}))
@patch("generic_config_updater.field_operation_validators.get_asic_name", mock.Mock(return_value="spc1"))
@patch("os.path.exists", mock.Mock(return_value=True))
Expand Down Expand Up @@ -103,6 +119,22 @@ def test_get_asic_spc1(self, mock_popen, mock_get_sonic_version_info):
mock_popen.return_value.communicate.return_value = ["Mellanox-SN2700-D48C8", 0]
self.assertEqual(fov.get_asic_name(), "spc1")

@patch('sonic_py_common.device_info.get_sonic_version_info')
@patch('subprocess.Popen')
def test_get_asic_spc2(self, mock_popen, mock_get_sonic_version_info):
mock_get_sonic_version_info.return_value = {'asic_type': 'mellanox'}
mock_popen.return_value = mock.Mock()
mock_popen.return_value.communicate.return_value = ["ACS-MSN3800", 0]
self.assertEqual(fov.get_asic_name(), "spc2")

@patch('sonic_py_common.device_info.get_sonic_version_info')
@patch('subprocess.Popen')
def test_get_asic_spc3(self, mock_popen, mock_get_sonic_version_info):
mock_get_sonic_version_info.return_value = {'asic_type': 'mellanox'}
mock_popen.return_value = mock.Mock()
mock_popen.return_value.communicate.return_value = ["Mellanox-SN4600C-C64", 0]
self.assertEqual(fov.get_asic_name(), "spc3")

@patch('sonic_py_common.device_info.get_sonic_version_info')
@patch('subprocess.Popen')
def test_get_asic_th(self, mock_popen, mock_get_sonic_version_info):
Expand Down