1#!/bin/sh 2# 3# Copyright (c) 2012 The FreeBSD Foundation 4# 5# This software was developed by Edward Tomasz Napierala under sponsorship 6# from the FreeBSD Foundation. 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 2. Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in the 15# documentation and/or other materials provided with the distribution. 16# 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27# SUCH DAMAGE. 28# 29# 30 31# 32# This expects that the iSCSI server being tested is at $TARGETIP and exports 33# two targets: $TARGET1 and $TARGET2; the former requiring no authentication, 34# and the latter using CHAP with user $USER and secret $SECRET. Discovery 35# must be permitted without authentication. Each target must contain exactly 36# two LUNs, 4GB each. For example, ctl.conf(5) should look like this: 37# 38# auth-group meh { 39# chap user secretsecret 40# } 41# 42# portal-group meh { 43# listen 0.0.0.0 44# discovery-auth-group no-authentication 45# } 46# 47# target iqn.2012-06.com.example:1 { 48# auth-group no-authentication 49# portal-group meh 50# lun 0 { 51# path /var/tmp/example_t1l0 52# size 4G 53# } 54# lun 1 { 55# path /var/tmp/example_t1l1 56# size 4G 57# } 58# } 59# 60# target iqn.2012-06.com.example:2 { 61# auth-group meh 62# portal-group meh 63# lun 0 { 64# path /var/tmp/example_t2l0 65# size 4G 66# } 67# lun 1 { 68# path /var/tmp/example_t2l1 69# size 4G 70# } 71# } 72# 73# Remember to create the backing files (/var/tmp/example_t1l0 etcc) 74# 75# On the initiator, $MNTDIR will be used for testing. 76# 77 78TARGETIP=192.168.56.101 79TARGET1=iqn.2012-06.com.example:1 80TARGET2=iqn.2012-06.com.example:2 81USER=user 82SECRET=secretsecret 83MNTDIR=/mnt 84TMPDIR=/tmp 85 86die() { 87 echo "$*" 88 exit 1 89} 90 91case `uname` in 92 FreeBSD) 93 LUN0=/dev/da0 94 LUN1=/dev/da1 95 LUN2=/dev/da2 96 LUN3=/dev/da3 97 ZFSPOOL=iscsipool 98 ;; 99 Linux) 100 LUN0=/dev/sdb 101 LUN1=/dev/sdc 102 LUN2=/dev/sdd 103 LUN3=/dev/sde 104 ;; 105 SunOS) 106 # LUN names are being set later, during attach. 107 ZFSPOOL=iscsipool 108 ;; 109 *) 110 die "unsupported system" 111 ;; 112esac 113 114check() { 115 echo "# $@" > /dev/stderr 116 $@ || die "$@ failed" 117} 118 119banner() { 120 echo "Will try to attach to $TARGET1 and $TARGET2 on $TARGETIP," 121 echo "user $USER, secret $SECRET. Will use mountpoint $MNTDIR, temporary dir $TMPDIR," 122 if [ -n "$LUN0" ]; then 123 echo "scratch disks $LUN0, $LUN1, $LUN2, $LUN3." 124 else 125 echo "scratch disks unknown at this stage." 126 fi 127 echo 128 echo "This script is NOT safe to run on multiuser system." 129 echo 130 echo "Press ^C to interrupt; will proceed in 5 seconds." 131 sleep 5 132} 133 134test_discovery_freebsd_9() { 135 kldload iscsi_initiator 136 check iscontrol -dt $TARGETIP > $TMPDIR/discovered 137 cat $TMPDIR/discovered 138 echo "TargetName=$TARGET1" > $TMPDIR/expected 139 echo "TargetName=$TARGET2" >> $TMPDIR/expected 140 check cmp $TMPDIR/expected $TMPDIR/discovered 141 rm -f $TMPDIR/expected $TMPDIR/discovered 142} 143 144test_discovery_freebsd() { 145 /etc/rc.d/iscsid onestart 146 check iscsictl -Ad $TARGETIP 147 sleep 1 148 iscsictl | awk '{ print $1 }' | sort > $TMPDIR/discovered 149 printf "Target\n$TARGET1\n$TARGET2\n" | sort > $TMPDIR/expected 150 check cmp $TMPDIR/expected $TMPDIR/discovered 151 rm -f $TMPDIR/expected $TMPDIR/discovered 152 check iscsictl -Ra 153 sleep 1 154} 155 156test_discovery_linux() { 157 cat > /etc/iscsi/iscsid.conf << END 158 159discovery.sendtargets.auth.authmethod = None 160node.startup = manual 161 162END 163 164 check iscsiadm -m discovery -t sendtargets -p $TARGETIP > $TMPDIR/discovered 165 cat $TMPDIR/discovered 166 echo "$TARGETIP:3260,-1 $TARGET1" > $TMPDIR/expected 167 echo "$TARGETIP:3260,-1 $TARGET2" >> $TMPDIR/expected 168 check cmp $TMPDIR/expected $TMPDIR/discovered 169 rm -f $TMPDIR/expected $TMPDIR/discovered 170 171} 172 173test_discovery_solaris() { 174 check iscsiadm add discovery-address $TARGETIP 175 check iscsiadm modify discovery --sendtargets enable 176 check iscsiadm modify discovery --static enable 177 check iscsiadm list target | awk '/^Target/ { print $2 }' | sort > $TMPDIR/discovered 178 check iscsiadm remove discovery-address $TARGETIP 179 cat $TMPDIR/discovered 180 echo "$TARGET1" > $TMPDIR/expected 181 echo "$TARGET2" >> $TMPDIR/expected 182 check cmp $TMPDIR/expected $TMPDIR/discovered 183 rm -f $TMPDIR/expected $TMPDIR/discovered 184} 185 186test_discovery() { 187 echo "*** discovery test ***" 188 case `uname` in 189 FreeBSD) 190 case `uname -r` in 191 9*) 192 test_discovery_freebsd_9 193 ;; 194 *) 195 test_discovery_freebsd 196 ;; 197 esac 198 ;; 199 Linux) 200 test_discovery_linux 201 ;; 202 SunOS) 203 test_discovery_solaris 204 ;; 205 *) 206 die "unsupported system" 207 ;; 208 esac 209} 210 211test_attach_freebsd_9() { 212 [ ! -e LUN0 ] || die "$LUN0 already exists" 213 [ ! -e LUN1 ] || die "$LUN1 already exists" 214 [ ! -e LUN2 ] || die "$LUN2 already exists" 215 [ ! -e LUN3 ] || die "$LUN3 already exists" 216 217 cat > $TMPDIR/iscsi.conf << END 218 219target1 { 220 TargetName = $TARGET1 221 TargetAddress = $TARGETIP 222} 223 224target2 { 225 TargetName = $TARGET2 226 TargetAddress = $TARGETIP 227 AuthMethod = CHAP 228 chapIName = $USER 229 chapSecret = $SECRET 230} 231 232END 233 check iscontrol -c $TMPDIR/iscsi.conf -n target1 234 check iscontrol -c $TMPDIR/iscsi.conf -n target2 235 236 echo "Waiting 10 seconds for attach to complete." 237 sleep 10 238 239 [ -e $LUN0 ] || die "$LUN0 doesn't exist" 240 [ -e $LUN1 ] || die "$LUN1 doesn't exist" 241 [ -e $LUN2 ] || die "$LUN2 doesn't exist" 242 [ -e $LUN3 ] || die "$LUN3 doesn't exist" 243 244 rm $TMPDIR/iscsi.conf 245} 246 247test_attach_freebsd() { 248 [ ! -e LUN0 ] || die "$LUN0 already exists" 249 [ ! -e LUN1 ] || die "$LUN1 already exists" 250 [ ! -e LUN2 ] || die "$LUN2 already exists" 251 [ ! -e LUN3 ] || die "$LUN3 already exists" 252 253 cat > $TMPDIR/iscsi.conf << END 254 255target1 { 256 TargetName = $TARGET1 257 TargetAddress = $TARGETIP 258} 259 260target2 { 261 TargetName = $TARGET2 262 TargetAddress = $TARGETIP 263 AuthMethod = CHAP 264 chapIName = $USER 265 chapSecret = $SECRET 266} 267 268END 269 check iscsictl -Ac $TMPDIR/iscsi.conf -n target1 270 check iscsictl -Ac $TMPDIR/iscsi.conf -n target2 271 272 echo "Waiting 10 seconds for attach to complete." 273 sleep 10 274 275 [ -e $LUN0 ] || die "$LUN0 doesn't exist" 276 [ -e $LUN1 ] || die "$LUN1 doesn't exist" 277 [ -e $LUN2 ] || die "$LUN2 doesn't exist" 278 [ -e $LUN3 ] || die "$LUN3 doesn't exist" 279 280 rm $TMPDIR/iscsi.conf 281} 282 283test_attach_linux() { 284 check iscsiadm --mode node --targetname "$TARGET1" -p "$TARGETIP:3260" --op=update --name node.session.auth.authmethod --value=None 285 check iscsiadm --mode node --targetname "$TARGET1" -p "$TARGETIP:3260" --login 286 check iscsiadm --mode node --targetname "$TARGET2" -p "$TARGETIP:3260" --op=update --name node.session.auth.authmethod --value=CHAP 287 check iscsiadm --mode node --targetname "$TARGET2" -p "$TARGETIP:3260" --op=update --name node.session.auth.username --value="$USER" 288 check iscsiadm --mode node --targetname "$TARGET2" -p "$TARGETIP:3260" --op=update --name node.session.auth.password --value="$SECRET" 289 check iscsiadm --mode node --targetname "$TARGET2" -p "$TARGETIP:3260" --login 290} 291 292test_attach_solaris() { 293 # XXX: How to enter the CHAP secret from the script? For now, 294 # just use the first target, and thus first two LUNs. 295 #check iscsiadm modify initiator-node --authentication CHAP 296 #check iscsiadm modify initiator-node --CHAP-name $USER 297 #check iscsiadm modify initiator-node --CHAP-secret $SECRET 298 iscsiadm add static-config $TARGET1,$TARGETIP 299 LUN0=`iscsiadm list target -S | awk '/OS Device Name/ { print $4 }' | sed -n 1p` 300 LUN1=`iscsiadm list target -S | awk '/OS Device Name/ { print $4 }' | sed -n 2p` 301 LUN0=`echo ${LUN0}2 | sed 's/rdsk/dsk/'` 302 LUN1=`echo ${LUN1}2 | sed 's/rdsk/dsk/'` 303 [ -n "$LUN0" -a -n "LUN1" ] || die "attach failed" 304 echo "Scratch disks: $LUN0, $LUN1" 305} 306 307test_attach() { 308 echo "*** attach test ***" 309 case `uname` in 310 FreeBSD) 311 case `uname -r` in 312 9*) 313 test_attach_freebsd_9 314 ;; 315 *) 316 test_attach_freebsd 317 ;; 318 esac 319 ;; 320 Linux) 321 test_attach_linux 322 ;; 323 SunOS) 324 test_attach_solaris 325 ;; 326 *) 327 die "unsupported system" 328 ;; 329 esac 330} 331 332test_newfs_freebsd_ufs() { 333 echo "*** UFS filesystem smoke test ***" 334 check newfs $LUN0 335 check newfs $LUN1 336 check newfs $LUN2 337 check newfs $LUN3 338 check fsck -t ufs $LUN0 339 check fsck -t ufs $LUN1 340 check fsck -t ufs $LUN2 341 check fsck -t ufs $LUN3 342} 343 344test_newfs_freebsd_zfs() { 345 echo "*** ZFS filesystem smoke test ***" 346 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 347 check zpool destroy -f $ZFSPOOL 348} 349 350test_newfs_linux_ext4() { 351 echo "*** ext4 filesystem smoke test ***" 352 yes | check mkfs $LUN0 353 yes | check mkfs $LUN1 354 yes | check mkfs $LUN2 355 yes | check mkfs $LUN3 356 check fsck -f $LUN0 357 check fsck -f $LUN1 358 check fsck -f $LUN2 359 check fsck -f $LUN3 360} 361 362test_newfs_linux_btrfs() { 363 echo "*** btrfs filesystem smoke test ***" 364 check mkfs.btrfs $LUN0 $LUN1 $LUN2 $LUN3 365} 366 367 368test_newfs_solaris_ufs() { 369 echo "*** UFS filesystem smoke test ***" 370 yes | check newfs $LUN0 371 yes | check newfs $LUN1 372 check fsck -F ufs $LUN0 373 check fsck -F ufs $LUN1 374} 375 376test_newfs_solaris_zfs() { 377 echo "*** ZFS filesystem smoke test ***" 378 check zpool create -f $ZFSPOOL $LUN0 $LUN1 379 check zpool destroy -f $ZFSPOOL 380} 381 382test_newfs() { 383 case `uname` in 384 FreeBSD) 385 test_newfs_freebsd_ufs 386 test_newfs_freebsd_zfs 387 ;; 388 Linux) 389 test_newfs_linux_ext4 390 test_newfs_linux_btrfs 391 ;; 392 SunOS) 393 test_newfs_solaris_ufs 394 test_newfs_solaris_zfs 395 ;; 396 *) 397 die "unsupported system" 398 ;; 399 esac 400} 401 402test_cp() { 403 echo "*** basic filesystem test ***" 404 case `uname` in 405 FreeBSD) 406 check newfs $LUN0 407 check mount -t ufs $LUN0 $MNTDIR 408 check dd if=/dev/urandom of=$MNTDIR/1 bs=1m count=500 409 check cp $MNTDIR/1 $MNTDIR/2 410 check umount $MNTDIR 411 check fsck -t ufs $LUN0 412 check mount -t ufs $LUN0 $MNTDIR 413 check cmp $MNTDIR/1 $MNTDIR/2 414 check umount $MNTDIR 415 416 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 417 check dd if=/dev/urandom of=/$ZFSPOOL/1 bs=1m count=500 418 check zpool scrub $ZFSPOOL 419 check cp /$ZFSPOOL/1 /$ZFSPOOL/2 420 check cmp /$ZFSPOOL/1 /$ZFSPOOL/2 421 check zpool destroy -f $ZFSPOOL 422 ;; 423 Linux) 424 yes | check mkfs $LUN0 425 check mount $LUN0 $MNTDIR 426 check dd if=/dev/urandom of=$MNTDIR/1 bs=1M count=500 427 check cp $MNTDIR/1 $MNTDIR/2 428 check umount $MNTDIR 429 check fsck -f $LUN0 430 check mount $LUN0 $MNTDIR 431 check cmp $MNTDIR/1 $MNTDIR/2 432 check umount $MNTDIR 433 434 check mkfs.btrfs $LUN0 $LUN1 $LUN2 $LUN3 435 check mount $LUN0 $MNTDIR 436 check dd if=/dev/urandom of=$MNTDIR/1 bs=1M count=500 437 check cp $MNTDIR/1 $MNTDIR/2 438 check umount $MNTDIR 439 check mount $LUN0 $MNTDIR 440 check cmp $MNTDIR/1 $MNTDIR/2 441 check umount $MNTDIR 442 ;; 443 SunOS) 444 yes | check newfs $LUN0 445 check mount -F ufs $LUN0 $MNTDIR 446 check dd if=/dev/urandom of=$MNTDIR/1 bs=1024k count=500 447 check cp $MNTDIR/1 $MNTDIR/2 448 check umount $MNTDIR 449 check fsck -yF ufs $LUN0 450 check mount -F ufs $LUN0 $MNTDIR 451 check cmp $MNTDIR/1 $MNTDIR/2 452 check umount $MNTDIR 453 454 check zpool create -f $ZFSPOOL $LUN0 $LUN1 455 check dd if=/dev/urandom of=/$ZFSPOOL/1 bs=1024k count=500 456 check zpool scrub $ZFSPOOL 457 check cp /$ZFSPOOL/1 /$ZFSPOOL/2 458 check cmp /$ZFSPOOL/1 /$ZFSPOOL/2 459 check zpool destroy -f $ZFSPOOL 460 ;; 461 *) 462 die "unsupported system" 463 ;; 464 esac 465} 466 467test_bonnie() { 468 echo "*** bonnie++ ***" 469 case `uname` in 470 FreeBSD) 471 check newfs $LUN0 472 check mount -t ufs $LUN0 $MNTDIR 473 check cd $MNTDIR 474 check bonnie++ -u root -s 2g -r 1g -n0 475 check bonnie++ -u root -s 0 476 check cd - 477 check umount $MNTDIR 478 check fsck -t ufs $LUN0 479 480 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 481 check cd /$ZFSPOOL 482 check bonnie++ -u root -s 2g -r 1g -n0 483 check bonnie++ -u root -s 0 484 check cd - 485 check zpool destroy -f $ZFSPOOL 486 ;; 487 Linux) 488 yes | check mkfs $LUN0 489 check mount $LUN0 $MNTDIR 490 check cd $MNTDIR 491 check bonnie++ -u root -s 2g -r 1g -n0 492 check bonnie++ -u root -s 0 493 check cd - 494 check umount $MNTDIR 495 check fsck -f $LUN0 496 497 check mkfs.btrfs $LUN0 $LUN1 $LUN2 $LUN3 498 check mount $LUN0 $MNTDIR 499 check cd $MNTDIR 500 check bonnie++ -u root -s 2g -r 1g -n0 501 check bonnie++ -u root -s 0 502 check cd - 503 check umount $MNTDIR 504 ;; 505 SunOS) 506 yes | check newfs $LUN0 507 check mount -F ufs $LUN0 $MNTDIR 508 check cd $MNTDIR 509 check bonnie++ -u root -s 2g -r 1g -n0 510 check bonnie++ -u root -s 0 511 check cd - 512 check umount $MNTDIR 513 check fsck -yF ufs $LUN0 514 515 check zpool create -f $ZFSPOOL $LUN0 $LUN1 516 check cd /$ZFSPOOL 517 check bonnie++ -u root -s 2g -r 1g -n0 518 check bonnie++ -u root -s 0 519 check cd - 520 check zpool destroy -f $ZFSPOOL 521 ;; 522 *) 523 die "unsupported system" 524 ;; 525 esac 526} 527 528test_iozone() { 529 echo "*** iozone ***" 530 case `uname` in 531 FreeBSD) 532 check newfs $LUN0 533 check mount -t ufs $LUN0 $MNTDIR 534 check cd $MNTDIR 535 check iozone -a 536 check cd - 537 check umount $MNTDIR 538 check fsck -t ufs $LUN0 539 540 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 541 check cd /$ZFSPOOL 542 check iozone -a 543 check cd - 544 check zpool destroy -f $ZFSPOOL 545 ;; 546 Linux) 547 yes | check mkfs $LUN0 548 check mount $LUN0 $MNTDIR 549 check cd $MNTDIR 550 check iozone -a 551 check cd - 552 check umount $MNTDIR 553 check fsck -f $LUN0 554 555 check mkfs.btrfs $LUN0 $LUN1 $LUN2 $LUN3 556 check mount $LUN0 $MNTDIR 557 check cd $MNTDIR 558 check iozone -a 559 check cd - 560 check umount $MNTDIR 561 ;; 562 SunOS) 563 yes | check newfs $LUN0 564 check mount -F ufs $LUN0 $MNTDIR 565 check cd $MNTDIR 566 check iozone -a 567 check cd - 568 check umount $MNTDIR 569 check fsck -yF ufs $LUN0 570 571 check zpool create -f $ZFSPOOL $LUN0 $LUN1 572 check cd /$ZFSPOOL 573 check iozone -a 574 check cd - 575 check zpool destroy -f $ZFSPOOL 576 ;; 577 *) 578 die "unsupported system" 579 ;; 580 esac 581 582} 583 584test_postmark() { 585 echo "*** postmark ***" 586 case `uname` in 587 FreeBSD) 588 check newfs $LUN0 589 check mount -t ufs $LUN0 $MNTDIR 590 check cd $MNTDIR 591 printf "set number 10000\nrun\n" | check postmark 592 check cd - 593 check umount $MNTDIR 594 check fsck -t ufs $LUN0 595 596 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 597 check cd /$ZFSPOOL 598 printf "set number 10000\nrun\n" | check postmark 599 check cd - 600 check zpool destroy -f $ZFSPOOL 601 ;; 602 Linux) 603 yes | check mkfs $LUN0 604 check mount $LUN0 $MNTDIR 605 check cd $MNTDIR 606 printf "set number 10000\nrun\n" | check postmark 607 check cd - 608 check umount $MNTDIR 609 check fsck -f $LUN0 610 611 check mkfs.btrfs $LUN0 $LUN1 $LUN2 $LUN3 612 check mount $LUN0 $MNTDIR 613 check cd $MNTDIR 614 printf "set number 10000\nrun\n" | check postmark 615 check cd - 616 check umount $MNTDIR 617 ;; 618 SunOS) 619 yes | check newfs $LUN0 620 check mount -F ufs $LUN0 $MNTDIR 621 check cd $MNTDIR 622 printf "set number 10000\nrun\n" | check postmark 623 check cd - 624 check umount $MNTDIR 625 check fsck -yF ufs $LUN0 626 627 check zpool create -f $ZFSPOOL $LUN0 $LUN1 628 check cd /$ZFSPOOL 629 printf "set number 10000\nrun\n" | check postmark 630 check cd - 631 check zpool destroy -f $ZFSPOOL 632 ;; 633 *) 634 die "unsupported system" 635 ;; 636 esac 637} 638 639test_postgresql_freebsd() { 640 check newfs $LUN0 641 check mount -t ufs $LUN0 $MNTDIR 642 check chown pgsql $MNTDIR 643 check chmod 755 $MNTDIR 644 check cd / 645 # XXX: How to make 'check' work here? 646 su -m pgsql -c "initdb -D $MNTDIR/db" 647 su -m pgsql -c "pg_ctl -D $MNTDIR/db -l /tmp/log start" 648 check sleep 10 649 su -m pgsql -c "pgbench -i postgres" 650 su -m pgsql -c "pgbench -t 10000 postgres" 651 su -m pgsql -c "pg_ctl -D $MNTDIR/db stop" 652 check cd - 653 check umount $MNTDIR 654 check fsck -t ufs $LUN0 655 656 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 657 check chown pgsql /$ZFSPOOL 658 check chmod 755 /$ZFSPOOL 659 check cd / 660 # XXX: How to make 'check' work here? 661 su -m pgsql -c "initdb -D /$ZFSPOOL/db" 662 su -m pgsql -c "pg_ctl -D /$ZFSPOOL/db -l /tmp/log start" 663 check sleep 10 664 su -m pgsql -c "pgbench -i postgres" 665 su -m pgsql -c "pgbench -t 10000 postgres" 666 su -m pgsql -c "pg_ctl -D /$ZFSPOOL/db stop" 667 check cd - 668 check zpool destroy -f $ZFSPOOL 669} 670 671test_postgresql_linux() { 672 yes | check mkfs $LUN0 673 check mount $LUN0 $MNTDIR 674 check chown postgres $MNTDIR 675 check chmod 755 $MNTDIR 676 check cd / 677 # XXX: How to make 'check' work here? 678 su -m postgres -c "initdb -D $MNTDIR/db" 679 su -m postgres -c "pg_ctl -D $MNTDIR/db -l /tmp/log start" 680 check sleep 5 681 su -m postgres -c "pgbench -i" 682 su -m postgres -c "pgbench -t 10000" 683 su -m postgres -c "pg_ctl -D $MNTDIR/db stop" 684 check cd - 685 check umount $MNTDIR 686 check fsck -f $LUN0 687 688 check mkfs.btrfs $LUN0 $LUN1 $LUN2 $LUN3 689 check mount $LUN0 $MNTDIR 690 check chown postgres $MNTDIR 691 check chmod 755 $MNTDIR 692 check cd / 693 su -m postgres -c "initdb -D $MNTDIR/db" 694 su -m postgres -c "pg_ctl -D $MNTDIR/db -l /tmp/log start" 695 check sleep 5 696 su -m postgres -c "pgbench -i" 697 su -m postgres -c "pgbench -t 10000" 698 su -m postgres -c "pg_ctl -D $MNTDIR/db stop" 699 check cd - 700 check umount $MNTDIR 701} 702 703test_postgresql_solaris() { 704 PATH="$PATH:/usr/postgres/9.2-pgdg/bin" export PATH 705 yes | check newfs $LUN0 706 check mount -F ufs $LUN0 $MNTDIR 707 check chown postgres $MNTDIR 708 check chmod 755 $MNTDIR 709 check cd / 710 # XXX: How to make 'check' work here? 711 su postgres -c "initdb -D $MNTDIR/db" 712 su postgres -c "pg_ctl -D $MNTDIR/db -l /tmp/log start" 713 check sleep 10 714 su postgres -c "pgbench -i postgres" 715 su postgres -c "pgbench -t 10000 postgres" 716 su postgres -c "pg_ctl -D $MNTDIR/db stop" 717 check cd - 718 check umount $MNTDIR 719 check fsck -yF ufs $LUN0 720 721 check zpool create -f $ZFSPOOL $LUN0 $LUN1 $LUN2 $LUN3 722 check chown postgres /$ZFSPOOL 723 check chmod 755 /$ZFSPOOL 724 check cd / 725 # XXX: How to make 'check' work here? 726 su postgres -c "initdb -D /$ZFSPOOL/db" 727 su postgres -c "pg_ctl -D /$ZFSPOOL/db -l /tmp/log start" 728 check sleep 10 729 su postgres -c "pgbench -i postgres" 730 su postgres -c "pgbench -t 10000 postgres" 731 su postgres -c "pg_ctl -D /$ZFSPOOL/db stop" 732 check cd - 733 check zpool destroy -f $ZFSPOOL 734} 735 736test_postgresql() { 737 echo "*** postgresql ***" 738 case `uname` in 739 FreeBSD) 740 test_postgresql_freebsd 741 ;; 742 Linux) 743 test_postgresql_linux 744 ;; 745 SunOS) 746 test_postgresql_solaris 747 ;; 748 *) 749 die "unsupported system" 750 ;; 751 esac 752} 753 754test_detach() { 755 echo "*** detach ***" 756 case `uname` in 757 FreeBSD) 758 case `uname -r` in 759 9*) 760 echo "*** detaching not supported on FreeBSD 9 ***" 761 echo "*** please reboot the initiator VM before trying to run this script again ***" 762 ;; 763 *) 764 check iscsictl -Ra 765 ;; 766 esac 767 ;; 768 Linux) 769 check iscsiadm -m node --logout 770 ;; 771 SunOS) 772 check iscsiadm remove static-config $TARGET1,$TARGETIP 773 ;; 774 *) 775 die "unsupported system" 776 ;; 777 esac 778} 779 780banner 781test_discovery 782test_attach 783test_newfs 784test_cp 785test_bonnie 786test_iozone 787test_postmark 788test_postgresql 789test_detach 790 791echo "*** done ***" 792 793