File:  [LON-CAPA] / loncom / build / weblayer_test / test_weblayer.pl
Revision 1.3: download - view: text, annotated - select for diffs
Sat May 11 21:20:15 2002 UTC (22 years, 1 month ago) by harris41
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_july, STABLE, HEAD
reading loncapa.conf (not using LONCAPA::Configuration::read_conf
because test scripts, in this case, should have low amounts of
software dependencies
BUG 129

    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.3 2002/05/11 21:20:15 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,5/8,5/11 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: open (CONFIG,"/etc/httpd/conf/loncapa.conf") || die "Can't read loncapa.conf";
   67: while ($configline=<CONFIG>) {
   68:     if ($configline =~ /^[^\#]*PerlSetVar/) {
   69: 	my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);
   70:         chomp($varvalue);
   71:         $perlvar{$varname}=$varvalue;
   72:     }
   73: }
   74: close(CONFIG);
   75: if ($perlvar{'lonRole'} ne 'library') {
   76:     print(<<END);
   77: Skipping web layer test...
   78:    (lonRole is defined as $perlvar{'lonRole'}
   79:     and the web layer test only runs on library servers.)
   80: END
   81:     exit(0);
   82: }
   83: 
   84: my $hostid=$perlvar{'lonHostID'};
   85: my $domain=$perlvar{'lonDefDomain'};
   86: 
   87: print "Testing web layer, hostid=$hostid, domain=$domain\n";
   88: 
   89: # ---------------------------------------------------------- determine password
   90: srand;
   91: my @abet=('a'..'z','A'..'Z',0..9);
   92: my $passwd='';
   93: for (my $i=0;$i<11;$i++) {
   94:     $passwd.=$abet[int(rand(62))];
   95: }
   96: 
   97: # -------------------------------------------------------------- make test user
   98: open OUT, "|perl make_test_user.pl ${hostid}$$ $domain" or
   99:     (print("**** ERROR **** cannot run make_test_user.pl\n") and exit(1));
  100: print OUT $passwd;
  101: close OUT;
  102: print "**** ERROR **** problems encountered with making user\n" 
  103:     and exit(1) if $?;
  104: 
  105: # ---------------------------------------------------------------- try to login
  106: open OUT, "|perl test_login.pl" or 
  107:     (print("**** ERROR **** cannot run test_login.pl\n") and exit(1));
  108: print OUT "ZXQTEST${hostid}$$\n";
  109: print OUT "$passwd";
  110: close OUT;
  111: print "**** ERROR **** problems encountered with testing login\n"
  112:     and exit(1) if $?;
  113: 
  114: # ---------------------------------------------------------- clean up test user
  115: `rm -Rf /home/httpd/lonUsers/$domain/Z/X/Q/ZXQTEST${hostid}*`;
  116: 
  117: =pod
  118: 
  119: =head1 AUTHOR
  120: 
  121: Scott Harrison, harris41@msu.edu
  122: 
  123: =cut

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