From 78f2f8f4bd7eb07a8183a88f9ed7d184bd580967 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 15 Jan 2002 16:30:55 +0000 Subject: [PATCH] test-suite-update-20020115 front-end script to tie together the test suite ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== remove bogus makefile ==================== stop bos bnodes before deleting --- src/tests/Makefile | 284 ---------------------------------------- src/tests/Makefile.in | 6 +- src/tests/reauth.pl | 2 +- src/tests/run-suite.pl | 236 +++++++++++++++++++++++++++++++++ src/tests/test-front.sh | 10 ++ 5 files changed, 250 insertions(+), 288 deletions(-) delete mode 100644 src/tests/Makefile create mode 100755 src/tests/run-suite.pl create mode 100755 src/tests/test-front.sh diff --git a/src/tests/Makefile b/src/tests/Makefile deleted file mode 100644 index 0ab6df332..000000000 --- a/src/tests/Makefile +++ /dev/null @@ -1,284 +0,0 @@ -# Generated automatically from Makefile.in by configure. -srcdir = . -include /usr/src/openafs/openafs/src/config/Makefile.config - -SHELL = /bin/sh - -CFLAGS = -I. -I${srcdir} ${DBG} ${OPTMZ} -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCFLAGS} -LDFLAGS=${DBG} ${OPTMZ} ${XLDFLAGS} - -SYS_LIBS = ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/util.a - -AUTH_LIBS = ${TOP_LIBDIR}/libauth.a ${SYS_LIBS} - -INT_LIBS = ${TOP_LIBDIR}/libafsint.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/util.a - -TEST_PROGRAMS = write-ro-file hello-world read-vs-mmap read-vs-mmap2 \ - mmap-and-read large-dir large-dir2 large-dir3 mountpoint \ - test-setgroups test-setpag hardlink1 hardlink2 mkdir2 \ - create-files create-symlinks create-dirs dup2-and-unlog \ - readdir-vs-lstat read-write create-remove mkdir3 \ - symlink echo-n test-parallel1 test-parallel2 create-stat \ - kill-softly kill-softer rm-rf exit-wo-close \ - mmap-vs-read mmap-vs-read2 strange-characters-c pine \ - append-over-page write-ucc utime-dir mmap-shared-write \ - rename5 rename-under-feet write-closed write-closed2 \ - truncate fchmod make-page utime-file rename6 \ - write3 still-there-p write-large afscp hardlink4 \ - intr-read asu truncate-files mmap-cat blocks-new-file \ - fsx write-rand - -TEST_OBJS = write-ro-file.o read-vs-mmap.o read-vs-mmap2.o \ - mmap-and-read.o large-dir.o large-dir2.o large-dir3.o \ - test-setgroups.o test-setpag.o hardlink1.o hardlink2.o \ - mkdir2.o create-files.o create-symlinks.o create-dirs.o \ - dup2-and-unlog.o readdir-vs-lstat.o read-write.o \ - create-remove.o symlink.o echo-n.o test-parallel1.o \ - test-parallel1.o mkdir3.o rename6.o \ - create-stat.o kill-softly.o kill-softer.o rm-rf.o \ - exit-wo-close.o mmap-vs-read.o mmap-vs-read2.o \ - strange-characters-c.o pine.o append-over-page.o \ - write-ucc.o utime-dir.o mmap-shared-write.o rename5.o \ - rename-under-feet.o write-closed.o write-closed2.o \ - truncate.o fchmod.o make-page.o utime-file.o \ - write3.o still-there-p.o write-large.o hardlink4.o \ - intr-read.o asu.o truncate-files.o mmap-cat.o \ - blocks-new-file.o fsx.o afscp.o afscp_callback.o \ - write-rand.o - -TEST_SRCS = write-ro-file.c read-vs-mmap.c read-vs-mmap2.c \ - mmap-and-read.c large-dir.c large-dir2.c large-dir3.c \ - test-setgroups.c test-setpag.c hardlink1.c hardlink2.c \ - mkdir2.c create-files.c create-symlinks.c create-dirs.c \ - dup2-and-unlog.c readdir-vs-lstat.c read-write.c \ - create-remove.c symlink.c echo-n.c test-parallel1.c \ - test-parallel2.c mkdir3.c rename6.c \ - create-stat.c kill-softly.c kill-softer.c rm-rf.c \ - exit-wo-close.c mmap-vs-read.c mmap-vs-read2.c \ - strange-characters-c.c pine.c append-over-page.c \ - write-ucc.c utime-dir.c mmap-shared-write.c rename5.c \ - rename-under-feet.c write-closed.c write-closed2.c \ - truncate.c fchmod.c make-page.c utime-file.c \ - write3.c still-there-p.c write-large.c hardlink4.c \ - intr-read.c asu.c truncate-files.c mmap-cat.c \ - blocks-new-file.c fsx.c afscp.c afscp_callback.c \ - write-rand.c - -EXTRA_OBJS = err.o errx.o warn.o warnx.o - -all: run-tests $(TEST_PROGRAMS) OS.pm - -OS.pm: OS-$(MKAFS_OSTYPE).pm - $(CP) OS-$(MKAFS_OSTYPE).pm OS.pm - -write-rand: write-rand.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write-rand.o $(EXTRA_OBJS) $(LIBS) - -write-ro-file: write-ro-file.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write-ro-file.o $(EXTRA_OBJS) $(LIBS) - -write-large: write-large.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write-large.o $(EXTRA_OBJS) $(LIBS) - -read-vs-mmap: read-vs-mmap.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ read-vs-mmap.o $(EXTRA_OBJS) $(LIBS) - -read-vs-mmap2: read-vs-mmap2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ read-vs-mmap2.o $(EXTRA_OBJS) $(LIBS) - -mmap-vs-read: mmap-vs-read.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mmap-vs-read.o $(EXTRA_OBJS) $(LIBS) - -mmap-vs-read2: mmap-vs-read2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mmap-vs-read2.o $(EXTRA_OBJS) $(LIBS) - -read-write: read-write.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ read-write.o $(EXTRA_OBJS) $(LIBS) - -mmap-and-read: mmap-and-read.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mmap-and-read.o $(EXTRA_OBJS) $(LIBS) - -large-dir: large-dir.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ large-dir.o $(EXTRA_OBJS) $(LIBS) - -large-dir2: large-dir2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ large-dir2.o $(EXTRA_OBJS) $(LIBS) - -large-dir3: large-dir3.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ large-dir3.o $(EXTRA_OBJS) $(LIBS) - -fchmod: fchmod.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ fchmod.o $(EXTRA_OBJS) $(LIBS) - -truncate: truncate.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ truncate.o $(EXTRA_OBJS) $(LIBS) - -make-page: make-page.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ make-page.o $(EXTRA_OBJS) $(LIBS) - -still-there-p: still-there-p.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ still-there-p.o $(EXTRA_OBJS) $(LIBS) - -intr-read: intr-read.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ intr-read.o $(EXTRA_OBJS) $(LIBS) - -blocks-new-file: blocks-new-file.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ blocks-new-file.o $(EXTRA_OBJS) $(LIBS) - -asu: asu.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ asu.o $(EXTRA_OBJS) $(LIBS) - -test-setgroups: test-setgroups.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ test-setgroups.o $(EXTRA_OBJS) $(SYS_LIBS) $(LIBS) - -test-setpag: test-setpag.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ test-setpag.o $(EXTRA_OBJS) $(SYS_LIBS) $(LIBS) - -hardlink1: hardlink1.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ hardlink1.o $(EXTRA_OBJS) $(LIBS) - -hardlink2: hardlink2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ hardlink2.o $(EXTRA_OBJS) $(LIBS) - -hardlink4: hardlink4.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ hardlink4.o $(EXTRA_OBJS) $(LIBS) - -mkdir2: mkdir2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mkdir2.o $(EXTRA_OBJS) $(LIBS) - -mkdir3: mkdir3.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mkdir3.o $(EXTRA_OBJS) $(LIBS) - -create-files: create-files.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ create-files.o $(EXTRA_OBJS) $(LIBS) - -create-symlinks: create-symlinks.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ create-symlinks.o $(EXTRA_OBJS) $(LIBS) - -create-dirs: create-dirs.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ create-dirs.o $(EXTRA_OBJS) $(LIBS) - -create-remove: create-remove.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ create-remove.o $(EXTRA_OBJS) $(LIBS) - -dup2-and-unlog: dup2-and-unlog.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ dup2-and-unlog.o $(EXTRA_OBJS) $(AUTH_LIBS) $(LIBS) - -readdir-vs-lstat: readdir-vs-lstat.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ readdir-vs-lstat.o $(EXTRA_OBJS) $(LIBS) - -symlink: symlink.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ symlink.o $(EXTRA_OBJS) $(LIBS) - -echo-n: echo-n.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ echo-n.o $(EXTRA_OBJS) - -test-parallel1: test-parallel1.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ test-parallel1.o $(EXTRA_OBJS) $(LIBS) - -test-parallel2: test-parallel2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ test-parallel2.o $(EXTRA_OBJS) $(LIBS) - -create-stat: create-stat.o fs_lib.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ create-stat.o fs_lib.o $(EXTRA_OBJS) $(SYS_LIBS) $(LIBS) - -kill-softly: kill-softly.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ kill-softly.o $(EXTRA_OBJS) $(LIBS) - -kill-softer: kill-softer.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ kill-softer.o $(EXTRA_OBJS) $(LIBS) - -rm-rf: rm-rf.o fs_lib.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ rm-rf.o fs_lib.o $(EXTRA_OBJS) $(SYS_LIBS) $(LIBS) - -exit-wo-close: exit-wo-close.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ exit-wo-close.o $(EXTRA_OBJS) $(LIBS) - -strange-characters-c: strange-characters-c.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ strange-characters-c.o $(EXTRA_OBJS) $(LIBS) - -pine: pine.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ pine.o $(EXTRA_OBJS) $(LIBS) - -append-over-page: append-over-page.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ append-over-page.o $(EXTRA_OBJS) $(LIBS) - -write-ucc: write-ucc.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write-ucc.o $(EXTRA_OBJS) $(LIBS) - -utime-dir: utime-dir.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ utime-dir.o $(EXTRA_OBJS) $(LIBS) - -utime-file: utime-file.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ utime-file.o $(EXTRA_OBJS) $(LIBS) - -mmap-shared-write: mmap-shared-write.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mmap-shared-write.o $(EXTRA_OBJS) $(LIBS) - -rename5: rename5.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ rename5.o $(EXTRA_OBJS) $(LIBS) - -rename6: rename6.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ rename6.o $(EXTRA_OBJS) $(LIBS) - -write3: write3.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write3.o $(EXTRA_OBJS) $(LIBS) - -rename-under-feet: rename-under-feet.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ rename-under-feet.o $(EXTRA_OBJS) $(LIBS) - -write-closed: write-closed.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write-closed.o $(EXTRA_OBJS) $(LIBS) - -write-closed2: write-closed2.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ write-closed2.o $(EXTRA_OBJS) $(SYS_LIBS) $(LIBS) - -truncate-files: truncate-files.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ truncate-files.o $(EXTRA_OBJS) $(LIBS) - -mmap-cat: mmap-cat.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ mmap-cat.o $(EXTRA_OBJS) $(LIBS) - -run-tests: run-tests.in - (cd ..; CONFIG_FILES=tests/run-tests CONFIG_HEADERS= $(SHELL) /usr/src/openafs/openafs/config.status) - @chmod +x run-tests - -#.c.o: -# $(CC) -c $(CPPFLAGS) $(DEFS) -I$(srcdir) -I. $(REALCFLAGS) $< - -afscp: afscp.o afscp_callback.o $(EXTRA_OBJS) - $(CC) $(LDFLAGS) -o $@ afscp.o afscp_callback.o $(EXTRA_OBJS) $(INT_LIBS) - -hello-world: hello-world.in - sed -e "s!%CC%!$(CC)!" $(srcdir)/hello-world.in > $@ - chmod +x hello-world - -mountpoint: mountpoint.in - sed -e "s!%bindir%!$(bindir)!" $(srcdir)/mountpoint.in > $@ - chmod +x mountpoint - -clean: - rm -f run-tests $(TEST_PROGRAMS) *.o *~ - -realclean: - -distclean: clean - rm -f Makefile - -mostlyclean: - -install: - -uninstall: - - -TAGS: $(TEST_SRCS) - etags $(TEST_SRCS) - -check: run-tests $(TEST_PROGRAMS) - ./run-tests -all - -check-fast: run-tests $(TEST_PROGRAMS) - ./run-tests -all -fast - -.PHONY: all install clean realclean distclean mostlyclean install uninstall check diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in index b1ae44d2b..064b63a89 100644 --- a/src/tests/Makefile.in +++ b/src/tests/Makefile.in @@ -10,8 +10,8 @@ INCDIRS=-I${TOP_OBJDIR}/src/config -I${TOP_INCDIR}/afs -I${TOP_INCDIR} INCLIBS=-L${SRCDIR}/lib/afs -L${TOP_LIBDIR} LIBS=\ - ${TOP_LIBDIR}/libdumpscan.a \ - ${TOP_LIBDIR}/libxfiles.a \ + libdumpscan.a \ + libxfiles.a \ ${TOP_LIBDIR}/libauth.a \ ${TOP_LIBDIR}/libaudit.a \ ${TOP_LIBDIR}/libvolser.a \ @@ -336,7 +336,7 @@ mmap-cat: mmap-cat.o $(EXTRA_OBJS) $(CC) $(LDFLAGS) -o $@ mmap-cat.o $(EXTRA_OBJS) $(LIBS) run-tests: run-tests.in - (cd ..; CONFIG_FILES=tests/run-tests CONFIG_HEADERS= $(SHELL) @TOP_OBJDIR@/config.status) + (cd ../..; CONFIG_FILES=src/tests/run-tests CONFIG_HEADERS= $(SHELL) @TOP_OBJDIR@/config.status) @chmod +x run-tests #.c.o: diff --git a/src/tests/reauth.pl b/src/tests/reauth.pl index 1b5855559..8ff803981 100755 --- a/src/tests/reauth.pl +++ b/src/tests/reauth.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env perl -w +#!/usr/bin/env perl use Term::ReadLine; use strict; use OpenAFS::ConfigUtils; diff --git a/src/tests/run-suite.pl b/src/tests/run-suite.pl new file mode 100755 index 000000000..d67524fcb --- /dev/null +++ b/src/tests/run-suite.pl @@ -0,0 +1,236 @@ +#!/usr/bin/env perl +# Copyright (C) 2000 by Sam Hartman +# This file may be copied either under the terms of the GNU GPL or the IBM Public License +# either version 2 or later of the GPL or version 1.0 or later of the IPL. + +use Term::ReadLine; +use strict; +use OpenAFS::ConfigUtils; +use OpenAFS::Dirpath; +use OpenAFS::OS; +use OpenAFS::Auth; +use Getopt::Long; +use vars qw($admin $server $cellname $cachesize $part + $shutdown_needed $csdb); +my $rl = new Term::ReadLine('run-suite'); + +=head1 NAME + + run-suite - Set up AFS cell and test. + +=head1 SYNOPSIS + +B [B<--cellname> cellname] [B<--cachesize> size] + +=head1 DESCRIPTION + + +This script sets up an AFS cell, then runs a suite of tests against the +cell to verify the build. + +The B option specifies the name of the cell. + +The B option specifies the size of the AFS cache. + +=cut + +# main script + +# mkvol(volume, mount) +sub mkvol($$) { + my ($vol, $mnt) = @_; + run("$openafsdirpath->{'afssrvsbindir'}/vos create $server $part $vol -localauth"); + unwind("$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part $vol -localauth"); + run("$openafsdirpath->{'afssrvbindir'}/fs mkm $mnt $vol "); + run("$openafsdirpath->{'afssrvbindir'}/fs sa $mnt system:anyuser rl"); +} + +GetOptions ( + "cellname=s" => \$cellname, + "cachesize=s" => \$cachesize, + "partition=s" => \$part, + "admin=s" => \$admin); + +if ($> != 0) { + die "This script should almost always be run as root.\n"; +} + +open(MOUNT, "mount |") or die "Failed to run mount: $!\n"; +while() { + if(m:^AFS:) { + print "The AFS client is currently running on this workstation.\n"; + print "Please restart this script after running $openafsinitcmd->{'client-stop'}\n"; + exit(1); + } + if(m:^/afs on AFS:) { + print "The AFS client is currently running on this workstation.\n"; + print "Please restart this script after running $openafsinitcmd->{'client-stop'}\n"; + exit(1); + } +} +close MOUNT; + +unless ( -f "$openafsdirpath->{'afsconfdir'}/KeyFile") { + print "You do not have an AFS keyfile. Please create this using asetkey from openafs-krb5 or +the bos addkey command"; + exit(1); +} + +print "If the fileserver is not running, this may hang for 30 seconds.\n"; +run("$openafsinitcmd->{'filesrv-stop'}"); +$server = `hostname`; +chomp $server; +$admin = "admin" unless $admin; +$admin =~ s:/:.:g; +if($admin =~ /@/) { +die "The administrative user must be in the same realm as the cell and no realm may be specified.\n"; +} + +$cellname = $rl->readline("What cellname should be used? ") unless $cellname; +die "Please specify a cellname\n" unless $cellname; + +if (! -f "$openafsdirpath->{'afsconfdir'}/ThisCell") { + open(CELL, "> $openafsdirpath->{'afsconfdir'}/ThisCell"); + print CELL "${cellname}"; + close CELL; +} + +open(CELL, "$openafsdirpath->{'afsconfdir'}/ThisCell") or + die "Cannot open $openafsdirpath->{'afsconfdir'}/ThisCell: $!\n"; + +my $lcell = ; +chomp $lcell; +close CELL; + +run( "echo \\>$lcell >$openafsdirpath->{'afsconfdir'}/CellServDB"); +$csdb = `host $server|awk '{print $4 " #" $1}'`; +run( "echo $csdb >>$openafsdirpath->{'afsconfdir'}/CellServDB"); +run("$openafsinitcmd->{'filesrv-start'}"); +unwind("$openafsinitcmd->{'filesrv-stop'}"); +$shutdown_needed = 1; +run ("$openafsdirpath->{'afssrvbindir'}/bos addhost $server $server -localauth ||true"); +run("$openafsdirpath->{'afssrvbindir'}/bos adduser $server $admin -localauth"); +unwind("$openafsdirpath->{'afssrvbindir'}/bos removeuser $server $admin -localauth"); +if ( -f "$openafsdirpath->{'afsdbdir'}/prdb.DB0" ) { + die "Protection database already exists; cell already partially created\n"; + } +open(PRDB, "|$openafsdirpath->{'afssrvsbindir'}/pt_util -p $openafsdirpath->{'afsdbdir'}/prdb.DB0 -w ") +or die "Unable to start pt_util: $!\n"; +print PRDB "$admin 128/20 1 -204 -204\n"; +print PRDB "system:administrators 130/20 -204 -204 -204\n"; +print PRDB" $admin 1\n"; +close PRDB; +unwind( "rm $openafsdirpath->{'afsdbdir'}/prdb* "); +# Start up ptserver and vlserver +run("$openafsdirpath->{'afssrvbindir'}/bos create $server ptserver simple $openafsdirpath->{'afssrvlibexecdir'}/ptserver -localauth"); +unwind("$openafsdirpath->{'afssrvbindir'}/bos delete $server ptserver -localauth"); +unwind("$openafsdirpath->{'afssrvbindir'}/bos stop $server ptserver -localauth -wait"); + +run("$openafsdirpath->{'afssrvbindir'}/bos create $server vlserver simple $openafsdirpath->{'afssrvlibexecdir'}/vlserver -localauth"); +unwind("$openafsdirpath->{'afssrvbindir'}/bos delete $server vlserver -localauth"); +unwind("$openafsdirpath->{'afssrvbindir'}/bos stop $server vlserver -localauth -wait"); + +run( "$openafsdirpath->{'afssrvbindir'}/bos create $server fs fs ". + "-cmd $openafsdirpath->{'afssrvlibexecdir'}/fileserver ". + "-cmd $openafsdirpath->{'afssrvlibexecdir'}/volserver ". + "-cmd $openafsdirpath->{'afssrvlibexecdir'}/salvager -localauth"); +unwind( "$openafsdirpath->{'afssrvbindir'}/bos delete $server fs -localauth "); +unwind( "$openafsdirpath->{'afssrvbindir'}/bos stop $server fs -localauth -wait"); + +print "Waiting for database elections: "; +sleep(30); +print "done.\n"; +# Past this point we want to control when bos shutdown happens +$shutdown_needed = 0; +unwind( "$openafsdirpath->{'afssrvbindir'}/bos shutdown $server -localauth "); +run("$openafsdirpath->{'afssrvsbindir'}/vos create $server a root.afs -localauth"); +# bring up client + +$cachesize = $rl->readline("What size cache (in 1k blocks)? ") unless $cachesize; +die "Please specify a cache size\n" unless $cachesize; + +run("echo $lcell >$openafsdirpath->{'viceetcdir'}/ThisCell"); +run("cp $openafsdirpath->{'afsconfdir'}/CellServDB $openafsdirpath->{'viceetcdir'}/CellServDB"); +run("echo /afs:/usr/vice/cache:${cachesize} >$openafsdirpath->{'viceetcdir'}/cacheinfo"); +run("$openafsinitcmd->{'client-forcestart'}"); +my $afs_running = 0; +open(MOUNT, "mount |") or die "Failed to run mount: $!\n"; +while() { +if(m:^AFS:) { + $afs_running = 1; +} + } +unless ($afs_running) { +print "*** The AFS client failed to start.\n"; +print "Please fix whatever problem kept it from running.\n"; + exit(1); +} +unwind("$openafsinitcmd->{'client-stop'}"); + +$part = "a" unless $part; + +&OpenAFS::Auth::authadmin(); + +run("$openafsdirpath->{'afssrvbindir'}/fs sa /afs system:anyuser rl"); + +run("$openafsdirpath->{'afssrvsbindir'}/vos create $server $part root.cell -localauth"); +unwind("$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part root.cell -localauth"); +# We make root.cell s:anyuser readable after we mount in the next +# loop. +open(CELLSERVDB, "$openafsdirpath->{'viceetcdir'}/CellServDB") + or die "Unable to open $openafsdirpath->{'viceetcdir'}/CellServDB: $!\n"; +while() { + chomp; + if (/^>\s*([a-z0-9_\-.]+)/ ) { + run("$openafsdirpath->{'afssrvbindir'}/fs mkm /afs/$1 root.cell -cell $1 -fast"); + unwind ("$openafsdirpath->{'afssrvbindir'}/fs rmm /afs/$1"); + } +} + +run("$openafsdirpath->{'afssrvbindir'}/fs sa /afs/$lcell system:anyuser rl"); +run ("$openafsdirpath->{'afssrvbindir'}/fs mkm /afs/.$lcell root.cell -cell $lcell -rw"); +unwind ("$openafsdirpath->{'afssrvbindir'}/fs rmm /afs/.$lcell"); +run("$openafsdirpath->{'afssrvbindir'}/fs mkm /afs/.root.afs root.afs -rw"); +unwind ("$openafsdirpath->{'afssrvbindir'}/fs rmm /afs/.root.afs"); + +mkvol( "user", "/afs/$lcell/user" ); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part user -localauth "); + +mkvol( "service", "/afs/$lcell/service" ); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part service -localauth "); + +mkvol( "rep", "/afs/$lcell/.replicated" ); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part rep -localauth "); +run( "$openafsdirpath->{'afssrvbindir'}/fs mkm /afs/$lcell/replicated rep.readonly " ); + +run( "$openafsdirpath->{'afssrvsbindir'}/vos addsite $server $part rep -localauth" ); +run( "$openafsdirpath->{'afssrvsbindir'}/vos release rep -localauth" ); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part rep.readonly -localauth "); + +mkvol( "unrep", "/afs/$lcell/unreplicated" ); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part unrep -localauth "); + +$lcell =~ /^([^.]*)/; +my $cellpart = $1; +run("ln -s /afs/$lcell /afs/$cellpart"); +unwind ("rm /afs/$cellpart"); +run( "ln -s /afs/.$lcell /afs/.$cellpart" ); +unwind ("rm /afs/.$cellpart"); + +run( "$openafsdirpath->{'afssrvsbindir'}/vos addsite $server $part root.afs -localauth" ); +run( "$openafsdirpath->{'afssrvsbindir'}/vos addsite $server $part root.cell -localauth" ); +run( "$openafsdirpath->{'afssrvsbindir'}/vos release root.afs -localauth" ); +run( "$openafsdirpath->{'afssrvsbindir'}/vos release root.cell -localauth" ); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part root.cell.readonly -localauth "); +unwind( "$openafsdirpath->{'afssrvsbindir'}/vos remove $server $part root.afs.readonly -localauth "); + +system ("pagsh -c './test-front.sh $lcell'"); + +@unwinds = (); +END { +# If we fail before all the instances are created, we need to perform +# our own bos shutdown + system("$openafsdirpath->{'afssrvbindir'}/bos shutdown $server -localauth") if $shutdown_needed; + run(pop @unwinds) while @unwinds; + } + diff --git a/src/tests/test-front.sh b/src/tests/test-front.sh new file mode 100755 index 000000000..9e999a3fd --- /dev/null +++ b/src/tests/test-front.sh @@ -0,0 +1,10 @@ +#!/bin/sh +pwd=`pwd` +cell=$1 +./reauth.pl +PERL5LIB=$pwd +export PERL5LIB +WORKDIR=/afs/${cell}/unreplicated +export WORKDIR +./run-tests -all + -- 2.39.5