Guest User

Untitled

a guest
Nov 19th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.98 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. #
  4. # Copyright (C) 2006-2010 Nexenta Systems, Inc.
  5. # All rights reserved.
  6. #
  7.  
  8. use File::Basename;
  9. use Test::More no_plan;
  10. use strict;
  11.  
  12. #Script paramatrs
  13. my $vol="data";
  14. my $folder="folder";
  15. my $lun="c1t2d0";
  16. my $vol2="vol2";
  17. my $zvol="z1";
  18. my $test_ip1="192.168.100.1";
  19. my $test_ip2="192.168.100.2";
  20. my $cmd_list;
  21. my $name="d".$$;
  22.  
  23.  
  24. sub check_result {
  25. my ($cmd, $err, $expr) = @_;
  26. #if expression set do comparing
  27. my @arr=`nmc -c "$cmd" 2>/dev/null`;
  28. my $e=$?;
  29. if($err!=0) {
  30. ok($e, "*****Command \"$cmd\" is expected to fail with error: $e");
  31. } else {
  32. is($err, $e, "****Command \"$cmd\" should be executed without errors: $e");
  33. }
  34. return if (!$expr);
  35. $expr=qr/$expr/;
  36. my $c = grep (/$expr/, @arr);
  37. ok ($c, "Check \"$cmd\" command")
  38. }
  39.  
  40. sub do_tests {
  41. my $tests=shift;
  42. my @commands = ();
  43. for my $command (split (/\n+/, $cmd_list)) {
  44. #skip all comments
  45. next if ($command=~/^#/);
  46. push @commands, $command;
  47. }
  48. #How much test will run from end
  49. if (defined $tests) { my @arr; for (my $i=(scalar(@commands)-$tests); $i<scalar(@commands); $i++)
  50. { push @arr, $commands[$i] } @commands=@arr};
  51. for my $command (@commands) { my @arr=split /#/, $command; check_result (@arr);}
  52. }
  53.  
  54.  
  55.  
  56.  
  57. $cmd_list="##
  58. ##help
  59. ##
  60. help#0#Nexenta Management Console
  61. help data-replication#0#Data Replication
  62. help first-steps#0#First Steps
  63. help keyword#0#NMC keywords
  64. help options#0#Options
  65. help tips#0#Tips
  66. help advanced-usage#0#Advanced Usage
  67. help dtrace#0#DTrace
  68. help getting-started#0#Welcome to Nexenta
  69. help more-help#0#More Help
  70. help runners#0#Runners
  71. help commands#0#Commands
  72. help fault-management#0#Fault Management
  73. help index#0#Indexing and Searching Archives
  74. help navigation#0#Navigation
  75. help terms#0#Term
  76. ##
  77. ##appliance authentication
  78. ##
  79. ##setup appliance authentication dbus-iptable add allow $test_ip1#0#allow\\s+$test_ip1
  80. setup appliance authentication dbus-iptable add allow $test_ip1#1#allow\\s+$test_ip1
  81. show appliance authentication dbus-iptable#0#$test_ip1
  82. setup appliance authentication dbus-iptable delete $test_ip1#0#Deleted.*$test_ip1
  83. setup appliance authentication dbus-iptable delete $test_ip1#1#Deleted.*$test_ip1
  84. setup appliance authentication keys add -k 12345 -v 54321#0#12345
  85. setup appliance authentication keys add -k 12345 -v 54321#1
  86. show appliance authentication keys#0#12345
  87. setup appliance authentication keys delete 12345#0#12345
  88. setup appliance authentication keys delete 12345#1
  89. ##
  90. ##appliance hostname
  91. ##
  92. setup appliance hostname testhostname -y#0#testhostname
  93. setup appliance hostname testhostname -y#1
  94. show appliance hostname#0#testhostname
  95. setup appliance hostname hostname -y#0
  96. ##
  97. ##setup appliance mailer
  98. ##
  99. setup appliance mailer smtp_addresses_faults -p test\@test1.ru#0#smtp_addresses_faults
  100. setup appliance mailer smtp_addresses_faults -p test\@test1.ru#1
  101. show appliance mailer#0#test\@test1.ru
  102. setup appliance mailer smtp_addresses_faults -p support\@nexenta.com#0
  103. setup appliance mailer smtp_to -p test\@test2.ru#0#smtp_to
  104. setup appliance mailer smtp_to -p test\@test2.ru#1
  105. show appliance mailer#0#smtp_to.*test\@test2.ru
  106. setup appliance mailer smtp_to -p support\@nexenta.com#0
  107. setup appliance mailer smtp_password -p 12345#0#smtp_password
  108. setup appliance mailer smtp_password -p 12345#1
  109. show appliance mailer#0#smtp_password.*xxxxx
  110. setup appliance mailer smtp_password -p none#0
  111. setup appliance mailer smtp_addresses -p test\@test3.ru#0#smtp_addresses
  112. setup appliance mailer smtp_addresses -p test\@test3.ru#1
  113. show appliance mailer#0#smtp_addresses.*test\@test3.ru
  114. setup appliance mailer smtp_addresses -p root\@localhost.ru#0#smtp_addresses
  115. setup appliance mailer smtp_auth -p SSL#0#smtp_auth
  116. setup appliance mailer smtp_auth -p SSL#1
  117. show appliance mailer#0#smtp_auth.*SSL
  118. setup appliance mailer smtp_auth -p Plain#0
  119. setup appliance mailer smtp_auth -p SSL#0#smtp_auth
  120. setup appliance mailer smtp_auth -p SSL#1
  121. show appliance mailer#0#smtp_auth.*SSL
  122. setup appliance mailer smtp_auth -p Plain#0
  123. setup appliance mailer smtp_timeout -p 31#0#smtp_timeout
  124. setup appliance mailer smtp_timeout -p 31#1
  125. show appliance mailer#0#smtp_timeout.*3
  126. setup appliance mailer smtp_timeout -p 30#0
  127. setup appliance mailer smtp_addresses_stats -p test\@test5.ru#0#smtp_addresses_stats
  128. setup appliance mailer smtp_addresses_stats -p test\@test5.ru#1
  129. show appliance mailer#0#smtp_addresses_stats.*test\@test5.ru
  130. setup appliance mailer smtp_addresses_stats -p root\@localhost.ru#0#smtp_addresses_stats
  131. setup appliance mailer smtp_cc -p test\@test6.ru#0#smtp_cc
  132. setup appliance mailer smtp_cc -p test\@test6.ru#1
  133. show appliance mailer#0#smtp_cc.*test\@test6.ru
  134. setup appliance mailer smtp_cc -p root\@localhost.ru#0#smtp_cc
  135. setup appliance mailer smtp_user -p test\@test7.ru#0#smtp_user
  136. setup appliance mailer smtp_user -p test\@test7.ru#1
  137. show appliance mailer#0#smtp_user.*test\@test7.ru
  138. setup appliance mailer smtp_user -p root\@localhost.ru#0#smtp_user
  139. setup appliance mailer smtp_server -p 127.0.0.1#0#smtp_server
  140. setup appliance mailer smtp_server -p 127.0.0.1#1
  141. show appliance mailer#0#smtp_server.*127\.0\.0\.1\
  142. setup appliance mailer smtp_server -p localhost#0#smtp_server
  143. setup appliance mailer smtp_from -p test\@test8.ru#0#smtp_from
  144. setup appliance mailer smtp_from -p test\@test8.ru#1
  145. show appliance mailer#0#smtp_from.*test\@test8.ru
  146. setup appliance mailer smtp_from -p root\@localhost.ru#0#smtp_from
  147. ##
  148. ##appliance nms
  149. ##
  150. show appliance nms locks#0
  151. show appliance nms log#0#Starting
  152. show appliance nms logtail#0
  153. show appliance nms property#0#PROPERTY
  154. show appliance nms svclog#0#start
  155. show appliance nms property#0#trace_level
  156. show appliance nms config#0#NMS
  157. setup appliance nms pool add#0#Added
  158. show appliance nms pool#0#active
  159. ##
  160. ##appliance swap
  161. ##
  162. create zvol $vol/$zvol -s 1M -b 128K -c on -y#0#$vol\/$zvol
  163. setup appliance swap add -y $vol/$zvol#0#$vol\/$zvol
  164. setup appliance swap add -y $vol/$zvol#1
  165. show appliance swap#0#$vol\/$zvol
  166. setup appliance swap delete $vol/$zvol#0#$vol\/$zvol
  167. setup appliance swap delete $vol/$zvol#1
  168. setup zvol $vol/$zvol destroy -y#0
  169. ##
  170. ##appliance usergroup
  171. ##
  172. show appliance usergroup#0#staff
  173. ##
  174. ##show appliance autoservices
  175. ##
  176. setup auto-snap create -i minute -p 10 -y -k 1 -r -I h#0#$vol
  177. show auto-snap#0#$vol
  178. show appliance auto-services#0#$vol.*auto-snap
  179. setup auto-snap destroy -y#0
  180. setup auto-snap destroy -y#1
  181. ##
  182. ##Other show*
  183. ##
  184. show appliance hosts#0#localhost
  185. show appliance memory#0#total
  186. show appliance repository#0#deb
  187. show appliance sysdef#0#Device
  188. show appliance uuid#0#-
  189. show appliance checkpoint#0rootfs
  190. show appliance netmasks#0#CDDL HEADER START
  191. show appliance runners#0#enabled
  192. show appliance sysinfo#0#domainname
  193. show appliance license#0#Machine Signature
  194. show appliance domainname#0#w\.w
  195. show appliance uptime#0#uptime
  196. show appliance version#0#NMS
  197. show appliance saved-configs#NULL#0
  198. show appliance syslog dmesg#0#kern\.info
  199. show appliance nmc#0#NMC
  200. show faults all-appliances#0#localhost
  201. show appliance user#0#root
  202. show appliance user none#1
  203. ##
  204. ##save configuration
  205. ##
  206. setup appliance configuration save -d $name -y#0#saved
  207. setup appliance configuration save -d $name -y#1
  208. show appliance saved-configs#0#$name
  209. ##
  210. ##folder
  211. ##
  212. create folder $vol/$folder -y#0#$vol/$folder
  213. create folder $vol/$folder -y#1
  214. show folder $vol/$folder#0#$vol/$folder
  215. show folder#0#$vol/$folder
  216. show folder no_folder#1
  217. destroy folder $vol/$folder -y#0
  218. destroy folder $vol/$folder -y#1
  219. ##
  220. ##network gatateway
  221. ##
  222. setup network gateway -g $test_ip1#0
  223. show network gateway#0#$test_ip1
  224. ##
  225. ##network nameservers
  226. ##
  227. setup network nameservers -1 $test_ip1 -2 $test_ip2 -3 $test_ip1#0
  228. show network nameservers $test_ip1#0#$test_ip1
  229. ##
  230. ##network other
  231. ##
  232. show network all-faults#0#localhost
  233. show network devices#0#LINK
  234. show network interface#0#Interfaces
  235. show network routes#0#\.0\.0\.0
  236. ##
  237. ##network service ftp-server
  238. ##
  239. setup network service ftp-server show#0#state.*disabled
  240. setup network service ftp-server enable#0
  241. setup network service ftp-server enable#1
  242. setup network service ftp-server show#0#state.*enabled
  243. setup network service ftp-server disable#0
  244. setup network service ftp-server disable#1
  245. setup network service ftp-server confcheck#0#disable
  246. ##
  247. ##network cifs server
  248. ##
  249. setup network service cifs-server show#0#state.*disabled
  250. setup network service cifs-server enable#0
  251. setup network service cifs-server enable#1
  252. sleep 10#0
  253. setup network service cifs-server show#0#state.*online
  254. setup network service cifs-server confcheck#0#online
  255. setup network service cifs-server disable#0
  256. setup network service cifs-server disable#1
  257. setup network service cifs-server confcheck#0#disable
  258. ##
  259. ##network hal-daemon
  260. ##
  261. setup network service hal-daemon show#0#state.*online
  262. setup network service hal-daemon enable#1
  263. setup network service hal-daemon disable#0
  264. setup network service hal-daemon disable#1
  265. setup network service hal-daemon confcheck#0#disable
  266. setup network service hal-daemon enable#0
  267. ##
  268. ##network rr-daemon
  269. ##
  270. ";
  271.  
  272. &do_tests();
  273.  
  274. 1;
Add Comment
Please, Sign In to add comment