File:  [LON-CAPA] / loncom / build / weblayer_test / test_weblayer.pl
Revision 1.2: download - view: text, annotated - select for diffs
Wed May 8 18:47:31 2002 UTC (22 years, 2 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
only run this test for library servers

    1: #!/usr/bin/perl
    2: 
    3: =pod
    4: 
    5: =head1 NAME
    6: 
    7: test_weblayer.pl - Test the LON-CAPA web layer by coordinating simulated web transactions
    8: 
    9: =cut
   10: 
   11: # The LearningOnline Network
   12: # test_weblayer.pl - Test the web layer
   13: #
   14: # $Id: test_weblayer.pl,v 1.2 2002/05/08 18:47:31 harris41 Exp $
   15: #
   16: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   17: #
   18: # LON-CAPA is free software; you can redistribute it and/or modify
   19: # it under the terms of the GNU General Public License as published by
   20: # the Free Software Foundation; either version 2 of the License, or
   21: # (at your option) any later version.
   22: #
   23: # LON-CAPA is distributed in the hope that it will be useful,
   24: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   25: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26: # GNU General Public License for more details.
   27: #
   28: # You should have received a copy of the GNU General Public License
   29: # along with LON-CAPA; if not, write to the Free Software
   30: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   31: #
   32: # /home/httpd/html/adm/gpl.txt
   33: #
   34: # http://www.lon-capa.org/
   35: #
   36: # YEAR=2002
   37: # 3/4 Scott Harrison
   38: #
   39: ###
   40: 
   41: =pod
   42: 
   43: =head1 SYNOPSIS
   44: 
   45: B<perl test_weblayer.pl>
   46: 
   47: =head1 DESCRIPTION
   48: 
   49: This program reads in the machine's host id and domain for LON-CAPA.
   50: A password is randomly generated and a test user with a name beginning
   51: with 'ZXQTEST' is created.  A test login is run.
   52: 
   53: =cut
   54: 
   55: # ------------------------------------------------ determine host id and domain
   56: my %perlvar;
   57: open (CONFIG,"/etc/httpd/conf/access.conf") || die "Can't read access.conf";
   58: while ($configline=<CONFIG>) {
   59:     if ($configline =~ /PerlSetVar/) {
   60: 	my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);
   61:         chomp($varvalue);
   62:         $perlvar{$varname}=$varvalue;
   63:     }
   64: }
   65: close(CONFIG);
   66: if ($perlvar{'lonRole'} ne 'library') {
   67:     print(<<END);
   68: Skipping web layer test...
   69:    (lonRole is defined as $perlvar{'lonRole'}
   70:     and the web layer test only runs on library servers.)
   71: END
   72:     exit(0);
   73: }
   74: 
   75: my $hostid=$perlvar{'lonHostID'};
   76: my $domain=$perlvar{'lonDefDomain'};
   77: 
   78: print "Testing web layer, hostid=$hostid, domain=$domain\n";
   79: 
   80: # ---------------------------------------------------------- determine password
   81: srand;
   82: my @abet=('a'..'z','A'..'Z',0..9);
   83: my $passwd='';
   84: for (my $i=0;$i<11;$i++) {
   85:     $passwd.=$abet[int(rand(62))];
   86: }
   87: 
   88: # -------------------------------------------------------------- make test user
   89: open OUT, "|perl make_test_user.pl ${hostid}$$ $domain" or
   90:     (print("**** ERROR **** cannot run make_test_user.pl\n") and exit(1));
   91: print OUT $passwd;
   92: close OUT;
   93: print "**** ERROR **** problems encountered with making user\n" 
   94:     and exit(1) if $?;
   95: 
   96: # ---------------------------------------------------------------- try to login
   97: open OUT, "|perl test_login.pl" or 
   98:     (print("**** ERROR **** cannot run test_login.pl\n") and exit(1));
   99: print OUT "ZXQTEST${hostid}$$\n";
  100: print OUT "$passwd";
  101: close OUT;
  102: print "**** ERROR **** problems encountered with testing login\n"
  103:     and exit(1) if $?;
  104: 
  105: # ---------------------------------------------------------- clean up test user
  106: `rm -Rf /home/httpd/lonUsers/$domain/Z/X/Q/ZXQTEST${hostid}*`;
  107: 
  108: =pod
  109: 
  110: =head1 AUTHOR
  111: 
  112: Scott Harrison, harris41@msu.edu
  113: 
  114: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>