Commit 877eead9 authored by lichenchong's avatar lichenchong
Browse files

Modify AdminAPISanityTest for chassis test.

parent 8f2a4c39
Loading
Loading
Loading
Loading
+36 −72
Original line number Diff line number Diff line
@@ -31,14 +31,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;

import kinetic.admin.ACL;
import kinetic.admin.AdminClientConfiguration;
import kinetic.admin.Capacity;
import kinetic.admin.Configuration;
import kinetic.admin.Device;
import kinetic.admin.Domain;
import kinetic.admin.Interface;
import kinetic.admin.KineticAdminClient;
import kinetic.admin.KineticAdminClientFactory;
import kinetic.admin.KineticLog;
import kinetic.admin.KineticLogType;
import kinetic.admin.Limits;
@@ -48,15 +46,12 @@ import kinetic.admin.Temperature;
import kinetic.admin.Utilization;
import kinetic.client.EntryNotFoundException;
import kinetic.client.KineticException;
import kinetic.simulator.KineticSimulator;
import kinetic.simulator.SimulatorConfiguration;

import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.google.protobuf.ByteString;
import com.seagate.kinetic.IntegrationTestCase;
import com.seagate.kinetic.IntegrationTestLoggerFactory;
import com.seagate.kinetic.client.internal.MessageFactory;
import com.seagate.kinetic.common.lib.KineticMessage;
@@ -86,45 +81,9 @@ import com.seagate.kinetic.proto.Kinetic.Command.Status.StatusCode;
 * 
 */
@Test(groups = { "simulator", "drive" })
public class AdminAPISanityTest {
public class AdminAPISanityTest extends IntegrationTestCase {
	private static final Logger logger = IntegrationTestLoggerFactory
			.getLogger(AdminAPISanityTest.class.getName());
	private SimulatorConfiguration sc;
	private KineticSimulator simulator;
	private AdminClientConfiguration acc;
	private KineticAdminClient adminClient;
	private Boolean runAgainstExternal = false;

	@BeforeClass
	public void beforeClass() throws KineticException {
		String host = System.getProperty("KINETIC_HOST", "localhost");
		int port = Integer.parseInt(System.getProperty("KINETIC_SSL_PORT",
				"8443"));
		runAgainstExternal = Boolean.parseBoolean(System
				.getProperty("RUN_AGAINST_EXTERNAL"));
		if (!runAgainstExternal) {
			sc = new SimulatorConfiguration();
			simulator = new KineticSimulator(sc);
		}

		acc = new AdminClientConfiguration();
		acc.setHost(host);
		acc.setPort(port);
		adminClient = KineticAdminClientFactory.createInstance(acc);
	}

	@AfterClass
	public void afterClass() throws KineticException {
		adminClient.close();
		if (!runAgainstExternal) {
			simulator.close();
		}
	}

	// @BeforeMethod
	// public void beforeMethod() throws KineticException {
	// adminClient.secureErase("123".getBytes(Charset.forName("UTF-8")));;
	// }

