Support to generate error, collect SNMP trap and verify SNMP trap

Changes:
    Added to keyword to generate error and collect trap.
    Added keyword to verify trap contents.
    Added test cases to configure SNMP manager with different ports.

Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
Change-Id: I3286835f26d7a3a693e6b557250c8181277d226b
diff --git a/redfish/events/test_bmc_snmp_trap.robot b/redfish/events/test_bmc_snmp_trap.robot
index 6946b80..7587371 100644
--- a/redfish/events/test_bmc_snmp_trap.robot
+++ b/redfish/events/test_bmc_snmp_trap.robot
@@ -22,6 +22,23 @@
 ${snmp_version}      SNMPv2c
 ${subscription_uri}  /redfish/v1/EventService/Subscriptions
 
+${CMD_INTERNAL_FAILURE}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
+...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
+...  xyz.openbmc_project.Logging.Entry.Level.Error 0
+
+${CMD_FRU_CALLOUT}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
+...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.Timeout
+...  xyz.openbmc_project.Logging.Entry.Level.Error 2 "TIMEOUT_IN_MSEC" "5"
+...  "CALLOUT_INVENTORY_PATH" "/xyz/openbmc_project/inventory/system/chassis/motherboard"
+
+${CMD_INFORMATIONAL_ERROR}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
+...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.TestError2
+...  xyz.openbmc_project.Logging.Entry.Level.Informational 0
+
+${SNMP_TRAP_BMC_INTERNAL_FAILURE}  xyz.openbmc_project.Common.Error.InternalFailure
+${SNMP_TRAP_BMC_CALLOUT_ERROR}  xyz.openbmc_project.Common.Error.Timeout
+${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}  xyz.openbmc_project.Common.Error.TestError2
+
 
 *** Test Cases ***
 
@@ -35,6 +52,47 @@
     Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
 
 
+Configure SNMP Manager On BMC With Non-default Port And Verify
+    [Documentation]  Configure SNMP Manager On BMC And Verify.
+    [Tags]  Configure_SNMP_Manager_On_BMC_With_Non_Default_Port_And_Verify
+    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
+
+    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}  ${HTTP_CREATED}
+
+    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
+
+
+Configure SNMP Manager On BMC With Out Of Range Port And Verify
+    [Documentation]  Configure SNMP Manager On BMC with out-of range port and verify.
+    [Tags]  Configure_SNMP_Manager_On_BMC_With_Out_Of_Range_Port_And_Verify
+    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${out_of_range_port}
+
+    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${out_of_range_port}  ${HTTP_BAD_REQUEST}
+
+    ${status}=  Run Keyword And Return Status
+    ...  Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${out_of_range_port}
+
+    Should Be Equal As Strings  ${status}  False
+    ...  msg=BMC is allowing to configure out of range port.
+
+
+Generate Error On BMC And Verify SNMP Trap
+    [Documentation]  Generate error on BMC and verify trap and its fields.
+    [Tags]  Generate_Error_On_BMC_And_Verify_SNMP_Trap
+    [Template]  Create Error On BMC And Verify Trap
+
+    # event_log                 expected_error
+
+    # Generate internal failure error.
+    ${CMD_INTERNAL_FAILURE}     ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
+
+    # Generate timeout error.
+    ${CMD_FRU_CALLOUT}          ${SNMP_TRAP_BMC_CALLOUT_ERROR}
+
+    # Generate informational error.
+    ${CMD_INFORMATIONAL_ERROR}  ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}
+
+
 *** Keywords ***
 
 Suite Setup Execution