Fix session duplication (#354)

TODO: bad session count with IP
environments/ppa-mbqj77/deployments/1
Xavier Guimard 8 years ago
parent 1c76c713e7
commit 122d9157cc
  1. 27
      e2e-tests/populate.pl
  2. 8
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm
  3. 11
      lemonldap-ng-manager/site/coffee/sessions.coffee
  4. 11
      lemonldap-ng-manager/site/htdocs/static/js/sessions.js
  5. 2
      lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js

@ -11,12 +11,15 @@ has id => ( is => 'rw' );
package main;
use Test::More;
use strict;
use POSIX qw(mktime strftime);
use lib 'lemonldap-ng-common/blib/lib';
use lib 'lemonldap-ng-handler/blib/lib';
use lib 'lemonldap-ng-portal/blib/lib';
use lib 'lemonldap-ng-manager/blib/lib';
require './lemonldap-ng-portal/t/test-lib.pm';
use constant COUNT => 1000;
my $portal = LLNG::Manager::Test->new(
{
ini => {
@ -30,17 +33,29 @@ my $portal = LLNG::Manager::Test->new(
)->p;
my @chars = ( "A" .. "Z", "a" .. "z" );
foreach my $i ( 1 .. 100000 ) {
foreach my $i ( 1 .. COUNT() ) {
my $string;
$string .= $chars[ rand @chars ] for 1 .. 8;
#$string = 'dwho';
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
localtime(time);
$hour = int( rand($hour) );
$min = int( rand(60) );
$sec = int( rand(60) );
my $req = Test::Request->new(
{
sessionInfo => {
_user => $string,
uid => $string,
cn => uc($string),
sn => $string,
mail => "$string\@badwolf.org",
_user => $string,
uid => $string,
cn => uc($string),
sn => $string,
mail => "$string\@badwolf.org",
_utime => mktime( $sec, $min, $hour, $mday, $mon, $year ),
startTime => strftime(
"%Y%m%d%H%M%S",
$sec, $min, $hour, $mday, $mon,
$year, $wday, $yday, $isdst
),
}
}
);

@ -99,6 +99,11 @@ sub sessions {
: ( $s => $params->{$_} );
} keys %$params;
$filters{_session_kind} = $type;
push @fields, keys(%filters);
{
my %seen;
@fields = grep { !$seen{$_}++ } @fields;
}
# Check if a '*' is required
my $function = 'searchOn';
@ -112,6 +117,8 @@ sub sessions {
: $b eq '_session_kind' ? -1
: $a cmp $b
} keys %filters;
$self->logger->debug(
"First filter: $firstFilter = $filters{$firstFilter} ($function)");
$res =
Lemonldap::NG::Common::Apache::Session->$function( $moduleOptions,
$firstFilter, $filters{$firstFilter}, @fields );
@ -128,6 +135,7 @@ sub sessions {
delete $filters{$firstFilter};
foreach my $k ( keys %filters ) {
$self->logger->debug("Removing unless $k =~ /^$filters{$k}\$/");
$filters{$k} =~ s/\*/\.\*/g;
foreach my $session ( keys %$res ) {
if ( $res->{$session}->{$k} ) {

@ -18,7 +18,7 @@ schemes =
]
ipAddr: [
(t,v) ->
"#{t}=#{v}*&groupBy=net4(#{t},1)"
"groupBy=net4(#{t},1)"
(t,v) ->
"#{t}=#{v}*&groupBy=net4(#{t},2)"
(t,v) ->
@ -34,14 +34,17 @@ schemes =
(t,v) ->
"groupBy=substr(#{t},8)"
(t,v) ->
"groupBy=substr(#{t},10)"
"#{t}=#{v}*&groupBy=substr(#{t},10)"
(t,v) ->
"groupBy=substr(#{t},11)"
"#{t}=#{v}*&groupBy=substr(#{t},11)"
(t,v) ->
"groupBy=substr(#{t},12)"
"#{t}=#{v}*&groupBy=substr(#{t},12)"
(t,v) ->
"#{t}=#{v}*&groupBy=_whatToTrace"
(t,v,q) ->
console.log t
console.log v
console.log q
q.replace(/\&groupBy.*$/, '') + "&_whatToTrace=#{v}"
]
doubleIp: [

@ -21,7 +21,7 @@
],
ipAddr: [
function(t, v) {
return t + "=" + v + "*&groupBy=net4(" + t + ",1)";
return "groupBy=net4(" + t + ",1)";
}, function(t, v) {
return t + "=" + v + "*&groupBy=net4(" + t + ",2)";
}, function(t, v) {
@ -38,14 +38,17 @@
function(t, v) {
return "groupBy=substr(" + t + ",8)";
}, function(t, v) {
return "groupBy=substr(" + t + ",10)";
return t + "=" + v + "*&groupBy=substr(" + t + ",10)";
}, function(t, v) {
return "groupBy=substr(" + t + ",11)";
return t + "=" + v + "*&groupBy=substr(" + t + ",11)";
}, function(t, v) {
return "groupBy=substr(" + t + ",12)";
return t + "=" + v + "*&groupBy=substr(" + t + ",12)";
}, function(t, v) {
return t + "=" + v + "*&groupBy=_whatToTrace";
}, function(t, v, q) {
console.log(t);
console.log(v);
console.log(q);
return q.replace(/\&groupBy.*$/, '') + ("&_whatToTrace=" + v);
}
],

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save