Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smradius
smradius
Commits
2b555351
Commit
2b555351
authored
8 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
CI: Improved checking of timestamps
parent
d38c5e7f
No related branches found
No related tags found
1 merge request
!420
IMPROVED: User stats update
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
t/200-dbtests.t
+36
-4
36 additions, 4 deletions
t/200-dbtests.t
with
36 additions
and
4 deletions
t/200-dbtests.t
+
36
−
4
View file @
2b555351
...
@@ -4,6 +4,7 @@ use warnings;
...
@@ -4,6 +4,7 @@ use warnings;
use
AWITPT::
Util
;
use
AWITPT::
Util
;
use
Data::
Dumper
;
use
Data::
Dumper
;
use
Date::
Parse
;
use
POSIX
qw(:sys_wait_h)
;
use
POSIX
qw(:sys_wait_h)
;
use
Test::
Most
;
use
Test::
Most
;
use
Test::Most::
Exception
'
throw_failure
';
use
Test::Most::
Exception
'
throw_failure
';
...
@@ -262,7 +263,7 @@ if ($child = fork()) {
...
@@ -262,7 +263,7 @@ if ($child = fork()) {
'
AcctDelayTime
'
=>
'
11
',
'
AcctDelayTime
'
=>
'
11
',
'
NASIdentifier
'
=>
'
Test-NAS1
',
'
NASIdentifier
'
=>
'
Test-NAS1
',
'
AcctStatusType
'
=>
1
,
'
AcctStatusType
'
=>
1
,
'
EventTimestamp
'
=>
$session1_Timestamp_str
,
'
EventTimestamp
'
=>
sub
{
_timestampCheck
(
shift
,
$session1_Timestamp_str
)
}
,
'
FramedIPAddress
'
=>
'
10.0.1.3
',
'
FramedIPAddress
'
=>
'
10.0.1.3
',
'
AcctSessionId
'
=>
$session1_ID
,
'
AcctSessionId
'
=>
$session1_ID
,
'
NASPortId
'
=>
'
test iface name1
',
'
NASPortId
'
=>
'
test iface name1
',
...
@@ -316,7 +317,7 @@ if ($child = fork()) {
...
@@ -316,7 +317,7 @@ if ($child = fork()) {
'
AcctDelayTime
'
=>
'
11
',
'
AcctDelayTime
'
=>
'
11
',
'
NASIdentifier
'
=>
'
Test-NAS1
',
'
NASIdentifier
'
=>
'
Test-NAS1
',
'
AcctStatusType
'
=>
3
,
'
AcctStatusType
'
=>
3
,
'
EventTimestamp
'
=>
$session1_Timestamp_str
,
'
EventTimestamp
'
=>
sub
{
_timestampCheck
(
shift
,
$session1_Timestamp_str
)
}
,
'
FramedIPAddress
'
=>
'
10.0.1.3
',
'
FramedIPAddress
'
=>
'
10.0.1.3
',
'
AcctSessionId
'
=>
$session1_ID
,
'
AcctSessionId
'
=>
$session1_ID
,
'
NASPortId
'
=>
'
test iface name1
',
'
NASPortId
'
=>
'
test iface name1
',
...
@@ -371,7 +372,7 @@ if ($child = fork()) {
...
@@ -371,7 +372,7 @@ if ($child = fork()) {
'
AcctDelayTime
'
=>
'
11
',
'
AcctDelayTime
'
=>
'
11
',
'
NASIdentifier
'
=>
'
Test-NAS1
',
'
NASIdentifier
'
=>
'
Test-NAS1
',
'
AcctStatusType
'
=>
2
,
'
AcctStatusType
'
=>
2
,
'
EventTimestamp
'
=>
$session1_Timestamp_str
,
'
EventTimestamp
'
=>
sub
{
_timestampCheck
(
shift
,
$session1_Timestamp_str
)
}
,
'
FramedIPAddress
'
=>
'
10.0.1.3
',
'
FramedIPAddress
'
=>
'
10.0.1.3
',
'
AcctSessionId
'
=>
$session1_ID
,
'
AcctSessionId
'
=>
$session1_ID
,
'
NASPortId
'
=>
'
test iface name1
',
'
NASPortId
'
=>
'
test iface name1
',
...
@@ -448,7 +449,7 @@ if ($child = fork()) {
...
@@ -448,7 +449,7 @@ if ($child = fork()) {
'
AcctInputGigawords
'
=>
'
0
',
'
AcctInputGigawords
'
=>
'
0
',
'
AcctInputOctets
'
=>
'
102600046
',
'
AcctInputOctets
'
=>
'
102600046
',
'
AcctSessionTime
'
=>
'
800
',
'
AcctSessionTime
'
=>
'
800
',
'
EventTimestamp
'
=>
$session2_Timestamp_str
,
'
EventTimestamp
'
=>
sub
{
_timestampCheck
(
shift
,
$session2_Timestamp_str
)
}
,
'
FramedIPAddress
'
=>
'
10.0.1.1
',
'
FramedIPAddress
'
=>
'
10.0.1.1
',
'
AcctSessionId
'
=>
$session2_ID
,
'
AcctSessionId
'
=>
$session2_ID
,
'
NASPortId
'
=>
'
wlan1
',
'
NASPortId
'
=>
'
wlan1
',
...
@@ -569,3 +570,34 @@ sub testDBResults
...
@@ -569,3 +570,34 @@ sub testDBResults
sub
_timestampCheck
{
my
(
$testVal
,
$rightVal
)
=
@_
;
# Make sure testVal is defined
return
"
_timestampCheck: NO
\$
testVal
"
if
(
!
defined
(
$testVal
));
# Make sure $testVal_time is returned form str2time
my
$testVal_time
=
str2time
(
$testVal
,'
UTC
');
# Check if $rightVal is defined
my
$rightVal_time
;
if
(
!
defined
(
$rightVal
))
{
$rightVal_time
=
time
();
}
elsif
(
$rightVal
=~
/^\d+$/
)
{
$rightVal_time
=
$rightVal
;
}
else
{
$rightVal_time
=
str2time
(
$rightVal
,'
UTC
');
}
# Make sure rightVal_time is defined
return
"
_timestampCheck: NO
\$
rightVal_time
"
if
(
!
defined
(
$rightVal_time
));
# Grab the absolute difference
my
$diff
=
abs
(
$testVal_time
-
$rightVal_time
);
return
(
$diff
<
10
)
//
"
TIME DEVIATION:
$diff
";
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment