Elive

 view release on metacpan or  search on metacpan

t/soap-session-participants.t  view on Meta::CPAN

#!perl -T
use warnings; use strict;
use Test::More tests => 33;
use Test::Fatal;
use List::Util;

use lib '.';
use t::Elive;

use Carp; $SIG{__DIE__} = \&Carp::confess;
use version;

use Elive;
use Elive::Entity::ParticipantList;
use Elive::Entity::Session;
use Elive::Entity::User;
use Elive::Entity::Group;
use Elive::Util;

our $t = Test::More->builder;
our $class = 'Elive::Entity::Session' ;

use Pod::Usage;
use Getopt::Long qw{};

=head1 NAME

soap-session-participants.t - elm 3.x participant tests (createSession etc)

=head1 SYNOPSIS

  prove --lib -v soap-session-participants.t :: \ #<opts>
    -[no]unknowns         # include unknown users in the stress test
    -timeout=sec          # set a timeout on the soap call
    -participant_limit=n  # max no. of participants in the stress-test

=head1 BUGS AND LIMITATIONS

I've found that my LDAP (OpenLDAP 2.4.26 on openSUSE 12.1, ELM 3.5.0) server
consistantly chokes and dies if I set the participant limit too high (500+).

If you need to handle this volume of participants, alternatives include LDAP
groups or the elm 2.x L<Elive::Entity::Particpant> C<update()> method.

=cut
 
my $unknowns = 1;
my $participant_limit = $ENV{ELIVE_TEST_PARTICIPANT_LIMIT} || 250;
my $timeout_sec = $ENV{ELIVE_TEST_PARTICIPANT_TIMEOUT} || 180;

Getopt::Long::GetOptions('u|unknowns!' => \$unknowns,
			 't|timeout=i' => \$timeout_sec,
			 'p|participant_limit=i' => \$participant_limit,
    ) or pod2usage(2);

our $connection;

SKIP: {

    my %result = t::Elive->test_connection( only => 'real', timeout => $timeout_sec);
    my $auth = $result{auth};

    my $skippable = 33;

    skip ($result{reason} || 'skipping live tests', $skippable)
	unless $auth;

    my $connection_class = $result{class};
    my $connection = $connection_class->connect(@$auth);
    Elive->connection($connection);

    my $min_version = '9.5.0';
    my $min_version_num = version->new($min_version)->numify;
    my $server_details =  Elive->server_details
	or die "unable to get server details - are all services running?";

    my $server_version = $server_details->version;
    my $server_version_num = version->new($server_version)->numify;

    if ($server_version_num < $min_version_num) {
	my $reason = "Sessions not available for Elluminate Live $server_version (< $min_version)"; 
	diag "Skipping session tests: $reason";
	skip($reason, $skippable)
    }

    my $session_start = time();
    my $session_end = $session_start + 900;

    $session_start .= '000';
    $session_end .= '000';

    my $participants_deep_ref = [{user => Elive->login->userId,
				  role => 2}];

    is_deeply($class->_freeze({participants => $participants_deep_ref}),
	      {invitedGuests => '',
	       invitedModerators =>  Elive->login->userId,



( run in 2.112 seconds using v1.01-cache-2.11-cpan-2e0ccfb7a10 )