Verify eSEL using REST

Add test to create eSEL using ipmi command and verify the eSEL logged
using REST. As a part of the test setup, logging service is restarted
to clear prior logged eSEL's.

Unfortunately the ipmitool needs to be on the BMC to test this.
Adding to skip list files to avoid failure in CT runs.

Resolves openbmc/openbmc-test-automation#364

Change-Id: I5ce0129a29797a93c6e4216b2531bb4677d02781
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index 55eb8c0..48cadda 100644
--- a/data/variables.py
+++ b/data/variables.py
@@ -35,6 +35,10 @@
 HOST_STATE_URI = '/xyz/openbmc_project/state/host0/'
 CHASSIS_STATE_URI = '/xyz/openbmc_project/state/chassis0/'
 
+# Logging URI variables
+BMC_LOGGING_URI = '/xyz/openbmc_project/Logging/'
+BMC_LOGGING_ENTRY = BMC_LOGGING_URI + 'Entry/'
+
 '''
   QEMU HTTPS variable:
 
diff --git a/test_lists/skip_test b/test_lists/skip_test
index c510a93..6e3574a 100644
--- a/test_lists/skip_test
+++ b/test_lists/skip_test
@@ -52,3 +52,5 @@
 -e Check_BMC_Name_Property_Is_Set
 -e Check_BMC_Clocks_Name_Property_Is_Set
 -e Check_BMC_Clocks_Compatible_Property_Is_Set
+#openbmc/openbmc-test-automation/issues/75
+-e eSEL_Logging
diff --git a/test_lists/skip_test_palmetto b/test_lists/skip_test_palmetto
index 7ceadf5..78859bd 100644
--- a/test_lists/skip_test_palmetto
+++ b/test_lists/skip_test_palmetto
@@ -56,3 +56,5 @@
 -e Set_BMC_Time_With_Split_And_Manual
 #https://github.com/openbmc/openbmc/issues/1142
 -e Check_BMC_Name_Property_Is_Set
+#openbmc/openbmc-test-automation/issues/75
+-e eSEL_Logging
diff --git a/test_lists/skip_test_witherspoon b/test_lists/skip_test_witherspoon
index 81c9d33..7e05a37 100644
--- a/test_lists/skip_test_witherspoon
+++ b/test_lists/skip_test_witherspoon
@@ -59,3 +59,5 @@
 -e Check_BMC_Name_Property_Is_Set
 -e Check_BMC_Clocks_Name_Property_Is_Set
 -e Check_BMC_Clocks_Compatible_Property_Is_Set
+#openbmc/openbmc-test-automation/issues/75
+-e eSEL_Logging
diff --git a/tests/test_esel.robot b/tests/test_esel.robot
index c45e29c..ed0fdc4 100644
--- a/tests/test_esel.robot
+++ b/tests/test_esel.robot
@@ -1,16 +1,53 @@
 *** Settings ***
 
-Documentation   This suite is for testing esel's mechanism of checking Reservation_ID.
+Documentation       eSEL's Test cases.
 
-Resource          ../lib/ipmi_client.robot
-Resource          ../lib/openbmc_ffdc.robot
+Resource            ../lib/ipmi_client.robot
+Resource            ../lib/openbmc_ffdc.robot
+Variables           ../data/variables.py
 
-Suite Setup            Open Connection And Log In
-Suite Teardown         Close All Connections
-Test Teardown          FFDC On Test Case Fail
+Suite Setup         Open Connection And Log In
+Suite Teardown      Close All Connections
+Test Teardown       FFDC On Test Case Fail
+
+Force Tags  eSEL_Logging
+
+*** Variables ***
+
+${RESERVE_ID}       raw 0x0a 0x42
+${RAW_PREFIX}       raw 0x32 0xf0 0x
+
+${RAW_SUFFIX}       0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00
+...  0xdf 0x00 0x00 0x00 0x00 0x20 0x00 0x04 0x12 0x35 0x6f 0xaa 0x00 0x00
+
+${RAW_SEL_COMMIT}   raw 0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x20
+...  0x00 0x04 0x12 0x35 0x6f 0x02 0x00 0x01
+
+${LOGGING_SERVICE}  xyz.openbmc_project.Logging.service
 
 *** Test Cases ***
 
+Verify eSEL Using REST
+    [Documentation]  Generate eSEL log and Verify using REST.
+    [setup]  Restart Logging Service
+    [Tags]  Verify_eSEL_Using_REST
+
+    # Prior eSEL log shouldn't exist
+    ${resp}=   OpenBMC Get Request  ${BMC_LOGGING_ENTRY}${1}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
+
+    Open Connection And Log In
+    ${Resv_id}=  Run Dbus IPMI Standard Command  ${RESERVE_ID}
+    ${cmd}=  Catenate
+    ...  ${RAW_PREFIX}${Resv_id.strip().rsplit(' ', 1)[0]}  ${RAW_SUFFIX}
+    Run Dbus IPMI Standard Command  ${cmd}
+    Run Dbus IPMI Standard Command  ${RAW_SEL_COMMIT}
+
+    # New eSEL log should exist
+    ${resp}=   OpenBMC Get Request  ${BMC_LOGGING_ENTRY}${1}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+
+
 Test Wrong Reservation_ID
     [Documentation]   This testcase is to test BMC can handle multi-requestor's
     ...               oem partial add command with incorrect reservation id.
@@ -48,6 +85,14 @@
 
 *** Keywords ***
 
+Restart Logging Service
+    [Documentation]  Restart Logging to clear eSEL log.
+    ${MainPID}  ${stderr}=  Execute Command
+    ...  systemctl restart ${LOGGING_SERVICE}  return_stderr=True
+    Should Be Empty  ${stderr}
+
+    Sleep  10s  reason=Wait for service to restart properly.
+
 Run IPMI Command Returned
     [Arguments]    ${args}
     ${output_1}=    Execute Command    /tmp/ipmitool -I dbus raw ${args}