[Home]

Summary:ASTERISK-28276: TESTTIME feature not working
Reporter:granjerox (granjerox)Labels:
Date Opened:2019-02-07 06:17:19.000-0600Date Closed:2019-03-12 08:10:10
Priority:MajorRegression?
Status:Closed/CompleteComponents:PBX/General
Versions:13.22.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Ubuntu LinuxAttachments:
Description:Can't get iftime nor gotoiftime to use a diferent datetime than systemtime.

{code}
Asterisk version
iospbx004*CLI> core show version
Asterisk 13.22.0 built by root @ iospbx004 on a x86_64 running Linux on 2018-08-10 10:22:19 UTC
{code}

*DIALPLAN*
{code}
[test]
exten => s,1,NoOp(Time is ${STRFTIME()} - TESTTIME IS ${TESTTIME})
   same => n,NoOp(Test IFTIME DEC ${IFTIME(*,*,*,dec?ok:nok)})
   same => n,GotoIfTime(*,*,*,dec?decok:decnok)
       same => n(decok),NoOp(GotoIftime DEC - OK)
       same => n,Goto(feb)
       same => n(decnok),NoOp(GotoIftime DEC - NOK)

   same => n(feb),NoOp(Test IFTIME FEB ${IFTIME(*,*,*,feb?ok:nook)})
   same => n,GotoIfTime(*,*,*,feb?febok:febnook)
       same => n(febok),NoOp(GotoIftime FEB - OK)
       same => n,Goto(end)
       same => n(febnook),NoOp(GotoIftime FEB - NOK)
   same => n(end),Hangup