	/**
	 * Test setClusterVersion API, set cluster version for simulator/drive. The
@@ -137,7 +96,7 @@ public class AdminAPISanityTest {

		// modify cluster version.
		try {
			adminClient.setClusterVersion(newClusterVersion);
			getAdminClient().setClusterVersion(newClusterVersion);

		} catch (KineticException e) {
			Assert.fail(e.getMessage());
@@ -152,10 +111,11 @@ public class AdminAPISanityTest {
	 * @throws KineticException
	 *             if any internal error occurred.
	 */
	@Test
	@Test(enabled = false)
	public void test_instanErase() {
		try {
			adminClient.instantErase("123".getBytes(Charset.forName("UTF-8")));
			getAdminClient().instantErase(
					"NULL".getBytes(Charset.forName("UTF-8")));
		} catch (KineticException e) {
			Assert.fail("instant erase throw exception: " + e.getMessage());
		}
@@ -169,10 +129,11 @@ public class AdminAPISanityTest {
	 * @throws KineticException
	 *             if any internal error occurred.
	 */
	@Test
	@Test(enabled = false)
	public void test_secureErase() {
		try {
			adminClient.secureErase("123".getBytes(Charset.forName("UTF-8")));
			getAdminClient().secureErase(
					"NULL".getBytes(Charset.forName("UTF-8")));
		} catch (KineticException e) {
			Assert.fail("secure erase throw exception: " + e.getMessage());
		}
@@ -186,7 +147,7 @@ public class AdminAPISanityTest {
	public void test_getLog() {
		KineticLog log;
		try {
			log = adminClient.getLog();
			log = getAdminClient().getLog();

			assertTrue(log.getTemperature().size() > 0);
			assertTrue(log.getUtilization().size() > 0);
@@ -219,7 +180,7 @@ public class AdminAPISanityTest {
		name2 = toByteArray(sname2);

		try {
			Device device = adminClient.getVendorSpecificDeviceLog(name);
			Device device = getAdminClient().getVendorSpecificDeviceLog(name);

			logger.info("got vendor specific log., name = " + sname
					+ ", log size=" + device.getValue().length);
@@ -231,7 +192,7 @@ public class AdminAPISanityTest {
		}

		try {
			adminClient.getVendorSpecificDeviceLog(name2);
			getAdminClient().getVendorSpecificDeviceLog(name2);

			Assert.fail("should have caught EntryNotFoundException");
		} catch (EntryNotFoundException enfe) {
@@ -278,7 +239,7 @@ public class AdminAPISanityTest {

		// all pins set the same
		try {
			adminClient.setAcl(acls);
			getAdminClient().setAcl(acls);
		} catch (KineticException e) {
			Assert.fail("Set Security throw exception" + e.getMessage());
		}
@@ -288,13 +249,13 @@ public class AdminAPISanityTest {
	 * Test set security, set erase pin.
	 * <p>
	 */
	@Test
	@Test(enabled = false)
	public void test_setErasePin() {
		String erasePin = "erasePin";
		byte[] erasePinB = toByteArray(erasePin);

		try {
			adminClient.setErasePin("123".getBytes(Charset.forName("UTF-8")),
			getAdminClient().setErasePin("".getBytes(Charset.forName("UTF-8")),
					erasePinB);
		} catch (KineticException e) {
			Assert.fail("Set erase pin throw exception" + e.getMessage());
@@ -302,7 +263,7 @@ public class AdminAPISanityTest {

		// clean pin
		try {
			adminClient.secureErase(erasePinB);
			getAdminClient().secureErase(erasePinB);
		} catch (KineticException e) {
			Assert.fail("secure erase throw exception" + e.getMessage());
		}
@@ -312,13 +273,13 @@ public class AdminAPISanityTest {
	 * Test set security, set lock pin.
	 * <p>
	 */
	@Test
	@Test(enabled = false)
	public void test_setLockPin() {
		String lockPin = "lockPin";
		byte[] lockPinB = toByteArray(lockPin);

		try {
			adminClient.setLockPin("123".getBytes(Charset.forName("UTF-8")),
			getAdminClient().setLockPin("".getBytes(Charset.forName("UTF-8")),
					lockPinB);
		} catch (KineticException e) {
			Assert.fail("Set erase pin throw exception" + e.getMessage());
@@ -326,7 +287,8 @@ public class AdminAPISanityTest {

		// clean pin
		try {
			adminClient.secureErase("123".getBytes(Charset.forName("UTF-8")));
			getAdminClient().secureErase(
					"NULL".getBytes(Charset.forName("UTF-8")));
		} catch (KineticException e) {
			Assert.fail("secure erase throw exception" + e.getMessage());
		}
@@ -336,19 +298,19 @@ public class AdminAPISanityTest {
	 * Test lock device with correct lock pin, should lock the device.
	 * <p>
	 */
	@Test
	@Test(enabled = false)
	public void test_lockDevice() {
		// set a lock pin
		byte[] lockPinB = toByteArray("lockpin");
		try {
			adminClient.setLockPin("123".getBytes(Charset.forName("UTF-8")),
			getAdminClient().setLockPin("".getBytes(Charset.forName("UTF-8")),
					lockPinB);
		} catch (KineticException e1) {
			Assert.fail("set lock pin throw exception: " + e1.getMessage());
		}

		try {
			adminClient.lockDevice(lockPinB);
			getAdminClient().lockDevice(lockPinB);
		} catch (KineticException e) {
			Assert.fail("Lock device with correct pin failed: "
					+ e.getMessage());
@@ -356,7 +318,7 @@ public class AdminAPISanityTest {

		// unlock device
		try {
			adminClient.unLockDevice(lockPinB);
			getAdminClient().unLockDevice(lockPinB);
		} catch (KineticException e) {
			Assert.fail("unLock device with correct pin failed: "
					+ e.getMessage());
@@ -364,7 +326,8 @@ public class AdminAPISanityTest {

		// clean pin
		try {
			adminClient.secureErase("123".getBytes(Charset.forName("UTF-8")));
			getAdminClient().secureErase(
					"NULL".getBytes(Charset.forName("UTF-8")));
		} catch (KineticException e) {
			Assert.fail("secure erase throw exception" + e.getMessage());
		}
@@ -374,26 +337,26 @@ public class AdminAPISanityTest {
	 * Test unlock device with correct unlock pin, should unlock the device.
	 * <p>
	 */
	@Test
	@Test(enabled = false)
	public void test_unLockDevice() {
		// set a lock pin
		byte[] lockPinB = toByteArray("lockpin");
		try {
			adminClient.setLockPin("123".getBytes(Charset.forName("UTF-8")),
			getAdminClient().setLockPin("".getBytes(Charset.forName("UTF-8")),
					lockPinB);
		} catch (KineticException e1) {
			Assert.fail("set lock pin throw exception: " + e1.getMessage());
		}

		try {
			adminClient.lockDevice(lockPinB);
			getAdminClient().lockDevice(lockPinB);
		} catch (KineticException e) {
			Assert.fail("Lock device with correct pin failed: "
					+ e.getMessage());
		}

		try {
			adminClient.unLockDevice(lockPinB);
			getAdminClient().unLockDevice(lockPinB);
		} catch (KineticException e) {
			Assert.fail("unLock device with correct pin failed: "
					+ e.getMessage());
@@ -401,7 +364,8 @@ public class AdminAPISanityTest {

		// clean pin
		try {
			adminClient.secureErase("123".getBytes(Charset.forName("UTF-8")));
			getAdminClient().secureErase(
					"NULL".getBytes(Charset.forName("UTF-8")));
		} catch (KineticException e) {
			Assert.fail("secure erase throw exception" + e.getMessage());
		}
@@ -424,7 +388,7 @@ public class AdminAPISanityTest {

		KineticLog log = null;
		try {
			log = adminClient.getLog(listOfLogType);
			log = getAdminClient().getLog(listOfLogType);
		} catch (KineticException e) {
			Assert.fail("getLog throw exception: " + e.getMessage());
		}
@@ -532,7 +496,7 @@ public class AdminAPISanityTest {
	public void test_firmwareDownload() {
		byte[] firmware = "frimware".getBytes(Charset.forName("UTF-8"));
		try {
			adminClient.firmwareDownload(
			getAdminClient().firmwareDownload(
					"123".getBytes(Charset.forName("UTF-8")), firmware);
		} catch (KineticException e) {
			Assert.fail("getLog throw exception: " + e.getMessage());
@@ -565,7 +529,7 @@ public class AdminAPISanityTest {
		Range range = rangeBuilder.build();

		try {
			KineticMessage kmrsp = adminClient.mediaScan(range,
			KineticMessage kmrsp = getAdminClient().mediaScan(range,
					Priority.HIGHEST);
			assertEquals(MessageType.MEDIASCAN_RESPONSE, kmrsp.getCommand()
					.getHeader().getMessageType());
@@ -604,7 +568,7 @@ public class AdminAPISanityTest {
		Range range = rangeBuilder.build();

		try {
			KineticMessage kmrsp = adminClient.mediaOptimize(range,
			KineticMessage kmrsp = getAdminClient().mediaOptimize(range,
					Priority.HIGHEST);
			assertEquals(MessageType.MEDIAOPTIMIZE_RESPONSE, kmrsp.getCommand()
					.getHeader().getMessageType());