You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/08/08 20:55:24 UTC
[28/43] Removed Base64 file and use the apache version
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6a864a1/test/src/com/cloud/test/stress/StressTestDirectAttach.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/stress/StressTestDirectAttach.java b/test/src/com/cloud/test/stress/StressTestDirectAttach.java
index a4afb80..28f5935 100644
--- a/test/src/com/cloud/test/stress/StressTestDirectAttach.java
+++ b/test/src/com/cloud/test/stress/StressTestDirectAttach.java
@@ -35,6 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
@@ -46,8 +47,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
-import com.cloud.utils.encoding.Base64;
import com.cloud.utils.exception.CloudRuntimeException;
import com.trilead.ssh2.ChannelCondition;
import com.trilead.ssh2.Connection;
@@ -55,28 +54,28 @@ import com.trilead.ssh2.SCPClient;
import com.trilead.ssh2.Session;
public class StressTestDirectAttach {
- private static long sleepTime = 180000L; // default 0
- private static boolean cleanUp = true;
- public static final Logger s_logger = Logger
- .getLogger(TestClientWithAPI.class.getName());
- private static boolean repeat = true;
- private static String[] users = null;
- private static boolean internet = false;
- private static ThreadLocal<String> _linuxIP = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxVmId = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxVmId1 = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxPassword = new ThreadLocal<String>();
- private static ThreadLocal<String> _windowsIP = new ThreadLocal<String>();
- private static ThreadLocal<String> _secretKey = new ThreadLocal<String>();
- private static ThreadLocal<String> _apiKey = new ThreadLocal<String>();
- private static ThreadLocal<Long> _userId = new ThreadLocal<Long>();
- private static ThreadLocal<String> _account = new ThreadLocal<String>();
- private static ThreadLocal<String> _domainRouterId = new ThreadLocal<String>();
- private static ThreadLocal<String> _newVolume = new ThreadLocal<String>();
- private static ThreadLocal<String> _newVolume1 = new ThreadLocal<String>();
- private static DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- private static int usageIterator = 1;
+ private static long sleepTime = 180000L; // default 0
+ private static boolean cleanUp = true;
+ public static final Logger s_logger = Logger
+ .getLogger(TestClientWithAPI.class.getName());
+ private static boolean repeat = true;
+ private static String[] users = null;
+ private static boolean internet = false;
+ private static ThreadLocal<String> _linuxIP = new ThreadLocal<String>();
+ private static ThreadLocal<String> _linuxVmId = new ThreadLocal<String>();
+ private static ThreadLocal<String> _linuxVmId1 = new ThreadLocal<String>();
+ private static ThreadLocal<String> _linuxPassword = new ThreadLocal<String>();
+ private static ThreadLocal<String> _windowsIP = new ThreadLocal<String>();
+ private static ThreadLocal<String> _secretKey = new ThreadLocal<String>();
+ private static ThreadLocal<String> _apiKey = new ThreadLocal<String>();
+ private static ThreadLocal<Long> _userId = new ThreadLocal<Long>();
+ private static ThreadLocal<String> _account = new ThreadLocal<String>();
+ private static ThreadLocal<String> _domainRouterId = new ThreadLocal<String>();
+ private static ThreadLocal<String> _newVolume = new ThreadLocal<String>();
+ private static ThreadLocal<String> _newVolume1 = new ThreadLocal<String>();
+ private static DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ private static int usageIterator = 1;
private static int numThreads = 1;
private static int wait = 5000;
private static String accountName = null;
@@ -85,363 +84,364 @@ public class StressTestDirectAttach {
private static String diskOfferingId="11";
private static String diskOfferingId1="12";
- private static final int MAX_RETRY_LINUX = 10;
- private static final int MAX_RETRY_WIN = 10;
-
-
- public static void main(String[] args) {
- String host = "http://localhost";
- String port = "8092";
- String devPort = "8080";
- String apiUrl = "/client/api";
-
- try {
- // Parameters
- List<String> argsList = Arrays.asList(args);
- Iterator<String> iter = argsList.iterator();
- while (iter.hasNext()) {
- String arg = iter.next();
- // host
- if (arg.equals("-h")) {
- host = "http://" + iter.next();
- }
-
- if (arg.equals("-p")) {
- port = iter.next();
- }
- if (arg.equals("-dp")) {
- devPort = iter.next();
- }
-
- if (arg.equals("-t")) {
- numThreads = Integer.parseInt(iter.next());
- }
-
- if (arg.equals("-s")) {
- sleepTime = Long.parseLong(iter.next());
- }
- if (arg.equals("-a")) {
- accountName = iter.next();
- }
-
- if (arg.equals("-c")) {
- cleanUp = Boolean.parseBoolean(iter.next());
- if (!cleanUp)
- sleepTime = 0L; // no need to wait if we don't ever
- // cleanup
- }
-
- if (arg.equals("-r")) {
- repeat = Boolean.parseBoolean(iter.next());
- }
-
- if (arg.equals("-i")) {
- internet = Boolean.parseBoolean(iter.next());
- }
-
- if (arg.equals("-w")) {
- wait = Integer.parseInt(iter.next());
- }
-
- if (arg.equals("-z")) {
- zoneId = iter.next();
- }
-
- if (arg.equals("-so")) {
- serviceOfferingId = iter.next();
- }
-
- }
-
- final String server = host + ":" + port + "/";
- final String developerServer = host + ":" + devPort + apiUrl;
- s_logger.info("Starting test against server: " + server + " with "
- + numThreads + " thread(s)");
- if (cleanUp)
- s_logger.info("Clean up is enabled, each test will wait "
- + sleepTime + " ms before cleaning up");
-
-
-
- for (int i = 0; i < numThreads; i++) {
- new Thread(new Runnable() {
- public void run() {
- do {
- String username = null;
- try {
- long now = System.currentTimeMillis();
- Random ran = new Random();
- username = Math.abs(ran.nextInt())+ "-user";
- NDC.push(username);
-
- s_logger.info("Starting test for the user " + username);
- int response = executeDeployment(server,
- developerServer, username);
- boolean success = false;
- String reason = null;
-
-
-
-
- if (response == 200) {
- success = true;
- if (internet) {
- s_logger
- .info("Deploy successful...waiting 5 minute before SSH tests");
- Thread.sleep(300000L); // Wait 60
- // seconds so
- // the windows VM
- // can boot up and do a sys prep.
-
- s_logger.info("Begin Linux SSH test for account " + _account.get());
- reason = sshTest(_linuxIP.get(), _linuxPassword.get());
-
-
- if (reason == null) {
- s_logger
- .info("Linux SSH test successful for account " + _account.get());
- }
- }
- if (reason == null) {
- if (internet) {
- s_logger
- .info("Windows SSH test successful for account " + _account.get());
- } else {
- s_logger
- .info("deploy test successful....now cleaning up");
- if (cleanUp) {
- s_logger
- .info("Waiting "
- + sleepTime
- + " ms before cleaning up vms");
- Thread.sleep(sleepTime);
- } else {
- success = true;
- }
- }
-
- if (usageIterator >= numThreads) {
- int eventsAndBillingResponseCode =
- executeEventsAndBilling(server, developerServer);
- s_logger.info("events and usage records command finished with response code: "
- + eventsAndBillingResponseCode);
- usageIterator = 1;
-
- }
- else {
- s_logger.info("Skipping events and usage records for this user: usageIterator " + usageIterator+ " and number of Threads " + numThreads);
- usageIterator++;
- }
-
- if ((users == null) && (accountName == null)) {
- s_logger
- .info("Sending cleanup command");
- int cleanupResponseCode = executeCleanup(
- server, developerServer, username);
- s_logger
- .info("cleanup command finished with response code: "
- + cleanupResponseCode);
- success = (cleanupResponseCode == 200);
- } else {
- s_logger
- .info("Sending stop DomR / destroy VM command");
- int stopResponseCode = executeStop(
- server, developerServer,
- username);
- s_logger
- .info("stop(destroy) command finished with response code: "
- + stopResponseCode);
- success = (stopResponseCode == 200);
- }
-
- } else {
- // Just stop but don't destroy the
- // VMs/Routers
- s_logger
- .info("SSH test failed for account " + _account.get() + "with reason '"
- + reason
- + "', stopping VMs");
- int stopResponseCode = executeStop(
- server, developerServer,
- username);
- s_logger
- .info("stop command finished with response code: "
- + stopResponseCode);
- success = false; // since the SSH test
- // failed, mark the
- // whole test as
- // failure
- }
- } else {
- // Just stop but don't destroy the
- // VMs/Routers
- s_logger
- .info("Deploy test failed with reason '"
- + reason
- + "', stopping VMs");
- int stopResponseCode = executeStop(server,
- developerServer, username);
- s_logger
- .info("stop command finished with response code: "
- + stopResponseCode);
- success = false; // since the deploy test
- // failed, mark the
- // whole test as failure
- }
-
- if (success) {
- s_logger
- .info("***** Completed test for user : "
- + username
- + " in "
- + ((System
- .currentTimeMillis() - now) / 1000L)
- + " seconds");
-
- } else {
- s_logger
- .info("##### FAILED test for user : "
- + username
- + " in "
- + ((System
- .currentTimeMillis() - now) / 1000L)
- + " seconds with reason : "
- + reason);
- }
- s_logger.info("Sleeping for " + wait + " seconds before starting next iteration");
- Thread.sleep(wait);
- } catch (Exception e) {
- s_logger.warn("Error in thread", e);
- try {
- int stopResponseCode = executeStop(server,
- developerServer, username);
- s_logger.info("stop response code: "
- + stopResponseCode);
- } catch (Exception e1) {
- }
- } finally {
- NDC.clear();
- }
- } while (repeat);
- }
- }).start();
- }
- } catch (Exception e) {
- s_logger.error(e);
- }
- }
-
-
- public static Map<String, List<String>> getMultipleValuesFromXML(
- InputStream is, String[] tagNames) {
- Map<String, List<String>> returnValues = new HashMap<String, List<String>>();
- try {
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document doc = docBuilder.parse(is);
- Element rootElement = doc.getDocumentElement();
- for (int i = 0; i < tagNames.length; i++) {
- NodeList targetNodes = rootElement
- .getElementsByTagName(tagNames[i]);
- if (targetNodes.getLength() <= 0) {
- s_logger.error("no " + tagNames[i]
- + " tag in XML response...returning null");
- } else {
- List<String> valueList = new ArrayList<String>();
- for (int j = 0; j < targetNodes.getLength(); j++) {
- Node node = targetNodes.item(j);
- valueList.add(node.getTextContent());
- }
- returnValues.put(tagNames[i], valueList);
- }
- }
- } catch (Exception ex) {
- s_logger.error(ex);
- }
- return returnValues;
- }
-
- public static Map<String, String> getSingleValueFromXML(InputStream is,
- String[] tagNames) {
- Map<String, String> returnValues = new HashMap<String, String>();
- try {
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document doc = docBuilder.parse(is);
- Element rootElement = doc.getDocumentElement();
-
- for (int i = 0; i < tagNames.length; i++) {
- NodeList targetNodes = rootElement
- .getElementsByTagName(tagNames[i]);
- if (targetNodes.getLength() <= 0) {
- s_logger.error("no " + tagNames[i]
- + " tag in XML response...returning null");
- } else {
- returnValues.put(tagNames[i], targetNodes.item(0)
- .getTextContent());
- }
- }
- } catch (Exception ex) {
- s_logger.error("error processing XML", ex);
- }
- return returnValues;
- }
-
- public static Map<String, String> getSingleValueFromXML(Element rootElement,
- String[] tagNames) {
- Map<String, String> returnValues = new HashMap<String, String>();
- if (rootElement == null) {
- s_logger.error("Root element is null, can't get single value from xml");
- return null;
- }
- try {
- for (int i = 0; i < tagNames.length; i++) {
- NodeList targetNodes = rootElement
- .getElementsByTagName(tagNames[i]);
- if (targetNodes.getLength() <= 0) {
- s_logger.error("no " + tagNames[i]
- + " tag in XML response...returning null");
- } else {
- returnValues.put(tagNames[i], targetNodes.item(0)
- .getTextContent());
- }
- }
- } catch (Exception ex) {
- s_logger.error("error processing XML", ex);
- }
- return returnValues;
- }
-
-
- private static List<String> getNonSourceNatIPs(InputStream is) {
- List<String> returnValues = new ArrayList<String>();
- try {
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document doc = docBuilder.parse(is);
- Element rootElement = doc.getDocumentElement();
- NodeList allocatedIpAddrNodes = rootElement
- .getElementsByTagName("publicipaddress");
- for (int i = 0; i < allocatedIpAddrNodes.getLength(); i++) {
- Node allocatedIpAddrNode = allocatedIpAddrNodes.item(i);
- NodeList childNodes = allocatedIpAddrNode.getChildNodes();
- String ipAddress = null;
- boolean isSourceNat = true; // assume it's source nat until we
- // find otherwise
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node n = childNodes.item(j);
- if ("ipaddress".equals(n.getNodeName())) {
- ipAddress = n.getTextContent();
- } else if ("issourcenat".equals(n.getNodeName())) {
- isSourceNat = Boolean.parseBoolean(n.getTextContent());
- }
- }
- if ((ipAddress != null) && !isSourceNat) {
- returnValues.add(ipAddress);
- }
- }
- } catch (Exception ex) {
- s_logger.error(ex);
- }
- return returnValues;
- }
+ private static final int MAX_RETRY_LINUX = 10;
+ private static final int MAX_RETRY_WIN = 10;
+
+
+ public static void main(String[] args) {
+ String host = "http://localhost";
+ String port = "8092";
+ String devPort = "8080";
+ String apiUrl = "/client/api";
+
+ try {
+ // Parameters
+ List<String> argsList = Arrays.asList(args);
+ Iterator<String> iter = argsList.iterator();
+ while (iter.hasNext()) {
+ String arg = iter.next();
+ // host
+ if (arg.equals("-h")) {
+ host = "http://" + iter.next();
+ }
+
+ if (arg.equals("-p")) {
+ port = iter.next();
+ }
+ if (arg.equals("-dp")) {
+ devPort = iter.next();
+ }
+
+ if (arg.equals("-t")) {
+ numThreads = Integer.parseInt(iter.next());
+ }
+
+ if (arg.equals("-s")) {
+ sleepTime = Long.parseLong(iter.next());
+ }
+ if (arg.equals("-a")) {
+ accountName = iter.next();
+ }
+
+ if (arg.equals("-c")) {
+ cleanUp = Boolean.parseBoolean(iter.next());
+ if (!cleanUp)
+ sleepTime = 0L; // no need to wait if we don't ever
+ // cleanup
+ }
+
+ if (arg.equals("-r")) {
+ repeat = Boolean.parseBoolean(iter.next());
+ }
+
+ if (arg.equals("-i")) {
+ internet = Boolean.parseBoolean(iter.next());
+ }
+
+ if (arg.equals("-w")) {
+ wait = Integer.parseInt(iter.next());
+ }
+
+ if (arg.equals("-z")) {
+ zoneId = iter.next();
+ }
+
+ if (arg.equals("-so")) {
+ serviceOfferingId = iter.next();
+ }
+
+ }
+
+ final String server = host + ":" + port + "/";
+ final String developerServer = host + ":" + devPort + apiUrl;
+ s_logger.info("Starting test against server: " + server + " with "
+ + numThreads + " thread(s)");
+ if (cleanUp)
+ s_logger.info("Clean up is enabled, each test will wait "
+ + sleepTime + " ms before cleaning up");
+
+
+
+ for (int i = 0; i < numThreads; i++) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ do {
+ String username = null;
+ try {
+ long now = System.currentTimeMillis();
+ Random ran = new Random();
+ username = Math.abs(ran.nextInt())+ "-user";
+ NDC.push(username);
+
+ s_logger.info("Starting test for the user " + username);
+ int response = executeDeployment(server,
+ developerServer, username);
+ boolean success = false;
+ String reason = null;
+
+
+
+
+ if (response == 200) {
+ success = true;
+ if (internet) {
+ s_logger
+ .info("Deploy successful...waiting 5 minute before SSH tests");
+ Thread.sleep(300000L); // Wait 60
+ // seconds so
+ // the windows VM
+ // can boot up and do a sys prep.
+
+ s_logger.info("Begin Linux SSH test for account " + _account.get());
+ reason = sshTest(_linuxIP.get(), _linuxPassword.get());
+
+
+ if (reason == null) {
+ s_logger
+ .info("Linux SSH test successful for account " + _account.get());
+ }
+ }
+ if (reason == null) {
+ if (internet) {
+ s_logger
+ .info("Windows SSH test successful for account " + _account.get());
+ } else {
+ s_logger
+ .info("deploy test successful....now cleaning up");
+ if (cleanUp) {
+ s_logger
+ .info("Waiting "
+ + sleepTime
+ + " ms before cleaning up vms");
+ Thread.sleep(sleepTime);
+ } else {
+ success = true;
+ }
+ }
+
+ if (usageIterator >= numThreads) {
+ int eventsAndBillingResponseCode =
+ executeEventsAndBilling(server, developerServer);
+ s_logger.info("events and usage records command finished with response code: "
+ + eventsAndBillingResponseCode);
+ usageIterator = 1;
+
+ }
+ else {
+ s_logger.info("Skipping events and usage records for this user: usageIterator " + usageIterator+ " and number of Threads " + numThreads);
+ usageIterator++;
+ }
+
+ if ((users == null) && (accountName == null)) {
+ s_logger
+ .info("Sending cleanup command");
+ int cleanupResponseCode = executeCleanup(
+ server, developerServer, username);
+ s_logger
+ .info("cleanup command finished with response code: "
+ + cleanupResponseCode);
+ success = (cleanupResponseCode == 200);
+ } else {
+ s_logger
+ .info("Sending stop DomR / destroy VM command");
+ int stopResponseCode = executeStop(
+ server, developerServer,
+ username);
+ s_logger
+ .info("stop(destroy) command finished with response code: "
+ + stopResponseCode);
+ success = (stopResponseCode == 200);
+ }
+
+ } else {
+ // Just stop but don't destroy the
+ // VMs/Routers
+ s_logger
+ .info("SSH test failed for account " + _account.get() + "with reason '"
+ + reason
+ + "', stopping VMs");
+ int stopResponseCode = executeStop(
+ server, developerServer,
+ username);
+ s_logger
+ .info("stop command finished with response code: "
+ + stopResponseCode);
+ success = false; // since the SSH test
+ // failed, mark the
+ // whole test as
+ // failure
+ }
+ } else {
+ // Just stop but don't destroy the
+ // VMs/Routers
+ s_logger
+ .info("Deploy test failed with reason '"
+ + reason
+ + "', stopping VMs");
+ int stopResponseCode = executeStop(server,
+ developerServer, username);
+ s_logger
+ .info("stop command finished with response code: "
+ + stopResponseCode);
+ success = false; // since the deploy test
+ // failed, mark the
+ // whole test as failure
+ }
+
+ if (success) {
+ s_logger
+ .info("***** Completed test for user : "
+ + username
+ + " in "
+ + ((System
+ .currentTimeMillis() - now) / 1000L)
+ + " seconds");
+
+ } else {
+ s_logger
+ .info("##### FAILED test for user : "
+ + username
+ + " in "
+ + ((System
+ .currentTimeMillis() - now) / 1000L)
+ + " seconds with reason : "
+ + reason);
+ }
+ s_logger.info("Sleeping for " + wait + " seconds before starting next iteration");
+ Thread.sleep(wait);
+ } catch (Exception e) {
+ s_logger.warn("Error in thread", e);
+ try {
+ int stopResponseCode = executeStop(server,
+ developerServer, username);
+ s_logger.info("stop response code: "
+ + stopResponseCode);
+ } catch (Exception e1) {
+ }
+ } finally {
+ NDC.clear();
+ }
+ } while (repeat);
+ }
+ }).start();
+ }
+ } catch (Exception e) {
+ s_logger.error(e);
+ }
+ }
+
+
+ public static Map<String, List<String>> getMultipleValuesFromXML(
+ InputStream is, String[] tagNames) {
+ Map<String, List<String>> returnValues = new HashMap<String, List<String>>();
+ try {
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.parse(is);
+ Element rootElement = doc.getDocumentElement();
+ for (int i = 0; i < tagNames.length; i++) {
+ NodeList targetNodes = rootElement
+ .getElementsByTagName(tagNames[i]);
+ if (targetNodes.getLength() <= 0) {
+ s_logger.error("no " + tagNames[i]
+ + " tag in XML response...returning null");
+ } else {
+ List<String> valueList = new ArrayList<String>();
+ for (int j = 0; j < targetNodes.getLength(); j++) {
+ Node node = targetNodes.item(j);
+ valueList.add(node.getTextContent());
+ }
+ returnValues.put(tagNames[i], valueList);
+ }
+ }
+ } catch (Exception ex) {
+ s_logger.error(ex);
+ }
+ return returnValues;
+ }
+
+ public static Map<String, String> getSingleValueFromXML(InputStream is,
+ String[] tagNames) {
+ Map<String, String> returnValues = new HashMap<String, String>();
+ try {
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.parse(is);
+ Element rootElement = doc.getDocumentElement();
+
+ for (int i = 0; i < tagNames.length; i++) {
+ NodeList targetNodes = rootElement
+ .getElementsByTagName(tagNames[i]);
+ if (targetNodes.getLength() <= 0) {
+ s_logger.error("no " + tagNames[i]
+ + " tag in XML response...returning null");
+ } else {
+ returnValues.put(tagNames[i], targetNodes.item(0)
+ .getTextContent());
+ }
+ }
+ } catch (Exception ex) {
+ s_logger.error("error processing XML", ex);
+ }
+ return returnValues;
+ }
+
+ public static Map<String, String> getSingleValueFromXML(Element rootElement,
+ String[] tagNames) {
+ Map<String, String> returnValues = new HashMap<String, String>();
+ if (rootElement == null) {
+ s_logger.error("Root element is null, can't get single value from xml");
+ return null;
+ }
+ try {
+ for (int i = 0; i < tagNames.length; i++) {
+ NodeList targetNodes = rootElement
+ .getElementsByTagName(tagNames[i]);
+ if (targetNodes.getLength() <= 0) {
+ s_logger.error("no " + tagNames[i]
+ + " tag in XML response...returning null");
+ } else {
+ returnValues.put(tagNames[i], targetNodes.item(0)
+ .getTextContent());
+ }
+ }
+ } catch (Exception ex) {
+ s_logger.error("error processing XML", ex);
+ }
+ return returnValues;
+ }
+
+
+ private static List<String> getNonSourceNatIPs(InputStream is) {
+ List<String> returnValues = new ArrayList<String>();
+ try {
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.parse(is);
+ Element rootElement = doc.getDocumentElement();
+ NodeList allocatedIpAddrNodes = rootElement
+ .getElementsByTagName("publicipaddress");
+ for (int i = 0; i < allocatedIpAddrNodes.getLength(); i++) {
+ Node allocatedIpAddrNode = allocatedIpAddrNodes.item(i);
+ NodeList childNodes = allocatedIpAddrNode.getChildNodes();
+ String ipAddress = null;
+ boolean isSourceNat = true; // assume it's source nat until we
+ // find otherwise
+ for (int j = 0; j < childNodes.getLength(); j++) {
+ Node n = childNodes.item(j);
+ if ("ipaddress".equals(n.getNodeName())) {
+ ipAddress = n.getTextContent();
+ } else if ("issourcenat".equals(n.getNodeName())) {
+ isSourceNat = Boolean.parseBoolean(n.getTextContent());
+ }
+ }
+ if ((ipAddress != null) && !isSourceNat) {
+ returnValues.add(ipAddress);
+ }
+ }
+ } catch (Exception ex) {
+ s_logger.error(ex);
+ }
+ return returnValues;
+ }
private static List<String> getSourceNatIPs(InputStream is) {
List<String> returnValues = new ArrayList<String>();
@@ -475,519 +475,519 @@ public class StressTestDirectAttach {
}
private static String executeRegistration(String server, String username,
- String password) throws HttpException, IOException {
- String url = server + "?command=registerUserKeys&id=" + _userId.get().toString();
- s_logger.info("registering: " + username);
- String returnValue = null;
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, String> requestKeyValues = getSingleValueFromXML(is,
- new String[] { "apikey", "secretkey" });
- _apiKey.set(requestKeyValues.get("apikey"));
- returnValue = requestKeyValues.get("secretkey");
- } else {
- s_logger.error("registration failed with error code: " + responseCode);
- }
- return returnValue;
- }
-
- private static Integer executeDeployment(String server, String developerServer,
- String username) throws HttpException, IOException {
- // test steps:
- // - create user
- // - deploy Windows VM
- // - deploy Linux VM
- // - associate IP address
- // - create two IP forwarding rules
- // - create load balancer rule
- // - list IP forwarding rules
- // - list load balancer rules
-
- // -----------------------------
- // CREATE USER
- // -----------------------------
- String encodedUsername = URLEncoder.encode(username, "UTF-8");
- String encryptedPassword = createMD5Password(username);
- String encodedPassword = URLEncoder.encode(encryptedPassword, "UTF-8");
-
- String url = server + "?command=createUser&username=" + encodedUsername
- + "&password=" + encodedPassword
- + "&firstname=Test&lastname=Test&email=test@vmops.com&domainId=1&accounttype=0";
- if (accountName != null ) {
- url = server + "?command=createUser&username=" + encodedUsername
- + "&password=" + encodedPassword
- + "&firstname=Test&lastname=Test&email=test@vmops.com&domainId=1&accounttype=0&account=" + accountName;
- }
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- long userId = -1;
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, String> userIdValues = getSingleValueFromXML(is,
- new String[] { "id", "account" });
- String userIdStr = userIdValues.get("id");
- s_logger.info("created user " + username + " with id "+ userIdStr);
- if (userIdStr != null) {
- userId = Long.parseLong(userIdStr);
- _userId.set(userId);
- _account.set(userIdValues.get("account"));
- if (userId == -1) {
- s_logger
- .error("create user (" + username + ") failed to retrieve a valid user id, aborting depolyment test");
- return -1;
- }
- }
- } else {
- s_logger.error("create user test failed for user " + username + " with error code :" + responseCode);
- return responseCode;
- }
-
- _secretKey.set(executeRegistration(server, username, username));
-
- if (_secretKey.get() == null) {
- s_logger
- .error("FAILED to retrieve secret key during registration, skipping user: "
- + username);
- return -1;
- } else {
- s_logger.info("got secret key: " + _secretKey.get());
- s_logger.info("got api key: " + _apiKey.get());
- }
-
-
- // ---------------------------------
- // CREATE NETWORK GROUP AND ADD INGRESS RULE TO IT
- // ---------------------------------
- String networkAccount = null;
- if (accountName != null) {
- networkAccount = accountName;
- }
- else {
- networkAccount = encodedUsername;
- }
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String requestToSign = "apikey=" + encodedApiKey
- + "&command=createSecurityGroup&name=" + encodedUsername;
- requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
- String encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=createSecurityGroup&name=" + encodedUsername + "&apikey=" + encodedApiKey
- + "&signature=" + encodedSignature;
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, String> values = getSingleValueFromXML(is,
- new String[] { "id" });
-
- if (values.get("id") == null) {
- s_logger.info("Create network rule response code: 401");
- return 401;
- }
- else {
- s_logger.info("Create security group response code: " + responseCode);
- }
- } else {
- s_logger.error("Create security group failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
-
- String encodedCidr = URLEncoder.encode("192.168.1.143/32", "UTF-8");
- url = server + "?command=authorizeSecurityGroupIngress&cidrlist=" + encodedCidr + "&endport=22&" +
- "securitygroupname=" + encodedUsername +"&protocol=tcp&startport=22&account=" + networkAccount + "&domainid=1";
-
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id" });
-
- if (values.get("id") == null) {
- s_logger.info("Authorise security group ingress response code: 401");
- return 401;
- }
- else {
- s_logger.info("Authorise security group ingress response code: " + responseCode);
- }
- } else {
- s_logger.error("Authorise security group ingress failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
-
-
- // ---------------------------------
- // DEPLOY LINUX VM
- // ---------------------------------
- {
- long templateId = 2;
- String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8");
- String encodedServiceOfferingId = URLEncoder.encode(""
- + serviceOfferingId, "UTF-8");
- String encodedTemplateId = URLEncoder.encode("" + templateId,
- "UTF-8");
- encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- requestToSign = "apikey=" + encodedApiKey
- + "&command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&serviceofferingid="
- + encodedServiceOfferingId + "&templateid="
- + encodedTemplateId + "&zoneid=" + encodedZoneId;
- requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
- encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&zoneid=" + encodedZoneId + "&serviceofferingid="
- + encodedServiceOfferingId + "&templateid="
- + encodedTemplateId + "&apikey=" + encodedApiKey
- + "&signature=" + encodedSignature;
-
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id", "ipaddress" });
-
- if ((values.get("ipaddress") == null) || (values
- .get("id") == null)) {
- s_logger.info("deploy linux vm response code: 401");
- return 401;
- }
- else {
- s_logger.info("deploy linux vm response code: " + responseCode);
- long linuxVMId = Long.parseLong(values.get("id"));
- s_logger.info("got linux virtual machine id: " + linuxVMId);
- _linuxVmId.set(values.get("id"));
- _linuxIP.set(values.get("ipaddress"));
- _linuxPassword.set("rs-ccb35ea5");
- }
- } else {
- s_logger.error("deploy linux vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
-
-
-
- //Create a new volume
- {
- url = server + "?command=createVolume&diskofferingid=" + diskOfferingId + "&zoneid=" + zoneId + "&name=newvolume&account=" + _account.get() + "&domainid=1";
- s_logger.info("Creating volume....");
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id" });
-
- if (values.get("id") == null) {
- s_logger.info("create volume response code: 401");
- return 401;
- }
- else {
- s_logger.info("create volume response code: " + responseCode);
- String volumeId = values.get("id");
- s_logger.info("got volume id: " + volumeId);
- _newVolume.set(volumeId);
- }
- } else {
- s_logger.error("create volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
-
- //attach a new volume to the vm
- {
- url = server + "?command=attachVolume&id=" + _newVolume.get() + "&virtualmachineid=" + _linuxVmId.get();
- s_logger.info("Attaching volume with id " + _newVolume.get() + " to the vm " + _linuxVmId.get());
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("Attach data volume response code: " + responseCode);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id" });
-
- if (values.get("id") == null) {
- s_logger.info("Attach volume response code: 401");
- return 401;
- }
- else {
- s_logger.info("Attach volume response code: " + responseCode);
- }
- } else {
- s_logger.error("Attach volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
-
- //DEPLOY SECOND VM, ADD VOLUME TO IT
-
- // ---------------------------------
- // DEPLOY another linux vm
- // ---------------------------------
- {
- long templateId = 2;
- String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8");
- String encodedServiceOfferingId = URLEncoder.encode(""
- + serviceOfferingId, "UTF-8");
- String encodedTemplateId = URLEncoder.encode("" + templateId,
- "UTF-8");
- encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- requestToSign = "apikey=" + encodedApiKey
- + "&command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&serviceofferingid="
- + encodedServiceOfferingId + "&templateid="
- + encodedTemplateId + "&zoneid=" + encodedZoneId;
- requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
- encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&zoneid=" + encodedZoneId + "&serviceofferingid="
- + encodedServiceOfferingId + "&templateid="
- + encodedTemplateId + "&apikey=" + encodedApiKey
- + "&signature=" + encodedSignature;
-
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id", "ipaddress" });
-
- if ((values.get("ipaddress") == null) || (values
- .get("id") == null)) {
- s_logger.info("deploy linux vm response code: 401");
- return 401;
- }
- else {
- s_logger.info("deploy linux vm response code: " + responseCode);
- long linuxVMId = Long.parseLong(values.get("id"));
- s_logger.info("got linux virtual machine id: " + linuxVMId);
- _linuxVmId1.set(values.get("id"));
- }
- } else {
- s_logger.error("deploy linux vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
-
-
-
- //Create a new volume
- {
- url = server + "?command=createVolume&diskofferingid=" + diskOfferingId1 + "&zoneid=" + zoneId + "&name=newvolume1&account=" + _account.get() + "&domainid=1";
- s_logger.info("Creating volume....");
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id" });
-
- if (values.get("id") == null) {
- s_logger.info("create volume response code: 401");
- return 401;
- }
- else {
- s_logger.info("create volume response code: " + responseCode);
- String volumeId = values.get("id");
- s_logger.info("got volume id: " + volumeId);
- _newVolume1.set(volumeId);
- }
- } else {
- s_logger.error("create volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
-
- //attach a new volume to the vm
- {
- url = server + "?command=attachVolume&id=" + _newVolume1.get() + "&virtualmachineid=" + _linuxVmId1.get();
- s_logger.info("Attaching volume with id " + _newVolume1.get() + " to the vm " + _linuxVmId1.get());
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("Attach data volume response code: " + responseCode);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> values = getSingleValueFromXML(el,
- new String[] { "id" });
-
- if (values.get("id") == null) {
- s_logger.info("Attach volume response code: 401");
- return 401;
- }
- else {
- s_logger.info("Attach volume response code: " + responseCode);
- }
- } else {
- s_logger.error("Attach volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
- return 200;
- }
-
-
-
-
- private static int executeCleanup(String server, String developerServer, String username)
- throws HttpException, IOException {
- // test steps:
- // - get user
- // - delete user
-
- // -----------------------------
- // GET USER
- // -----------------------------
- String userId = _userId.get().toString();
- String encodedUserId = URLEncoder.encode(userId, "UTF-8");
- String url = server + "?command=listUsers&id=" + encodedUserId;
- s_logger.info("Cleaning up resources for user: " + userId + " with url " + url);
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- s_logger.info("get user response code: " + responseCode);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, String> userInfo = getSingleValueFromXML(is,
- new String[] { "username", "id", "account" });
- if (!username.equals(userInfo.get("username"))) {
- s_logger
- .error("get user failed to retrieve requested user, aborting cleanup test" + ". Following URL was sent: " + url);
- return -1;
- }
-
- } else {
- s_logger.error("get user failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
- // -----------------------------
- // UPDATE USER
- // -----------------------------
- {
- url = server + "?command=updateUser&id=" + userId
- + "&firstname=delete&lastname=me";
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("update user response code: " + responseCode);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, String> success = getSingleValueFromXML(is,
- new String[] { "success" });
- s_logger
- .info("update user..success? " + success.get("success"));
- } else {
- s_logger.error("update user failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
-
- // -----------------------------
- // Execute reboot/stop/start commands for the VMs before deleting the account - made to exercise xen
- // -----------------------------
-
- //Reboot centos VM
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String requestToSign = "apikey=" + encodedApiKey + "&command=rebootVirtualMachine&id=" + _linuxVmId.get();
- requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
- String encodedSignature = URLEncoder.encode(signature, "UTF-8");
-
- url = developerServer + "?command=rebootVirtualMachine&id=" + _linuxVmId.get() + "&apikey="
- + encodedApiKey + "&signature=" + encodedSignature;
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("Reboot VM response code: "
- + responseCode);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> success = getSingleValueFromXML(el,
- new String[] { "success" });
- s_logger.info("VM was rebooted with the status: "
- + success.get("success"));
- } else {
- s_logger.error(" VM test failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
- //Stop centos VM
- requestToSign = "apikey=" + encodedApiKey + "&command=stopVirtualMachine&id=" + _linuxVmId.get();
- requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
- encodedSignature = URLEncoder.encode(signature, "UTF-8");
-
- url = developerServer + "?command=stopVirtualMachine&id=" + _linuxVmId.get() + "&apikey="
- + encodedApiKey + "&signature=" + encodedSignature;
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("Stop VM response code: "
- + responseCode);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> success = getSingleValueFromXML(el,
- new String[] { "success" });
- s_logger.info("VM was stopped with the status: "
- + success.get("success"));
- } else {
- s_logger.error("Stop VM test failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
- //Start centos VM
- requestToSign = "apikey=" + encodedApiKey + "&command=startVirtualMachine&id=" + _linuxVmId.get();
- requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
- encodedSignature = URLEncoder.encode(signature, "UTF-8");
-
- url = developerServer + "?command=startVirtualMachine&id=" + _linuxVmId.get() + "&apikey="
- + encodedApiKey + "&signature=" + encodedSignature;
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("Start VM response code: "
- + responseCode);
-
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> success = getSingleValueFromXML(el,
- new String[] { "id" });
-
- if (success.get("id") == null) {
- s_logger.info("Start linux vm response code: 401");
- return 401;
- }
- else {
- s_logger.info("Start vm response code: " + responseCode);
- }
-
- s_logger.info("VM was started with the status: "
- + success.get("success"));
- } else {
- s_logger.error("Start VM test failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
+ String password) throws HttpException, IOException {
+ String url = server + "?command=registerUserKeys&id=" + _userId.get().toString();
+ s_logger.info("registering: " + username);
+ String returnValue = null;
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, String> requestKeyValues = getSingleValueFromXML(is,
+ new String[] { "apikey", "secretkey" });
+ _apiKey.set(requestKeyValues.get("apikey"));
+ returnValue = requestKeyValues.get("secretkey");
+ } else {
+ s_logger.error("registration failed with error code: " + responseCode);
+ }
+ return returnValue;
+ }
+
+ private static Integer executeDeployment(String server, String developerServer,
+ String username) throws HttpException, IOException {
+ // test steps:
+ // - create user
+ // - deploy Windows VM
+ // - deploy Linux VM
+ // - associate IP address
+ // - create two IP forwarding rules
+ // - create load balancer rule
+ // - list IP forwarding rules
+ // - list load balancer rules
+
+ // -----------------------------
+ // CREATE USER
+ // -----------------------------
+ String encodedUsername = URLEncoder.encode(username, "UTF-8");
+ String encryptedPassword = createMD5Password(username);
+ String encodedPassword = URLEncoder.encode(encryptedPassword, "UTF-8");
+
+ String url = server + "?command=createUser&username=" + encodedUsername
+ + "&password=" + encodedPassword
+ + "&firstname=Test&lastname=Test&email=test@vmops.com&domainId=1&accounttype=0";
+ if (accountName != null ) {
+ url = server + "?command=createUser&username=" + encodedUsername
+ + "&password=" + encodedPassword
+ + "&firstname=Test&lastname=Test&email=test@vmops.com&domainId=1&accounttype=0&account=" + accountName;
+ }
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ long userId = -1;
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, String> userIdValues = getSingleValueFromXML(is,
+ new String[] { "id", "account" });
+ String userIdStr = userIdValues.get("id");
+ s_logger.info("created user " + username + " with id "+ userIdStr);
+ if (userIdStr != null) {
+ userId = Long.parseLong(userIdStr);
+ _userId.set(userId);
+ _account.set(userIdValues.get("account"));
+ if (userId == -1) {
+ s_logger
+ .error("create user (" + username + ") failed to retrieve a valid user id, aborting depolyment test");
+ return -1;
+ }
+ }
+ } else {
+ s_logger.error("create user test failed for user " + username + " with error code :" + responseCode);
+ return responseCode;
+ }
+
+ _secretKey.set(executeRegistration(server, username, username));
+
+ if (_secretKey.get() == null) {
+ s_logger
+ .error("FAILED to retrieve secret key during registration, skipping user: "
+ + username);
+ return -1;
+ } else {
+ s_logger.info("got secret key: " + _secretKey.get());
+ s_logger.info("got api key: " + _apiKey.get());
+ }
+
+
+ // ---------------------------------
+ // CREATE NETWORK GROUP AND ADD INGRESS RULE TO IT
+ // ---------------------------------
+ String networkAccount = null;
+ if (accountName != null) {
+ networkAccount = accountName;
+ }
+ else {
+ networkAccount = encodedUsername;
+ }
+ String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ String requestToSign = "apikey=" + encodedApiKey
+ + "&command=createSecurityGroup&name=" + encodedUsername;
+ requestToSign = requestToSign.toLowerCase();
+ String signature = signRequest(requestToSign, _secretKey.get());
+ String encodedSignature = URLEncoder.encode(signature, "UTF-8");
+ url = developerServer + "?command=createSecurityGroup&name=" + encodedUsername + "&apikey=" + encodedApiKey
+ + "&signature=" + encodedSignature;
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, String> values = getSingleValueFromXML(is,
+ new String[] { "id" });
+
+ if (values.get("id") == null) {
+ s_logger.info("Create network rule response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("Create security group response code: " + responseCode);
+ }
+ } else {
+ s_logger.error("Create security group failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+
+
+ String encodedCidr = URLEncoder.encode("192.168.1.143/32", "UTF-8");
+ url = server + "?command=authorizeSecurityGroupIngress&cidrlist=" + encodedCidr + "&endport=22&" +
+ "securitygroupname=" + encodedUsername +"&protocol=tcp&startport=22&account=" + networkAccount + "&domainid=1";
+
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id" });
+
+ if (values.get("id") == null) {
+ s_logger.info("Authorise security group ingress response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("Authorise security group ingress response code: " + responseCode);
+ }
+ } else {
+ s_logger.error("Authorise security group ingress failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+
+
+
+ // ---------------------------------
+ // DEPLOY LINUX VM
+ // ---------------------------------
+ {
+ long templateId = 2;
+ String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8");
+ String encodedServiceOfferingId = URLEncoder.encode(""
+ + serviceOfferingId, "UTF-8");
+ String encodedTemplateId = URLEncoder.encode("" + templateId,
+ "UTF-8");
+ encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ requestToSign = "apikey=" + encodedApiKey
+ + "&command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&serviceofferingid="
+ + encodedServiceOfferingId + "&templateid="
+ + encodedTemplateId + "&zoneid=" + encodedZoneId;
+ requestToSign = requestToSign.toLowerCase();
+ signature = signRequest(requestToSign, _secretKey.get());
+ encodedSignature = URLEncoder.encode(signature, "UTF-8");
+ url = developerServer + "?command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&zoneid=" + encodedZoneId + "&serviceofferingid="
+ + encodedServiceOfferingId + "&templateid="
+ + encodedTemplateId + "&apikey=" + encodedApiKey
+ + "&signature=" + encodedSignature;
+
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id", "ipaddress" });
+
+ if ((values.get("ipaddress") == null) || (values
+ .get("id") == null)) {
+ s_logger.info("deploy linux vm response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("deploy linux vm response code: " + responseCode);
+ long linuxVMId = Long.parseLong(values.get("id"));
+ s_logger.info("got linux virtual machine id: " + linuxVMId);
+ _linuxVmId.set(values.get("id"));
+ _linuxIP.set(values.get("ipaddress"));
+ _linuxPassword.set("rs-ccb35ea5");
+ }
+ } else {
+ s_logger.error("deploy linux vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+
+
+
+ //Create a new volume
+ {
+ url = server + "?command=createVolume&diskofferingid=" + diskOfferingId + "&zoneid=" + zoneId + "&name=newvolume&account=" + _account.get() + "&domainid=1";
+ s_logger.info("Creating volume....");
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id" });
+
+ if (values.get("id") == null) {
+ s_logger.info("create volume response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("create volume response code: " + responseCode);
+ String volumeId = values.get("id");
+ s_logger.info("got volume id: " + volumeId);
+ _newVolume.set(volumeId);
+ }
+ } else {
+ s_logger.error("create volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+
+ //attach a new volume to the vm
+ {
+ url = server + "?command=attachVolume&id=" + _newVolume.get() + "&virtualmachineid=" + _linuxVmId.get();
+ s_logger.info("Attaching volume with id " + _newVolume.get() + " to the vm " + _linuxVmId.get());
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("Attach data volume response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id" });
+
+ if (values.get("id") == null) {
+ s_logger.info("Attach volume response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("Attach volume response code: " + responseCode);
+ }
+ } else {
+ s_logger.error("Attach volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+
+ //DEPLOY SECOND VM, ADD VOLUME TO IT
+
+ // ---------------------------------
+ // DEPLOY another linux vm
+ // ---------------------------------
+ {
+ long templateId = 2;
+ String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8");
+ String encodedServiceOfferingId = URLEncoder.encode(""
+ + serviceOfferingId, "UTF-8");
+ String encodedTemplateId = URLEncoder.encode("" + templateId,
+ "UTF-8");
+ encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ requestToSign = "apikey=" + encodedApiKey
+ + "&command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&serviceofferingid="
+ + encodedServiceOfferingId + "&templateid="
+ + encodedTemplateId + "&zoneid=" + encodedZoneId;
+ requestToSign = requestToSign.toLowerCase();
+ signature = signRequest(requestToSign, _secretKey.get());
+ encodedSignature = URLEncoder.encode(signature, "UTF-8");
+ url = developerServer + "?command=deployVirtualMachine&securitygrouplist=" + encodedUsername + "&zoneid=" + encodedZoneId + "&serviceofferingid="
+ + encodedServiceOfferingId + "&templateid="
+ + encodedTemplateId + "&apikey=" + encodedApiKey
+ + "&signature=" + encodedSignature;
+
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id", "ipaddress" });
+
+ if ((values.get("ipaddress") == null) || (values
+ .get("id") == null)) {
+ s_logger.info("deploy linux vm response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("deploy linux vm response code: " + responseCode);
+ long linuxVMId = Long.parseLong(values.get("id"));
+ s_logger.info("got linux virtual machine id: " + linuxVMId);
+ _linuxVmId1.set(values.get("id"));
+ }
+ } else {
+ s_logger.error("deploy linux vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+
+
+
+ //Create a new volume
+ {
+ url = server + "?command=createVolume&diskofferingid=" + diskOfferingId1 + "&zoneid=" + zoneId + "&name=newvolume1&account=" + _account.get() + "&domainid=1";
+ s_logger.info("Creating volume....");
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id" });
+
+ if (values.get("id") == null) {
+ s_logger.info("create volume response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("create volume response code: " + responseCode);
+ String volumeId = values.get("id");
+ s_logger.info("got volume id: " + volumeId);
+ _newVolume1.set(volumeId);
+ }
+ } else {
+ s_logger.error("create volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+
+ //attach a new volume to the vm
+ {
+ url = server + "?command=attachVolume&id=" + _newVolume1.get() + "&virtualmachineid=" + _linuxVmId1.get();
+ s_logger.info("Attaching volume with id " + _newVolume1.get() + " to the vm " + _linuxVmId1.get());
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("Attach data volume response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> values = getSingleValueFromXML(el,
+ new String[] { "id" });
+
+ if (values.get("id") == null) {
+ s_logger.info("Attach volume response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("Attach volume response code: " + responseCode);
+ }
+ } else {
+ s_logger.error("Attach volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+ return 200;
+ }
+
+
+
+
+ private static int executeCleanup(String server, String developerServer, String username)
+ throws HttpException, IOException {
+ // test steps:
+ // - get user
+ // - delete user
+
+ // -----------------------------
+ // GET USER
+ // -----------------------------
+ String userId = _userId.get().toString();
+ String encodedUserId = URLEncoder.encode(userId, "UTF-8");
+ String url = server + "?command=listUsers&id=" + encodedUserId;
+ s_logger.info("Cleaning up resources for user: " + userId + " with url " + url);
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ s_logger.info("get user response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, String> userInfo = getSingleValueFromXML(is,
+ new String[] { "username", "id", "account" });
+ if (!username.equals(userInfo.get("username"))) {
+ s_logger
+ .error("get user failed to retrieve requested user, aborting cleanup test" + ". Following URL was sent: " + url);
+ return -1;
+ }
+
+ } else {
+ s_logger.error("get user failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+
+ // -----------------------------
+ // UPDATE USER
+ // -----------------------------
+ {
+ url = server + "?command=updateUser&id=" + userId
+ + "&firstname=delete&lastname=me";
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("update user response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, String> success = getSingleValueFromXML(is,
+ new String[] { "success" });
+ s_logger
+ .info("update user..success? " + success.get("success"));
+ } else {
+ s_logger.error("update user failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+
+ // -----------------------------
+ // Execute reboot/stop/start commands for the VMs before deleting the account - made to exercise xen
+ // -----------------------------
+
+ //Reboot centos VM
+ String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ String requestToSign = "apikey=" + encodedApiKey + "&command=rebootVirtualMachine&id=" + _linuxVmId.get();
+ requestToSign = requestToSign.toLowerCase();
+ String signature = signRequest(requestToSign, _secretKey.get());
+ String encodedSignature = URLEncoder.encode(signature, "UTF-8");
+
+ url = developerServer + "?command=rebootVirtualMachine&id=" + _linuxVmId.get() + "&apikey="
+ + encodedApiKey + "&signature=" + encodedSignature;
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("Reboot VM response code: "
+ + responseCode);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> success = getSingleValueFromXML(el,
+ new String[] { "success" });
+ s_logger.info("VM was rebooted with the status: "
+ + success.get("success"));
+ } else {
+ s_logger.error(" VM test failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+
+ //Stop centos VM
+ requestToSign = "apikey=" + encodedApiKey + "&command=stopVirtualMachine&id=" + _linuxVmId.get();
+ requestToSign = requestToSign.toLowerCase();
+ signature = signRequest(requestToSign, _secretKey.get());
+ encodedSignature = URLEncoder.encode(signature, "UTF-8");
+
+ url = developerServer + "?command=stopVirtualMachine&id=" + _linuxVmId.get() + "&apikey="
+ + encodedApiKey + "&signature=" + encodedSignature;
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("Stop VM response code: "
+ + responseCode);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> success = getSingleValueFromXML(el,
+ new String[] { "success" });
+ s_logger.info("VM was stopped with the status: "
+ + success.get("success"));
+ } else {
+ s_logger.error("Stop VM test failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+
+ //Start centos VM
+ requestToSign = "apikey=" + encodedApiKey + "&command=startVirtualMachine&id=" + _linuxVmId.get();
+ requestToSign = requestToSign.toLowerCase();
+ signature = signRequest(requestToSign, _secretKey.get());
+ encodedSignature = URLEncoder.encode(signature, "UTF-8");
+
+ url = developerServer + "?command=startVirtualMachine&id=" + _linuxVmId.get() + "&apikey="
+ + encodedApiKey + "&signature=" + encodedSignature;
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("Start VM response code: "
+ + responseCode);
+
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ Map<String, String> success = getSingleValueFromXML(el,
+ new String[] { "id" });
+
+ if (success.get("id") == null) {
+ s_logger.info("Start linux vm response code: 401");
+ return 401;
+ }
+ else {
+ s_logger.info("Start vm response code: " + responseCode);
+ }
+
+ s_logger.info("VM was started with the status: "
+ + success.get("success"));
+ } else {
+ s_logger.error("Start VM test failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+
//// // -----------------------------
//// // DISABLE USER
//// // -----------------------------
@@ -1008,184 +1008,184 @@ public class StressTestDirectAttach {
// }
// }
- // -----------------------------
- // DELETE USER
- // -----------------------------
- {
- url = server + "?command=deleteUser&id=" + userId;
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("delete user response code: " + responseCode);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- s_logger
- .info("Deleted user successfully");
- } else {
- s_logger.error("delete user failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
- return responseCode;
- }
-
- private static int executeEventsAndBilling(String server, String developerServer)
- throws HttpException, IOException {
- // test steps:
- // - get all the events in the system for all users in the system
- // - generate all the usage records in the system
- // - get all the usage records in the system
-
- // -----------------------------
- // GET EVENTS
- // -----------------------------
- String url =server+"?command=listEvents&page=1&account=" + _account.get();
-
- s_logger.info("Getting events for the account " + _account.get());
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- s_logger.info("get events response code: " + responseCode);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, List<String>> eventDescriptions = getMultipleValuesFromXML(
- is, new String[] { "description" });
- List<String> descriptionText = eventDescriptions.get("description");
- if (descriptionText == null) {
- s_logger.info("no events retrieved...");
- } else {
- for (String text : descriptionText) {
- s_logger.info("event: " + text);
- }
- }
- } else {
- s_logger.error("list events failed with error code: " + responseCode + ". Following URL was sent: " + url);
-
- return responseCode;
- }
- return responseCode;
- }
-
-
- private static int executeStop(String server, String developerServer,
- String username) throws HttpException, IOException {
- // test steps:
- // - get userId for the given username
- // - list virtual machines for the user
- // - stop all virtual machines
- // - get ip addresses for the user
- // - release ip addresses
-
- // -----------------------------
- // GET USER
- // -----------------------------
- String userId = _userId.get().toString();
- String encodedUserId = URLEncoder.encode(userId, "UTF-8");
-
- String url = server + "?command=listUsers&id=" + encodedUserId;
- s_logger.info("Stopping resources for user: " + username);
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- s_logger.info("get user response code: " + responseCode);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, String> userIdValues = getSingleValueFromXML(is,
- new String[] { "id" });
- String userIdStr = userIdValues.get("id");
- if (userIdStr != null) {
- userId = userIdStr;
- if (userId == null) {
- s_logger
- .error("get user failed to retrieve a valid user id, aborting depolyment test" + ". Following URL was sent: " + url);
- return -1;
- }
- }
- } else {
- s_logger.error("get user failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
- {
- // ----------------------------------
- // LIST VIRTUAL MACHINES
- // ----------------------------------
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String requestToSign = "apikey=" + encodedApiKey
- + "&command=listVirtualMachines";
- requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
- String encodedSignature = URLEncoder.encode(signature, "UTF-8");
-
- url = developerServer + "?command=listVirtualMachines&apikey=" + encodedApiKey + "&signature="
- + encodedSignature;
-
- s_logger.info("Listing all virtual machines for the user with url " + url);
- String[] vmIds = null;
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("list virtual machines response code: "
- + responseCode);
- if (responseCode == 200) {
- InputStream is = method.getResponseBodyAsStream();
- Map<String, List<String>> vmIdValues = getMultipleValuesFromXML(
- is, new String[] { "id" });
- if (vmIdValues.containsKey("id")) {
- List<String> vmIdList = vmIdValues.get("id");
- if (vmIdList != null) {
- vmIds = new String[vmIdList.size()];
- vmIdList.toArray(vmIds);
- String vmIdLogStr = "";
- if ((vmIds != null) && (vmIds.length > 0)) {
- vmIdLogStr = vmIds[0];
- for (int i = 1; i < vmIds.length; i++) {
- vmIdLogStr = vmIdLogStr + "," + vmIds[i];
- }
- }
- s_logger.info("got virtual machine ids: " + vmIdLogStr);
- }
- }
-
-
- } else {
- s_logger.error("list virtual machines test failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
-
-
- // ----------------------------------
- // STOP/DESTROY VIRTUAL MACHINES
- // ----------------------------------
- if (vmIds != null) {
- for (String vmId : vmIds) {
- requestToSign = "apikey=" + encodedApiKey + "&command=stopVirtualMachine&id=" + vmId;
- requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
- encodedSignature = URLEncoder.encode(signature, "UTF-8");
-
- url = developerServer + "?command=stopVirtualMachine&id=" + vmId + "&apikey="
- + encodedApiKey + "&signature=" + encodedSignature;
- client = new HttpClient();
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- s_logger.info("StopVirtualMachine" + " [" + vmId + "] response code: "
- + responseCode);
- if (responseCode == 200) {
- InputStream input = method.getResponseBodyAsStream();
- Element el = queryAsyncJobResult(server, input);
- Map<String, String> success = getSingleValueFromXML(el,
- new String[] { "success" });
- s_logger.info("StopVirtualMachine..success? "
- + success.get("success"));
- } else {
- s_logger.error("Stop virtual machine test failed with error code: " + responseCode + ". Following URL was sent: " + url);
- return responseCode;
- }
- }
- }
-
+ // -----------------------------
+ // DELETE USER
+ // -----------------------------
+ {
+ url = server + "?command=deleteUser&id=" + userId;
+ client = new HttpClient();
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ s_logger.info("delete user response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream input = method.getResponseBodyAsStream();
+ Element el = queryAsyncJobResult(server, input);
+ s_logger
+ .info("Deleted user successfully");
+ } else {
+ s_logger.error("delete user failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseCode;
+ }
+ }
+ return responseCode;
+ }
+
+ private static int executeEventsAndBilling(String server, String developerServer)
+ throws HttpException, IOException {
+ // test steps:
+ // - get all the events in the system for all users in the system
+ // - generate all the usage records in the system
+ // - get all the usage records in the system
+
+ // -----------------------------
+ // GET EVENTS
+ // -----------------------------
+ String url =server+"?command=listEvents&page=1&account=" + _account.get();
+
+ s_logger.info("Getting events for the account " + _account.get());
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ s_logger.info("get events response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, List<String>> eventDescriptions = getMultipleValuesFromXML(
+ is, new String[] { "description" });
+ List<String> descriptionText = eventDescriptions.get("description");
+ if (descriptionText == null) {
+ s_logger.info("no events retrieved...");
+ } else {
+ for (String text : descriptionText) {
+ s_logger.info("event: " + text);
+ }
+ }
+ } else {
+ s_logger.error("list events failed with error code: " + responseCode + ". Following URL was sent: " + url);
+
+ return responseCode;
+ }
+ return responseCode;
+ }
+
+
+ private static int executeStop(String server, String developerServer,
+ String username) throws HttpException, IOException {
+ // test steps:
+ // - get userId for the given username
+ // - list virtual machines for the user
+ // - stop all virtual machines
+ // - get ip addresses for the user
+ // - release ip addresses
+
+ // -----------------------------
+ // GET USER
+ // -----------------------------
+ String userId = _userId.get().toString();
+ String encodedUserId = URLEncoder.encode(userId, "UTF-8");
+
+ String url = server + "?command=listUsers&id=" + encodedUserId;
+ s_logger.info("Stopping resources for user: " + username);
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ s_logger.info("get user response code: " + responseCode);
+ if (responseCode == 200) {
+ InputStream is = method.getResponseBodyAsStream();
+ Map<String, String> userIdValues = getSingleValueFromXML(is,
+ new String[] { "id" });
+ String userIdStr = userIdValues.get("id");
+ if (userIdStr != null) {
+ userId = userIdStr;
+ if (userId == null) {
+ s_logger
+ .error("get user failed to retrieve a valid user id, aborting depolyment test" + ". Following URL was sent: " + url);
+ return -1;
+ }
+ }
+ } else {
+ s_logger.error("get user failed with error code: " + responseCode + ". Following URL was sent: " + url);
+ return responseC
<TRUNCATED>