exten => Test1,1,NoOp(Time is ${STRFTIME()}")
   same => n,Set(__TESTTIME=2018-12-30 18:00:00 Europe/Madrid)
   same => n,Goto(s,1)
exten => Test2,1,NoOp(Time is ${STRFTIME()}")
   same => n,Set(__TESTTIME=2018-12-30,18:00:00,Europe/Madrid)
   same => n,Goto(s,1)
exten => Test3,1,NoOp(Time is ${STRFTIME()}")
   same => n,Set(TESTTIME(2018-12-30,18:00:00,Europe/Madrid)=TestTime)
   same => n,Goto(s,1)
exten => Test4,1,NoOp(Time is ${STRFTIME()}")
   same => n,Set(TESTTIME()=2018-12-30,18:00:00,Europe/Madrid)
   same => n,Goto(s,1)
{code}
*test 0: not using testtime - Expected consistent with real*
* Expected Result:
** IFTIME DEC nok
** GotoIftime DEC nok
** IFTIME FEB ok
** GotoIftime FEB ok

* Obtained Result:
** IFTIME DEC nok
** GotoIftime DEC nok
** IFTIME FEB ok
** GotoIftime FEB ok

{code}
iospbx004*CLI> originate local/s@test application wait 5
   -- Called s@test
   -- Executing [s@test:1] NoOp("Local/s@test-00000035;2", "Time is Thu Feb  7 12:53:34 2019 - TESTTIME IS ") in new stack
   -- Executing [s@test:2] NoOp("Local/s@test-00000035;2", "Test IFTIME DEC nok") in new stack
   -- Executing [s@test:3] GotoIfTime("Local/s@test-00000035;2", "*,*,*,dec?decok:decnok") in new stack
   -- Goto (test,s,6)
   -- Executing [s@test:6] NoOp("Local/s@test-00000035;2", "GotoIftime DEC - NOK") in new stack
   -- Executing [s@test:7] NoOp("Local/s@test-00000035;2", "Test IFTIME FEB ok") in new stack
   -- Executing [s@test:8] GotoIfTime("Local/s@test-00000035;2", "*,*,*,feb?febok:febnook") in new stack
   -- Goto (test,s,9)
   -- Executing [s@test:9] NoOp("Local/s@test-00000035;2", "GotoIftime FEB - OK") in new stack
   -- Executing [s@test:10] Goto("Local/s@test-00000035;2", "end") in new stack
   -- Goto (test,s,12)
   -- Executing [s@test:12] Hangup("Local/s@test-00000035;2", "") in new stack
 == Spawn extension (test, s, 12) exited non-zero on 'Local/s@test-00000035;2'
{code}

*test 1: Setting TESTTIME Variable with spaces - Expected NOT consistent with real. But modifies gotoiftime result*

* Expected Result:
** IFTIME DEC ok
** GotoIftime DEC ok
** IFTIME FEB nok
** GotoIftime FEB nok
* Obtained Result:
** IFTIME DEC nok
** GotoIftime DEC nok
** IFTIME FEB ok
** GotoIftime FEB nok

{code}
iospbx004*CLI> originate local/Test1@test application wait 5
   -- Called Test1@test
   -- Executing [Test1@test:1] NoOp("Local/Test1@test-00000036;2", "Time is Thu Feb  7 12:54:15 2019"") in new stack
   -- Executing [Test1@test:2] Set("Local/Test1@test-00000036;2", "__TESTTIME=2018-12-30 18:00:00 Europe/Madrid") in new stack
   -- Executing [Test1@test:3] Goto("Local/Test1@test-00000036;2", "s,1") in new stack
   -- Goto (test,s,1)
   -- Executing [s@test:1] NoOp("Local/Test1@test-00000036;2", "Time is Thu Feb  7 12:54:15 2019 - TESTTIME IS 2018-12-30 18:00:00 Europe/Madrid") in new stack
   -- Executing [s@test:2] NoOp("Local/Test1@test-00000036;2", "Test IFTIME DEC nok") in new stack
   -- Executing [s@test:3] GotoIfTime("Local/Test1@test-00000036;2", "*,*,*,dec?decok:decnok") in new stack
   -- Goto (test,s,6)
   -- Executing [s@test:6] NoOp("Local/Test1@test-00000036;2", "GotoIftime DEC - NOK") in new stack
   -- Executing [s@test:7] NoOp("Local/Test1@test-00000036;2", "Test IFTIME FEB ok") in new stack
   -- Executing [s@test:8] GotoIfTime("Local/Test1@test-00000036;2", "*,*,*,feb?febok:febnook") in new stack
   -- Goto (test,s,11)
   -- Executing [s@test:11] NoOp("Local/Test1@test-00000036;2", "GotoIftime FEB - NOK") in new stack
   -- Executing [s@test:12] Hangup("Local/Test1@test-00000036;2", "") in new stack
 == Spawn extension (test, s, 12) exited non-zero on 'Local/Test1@test-00000036;2'
{code}

*test 2: Setting TESTTIME Variable with comas - Expected NOT consistent with real, But modifies gotoiftime result*

* Expected Result:
** IFTIME DEC ok
** GotoIftime DEC ok
** IFTIME FEB nok
** GotoIftime FEB nok
* Obtained Result:
** IFTIME DEC nok
** GotoIftime DEC nok
** IFTIME FEB ok
** GotoIftime FEB nok

{code}
iospbx004*CLI> originate local/Test2@test application wait 5
   -- Called Test2@test
   -- Executing [Test2@test:1] NoOp("Local/Test2@test-00000037;2", "Time is Thu Feb  7 12:54:18 2019"") in new stack
   -- Executing [Test2@test:2] Set("Local/Test2@test-00000037;2", "__TESTTIME=2018-12-30,18:00:00,Europe/Madrid") in new stack
   -- Executing [Test2@test:3] Goto("Local/Test2@test-00000037;2", "s,1") in new stack
   -- Goto (test,s,1)
   -- Executing [s@test:1] NoOp("Local/Test2@test-00000037;2", "Time is Thu Feb  7 12:54:18 2019 - TESTTIME IS 2018-12-30,18:00:00,Europe/Madrid") in new stack
   -- Executing [s@test:2] NoOp("Local/Test2@test-00000037;2", "Test IFTIME DEC nok") in new stack
   -- Executing [s@test:3] GotoIfTime("Local/Test2@test-00000037;2", "*,*,*,dec?decok:decnok") in new stack
   -- Goto (test,s,6)
   -- Executing [s@test:6] NoOp("Local/Test2@test-00000037;2", "GotoIftime DEC - NOK") in new stack
   -- Executing [s@test:7] NoOp("Local/Test2@test-00000037;2", "Test IFTIME FEB ok") in new stack
   -- Executing [s@test:8] GotoIfTime("Local/Test2@test-00000037;2", "*,*,*,feb?febok:febnook") in new stack
   -- Goto (test,s,11)
   -- Executing [s@test:11] NoOp("Local/Test2@test-00000037;2", "GotoIftime FEB - NOK") in new stack
   -- Executing [s@test:12] Hangup("Local/Test2@test-00000037;2", "") in new stack
 == Spawn extension (test, s, 12) exited non-zero on 'Local/Test2@test-00000037;2'
{code}

*test 3: Setting TESTTIME function by values - Expected NOT consistent with real. Nothing seems to happen, same behabiour as test0*
* Expected Result:
** IFTIME DEC ok
** GotoIftime DEC ok
** IFTIME FEB nok
** GotoIftime FEB nok
* Obtained Result:
** IFTIME DEC nok
** GotoIftime DEC nok
** IFTIME FEB ok
** GotoIftime FEB ok

{code}
iospbx004*CLI> originate local/Test3@test application wait 5
   -- Called Test3@test
   -- Executing [Test3@test:1] NoOp("Local/Test3@test-00000038;2", "Time is Thu Feb  7 12:54:21 2019"") in new stack
   -- Executing [Test3@test:2] Set("Local/Test3@test-00000038;2", "TESTTIME(2018-12-30,18:00:00,Europe/Madrid)=TestTime") in new stack
   -- Executing [Test3@test:3] Goto("Local/Test3@test-00000038;2", "s,1") in new stack
   -- Goto (test,s,1)
   -- Executing [s@test:1] NoOp("Local/Test3@test-00000038;2", "Time is Thu Feb  7 12:54:21 2019 - TESTTIME IS ") in new stack
   -- Executing [s@test:2] NoOp("Local/Test3@test-00000038;2", "Test IFTIME DEC nok") in new stack
   -- Executing [s@test:3] GotoIfTime("Local/Test3@test-00000038;2", "*,*,*,dec?decok:decnok") in new stack
   -- Goto (test,s,6)
   -- Executing [s@test:6] NoOp("Local/Test3@test-00000038;2", "GotoIftime DEC - NOK") in new stack
   -- Executing [s@test:7] NoOp("Local/Test3@test-00000038;2", "Test IFTIME FEB ok") in new stack
   -- Executing [s@test:8] GotoIfTime("Local/Test3@test-00000038;2", "*,*,*,feb?febok:febnook") in new stack
   -- Goto (test,s,9)
   -- Executing [s@test:9] NoOp("Local/Test3@test-00000038;2", "GotoIftime FEB - OK") in new stack
   -- Executing [s@test:10] Goto("Local/Test3@test-00000038;2", "end") in new stack
   -- Goto (test,s,12)
   -- Executing [s@test:12] Hangup("Local/Test3@test-00000038;2", "") in new stack
 == Spawn extension (test, s, 12) exited non-zero on 'Local/Test3@test-00000038;2'
{code}

*test 4: Setting TESTTIME function by args - Expected NOT consistent with real Nothing seems to happen, same behabiour as test0*
* Expected Result:
** IFTIME DEC ok
** GotoIftime DEC ok
** IFTIME FEB nok
** GotoIftime FEB nok
* Obtained Result:
** IFTIME DEC nok
** GotoIftime DEC nok
** IFTIME FEB ok
** GotoIftime FEB ok

{code}
iospbx004*CLI> originate local/Test4@test application wait 5
   -- Called Test4@test
   -- Executing [Test4@test:1] NoOp("Local/Test4@test-00000039;2", "Time is Thu Feb  7 12:54:24 2019"") in new stack
   -- Executing [Test4@test:2] Set("Local/Test4@test-00000039;2", "TESTTIME()=2018-12-30,18:00:00,Europe/Madrid") in new stack
   -- Executing [Test4@test:3] Goto("Local/Test4@test-00000039;2", "s,1") in new stack
   -- Goto (test,s,1)
   -- Executing [s@test:1] NoOp("Local/Test4@test-00000039;2", "Time is Thu Feb  7 12:54:24 2019 - TESTTIME IS ") in new stack
   -- Executing [s@test:2] NoOp("Local/Test4@test-00000039;2", "Test IFTIME DEC nok") in new stack
   -- Executing [s@test:3] GotoIfTime("Local/Test4@test-00000039;2", "*,*,*,dec?decok:decnok") in new stack
   -- Goto (test,s,6)
   -- Executing [s@test:6] NoOp("Local/Test4@test-00000039;2", "GotoIftime DEC - NOK") in new stack
   -- Executing [s@test:7] NoOp("Local/Test4@test-00000039;2", "Test IFTIME FEB ok") in new stack
   -- Executing [s@test:8] GotoIfTime("Local/Test4@test-00000039;2", "*,*,*,feb?febok:febnook") in new stack
   -- Goto (test,s,9)
   -- Executing [s@test:9] NoOp("Local/Test4@test-00000039;2", "GotoIftime FEB - OK") in new stack
   -- Executing [s@test:10] Goto("Local/Test4@test-00000039;2", "end") in new stack
   -- Goto (test,s,12)
   -- Executing [s@test:12] Hangup("Local/Test4@test-00000039;2", "") in new stack
 == Spawn extension (test, s, 12) exited non-zero on 'Local/Test4@test-00000039;2'
{code}
Comments:By: Asterisk Team (asteriskteam) 2019-02-07 06:17:20.535-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: George Joseph (gjoseph) 2019-02-07 09:33:08.249-0600

Did this work in an earlier release of Asterisk?  If so, which release was the latest it worked?


By: granjerox (granjerox) 2019-02-08 00:30:19.825-0600

No, as far as I know. I've tried this without luck from time to time, and always thought it was a syntax error. I've alwais been in Asterisk 13.x

By: Chris Savinovich (csavinovich) 2019-02-15 16:46:29.113-0600

Hello granjerox, thanks for reporting this issue.  After reviewing the code I can let you know you are not using the TESTTIME() function the way it is intended to.  The documentation on the function certainly could be better and I will be making the necessary changes in the documentation to explain its usage in a more clear manner.

{noformat}
It works like this:
1.The function TESTTIME() works by filling up channel variable ${TESTTIME} with the desired date.
2. The value saved on channel variable ${TESTTIME} after successfully invoking function TESTTIME() will be a long integer
corresponding to a date value. To display it in readable format it will be necessary to use function STRFTIME(), like this:

same => n,NoOp(${STRFTIME(${TESTTIME},GMT-6)})

3. function IFTIME() *does not*  use the time value saved on ${TESTTIME} Only current date.

4. function GoToIfTime() *does* use the time valued saved on ${TESTTIME} and will use it
provided the value is valid (not null), otherwise it will use the system's value.

SAMPLE CODE:
exten => Test5,1,NoOp(Today's date is ${STRFTIME()}")
   same => n,Set(TESTTIME()=2018/10/30 18:00:00 Europe/Madrid)
   same => n,NoOp(--->TESTIME=${STRFTIME(${TESTTIME})})

   same => n,GotoIfTime(*,*,*,dec?decok:decnok)

   same => n(decok),NoOp(---->IT IS DECEMBER-OK)
   same => n,Goto(goodbye)
   same => n(decnok),NoOp(---->IT IS NOT DECEMBER-NOK)
   same => n,Goto(goodbye)

   same => n(goodbye),Hangup()

{noformat}

Thank you. I am closing this issue, should you find it still doesn't work as desired please reopen.


By: Chris Savinovich (csavinovich) 2019-02-15 17:01:24.881-0600

Solution entered in previous comment

By: granjerox (granjerox) 2019-03-12 04:44:23.435-0500

Thanks Chris, solution tested and working fine. I think that was one of the few constructions that i didn' try in my tests. I guess it would be great that IFTIME could use also TESTIME.

By: Asterisk Team (asteriskteam) 2019-03-12 04:44:24.193-0500

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.