Commit 6cdccbd2 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add prelim support for using linktest. Because of problems, this is

currently available to only people with stud=1 status in the DB.

* www/tbauth.php3: Add a STUDLY() function to check that bit.

* www/linktest.php3: New page to run linktest on the fly. The level
  defaults to the current level in the experiments table, but you can
  override that via the form on the page.

* www/showexp.php3: Add link to aforementioned page. STUDLY() only.

* www/beginexp_form.php3: Add an option (selection) to set the linktest
  level for create/swapin. Defaults to 0 (no linktest). STUDLY() only.

* www/editexp.php3: Add an option to edit the default linktest level
  for an experiment. STUDLY() only.

* tbsetup/batchexp.in and tbsetup/swapexp.in: Add code to optionally run
  the linktest, sending email if it fails (exists with non-zero status).
  Failure does not affect the swapin.
parent b43f1ae4
......@@ -50,11 +50,12 @@ sub usage()
exit(-1);
}
my $optlist = "iE:g:e:p:S:L:a:l:fwq";
my $optlist = "iE:g:e:p:S:L:a:l:fwqt:";
my $batchmode= 1;
my $frontend = 0;
my $waitmode = 0;
my $quiet = 0;
my $linktest = 0; # non-zero means level to run at.
#
# Configure variables
......@@ -249,13 +250,14 @@ if (! DBQueryWarn("INSERT INTO experiments ".
" expt_head_uid,expt_swap_uid, state, priority, swappable,".
" idleswap, idleswap_timeout, autoswap, autoswap_timeout,".
" idle_ignore, keyhash, expt_locked, eventkey,".
" noswap_reason, noidleswap_reason, batchmode) ".
" noswap_reason, noidleswap_reason, batchmode, ".
" linktest_level) ".
"VALUES ('$eid', '$pid', '$gid', now(), ".
"$description,'$dbuid', '$dbuid', '$exptstate', $priority, ".
"$swappable, $idleswap, '$swaptime', $autoswap, ".
"'$autoswaptime', $idleignore, '$webkey', ".
"now(), '$eventkey', $noswap_reason, ".
"$noidleswap_reason, $batchmode)")) {
"$noidleswap_reason, $batchmode, $linktest)")) {
DBQueryWarn("unlock tables");
die("*** $0:\n".
" Database error inserting record for $pid/$eid!\n");
......@@ -483,16 +485,6 @@ if (system("$tbbindir/tbreport -b $pid $eid 2>&1 > $repfile") != 0) {
fatal("tbreport failed!\n");
}
#
# Gather statistics.
#
if ($frontend || $batchmode) {
GatherSwapStats($pid, $eid, $dbuid, TBDB_STATS_PRELOAD, 0);
}
else {
GatherSwapStats($pid, $eid, $dbuid, TBDB_STATS_START, 0);
}
#
# Try to copy off the files for testbed information gathering.
#
......@@ -504,6 +496,55 @@ TBSaveExpLogFiles($pid, $eid);
#
system("cp -Rfp $workdir/ $userdir/tbdata");
#
# Deal with linktest. If requested, swapping in or modifying, and experiment
# is indeed active, then run it!
#
# XXX - linktest uses files from $userdir/tbdata/, so the above cp must
# happen first!
#
if ($linktest && ExpState($pid, $eid) eq EXPTSTATE_ACTIVE) {
#
# Run it. No worries about failures.
#
my $output = "linktest.$$";
my $optarg = "-o $output";
if ($linktest =~ /^(\d)$/) {
$optarg .= " -l $1";
}
else {
$optarg .= " -l 1";
}
print "Running 'run_linktest.pl $optarg -e $pid/$eid'\n";
if (system("$tbbindir/run_linktest.pl $optarg -e $pid/$eid") != 0) {
system("cat $output")
if (-r $output);
print STDERR "*** WARNING: ".
"Linktest run returned non-zero status!\n";
SENDMAIL("$user_name <$user_email>",
"Linktest Failure: $pid/$eid",
"Failure in linktest (level $linktest); ".
"returned non-zero status",
"$user_name <$user_email>",
"Cc: $TBOPS",
($output));
}
}
#
# Gather statistics.
#
if ($frontend || $batchmode) {
GatherSwapStats($pid, $eid, $dbuid, TBDB_STATS_PRELOAD, 0);
}
else {
GatherSwapStats($pid, $eid, $dbuid, TBDB_STATS_START, 0);
}
#
# Close up the log file so the webpage stops.
#
......@@ -824,6 +865,13 @@ sub ParseArgs()
$autoswap = 1;
$autoswaptime = $options{"a"};
}
if (defined($options{"t"})) {
if (! TBcheck_dbslot($options{"t"}, "experiments", "linktest_level",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) {
die("Improper linktest level!\n");
}
$linktest = $options{"t"};
}
if (defined($options{"w"})) {
$waitmode = 1;
}
......
......@@ -308,6 +308,7 @@ my $expt_path = $hashrow{'path'};
my $expt_locked = $hashrow{'expt_locked'};
my $isbatchexpt = $hashrow{'batchmode'};
my $canceled = $hashrow{'canceled'};
my $linktest_level = $hashrow{'linktest_level'};
my $swappablebit= $hashrow{'swappable'};
my $idleswapbit = $hashrow{'idleswap'};
my $autoswapbit = $hashrow{'autoswap'};
......@@ -816,6 +817,39 @@ TBSaveExpLogFiles($pid, $eid);
#
system("cp -Rfp $workdir/ $userdir/tbdata/");
#
# Deal with linktest. If requested, swapping in or modifying, and experiment
# is indeed active, then run it!
#
# XXX - linktest uses files from $userdir/tbdata/, so the above cp must
# happen first!
#
if ($linktest_level && ExpState($pid, $eid) eq EXPTSTATE_ACTIVE) {
#
# Run it. No worries about failures.
#
my $output = "linktest.$$";
my $optarg = "-l $linktest_level -o $output";
print STDOUT "Running 'run_linktest.pl $optarg -e $pid/$eid'\n";
if (system("$tbdir/run_linktest.pl $optarg -e $pid/$eid") != 0) {
system("cat $output")
if (-r $output);
print STDERR "*** WARNING: ".
"Linktest run returned non-zero status!\n";
SENDMAIL("$user_name <$user_email>",
"Linktest Failure: $pid/$eid",
"Failure in linktest (level $linktest_level); ".
"returned non-zero status",
"$user_name <$user_email>",
"Cc: $expt_head_name <$expt_head_email>\n".
"Cc: $TBOPS",
($output));
}
}
#
# Gather stats.
#
......
......@@ -62,6 +62,7 @@ function INITFORM($formfields, $projlist)
$defaults[exp_nsfile] = ""; # Multipart data.
$defaults[exp_preload] = "no";
$defaults[exp_batched] = "no";
$defaults[exp_linktest] = 0;
#
# Allow formfields that are already set to override defaults
......@@ -140,7 +141,7 @@ function CHECKFORM(&$formfields, $projlist)
function SPITFORM($formfields, $errors)
{
global $TBDB_PIDLEN, $TBDB_GIDLEN, $TBDB_EIDLEN, $TBDOCBASE;
global $view, $view_style, $projlist;
global $view, $view_style, $projlist, $linktest_levels;
PAGEHEADER("Begin a Testbed Experiment");
......@@ -468,6 +469,31 @@ function SPITFORM($formfields, $errors)
</tr>";
}
#
# Run linktest, and level.
#
if (STUDLY()) {
echo "<tr>
<td><a href='$TBDOCBASE/doc/docwrapper.php3?".
"docname=linktest.html'>Linktest</a> Option:</td>
<td><select name=\"formfields[exp_linktest]\">
<option value=0>Skip Linktest </option>\n";
for ($i = 1; $i <= TBDB_LINKTEST_MAX; $i++) {
$selected = "";
if (strcmp($formfields[exp_linktest], "$i") == 0)
$selected = "selected";
echo " <option $selected value=$i>Level $i - " .
$linktest_levels[$i] . "</option>\n";
}
echo " </select>";
echo " (Experimental; will not affect swapin)";
echo " </td>
</tr>\n";
}
#
# Batch Experiment?
#
......
......@@ -257,12 +257,22 @@ else {
$formfields[exp_autoswap] = 1;
if (!isset($formfields[exp_autoswap_timeout]) ||
!preg_match("/[\d]+/", $formfields[exp_idleswap_timeout]) ||
!preg_match("/^[\d]+$/", $formfields[exp_idleswap_timeout]) ||
($formfields[exp_autoswap_timeout] + 0) <= 0) {
$errors["Max. Duration"] = "No or invalid time provided";
}
}
#
# Linktest option
#
if (isset($formfields[exp_linktest]) && $formfields[exp_linktest] != "") {
if (!preg_match("/^[\d]+$/", $formfields[exp_linktest]) ||
$formfields[exp_linktest] < 0 || $formfields[exp_linktest] > 4) {
$errors["Linktest Option"] = "Invalid level selection";
}
}
#
# If any errors, stop now. pid/eid/gid must be okay before continuing.
#
......@@ -307,6 +317,10 @@ elseif ($nsfilelocale == "nsref") {
else {
$thensfile = "/tmp/$uid-$nsref.nsfile";
}
if (! file_exists($thensfile)) {
$errors["NS File"] = "Temp file no longer exists on server";
XMLERROR();
}
$deletensfile = 1;
}
elseif ($nsfilelocale == "inline") {
......@@ -360,6 +374,7 @@ else {
$exp_batched = 0;
$exp_preload = 0;
$batcharg = "-i";
$linktestarg = "";
if (isset($formfields[exp_batched]) &&
strcmp($formfields[exp_batched], "Yep") == 0) {
......@@ -371,6 +386,9 @@ if (isset($formfields[exp_preload]) &&
$exp_preload = 1;
$batcharg .= " -f";
}
if (isset($formfields[exp_linktest]) && $formfields[exp_linktest] != "") {
$linktestarg = "-t " . $formfields[exp_linktest];
}
#
# We need the email address for messages below.
......@@ -391,7 +409,7 @@ set_time_limit(0);
$retval = SUEXEC($uid, $unix_gid,
"webbatchexp $batcharg -E $exp_desc $exp_swappable ".
"-p $exp_pid -g $exp_gid -e $exp_id ".
"$linktestarg -p $exp_pid -g $exp_gid -e $exp_id ".
($nonsfile ? "" : "$thensfile"),
SUEXEC_ACTION_IGNORE);
......
......@@ -149,6 +149,15 @@ define("TBDB_USER_INTERFACE_PLAB", "plab");
$TBDB_USER_INTERFACE_LIST = array(TBDB_USER_INTERFACE_EMULAB,
TBDB_USER_INTERFACE_PLAB);
# Lintest levels.
$linktest_levels = array();
$linktest_levels[0] = "Skip Linktest";
$linktest_levels[1] = "Connectivity and Latency";
$linktest_levels[2] = "Static Routing";
$linktest_levels[3] = "Loss";
$linktest_levels[4] = "Bandwidth";
define("TBDB_LINKTEST_MAX", 4);
#
# Convert a trust string to the above numeric values.
#
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -50,7 +50,7 @@ if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_MODIFY)) {
#
function SPITFORM($formfields, $errors)
{
global $eid, $pid, $TBDOCBASE;
global $eid, $pid, $TBDOCBASE, $linktest_levels;
#
# Standard Testbed Header
......@@ -260,6 +260,31 @@ function SPITFORM($formfields, $errors)
</td>
</tr>\n";
#
# Run linktest, and level.
#
if (STUDLY()) {
echo "<tr>
<td><a href='$TBDOCBASE/doc/docwrapper.php3?".
"docname=linktest.html'>Linktest</a> Option:</td>
<td><select name=\"formfields[linktest_level]\">
<option value=0>Skip Linktest </option>\n";
for ($i = 1; $i <= TBDB_LINKTEST_MAX; $i++) {
$selected = "";
if (strcmp($formfields[linktest_level], "$i") == 0)
$selected = "selected";
echo " <option $selected value=$i>Level $i - " .
$linktest_levels[$i] . "</option>\n";
}
echo " </select>";
echo " (Experimental; will not affect swapin)";
echo " </td>
</tr>\n";
}
echo "<tr>
<td colspan=2 align=center>
<b><input type=submit name=submit value=Submit></b>
......@@ -304,6 +329,7 @@ $defaults[autoswap_timeout] = $row[autoswap_timeout] / 60.0;
$defaults[idle_ignore] = $row[idle_ignore];
$defaults[mem_usage] = $row["mem_usage"];
$defaults[cpu_usage] = $row["cpu_usage"];
$defaults[linktest_level] = $row["linktest_level"];
#
# A couple of defaults for turning things on.
......@@ -478,6 +504,24 @@ else {
$inserts[] = "mem_usage=0";
}
#
# Linktest level
#
if (isset($formfields[linktest_level]) &&
strcmp($formfields[linktest_level], "")) {
if (($formfields[linktest_level] + 0) < 0 ||
($formfields[linktest_level] + 0) > 4) {
$errors["Linktest Level"] = "Invalid linktest level";
}
else {
$inserts[] = "linktest_level=$formfields[linktest_level]";
}
}
else {
$inserts[] = "linktest_level=0";
}
#
# Spit any errors before dealing with batchmode, which changes the DB.
#
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");
#
# No PAGEHEADER since we spit out a Location header later. See below.
#
#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Check to make sure a valid experiment.
#
if (isset($pid) && strcmp($pid, "") &&
isset($eid) && strcmp($eid, "")) {
if (! TBvalid_eid($eid)) {
PAGEARGERROR("$eid is contains invalid characters!");
}
if (! TBvalid_pid($pid)) {
PAGEARGERROR("$pid is contains invalid characters!");
}
if (! TBValidExperiment($pid, $eid)) {
USERERROR("$pid/$eid is not a valid experiment!", 1);
}
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_MODIFY)) {
USERERROR("You do not have permission to run linktest on $pid/$eid!",
1);
}
}
else {
PAGEARGERROR("Must specify pid and eid!");
}
$query_result = DBQueryFatal("select gid,linktest_level from experiments ".
"where pid='$pid' and eid='$eid'");
$row = mysql_fetch_array($query_result);
$gid = $row[0];
#
# See if a level came in. If not, then get the default from the DB.
#
if (!isset($level) || $level == "") {
$level = $row[1];
}
elseif (! TBvalid_tinyint($level) ||
$level < 0 || $level > TBDB_LINKTEST_MAX) {
PAGEARGERROR("Linktest level must be an integer 0 <= level <= ".
TBDB_LINKTEST_MAX);
}
#
# We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be
# set. Or, the user can hit the cancel button, in which case we should
# probably redirect the browser back up a level.
#
if ($canceled) {
PAGEHEADER("Run Linktest");
echo "<center><h3><br>
Operation canceled!
</h3></center>\n";
PAGEFOOTER();
return;
}
if (!$confirmed) {
PAGEHEADER("Run Linktest at level $level");
echo "<font size=+2>Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
echo "<center><font size=+2><br>
Are you <b>REALLY</b>
sure you want to run linktest at level $level?
</font>\n";
SHOWEXP($pid, $eid, 1);
echo "<form action=linktest.php3 method=post>";
echo "<input type=hidden name=pid value=$pid>\n";
echo "<input type=hidden name=eid value=$eid>\n";
echo "<table align=center border=1>\n";
echo "<tr>
<td><a href='$TBDOCBASE/doc/docwrapper.php3?".
"docname=linktest.html'>Linktest</a> Option:</td>
<td><select name=level>
<option value=0>Skip Linktest </option>\n";
for ($i = 1; $i <= TBDB_LINKTEST_MAX; $i++) {
$selected = "";
if (strcmp("$level", "$i") == 0)
$selected = "selected";
echo " <option $selected value=$i>Level $i - " .
$linktest_levels[$i] . "</option>\n";
}
echo " </select>";
echo " </td>
</tr>
</table><br>\n";
echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
echo "<b><input type=submit name=canceled value=Cancel></b>\n";
echo "</form>\n";
echo "</center>\n";
PAGEFOOTER();
return;
}
#
# A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam.
#
$fp = 0;
function SPEWCLEANUP()
{
global $fp;
if (connection_aborted() && $fp) {
pclose($fp);
}
exit();
}
register_shutdown_function("SPEWCLEANUP");
ignore_user_abort(1);
# For backend.
TBGroupUnixInfo($pid, $gid, $unix_gid, $unix_name);
$fp = popen("$TBSUEXEC_PATH $uid $unix_gid weblinktest -l $level -e $pid/$eid",
"r");
if (! $fp) {
USERERROR("Linktest failed!", 1);
}
header("Content-Type: text/plain");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();
echo date("D M d G:i:s T");
echo "\n";
echo "Starting linktest run at level $level\n";
flush();
while (!feof($fp)) {
$string = fgets($fp, 1024);
echo "$string";
flush();
}
$retval = pclose($fp);
$fp = 0;
if ($retval == 0)
echo "Linktest run was successful!\n";
echo date("D M d G:i:s T");
echo "\n";
?>
......@@ -172,6 +172,11 @@ if ($wireless) {
WRITESUBMENUBUTTON("Show History",
"showstats.php3?showby=expt&which=$expindex");
if (STUDLY()) {
WRITESUBMENUBUTTON("Run Linktest",
"linktest.php3?pid=$exp_pid&eid=$exp_eid");
}
if (ISADMIN($uid)) {
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
SUBMENUSECTION("Beta-Test Options");
......
......@@ -416,6 +416,19 @@ function ISADMIN($uid = 1) {
(CHECKLOGIN_LOGGEDIN|CHECKLOGIN_ISADMIN));
}
function STUDLY() {
global $CHECKLOGIN_STATUS;
if ($CHECKLOGIN_STATUS == CHECKLOGIN_NOSTATUS) {
$uid=GETUID();
TBERROR("STUDLY: $uid is not logged in!", 1);
}
return (($CHECKLOGIN_STATUS &
(CHECKLOGIN_LOGGEDIN|CHECKLOGIN_STUDLY)) ==
(CHECKLOGIN_LOGGEDIN|CHECKLOGIN_STUDLY));
}
# Is this user a real administrator (ignore onoff bit).
function ISADMINISTRATOR() {
global $CHECKLOGIN_STATUS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment