VOL-2610 Update alarm sim tests to voltha api v3;
Validate raised_ts and reported_ts;
Update to reflect dying gasp changes in patch 17479

Change-Id: I05dba9850545c72278408d2e312aecd08f99c2fc
diff --git a/docker/Dockerfile.voltctl b/docker/Dockerfile.voltctl
index d17711f..44aaae6 100644
--- a/docker/Dockerfile.voltctl
+++ b/docker/Dockerfile.voltctl
@@ -15,7 +15,7 @@
 FROM busybox:1.31.1-glibc
 
 RUN mkdir -p /usr/bin
-RUN wget -O - https://github.com/opencord/voltctl/releases/download/v1.0.6/voltctl-1.0.6-linux-amd64 > /usr/bin/voltctl
+RUN wget -O - https://github.com/opencord/voltctl/releases/download/v1.0.9/voltctl-1.0.9-linux-amd64 > /usr/bin/voltctl
 COPY volt.config /root/.volt/config
 RUN chmod a+x /usr/bin/voltctl && sync && voltctl completion bash >> /root/.bashrc
 CMD ["sh", "-c", "sleep infinity"]
\ No newline at end of file
diff --git a/docker/volt.config b/docker/volt.config
index 991e01e..17acf5d 100644
--- a/docker/volt.config
+++ b/docker/volt.config
@@ -14,7 +14,7 @@
 # limitations under the License.
 #
 
-apiVersion: v2
+apiVersion: v3
 server: voltha-api.voltha:55555
 kafka: voltha-kafka-0.voltha-kafka-headless.voltha:9092
 tls:
diff --git a/libraries/utils.robot b/libraries/utils.robot
index e776ed5..9143fc1 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -355,13 +355,34 @@
     Run Keyword If    ${value_1} <= ${value_2}
     ...    Fail    The value ${value_1} is not larger than ${value_2}
 
+Should Be Larger Than Or Equal To
+    [Documentation]    Verify that value_1 is >= value_2
+    [Arguments]    ${value_1}    ${value_2}
+    Run Keyword If    ${value_1} < ${value_2}
+    ...    Fail    The value ${value_1} is not larger than or equal to ${value_2}
+
 Should Be Float
     [Documentation]    Verify that value is a floating point number type
     [Arguments]    ${value}
     ${type}    Evaluate    type(${value}).__name__
     Should Be Equal    ${type}    float
 
+Should Be Newer Than Or Equal To
+    [Documentation]    Compare two RFC3339 dates
+    [Arguments]    ${value_1}    ${value_2}
+    ${unix_v1}    Parse RFC3339    ${value_1}
+    ${unix_v2}    Parse RFC3339    ${value_2}
+    Run Keyword If    ${unix_v1} < ${unix_v2}
+    ...    Fail    The value ${value_1} is not newer than or equal to ${value_2}
+
 Get Current Time
     [Documentation]    Return the current time in RFC3339 format
     ${output}=    Run    date -u +"%FT%T%:z"
     [return]     ${output}
+
+Parse RFC3339
+    [Documentation]     Parse an RFC3339 timestamp
+    [Arguments]    ${dateStr}
+    ${rc}    ${output}=    Run and Return Rc and Output     date --date="${dateStr}" "+%s"
+    Should Be Equal As Numbers    ${rc}    0
+    [return]    ${output}
diff --git a/tests/functional/Voltha_AlarmTests.robot b/tests/functional/Voltha_AlarmTests.robot
index 5a35e48..5a6cc94 100755
--- a/tests/functional/Voltha_AlarmTests.robot
+++ b/tests/functional/Voltha_AlarmTests.robot
@@ -103,20 +103,10 @@
     [Documentation]    Raise Dying Gasp Alarm and verify event received
     [Tags]    active
     ${header}    ${deviceEvent}    Raise Alarm And Get Event    DyingGasp
-    ...     ${onu_sn}    ONU_DYING_GASP_RAISE_EVENT
+    ...     ${onu_sn}    ONU_DYING_GASP_EVENT
     # Note: PON is the zero value of the subCategory field, and causes it to be not present
-    Verify Header   ${header}    Voltha.openolt.ONU_DYING_GASP\.(\\d+)    ${EMPTY}
-    Should Be Equal    ${deviceEvent}[deviceEventName]    ONU_DYING_GASP_RAISE_EVENT
-    Should Be Equal    ${deviceEvent}[resourceId]    ${parent_id}
-
-Test ClearDyingGaspAlarm
-    [Documentation]    Clear Dying Gasp Alarm and verify event received
-    [Tags]    active
-    ${header}    ${deviceEvent}    Clear Alarm And Get Event    DyingGasp
-    ...     ${onu_sn}    ONU_DYING_GASP_CLEAR_EVENT
-    # Note: PON is the zero value of the subCategory field, and causes it to be not present
-    Verify Header   ${header}    Voltha.openolt.ONU_DYING_GASP\.(\\d+)    ${EMPTY}
-    Should Be Equal    ${deviceEvent}[deviceEventName]    ONU_DYING_GASP_CLEAR_EVENT
+    Verify Header   ${header}    Voltha.openolt.ONU_DYING\.(\\d+)    ${EMPTY}
+    Should Be Equal    ${deviceEvent}[deviceEventName]    ONU_DYING_GASP_EVENT
     Should Be Equal    ${deviceEvent}[resourceId]    ${parent_id}
 
 Test RaiseLopcMissAlarm
@@ -410,6 +400,8 @@
     ${since}    Get Current Time
     Raise Alarm    ${name}    ${sn}
     ${header}    ${deviceEvent}    Get Device Event    ${deviceEventName}    ${since}
+    ${LastEventPostTimestamp}    Set Variable     ${since}
+    Set Suite Variable     ${LastEventPostTimestamp}
     [return]    ${header}    ${deviceEvent}
 
 Clear Alarm And Get Event
@@ -418,6 +410,8 @@
     ${since}    Get Current Time
     Clear Alarm    ${name}    ${sn}
     ${header}    ${deviceEvent}    Get Device Event    ${deviceEventName}    ${since}
+    ${LastEventPostTimestamp}    Set Variable     ${since}
+    Set Suite Variable     ${LastEventPostTimestamp}
     [return]    ${header}    ${deviceEvent}
 
 Raise Alarm
@@ -457,7 +451,8 @@
     Should Be Equal   ${headerSubCategory}    ${subCategory}
     Should Be Equal   ${header}[type]    DEVICE_EVENT
     Should Match Regexp    ${header}[id]    ${id}
-    # TODO Revisit when timestamp format is changed from Float to Timestamp
-    Should Be Float   ${header}[raisedTs]
-    Should Be Float   ${header}[reportedTs]
-
+    # TODO Timestamps are now RFC3339 date strings. Add Verification
+    ${reportedTs}    Set Variable    ${header}[reportedTs]
+    ${raisedTs}    Set Variable    ${header}[raisedTs]
+    Should Be Newer Than Or Equal To    ${reportedTs}    ${LastEventPostTimestamp}
+    Should Be Newer Than Or Equal To    ${raisedTs}    ${LastEventPostTimestamp}