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

Message Forwarding Configuration Support for TIMs #59

Merged
merged 6 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 21 additions & 2 deletions services/common/rsufwdsnmpset.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ def config_del(rsu_ip, snmp_version, snmp_creds, msg_type, rsu_index):
snmp_mods += "NTCIP1218-v01:rsuReceivedMsgStatus.{index} i 6 ".format(
index=rsu_index
)
if msg_type.lower() == "tim":
snmp_mods += "NTCIP1218-v01:rsuXmitMsgFwdingStatus.{index} i 6 ".format(
index=rsu_index
)

# Perform configurations
logging.info(f'Running SNMPSET deletion "{snmp_mods}"')
Expand Down Expand Up @@ -480,9 +484,20 @@ def config_init(
"E0000016",
raw=True,
)
if msg_type.lower() == "tim":
return config_rsudsrcfwd(
rsu_ip,
manufacturer,
snmp_creds,
dest_ip,
"47900",
index,
"8003",
raw=True
)
else:
return (
"Supported message type is currently only BSM, SPaT, MAP, SSM and SRM",
"Supported message type is currently only BSM, SPaT, MAP, SSM, SRM and TIM",
501,
)
elif snmp_version == "1218":
Expand All @@ -507,9 +522,13 @@ def config_init(
return config_txrxmsg(
rsu_ip, snmp_creds, dest_ip, "44930", index, "E0000016", False
)
if msg_type.lower() == "tim":
return config_txrxmsg(
rsu_ip, snmp_creds, dest_ip, "47900", index, "8003", False
)
else:
return (
"Supported message type is currently only BSM, SPaT, MAP, SSM and SRM",
"Supported message type is currently only BSM, SPaT, MAP, SSM, SRM and TIM",
501,
)
else:
Expand Down
56 changes: 54 additions & 2 deletions services/common/tests/test_rsufwdsnmpset.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,33 @@ def test_config_del_ntcip1218_srm(mock_subprocess_run, mock_set_rsu_status):
assert result == ("Successfully deleted the NTCIP 1218 SNMPSET configuration", 200)


@patch("common.rsufwdsnmpset.set_rsu_status")
@patch("common.rsufwdsnmpset.subprocess.run")
def test_config_del_ntcip1218_tim(mock_subprocess_run, mock_set_rsu_status):
# mock
mock_subprocess_run.return_value = Mock()
mock_subprocess_run.return_value.stdout = Mock()
mock_subprocess_run.return_value.stdout.decode.return_value = "test_output"
mock_set_rsu_status.return_value = "success"

# call
snmp_version = "1218"
msg_type = "tim"
result = rsufwdsnmpset.config_del(
rsu_ip, snmp_version, snmp_creds, msg_type, rsu_index
)

# check
mock_set_rsu_status.assert_not_called()
mock_subprocess_run.assert_called_once_with(
"snmpset -v 3 -u test_username -a SHA -A test_password -x AES -X test_password -l authpriv 192.168.0.20 NTCIP1218-v01:rsuXmitMsgFwdingStatus.1 i 6 ",
shell=True,
capture_output=True,
check=True,
)
assert result == ("Successfully deleted the NTCIP 1218 SNMPSET configuration", 200)


@patch("common.rsufwdsnmpset.set_rsu_status")
def test_config_del_unsupported_snmp_version(mock_set_rsu_status):
# prepare args
Expand Down Expand Up @@ -486,6 +513,31 @@ def test_config_init_commsignia_srm(mock_config_msgfwd_yunex, mock_config_msgfwd
mock_config_msgfwd_yunex.assert_not_called()


@patch("common.rsufwdsnmpset.config_rsudsrcfwd")
@patch("common.rsufwdsnmpset.config_txrxmsg")
def test_config_init_commsignia_tim(mock_config_msgfwd_yunex, mock_config_msgfwd):
mock_config_msgfwd.return_value = "success"
snmp_version = "41"
manufacturer = "Commsignia"
msg_type = "TIM"
result = rsufwdsnmpset.config_init(
rsu_ip, manufacturer, snmp_version, snmp_creds, dest_ip, msg_type, rsu_index
)
expected_result = "success"
assert result == expected_result
mock_config_msgfwd.assert_called_once_with(
rsu_ip,
manufacturer,
snmp_creds,
dest_ip,
"47900",
rsu_index,
"8003",
raw=True,
)
mock_config_msgfwd_yunex.assert_not_called()


@patch("common.rsufwdsnmpset.config_rsudsrcfwd")
@patch("common.rsufwdsnmpset.config_txrxmsg")
def test_config_init_unsupported_msg_type_rsu41(
Expand All @@ -498,7 +550,7 @@ def test_config_init_unsupported_msg_type_rsu41(
rsu_ip, manufacturer, snmp_version, snmp_creds, dest_ip, msg_type, rsu_index
)
expected_result = (
"Supported message type is currently only BSM, SPaT, MAP, SSM and SRM",
"Supported message type is currently only BSM, SPaT, MAP, SSM, SRM and TIM",
501,
)
assert result == expected_result
Expand All @@ -518,7 +570,7 @@ def test_config_init_unsupported_msg_type_ntcip1218(
rsu_ip, manufacturer, snmp_version, snmp_creds, dest_ip, msg_type, rsu_index
)
expected_result = (
"Supported message type is currently only BSM, SPaT, MAP, SSM and SRM",
"Supported message type is currently only BSM, SPaT, MAP, SSM, SRM and TIM",
501,
)
assert result == expected_result
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/SnmpsetMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const SnmpsetMenu = (props: SnmpsetMenu) => {
<option value="map">MAP</option>
<option value="srm">SRM</option>
<option value="ssm">SSM</option>
<option value="tim">TIM</option>
</select>
</label>
</form>
Expand Down
5 changes: 5 additions & 0 deletions webapp/src/components/__snapshots__/SnmpsetMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ exports[`should take a snapshot 1`] = `
>
SSM
</option>
<option
value="tim"
>
TIM
</option>
</select>
</label>
</form>
Expand Down
Loading