1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * 26 * ident "@(#)iscsiadmMultiNodeTestSuite.java 1.5 08/10/16 SMI" 27 */ 28 29 package com.sun.jist.command.test; 30 import com.sun.jist.command.iscsiadmData; 31 import com.sun.jist.command.iscsiadmLogic; 32 import com.sun.jist.JISTAgent; 33 import com.sun.jist.JISTData; 34 import com.sun.jist.JISTLogic; 35 import com.sun.jist.JISTRemoteLogic; 36 import com.sun.jist.util.test.AgentInit; 37 import com.sun.jist.util.test.AgentMonitor; 38 import com.sun.jist.util.test.AgentPersist; 39 40 /** 41 * JIST Sun Solaris[tm] 10 & 11 iscsiadm(1M) Command Line Interface "Discovery" 42 * SubCommand Test Cases. 43 * <p> 44 * Verifies Compliance to Sun Microsystem iSCSI CLI Specification. 45 * <p> 46 * @author Nigusu.Teshale (at) Sun.COM 47 * @since 5.0 48 */ 49 public class iscsiadmMultiNodeTestSuite extends JISTRemoteLogic { 50 51 public iscsiadmMultiNodeTestSuite() { 52 setBranch("iscsiadm"); 53 } 54 55 /** 56 * Method used to detect offshoot Test Branches. 57 * <p> 58 * All methods with signature 59 * "<FONT SIZE="-1"><CODE>public void test*(void)</CODE></FONT>" in this class 60 * or this class' parent classes are automatically detected. 61 * <p> 62 * @see JISTLogic#getTree(String) 63 * @see JISTLogic#getTree(String[]) 64 */ 65 public static String[] getTree() { 66 return getTree("com.sun.jist.command.test.iscsiadmMultiNodeTestSuite"); 67 } 68 69 /** 70 * Method to test send target discovery method. 71 * <p> 72 * {@link JISTData#JIST_MANDATORY Sun Mandatory} Test Branch. 73 * <p> 74 * This test validates the behaviour of the iSCSI driver sendtarget discovery. 75 * <p> 76 * Test Step: 77 * Adding the iSCSI target discovery address using sendtarget. 78 * Enable discovery method. 79 * Perform "devfsadm -i iscsi" command. 80 * Rebooted the host with discovery method enabled. 81 * Disable discovery method. 82 * Rebooted the host with discovery method disabled. 83 * <p> 84 * Expected Result: 85 * Target discovery address should be added successfully. 86 * Discovery method enabled and disable successfully. 87 * Ensure target is not discovered after target name added. 88 * Ensure target is not discovered after discovery method enabled. 89 * After the devfsadm command, ensure target is discovered suceessfully 90 * with sendtarget discovery method. 91 * Ensure target is discovered after the host is rebooted with discovery 92 * method enabled. 93 * Ensure target is not discovered after the host is rebooted with 94 * discovery method disabled. 95 * Ensure no connection made after the host is rebooted with discovery 96 * method disabled. 97 * Ensure target discovery address removed successfully. 98 */ 99 public void testSendTargetDiscovery1() { 100 setLeaf(getBranch(), "sendtarget discovery test"); 101 assertBypass("Sun Mandatory Test Branch", 102 ((testLevel & JISTData.JIST_MANDATORY) == 0)); 103 104 barrierTest("Persist the paths onto their respective persistence", 105 "com.sun.jist.util.test.AgentPersist persistAction=" + 106 AgentPersist.PERSIST_ACTION.getInt("ADD")); 107 108 barrierTest("Remove if any iSCSI configuration exist.", 109 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 110 " targetPort=" + targetPort + " confID=7"); 111 112 rebootHost(); 113 114 barrierTest("Add target discovery address and verify discovery.", 115 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 116 " targetPort=" + targetPort + " confID=0"); 117 118 barrierTest("Enable discovery address and verify target discovery.", 119 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 120 " targetPort=" + targetPort + " confID=1"); 121 122 barrierTest("Run devfsadm command and verify target is discovered.", 123 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 124 " targetPort=" + targetPort + " confID=3"); 125 126 rebootHost(); 127 128 barrierTest("Verify the target after the iSCSI host rebooted.", 129 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 130 " targetPort=" + targetPort + " confID=9"); 131 132 barrierTest("Disable discovery methods and verify discovered target.", 133 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 134 " targetPort=" + targetPort + " confID=2"); 135 136 rebootHost(); 137 138 barrierTest("Verify no target discovered after reboot.", 139 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 140 " targetPort=" + targetPort + " confID=8"); 141 142 barrierTest("Remove any iSCSI configuration.", 143 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 144 " targetPort=" + targetPort + " confID=7"); 145 146 barrierTest("Remove the agents from persistence", 147 "com.sun.jist.util.test.AgentPersist persistAction=" + 148 AgentPersist.PERSIST_ACTION.getInt("REMOVE")); 149 assertTrue(passfailBoolean); 150 } 151 152 /** 153 * Method to test send target discovery method. 154 * <p> 155 * {@link JISTData#JIST_MANDATORY Sun Mandatory} Test Branch. 156 * <p> 157 * This test validates the behaviour of the iSCSI driver sendtarget discovery. 158 * <p> 159 * Test Step: 160 * Adding the iSCSI target discovery address using sendtarget. 161 * Enable discovery method. 162 * "devfsadm -i iscsi" command will not be run. 163 * Rebooted the host with discovery method enabled. 164 * Disable discovery method. 165 * Rebooted the host with discovery method disabled. 166 * <p> 167 * Expected Result: 168 * Target discovery address should be added successfully. 169 * Discovery method enabled and disable successfully. 170 * Ensure target is not discovered after target name added. 171 * Ensure target is not discovered after discovery method enabled. 172 * Ensure target is discovered after the host is rebooted with discovery 173 * method enabled. 174 * Ensure target is not discovered after the host is rebooted with 175 * discovery method disabled. 176 * Ensure no connection made after the host is rebooted with discovery 177 * method disabled. 178 */ 179 public void testSendTargetDiscovery2() { 180 setLeaf(getBranch(), "sendtarget discovery after host reboot test"); 181 assertBypass("Sun Mandatory Test Branch", 182 ((testLevel & JISTData.JIST_MANDATORY) == 0)); 183 184 barrierTest("Persist the paths onto their respective persistence", 185 "com.sun.jist.util.test.AgentPersist persistAction=" + 186 AgentPersist.PERSIST_ACTION.getInt("ADD")); 187 188 barrierTest("Remove if any iSCSI configuration exist.", 189 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 190 " targetPort=" + targetPort + " confID=7"); 191 192 rebootHost(); 193 194 barrierTest("Add target discovery-address and verify discovery", 195 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 196 " targetPort=" + targetPort + " confID=0"); 197 198 barrierTest("Enable discovery address and no target discovered.", 199 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 200 " targetPort=" + targetPort + " confID=1"); 201 202 rebootHost(); 203 204 barrierTest("Verify if target is discovered after reboot.", 205 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 206 " targetPort=" + targetPort + " confID=9"); 207 208 barrierTest("Disable discovery methods verify no target discovered.", 209 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 210 " targetPort=" + targetPort + " confID=2"); 211 212 rebootHost(); 213 214 barrierTest("Verify if not target discovered after reboot.", 215 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 216 " targetPort=" + targetPort + " confID=8"); 217 218 barrierTest("Remove any iSCSI configuration.", 219 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 220 " targetPort=" + targetPort + " confID=7"); 221 222 barrierTest("Remove the agents from persistence", 223 "com.sun.jist.util.test.AgentPersist persistAction=" + 224 AgentPersist.PERSIST_ACTION.getInt("REMOVE")); 225 assertTrue(passfailBoolean); 226 } 227 228 /** 229 * Method to test static-config discovery method. 230 * <p> 231 * {@link JISTData#JIST_MANDATORY Sun Mandatory} Test Branch. 232 * <p> 233 * This test validates the behaviour of the iSCSI driver static-config 234 * discovery. 235 * <p> 236 * Test Step: 237 * Adding the iSCSI target discovery address using static-config. 238 * Enable discovery method. 239 * Perform "devfsadm -i iscsi" command. 240 * Rebooted the host with discovery method enabled. 241 * Disable discovery method. 242 * Rebooted the host with discovery method disabled. 243 * <p> 244 * Expected Result: 245 * Target discovery address should be added successfully. 246 * Discovery method enabled and disable successfully. 247 * Ensure target is not discovered after target name added. 248 * Ensure target is not discovered after discovery method enabled. 249 * After the devfsadm command, ensure target is discovered suceessfully 250 * with static-config discovery method. 251 * Ensure target is discovered after the host is rebooted with discovery 252 * method enabled. 253 * Ensure target is not discovered after the host is rebooted with 254 * discovery method disabled. 255 * Ensure no connection made after the host is rebooted with discovery 256 * method disabled. 257 * Ensure target discovery name removed successfully. 258 */ 259 public void testStaticConfigDiscovery1() { 260 setLeaf(getBranch(), "static-config discovery test"); 261 assertBypass("Sun Mandatory Test Branch", 262 ((testLevel & JISTData.JIST_MANDATORY) == 0)); 263 264 barrierTest("Persist the paths onto their respective persistence", 265 "com.sun.jist.util.test.AgentPersist persistAction=" + 266 AgentPersist.PERSIST_ACTION.getInt("ADD")); 267 268 barrierTest("Remove if any iSCSI configuration exist.", 269 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 270 " targetPort=" + targetPort + " confID=7"); 271 272 rebootHost(); 273 274 barrierTest("Add static-config name, verify and discovery.", 275 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 276 " targetPort=" + targetPort + " confID=4"); 277 278 barrierTest("Enable discovery address and verify target discovery.", 279 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 280 " targetPort=" + targetPort + " confID=5"); 281 282 barrierTest("Run devfsadm command and verify target discovery.", 283 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 284 " targetPort=" + targetPort + " confID=3"); 285 286 rebootHost(); 287 288 barrierTest("Verify the target discovered after reboot.", 289 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 290 " targetPort=" + targetPort + " confID=9"); 291 292 barrierTest("Disable discovery methods and verify target.", 293 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 294 " targetPort=" + targetPort + " confID=6"); 295 296 rebootHost(); 297 298 barrierTest("Verify target after discovery disabled ane host rebooted.", 299 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 300 " targetPort=" + targetPort + " confID=8"); 301 302 barrierTest("Remove iSCSI configuration.", 303 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 304 " targetPort=" + targetPort + " confID=7"); 305 306 barrierTest("Remove the agents from persistence", 307 "com.sun.jist.util.test.AgentPersist persistAction=" + 308 AgentPersist.PERSIST_ACTION.getInt("REMOVE")); 309 assertTrue(passfailBoolean); 310 } 311 312 /** 313 * Method to test static-config discovery method. 314 * <p> 315 * {@link JISTData#JIST_MANDATORY Sun Mandatory} Test Branch. 316 * <p> 317 * This test validates the behaviour of the iSCSI driver static-config 318 * discovery. 319 * <p> 320 * Test Step: 321 * Adding the iSCSI target discovery address using static-config. 322 * Enable discovery method. 323 * "devfsadm -i iscsi" command will not be run. 324 * Rebooted the host with discovery method enabled. 325 * Disable discovery method. 326 * Rebooted the host with discovery method disabled. 327 * <p> 328 * Expected Result: 329 * Target discovery static discovery name should be added successfully. 330 * Discovery method enabled and disable successfully. 331 * Ensure target is not discovered after target name added. 332 * Ensure target is not discovered after discovery method enabled. 333 * Ensure target is discovered after the host is rebooted with discovery 334 * method enabled. 335 * Ensure no connection made after the host is rebooted with discovery 336 * method disabled. 337 */ 338 public void testStaticConfigDiscovery2() { 339 setLeaf(getBranch(), "static-config discovery test"); 340 assertBypass("Sun Mandatory Test Branch", 341 ((testLevel & JISTData.JIST_MANDATORY) == 0)); 342 343 barrierTest("Persist the paths onto their respective persistence", 344 "com.sun.jist.util.test.AgentPersist persistAction=" + 345 AgentPersist.PERSIST_ACTION.getInt("ADD")); 346 347 barrierTest("Remove if any iSCSI configuration exist.", 348 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 349 " targetPort=" + targetPort + " confID=7"); 350 351 rebootHost(); 352 353 barrierTest("Add target static-config name and verify discovery.", 354 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 355 " targetPort=" + targetPort + " confID=4"); 356 357 barrierTest("Enable discovery address and verify target discovery.", 358 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 359 " targetPort=" + targetPort + " confID=5"); 360 361 rebootHost(); 362 363 barrierTest("Verify target after discovery enable and host rebooted.", 364 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 365 " targetPort=" + targetPort + " confID=9"); 366 367 barrierTest("Disable discovery methods and verify target.", 368 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 369 " targetPort=" + targetPort + " confID=6"); 370 371 rebootHost(); 372 373 barrierTest("Verify target after discovery disabled and host rebooted.", 374 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 375 " targetPort=" + targetPort + " confID=8"); 376 377 barrierTest("Remove iSCSI configuration.", 378 "com.sun.jist.command.test.iscsiadmGeneric targetIP=" + targetIP + 379 " targetPort=" + targetPort + " confID=7"); 380 381 barrierTest("Remove the agents from persistence", 382 "com.sun.jist.util.test.AgentPersist persistAction=" + 383 AgentPersist.PERSIST_ACTION.getInt("REMOVE")); 384 assertTrue(passfailBoolean); 385 } 386 387 /** 388 * Method to reboot host 389 * <p> 390 * This method will reboot the host that being under test and it will wait 391 * until the host come back for reasonable amount of time. After the host 392 * successfully rebooted, new socket connection will be made. 393 */ 394 public void rebootHost() { 395 barrierTest("Reboot host", 396 "com.sun.jist.util.test.AgentInit initLevel=6"); 397 try { 398 Thread.currentThread().sleep(20000); 399 } catch (InterruptedException ie) {} 400 401 /** while the host rebooted. */ 402 while (!agentMonitor.checkAll()) { 403 try { 404 Thread.currentThread().sleep(2000); 405 } catch (InterruptedException ie) {} 406 } 407 } 408 409 } /* Class End */ 410