Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- #
- # Copyright (C) 2006-2010 Nexenta Systems, Inc.
- # All rights reserved.
- #
- use File::Basename;
- use Test::More no_plan;
- use strict;
- #Script paramatrs
- my $vol="data";
- my $folder="folder";
- my $lun="c1t2d0";
- my $vol2="vol2";
- my $zvol="z1";
- my $test_ip1="192.168.100.1";
- my $test_ip2="192.168.100.2";
- my $cmd_list;
- my $name="d".$$;
- sub check_result {
- my ($cmd, $err, $expr) = @_;
- #if expression set do comparing
- my @arr=`nmc -c "$cmd" 2>/dev/null`;
- my $e=$?;
- if($err!=0) {
- ok($e, "*****Command \"$cmd\" is expected to fail with error: $e");
- } else {
- is($err, $e, "****Command \"$cmd\" should be executed without errors: $e");
- }
- return if (!$expr);
- $expr=qr/$expr/;
- my $c = grep (/$expr/, @arr);
- ok ($c, "Check \"$cmd\" command")
- }
- sub do_tests {
- my $tests=shift;
- my @commands = ();
- for my $command (split (/\n+/, $cmd_list)) {
- #skip all comments
- next if ($command=~/^#/);
- push @commands, $command;
- }
- #How much test will run from end
- if (defined $tests) { my @arr; for (my $i=(scalar(@commands)-$tests); $i<scalar(@commands); $i++)
- { push @arr, $commands[$i] } @commands=@arr};
- for my $command (@commands) { my @arr=split /#/, $command; check_result (@arr);}
- }
- $cmd_list="##
- ##help
- ##
- help#0#Nexenta Management Console
- help data-replication#0#Data Replication
- help first-steps#0#First Steps
- help keyword#0#NMC keywords
- help options#0#Options
- help tips#0#Tips
- help advanced-usage#0#Advanced Usage
- help dtrace#0#DTrace
- help getting-started#0#Welcome to Nexenta
- help more-help#0#More Help
- help runners#0#Runners
- help commands#0#Commands
- help fault-management#0#Fault Management
- help index#0#Indexing and Searching Archives
- help navigation#0#Navigation
- help terms#0#Term
- ##
- ##appliance authentication
- ##
- ##setup appliance authentication dbus-iptable add allow $test_ip1#0#allow\\s+$test_ip1
- setup appliance authentication dbus-iptable add allow $test_ip1#1#allow\\s+$test_ip1
- show appliance authentication dbus-iptable#0#$test_ip1
- setup appliance authentication dbus-iptable delete $test_ip1#0#Deleted.*$test_ip1
- setup appliance authentication dbus-iptable delete $test_ip1#1#Deleted.*$test_ip1
- setup appliance authentication keys add -k 12345 -v 54321#0#12345
- setup appliance authentication keys add -k 12345 -v 54321#1
- show appliance authentication keys#0#12345
- setup appliance authentication keys delete 12345#0#12345
- setup appliance authentication keys delete 12345#1
- ##
- ##appliance hostname
- ##
- setup appliance hostname testhostname -y#0#testhostname
- setup appliance hostname testhostname -y#1
- show appliance hostname#0#testhostname
- setup appliance hostname hostname -y#0
- ##
- ##setup appliance mailer
- ##
- setup appliance mailer smtp_addresses_faults -p test\@test1.ru#0#smtp_addresses_faults
- setup appliance mailer smtp_addresses_faults -p test\@test1.ru#1
- show appliance mailer#0#test\@test1.ru
- setup appliance mailer smtp_addresses_faults -p support\@nexenta.com#0
- setup appliance mailer smtp_to -p test\@test2.ru#0#smtp_to
- setup appliance mailer smtp_to -p test\@test2.ru#1
- show appliance mailer#0#smtp_to.*test\@test2.ru
- setup appliance mailer smtp_to -p support\@nexenta.com#0
- setup appliance mailer smtp_password -p 12345#0#smtp_password
- setup appliance mailer smtp_password -p 12345#1
- show appliance mailer#0#smtp_password.*xxxxx
- setup appliance mailer smtp_password -p none#0
- setup appliance mailer smtp_addresses -p test\@test3.ru#0#smtp_addresses
- setup appliance mailer smtp_addresses -p test\@test3.ru#1
- show appliance mailer#0#smtp_addresses.*test\@test3.ru
- setup appliance mailer smtp_addresses -p root\@localhost.ru#0#smtp_addresses
- setup appliance mailer smtp_auth -p SSL#0#smtp_auth
- setup appliance mailer smtp_auth -p SSL#1
- show appliance mailer#0#smtp_auth.*SSL
- setup appliance mailer smtp_auth -p Plain#0
- setup appliance mailer smtp_auth -p SSL#0#smtp_auth
- setup appliance mailer smtp_auth -p SSL#1
- show appliance mailer#0#smtp_auth.*SSL
- setup appliance mailer smtp_auth -p Plain#0
- setup appliance mailer smtp_timeout -p 31#0#smtp_timeout
- setup appliance mailer smtp_timeout -p 31#1
- show appliance mailer#0#smtp_timeout.*3
- setup appliance mailer smtp_timeout -p 30#0
- setup appliance mailer smtp_addresses_stats -p test\@test5.ru#0#smtp_addresses_stats
- setup appliance mailer smtp_addresses_stats -p test\@test5.ru#1
- show appliance mailer#0#smtp_addresses_stats.*test\@test5.ru
- setup appliance mailer smtp_addresses_stats -p root\@localhost.ru#0#smtp_addresses_stats
- setup appliance mailer smtp_cc -p test\@test6.ru#0#smtp_cc
- setup appliance mailer smtp_cc -p test\@test6.ru#1
- show appliance mailer#0#smtp_cc.*test\@test6.ru
- setup appliance mailer smtp_cc -p root\@localhost.ru#0#smtp_cc
- setup appliance mailer smtp_user -p test\@test7.ru#0#smtp_user
- setup appliance mailer smtp_user -p test\@test7.ru#1
- show appliance mailer#0#smtp_user.*test\@test7.ru
- setup appliance mailer smtp_user -p root\@localhost.ru#0#smtp_user
- setup appliance mailer smtp_server -p 127.0.0.1#0#smtp_server
- setup appliance mailer smtp_server -p 127.0.0.1#1
- show appliance mailer#0#smtp_server.*127\.0\.0\.1\
- setup appliance mailer smtp_server -p localhost#0#smtp_server
- setup appliance mailer smtp_from -p test\@test8.ru#0#smtp_from
- setup appliance mailer smtp_from -p test\@test8.ru#1
- show appliance mailer#0#smtp_from.*test\@test8.ru
- setup appliance mailer smtp_from -p root\@localhost.ru#0#smtp_from
- ##
- ##appliance nms
- ##
- show appliance nms locks#0
- show appliance nms log#0#Starting
- show appliance nms logtail#0
- show appliance nms property#0#PROPERTY
- show appliance nms svclog#0#start
- show appliance nms property#0#trace_level
- show appliance nms config#0#NMS
- setup appliance nms pool add#0#Added
- show appliance nms pool#0#active
- ##
- ##appliance swap
- ##
- create zvol $vol/$zvol -s 1M -b 128K -c on -y#0#$vol\/$zvol
- setup appliance swap add -y $vol/$zvol#0#$vol\/$zvol
- setup appliance swap add -y $vol/$zvol#1
- show appliance swap#0#$vol\/$zvol
- setup appliance swap delete $vol/$zvol#0#$vol\/$zvol
- setup appliance swap delete $vol/$zvol#1
- setup zvol $vol/$zvol destroy -y#0
- ##
- ##appliance usergroup
- ##
- show appliance usergroup#0#staff
- ##
- ##show appliance autoservices
- ##
- setup auto-snap create -i minute -p 10 -y -k 1 -r -I h#0#$vol
- show auto-snap#0#$vol
- show appliance auto-services#0#$vol.*auto-snap
- setup auto-snap destroy -y#0
- setup auto-snap destroy -y#1
- ##
- ##Other show*
- ##
- show appliance hosts#0#localhost
- show appliance memory#0#total
- show appliance repository#0#deb
- show appliance sysdef#0#Device
- show appliance uuid#0#-
- show appliance checkpoint#0rootfs
- show appliance netmasks#0#CDDL HEADER START
- show appliance runners#0#enabled
- show appliance sysinfo#0#domainname
- show appliance license#0#Machine Signature
- show appliance domainname#0#w\.w
- show appliance uptime#0#uptime
- show appliance version#0#NMS
- show appliance saved-configs#NULL#0
- show appliance syslog dmesg#0#kern\.info
- show appliance nmc#0#NMC
- show faults all-appliances#0#localhost
- show appliance user#0#root
- show appliance user none#1
- ##
- ##save configuration
- ##
- setup appliance configuration save -d $name -y#0#saved
- setup appliance configuration save -d $name -y#1
- show appliance saved-configs#0#$name
- ##
- ##folder
- ##
- create folder $vol/$folder -y#0#$vol/$folder
- create folder $vol/$folder -y#1
- show folder $vol/$folder#0#$vol/$folder
- show folder#0#$vol/$folder
- show folder no_folder#1
- destroy folder $vol/$folder -y#0
- destroy folder $vol/$folder -y#1
- ##
- ##network gatateway
- ##
- setup network gateway -g $test_ip1#0
- show network gateway#0#$test_ip1
- ##
- ##network nameservers
- ##
- setup network nameservers -1 $test_ip1 -2 $test_ip2 -3 $test_ip1#0
- show network nameservers $test_ip1#0#$test_ip1
- ##
- ##network other
- ##
- show network all-faults#0#localhost
- show network devices#0#LINK
- show network interface#0#Interfaces
- show network routes#0#\.0\.0\.0
- ##
- ##network service ftp-server
- ##
- setup network service ftp-server show#0#state.*disabled
- setup network service ftp-server enable#0
- setup network service ftp-server enable#1
- setup network service ftp-server show#0#state.*enabled
- setup network service ftp-server disable#0
- setup network service ftp-server disable#1
- setup network service ftp-server confcheck#0#disable
- ##
- ##network cifs server
- ##
- setup network service cifs-server show#0#state.*disabled
- setup network service cifs-server enable#0
- setup network service cifs-server enable#1
- sleep 10#0
- setup network service cifs-server show#0#state.*online
- setup network service cifs-server confcheck#0#online
- setup network service cifs-server disable#0
- setup network service cifs-server disable#1
- setup network service cifs-server confcheck#0#disable
- ##
- ##network hal-daemon
- ##
- setup network service hal-daemon show#0#state.*online
- setup network service hal-daemon enable#1
- setup network service hal-daemon disable#0
- setup network service hal-daemon disable#1
- setup network service hal-daemon confcheck#0#disable
- setup network service hal-daemon enable#0
- ##
- ##network rr-daemon
- ##
- ";
- &do_tests();
- 1;
Add Comment
Please, Sign In to add comment