You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/06/26 17:20:25 UTC
[7/58] fixing a bunch of line endings in the test directory
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/stress/WgetTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/stress/WgetTest.java b/test/src/com/cloud/test/stress/WgetTest.java
index 276fe22..28e7408 100644
--- a/test/src/com/cloud/test/stress/WgetTest.java
+++ b/test/src/com/cloud/test/stress/WgetTest.java
@@ -10,148 +10,148 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.stress;
-
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.trilead.ssh2.ChannelCondition;
-import com.trilead.ssh2.Connection;
-import com.trilead.ssh2.Session;
-
-public class WgetTest {
-
- public static int MAX_RETRY_LINUX = 1;
- public static final Logger s_logger = Logger.getLogger(WgetTest.class.getName());
- public static String host = "";
- public static String password = "rs-ccb35ea5";
-
-
-
- public static void main (String[] args) {
-
- // 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 = iter.next();
- }
- //password
-
- if (arg.equals("-p")) {
- password = iter.next();
- }
-
- }
-
- int i = 0;
- if (host == null || host.equals("")) {
- s_logger
- .info("Did not receive a host back from test, ignoring ssh test");
- System.exit(2);
- }
-
- if (password == null){
- s_logger.info("Did not receive a password back from test, ignoring ssh test");
- System.exit(2);
- }
- int retry = 0;
-
- try {
- if (retry > 0) {
- s_logger.info("Retry attempt : " + retry
- + " ...sleeping 120 seconds before next attempt");
- Thread.sleep(120000);
- }
-
- s_logger.info("Attempting to SSH into linux host " + host
- + " with retry attempt: " + retry);
-
- Connection conn = new Connection(host);
- conn.connect(null, 60000, 60000);
-
- s_logger.info("User + ssHed successfully into linux host " + host);
-
- boolean isAuthenticated = conn.authenticateWithPassword("root",
- password);
-
- if (isAuthenticated == false) {
- s_logger.info("Authentication failed for root with password" + password);
- System.exit(2);
- }
-
- boolean success = false;
- String linuxCommand = null;
-
- if (i % 10 == 0)
- linuxCommand = "rm -rf *; wget http://192.168.1.250/dump.bin && ls -al dump.bin";
- else
- linuxCommand = "wget http://192.168.1.250/dump.bin && ls -al dump.bin";
-
- Session sess = conn.openSession();
- sess.execCommand(linuxCommand);
-
- InputStream stdout = sess.getStdout();
- InputStream stderr = sess.getStderr();
-
-
- byte[] buffer = new byte[8192];
- while (true) {
- if ((stdout.available() == 0) && (stderr.available() == 0)) {
- int conditions = sess.waitForCondition(
- ChannelCondition.STDOUT_DATA
- | ChannelCondition.STDERR_DATA
- | ChannelCondition.EOF, 120000);
-
- if ((conditions & ChannelCondition.TIMEOUT) != 0) {
- s_logger
- .info("Timeout while waiting for data from peer.");
- System.exit(2);
- }
-
- if ((conditions & ChannelCondition.EOF) != 0) {
- if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
- break;
- }
- }
- }
-
- while (stdout.available() > 0) {
- success = true;
- int len = stdout.read(buffer);
- if (len > 0) // this check is somewhat paranoid
- s_logger.info(new String(buffer, 0, len));
- }
-
- while (stderr.available() > 0) {
- /* int len = */stderr.read(buffer);
- }
- }
-
- sess.close();
- conn.close();
-
- if (!success) {
- retry++;
- if (retry == MAX_RETRY_LINUX) {
- System.exit(2);
- }
- }
- } catch (Exception e) {
- retry++;
- s_logger.error("SSH Linux Network test fail with error");
- if (retry == MAX_RETRY_LINUX) {
- s_logger.error("Ssh test failed");
- System.exit(2);
- }
- }
- }
-
-}
+package com.cloud.test.stress;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import com.trilead.ssh2.ChannelCondition;
+import com.trilead.ssh2.Connection;
+import com.trilead.ssh2.Session;
+
+public class WgetTest {
+
+ public static int MAX_RETRY_LINUX = 1;
+ public static final Logger s_logger = Logger.getLogger(WgetTest.class.getName());
+ public static String host = "";
+ public static String password = "rs-ccb35ea5";
+
+
+
+ public static void main (String[] args) {
+
+ // 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 = iter.next();
+ }
+ //password
+
+ if (arg.equals("-p")) {
+ password = iter.next();
+ }
+
+ }
+
+ int i = 0;
+ if (host == null || host.equals("")) {
+ s_logger
+ .info("Did not receive a host back from test, ignoring ssh test");
+ System.exit(2);
+ }
+
+ if (password == null){
+ s_logger.info("Did not receive a password back from test, ignoring ssh test");
+ System.exit(2);
+ }
+ int retry = 0;
+
+ try {
+ if (retry > 0) {
+ s_logger.info("Retry attempt : " + retry
+ + " ...sleeping 120 seconds before next attempt");
+ Thread.sleep(120000);
+ }
+
+ s_logger.info("Attempting to SSH into linux host " + host
+ + " with retry attempt: " + retry);
+
+ Connection conn = new Connection(host);
+ conn.connect(null, 60000, 60000);
+
+ s_logger.info("User + ssHed successfully into linux host " + host);
+
+ boolean isAuthenticated = conn.authenticateWithPassword("root",
+ password);
+
+ if (isAuthenticated == false) {
+ s_logger.info("Authentication failed for root with password" + password);
+ System.exit(2);
+ }
+
+ boolean success = false;
+ String linuxCommand = null;
+
+ if (i % 10 == 0)
+ linuxCommand = "rm -rf *; wget http://192.168.1.250/dump.bin && ls -al dump.bin";
+ else
+ linuxCommand = "wget http://192.168.1.250/dump.bin && ls -al dump.bin";
+
+ Session sess = conn.openSession();
+ sess.execCommand(linuxCommand);
+
+ InputStream stdout = sess.getStdout();
+ InputStream stderr = sess.getStderr();
+
+
+ byte[] buffer = new byte[8192];
+ while (true) {
+ if ((stdout.available() == 0) && (stderr.available() == 0)) {
+ int conditions = sess.waitForCondition(
+ ChannelCondition.STDOUT_DATA
+ | ChannelCondition.STDERR_DATA
+ | ChannelCondition.EOF, 120000);
+
+ if ((conditions & ChannelCondition.TIMEOUT) != 0) {
+ s_logger
+ .info("Timeout while waiting for data from peer.");
+ System.exit(2);
+ }
+
+ if ((conditions & ChannelCondition.EOF) != 0) {
+ if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
+ break;
+ }
+ }
+ }
+
+ while (stdout.available() > 0) {
+ success = true;
+ int len = stdout.read(buffer);
+ if (len > 0) // this check is somewhat paranoid
+ s_logger.info(new String(buffer, 0, len));
+ }
+
+ while (stderr.available() > 0) {
+ /* int len = */stderr.read(buffer);
+ }
+ }
+
+ sess.close();
+ conn.close();
+
+ if (!success) {
+ retry++;
+ if (retry == MAX_RETRY_LINUX) {
+ System.exit(2);
+ }
+ }
+ } catch (Exception e) {
+ retry++;
+ s_logger.error("SSH Linux Network test fail with error");
+ if (retry == MAX_RETRY_LINUX) {
+ s_logger.error("Ssh test failed");
+ System.exit(2);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/ui/AddAndDeleteAISO.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/ui/AddAndDeleteAISO.java b/test/src/com/cloud/test/ui/AddAndDeleteAISO.java
index 7e6dff1..9063472 100644
--- a/test/src/com/cloud/test/ui/AddAndDeleteAISO.java
+++ b/test/src/com/cloud/test/ui/AddAndDeleteAISO.java
@@ -10,104 +10,104 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.ui;
-
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import com.cloud.test.ui.AbstractSeleniumTestCase;
-import com.thoughtworks.selenium.SeleniumException;
-
-public class AddAndDeleteAISO extends AbstractSeleniumTestCase {
-
- @Test
- public void testAddAndDeleteISO() throws Exception {
- try {
- selenium.open("/client/");
- selenium.type("account_username", "admin");
- selenium.type("account_password", "password");
- selenium.click("loginbutton");
- Thread.sleep(3000);
- assertTrue(selenium.isTextPresent("admin"));
- selenium.click("//div[@id='leftmenu_templates']/div");
- selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]");
- Thread.sleep(3000);
- selenium.click("label");
-
- selenium.type("add_iso_name", "abc");
- selenium.type("add_iso_display_text", "abc");
- String iso_url = System.getProperty("add_iso_url", "http://10.91.28.6/ISO/Fedora-11-i386-DVD.iso");
- selenium.type("add_iso_url", iso_url);
- String iso_zone = System.getProperty("add_iso_zone", "All Zones");
- selenium.select("add_iso_zone", "label="+iso_zone);
- String iso_os_type = System.getProperty("add_iso_os_type", "Fedora 11");
- selenium.select("add_iso_os_type", "label="+iso_os_type);
- selenium.click("//div[28]/div[11]/button[1]");
- Thread.sleep(3000);
- int i=1;
- try
- {
- for(;;i++)
- {
- System.out.println("i= "+i);
- selenium.click("//div[" +i+ "]/div/div[2]/span/span");
- }
- }
- catch(Exception ex) {
- }
-
- for (int second = 0;; second++) {
- if (second >= 60) fail("timeout");
- try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {}
- Thread.sleep(10000);
- }
-
- assertTrue(selenium.isTextPresent("Adding succeeded"));
- Thread.sleep(3000);
- int status=1;
- while(!selenium.isTextPresent("Ready"))
- {
- for(int j =1;j<=i;j++)
-
- {
- if (selenium.isTextPresent("Ready"))
- {
- status=0;
- break;
- }
- selenium.click("//div["+j+"]/div/div[2]/span/span");
- }
- if(status==0){
- break;
- }
- else
- {
- selenium.click("//div[@id='leftmenu_submenu_featured_iso']/div/div[2]");
- Thread.sleep(3000);
- selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]");
- Thread.sleep(3000);
- }
-
- }
- selenium.click("link=Delete ISO");
- selenium.click("//div[28]/div[11]/button[1]");
- for (int second = 0;; second++) {
- if (second >= 60) fail("timeout");
- try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {}
- Thread.sleep(1000);
- }
-
- assertTrue(selenium.isTextPresent("Delete ISO action succeeded"));
- selenium.click("main_logout");
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.isTextPresent("Welcome to Management Console"));
-
- } catch (SeleniumException ex) {
-
- System.err.println(ex.getMessage());
- fail(ex.getMessage());
-
- throw ex;
- }
- }
+package com.cloud.test.ui;
+
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import com.cloud.test.ui.AbstractSeleniumTestCase;
+import com.thoughtworks.selenium.SeleniumException;
+
+public class AddAndDeleteAISO extends AbstractSeleniumTestCase {
+
+ @Test
+ public void testAddAndDeleteISO() throws Exception {
+ try {
+ selenium.open("/client/");
+ selenium.type("account_username", "admin");
+ selenium.type("account_password", "password");
+ selenium.click("loginbutton");
+ Thread.sleep(3000);
+ assertTrue(selenium.isTextPresent("admin"));
+ selenium.click("//div[@id='leftmenu_templates']/div");
+ selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]");
+ Thread.sleep(3000);
+ selenium.click("label");
+
+ selenium.type("add_iso_name", "abc");
+ selenium.type("add_iso_display_text", "abc");
+ String iso_url = System.getProperty("add_iso_url", "http://10.91.28.6/ISO/Fedora-11-i386-DVD.iso");
+ selenium.type("add_iso_url", iso_url);
+ String iso_zone = System.getProperty("add_iso_zone", "All Zones");
+ selenium.select("add_iso_zone", "label="+iso_zone);
+ String iso_os_type = System.getProperty("add_iso_os_type", "Fedora 11");
+ selenium.select("add_iso_os_type", "label="+iso_os_type);
+ selenium.click("//div[28]/div[11]/button[1]");
+ Thread.sleep(3000);
+ int i=1;
+ try
+ {
+ for(;;i++)
+ {
+ System.out.println("i= "+i);
+ selenium.click("//div[" +i+ "]/div/div[2]/span/span");
+ }
+ }
+ catch(Exception ex) {
+ }
+
+ for (int second = 0;; second++) {
+ if (second >= 60) fail("timeout");
+ try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {}
+ Thread.sleep(10000);
+ }
+
+ assertTrue(selenium.isTextPresent("Adding succeeded"));
+ Thread.sleep(3000);
+ int status=1;
+ while(!selenium.isTextPresent("Ready"))
+ {
+ for(int j =1;j<=i;j++)
+
+ {
+ if (selenium.isTextPresent("Ready"))
+ {
+ status=0;
+ break;
+ }
+ selenium.click("//div["+j+"]/div/div[2]/span/span");
+ }
+ if(status==0){
+ break;
+ }
+ else
+ {
+ selenium.click("//div[@id='leftmenu_submenu_featured_iso']/div/div[2]");
+ Thread.sleep(3000);
+ selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]");
+ Thread.sleep(3000);
+ }
+
+ }
+ selenium.click("link=Delete ISO");
+ selenium.click("//div[28]/div[11]/button[1]");
+ for (int second = 0;; second++) {
+ if (second >= 60) fail("timeout");
+ try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {}
+ Thread.sleep(1000);
+ }
+
+ assertTrue(selenium.isTextPresent("Delete ISO action succeeded"));
+ selenium.click("main_logout");
+ selenium.waitForPageToLoad("30000");
+ assertTrue(selenium.isTextPresent("Welcome to Management Console"));
+
+ } catch (SeleniumException ex) {
+
+ System.err.println(ex.getMessage());
+ fail(ex.getMessage());
+
+ throw ex;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java b/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java
index d03b788..7046bde 100644
--- a/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java
+++ b/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java
@@ -10,102 +10,102 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.ui;
-
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import com.cloud.test.ui.AbstractSeleniumTestCase;
-import com.thoughtworks.selenium.SeleniumException;
-
-public class AddAndDeleteATemplate extends AbstractSeleniumTestCase {
-
- @Test
- public void testAddAndDeleteTemplate() throws Exception {
- try {
- selenium.open("/client/");
- selenium.type("account_username", "admin");
- selenium.type("account_password", "password");
- selenium.click("loginbutton");
- Thread.sleep(3000);
- assertTrue(selenium.isTextPresent("admin"));
- selenium.click("//div[@id='leftmenu_templates']/div");
- selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]");
- Thread.sleep(3000);
- selenium.click("label");
- selenium.type("add_template_name", "abc");
- selenium.type("add_template_display_text", "abc");
- String template_url = System.getProperty("add_template_url", "http://10.91.28.6/templates/centos53-x86_64/latest/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2");
- selenium.type("add_template_url", template_url);
- String template_zone = System.getProperty("add_template_zone", "All Zones");
- selenium.select("add_template_zone", "label="+template_zone);
- String template_os_type = System.getProperty("add_template_os_type", "CentOS 5.3 (32-bit)");
- selenium.select("add_template_os_type", "label="+template_os_type);
- selenium.click("//div[28]/div[11]/button[1]");
- Thread.sleep(3000);
- int i=1;
- try
- {
- for(;;i++)
- {
- System.out.println("i= "+i);
- selenium.click("//div[" +i+ "]/div/div[2]/span/span");
- }
- }
- catch(Exception ex) {
- }
-
- for (int second = 0;; second++) {
- if (second >= 60) fail("timeout");
- try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {}
- Thread.sleep(10000);
- }
-
- assertTrue(selenium.isTextPresent("Adding succeeded"));
- Thread.sleep(3000);
- int status=1;
- while(!selenium.isTextPresent("Ready"))
- {
- for(int j =1;j<=i;j++)
-
- {
- if (selenium.isTextPresent("Ready"))
- {
- status=0;
- break;
- }
- selenium.click("//div["+j+"]/div/div[2]/span/span");
- }
- if(status==0){
- break;
- }
- else
- {
- selenium.click("//div[@id='leftmenu_submenu_featured_template']/div/div[2]");
- Thread.sleep(3000);
- selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]");
- Thread.sleep(3000);
- }
-
- }
- selenium.click("link=Delete Template");
- selenium.click("//div[28]/div[11]/button[1]");
- for (int second = 0;; second++) {
- if (second >= 60) fail("timeout");
- try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {}
- Thread.sleep(1000);
- }
-
- assertTrue(selenium.isTextPresent("Delete Template action succeeded"));
- selenium.click("main_logout");
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.isTextPresent("Welcome to Management Console"));
- } catch (SeleniumException ex) {
-
- System.err.println(ex.getMessage());
- fail(ex.getMessage());
-
- throw ex;
- }
- }
+package com.cloud.test.ui;
+
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import com.cloud.test.ui.AbstractSeleniumTestCase;
+import com.thoughtworks.selenium.SeleniumException;
+
+public class AddAndDeleteATemplate extends AbstractSeleniumTestCase {
+
+ @Test
+ public void testAddAndDeleteTemplate() throws Exception {
+ try {
+ selenium.open("/client/");
+ selenium.type("account_username", "admin");
+ selenium.type("account_password", "password");
+ selenium.click("loginbutton");
+ Thread.sleep(3000);
+ assertTrue(selenium.isTextPresent("admin"));
+ selenium.click("//div[@id='leftmenu_templates']/div");
+ selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]");
+ Thread.sleep(3000);
+ selenium.click("label");
+ selenium.type("add_template_name", "abc");
+ selenium.type("add_template_display_text", "abc");
+ String template_url = System.getProperty("add_template_url", "http://10.91.28.6/templates/centos53-x86_64/latest/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2");
+ selenium.type("add_template_url", template_url);
+ String template_zone = System.getProperty("add_template_zone", "All Zones");
+ selenium.select("add_template_zone", "label="+template_zone);
+ String template_os_type = System.getProperty("add_template_os_type", "CentOS 5.3 (32-bit)");
+ selenium.select("add_template_os_type", "label="+template_os_type);
+ selenium.click("//div[28]/div[11]/button[1]");
+ Thread.sleep(3000);
+ int i=1;
+ try
+ {
+ for(;;i++)
+ {
+ System.out.println("i= "+i);
+ selenium.click("//div[" +i+ "]/div/div[2]/span/span");
+ }
+ }
+ catch(Exception ex) {
+ }
+
+ for (int second = 0;; second++) {
+ if (second >= 60) fail("timeout");
+ try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {}
+ Thread.sleep(10000);
+ }
+
+ assertTrue(selenium.isTextPresent("Adding succeeded"));
+ Thread.sleep(3000);
+ int status=1;
+ while(!selenium.isTextPresent("Ready"))
+ {
+ for(int j =1;j<=i;j++)
+
+ {
+ if (selenium.isTextPresent("Ready"))
+ {
+ status=0;
+ break;
+ }
+ selenium.click("//div["+j+"]/div/div[2]/span/span");
+ }
+ if(status==0){
+ break;
+ }
+ else
+ {
+ selenium.click("//div[@id='leftmenu_submenu_featured_template']/div/div[2]");
+ Thread.sleep(3000);
+ selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]");
+ Thread.sleep(3000);
+ }
+
+ }
+ selenium.click("link=Delete Template");
+ selenium.click("//div[28]/div[11]/button[1]");
+ for (int second = 0;; second++) {
+ if (second >= 60) fail("timeout");
+ try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {}
+ Thread.sleep(1000);
+ }
+
+ assertTrue(selenium.isTextPresent("Delete Template action succeeded"));
+ selenium.click("main_logout");
+ selenium.waitForPageToLoad("30000");
+ assertTrue(selenium.isTextPresent("Welcome to Management Console"));
+ } catch (SeleniumException ex) {
+
+ System.err.println(ex.getMessage());
+ fail(ex.getMessage());
+
+ throw ex;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/ConsoleProxy.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/ConsoleProxy.java b/test/src/com/cloud/test/utils/ConsoleProxy.java
index 925195e..cd4741c 100644
--- a/test/src/com/cloud/test/utils/ConsoleProxy.java
+++ b/test/src/com/cloud/test/utils/ConsoleProxy.java
@@ -10,101 +10,101 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-
+package com.cloud.test.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+
import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.Script;
-
-public class ConsoleProxy implements Runnable {
- public static String proxyIp;
- private String command;
- private int connectionsMade;
- private long responseTime;
- public static final Logger s_logger = Logger.getLogger(ConsoleProxy.class
- .getClass());
-
- public ConsoleProxy(String port, String sid, String host) {
- this.command = "https://" + proxyIp
- + ".realhostip.com:8000/getscreen?w=100&h=75&host=" + host
- + "&port=" + port + "&sid=" + sid;
- s_logger.info("Command for a console proxy is " + this.command);
- this.connectionsMade=0;
- this.responseTime=0;
- }
-
- public int getConnectionsMade() {
- return this.connectionsMade;
- }
-
- public long getResponseTime() {
- return this.responseTime;
- }
-
- public void run() {
- while (true){
-
- Script myScript = new Script("wget");
- myScript.add(command);
- myScript.execute();
- long begin = System.currentTimeMillis();
- wgetInt process = new wgetInt();
- String response = myScript.execute(process);
- long end = process.getEnd();
- if (response!=null){
- s_logger.info("Content lenght is incorrect: "+response);
- }
-
- long duration = (end - begin);
- this.connectionsMade++;
- this.responseTime=this.responseTime+duration;
- try{
- Thread.sleep(1000);
- }catch (InterruptedException e){
-
- }
-
- }
- }
-
- public class wgetInt extends OutputInterpreter {
- private long end;
-
- public long getEnd() {
- return end;
- }
-
- public void setEnd(long end) {
- this.end = end;
- }
-
- @Override
- public String interpret(BufferedReader reader) throws IOException {
- // TODO Auto-generated method stub
- end = System.currentTimeMillis();
- String status = null;
- String line = null;
- while ((line = reader.readLine()) != null) {
- int index = line.indexOf("Length:");
- if (index == -1) {
- continue;
- }
- else{
- int index1 = line.indexOf("Length: 1827");
- if (index1 == -1) {
- return status;
- }
- else
- status=line;
- }
-
- }
- return status;
- }
-
- }
-}
+
+public class ConsoleProxy implements Runnable {
+ public static String proxyIp;
+ private String command;
+ private int connectionsMade;
+ private long responseTime;
+ public static final Logger s_logger = Logger.getLogger(ConsoleProxy.class
+ .getClass());
+
+ public ConsoleProxy(String port, String sid, String host) {
+ this.command = "https://" + proxyIp
+ + ".realhostip.com:8000/getscreen?w=100&h=75&host=" + host
+ + "&port=" + port + "&sid=" + sid;
+ s_logger.info("Command for a console proxy is " + this.command);
+ this.connectionsMade=0;
+ this.responseTime=0;
+ }
+
+ public int getConnectionsMade() {
+ return this.connectionsMade;
+ }
+
+ public long getResponseTime() {
+ return this.responseTime;
+ }
+
+ public void run() {
+ while (true){
+
+ Script myScript = new Script("wget");
+ myScript.add(command);
+ myScript.execute();
+ long begin = System.currentTimeMillis();
+ wgetInt process = new wgetInt();
+ String response = myScript.execute(process);
+ long end = process.getEnd();
+ if (response!=null){
+ s_logger.info("Content lenght is incorrect: "+response);
+ }
+
+ long duration = (end - begin);
+ this.connectionsMade++;
+ this.responseTime=this.responseTime+duration;
+ try{
+ Thread.sleep(1000);
+ }catch (InterruptedException e){
+
+ }
+
+ }
+ }
+
+ public class wgetInt extends OutputInterpreter {
+ private long end;
+
+ public long getEnd() {
+ return end;
+ }
+
+ public void setEnd(long end) {
+ this.end = end;
+ }
+
+ @Override
+ public String interpret(BufferedReader reader) throws IOException {
+ // TODO Auto-generated method stub
+ end = System.currentTimeMillis();
+ String status = null;
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ int index = line.indexOf("Length:");
+ if (index == -1) {
+ continue;
+ }
+ else{
+ int index1 = line.indexOf("Length: 1827");
+ if (index1 == -1) {
+ return status;
+ }
+ else
+ status=line;
+ }
+
+ }
+ return status;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/IpSqlGenerator.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/IpSqlGenerator.java b/test/src/com/cloud/test/utils/IpSqlGenerator.java
index 31f3b31..1a90c20 100644
--- a/test/src/com/cloud/test/utils/IpSqlGenerator.java
+++ b/test/src/com/cloud/test/utils/IpSqlGenerator.java
@@ -10,75 +10,75 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.StringTokenizer;
-
-public class IpSqlGenerator {
- public static void main (String[] args) {
- try {
- if (args.length != 5) {
- System.out.println("Usage -- generate-ip.sh <public|private> <begin ip range> <end ip range> <data center id> <pod id>");
- System.out.println("Example -- generate-ip.sh public 192.168.1.1 192.168.1.255 1 1");
- System.out.println(" will generate ips ranging from public ips 192.168.1.1 to 192.168.1.255 for dc 1 and pod 1");
- return;
- }
-
- String type = args[0];
-
- StringTokenizer st = new StringTokenizer(args[1], ".");
- int ipS1 = Integer.parseInt(st.nextToken());
- int ipS2 = Integer.parseInt(st.nextToken());
- int ipS3 = Integer.parseInt(st.nextToken());
- int ipS4 = Integer.parseInt(st.nextToken());
-
- st = new StringTokenizer(args[2], ".");
- int ipE1 = Integer.parseInt(st.nextToken());
- int ipE2 = Integer.parseInt(st.nextToken());
- int ipE3 = Integer.parseInt(st.nextToken());
- int ipE4 = Integer.parseInt(st.nextToken());
-
- String dcId = args[3];
- String podId = args[4];
-
- if (type.equals("private")) {
- FileOutputStream fs = new FileOutputStream(new File("private-ips.sql"));
- DataOutputStream out = new DataOutputStream(fs);
- for (int i = ipS1; i <= ipE1; i++) {
- for (int j = ipS2; j <= ipE2; j++) {
- for (int k = ipS3; k <= ipE3; k++) {
- for (int l = ipS4; l <= ipE4; l++) {
- out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('"
- + i + "." + j + "." + k + "." + l + "'," + dcId + "," + podId + ");\r\n");
- }
- }
- }
- }
- out.writeBytes("\r\n");
- out.flush();
- out.close();
- } else {
- FileOutputStream fs = new FileOutputStream(new File("public-ips.sql"));
- DataOutputStream out = new DataOutputStream(fs);
- for (int i = ipS1; i <= ipE1; i++) {
- for (int j = ipS2; j <= ipE2; j++) {
- for (int k = ipS3; k <= ipE3; k++) {
- for (int l = ipS4; l <= ipE4; l++) {
- out.writeBytes("INSERT INTO `vmops`.`user_ip_address` (ip_address, data_center_id) VALUES ('"
- + i + "." + j + "." + k + "." + l + "'," + dcId + ");\r\n");
- }
- }
- }
- }
- out.writeBytes("\r\n");
- out.flush();
- out.close();
- }
- } catch (Exception e) {
-
- }
- }
-}
+package com.cloud.test.utils;
+
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.StringTokenizer;
+
+public class IpSqlGenerator {
+ public static void main (String[] args) {
+ try {
+ if (args.length != 5) {
+ System.out.println("Usage -- generate-ip.sh <public|private> <begin ip range> <end ip range> <data center id> <pod id>");
+ System.out.println("Example -- generate-ip.sh public 192.168.1.1 192.168.1.255 1 1");
+ System.out.println(" will generate ips ranging from public ips 192.168.1.1 to 192.168.1.255 for dc 1 and pod 1");
+ return;
+ }
+
+ String type = args[0];
+
+ StringTokenizer st = new StringTokenizer(args[1], ".");
+ int ipS1 = Integer.parseInt(st.nextToken());
+ int ipS2 = Integer.parseInt(st.nextToken());
+ int ipS3 = Integer.parseInt(st.nextToken());
+ int ipS4 = Integer.parseInt(st.nextToken());
+
+ st = new StringTokenizer(args[2], ".");
+ int ipE1 = Integer.parseInt(st.nextToken());
+ int ipE2 = Integer.parseInt(st.nextToken());
+ int ipE3 = Integer.parseInt(st.nextToken());
+ int ipE4 = Integer.parseInt(st.nextToken());
+
+ String dcId = args[3];
+ String podId = args[4];
+
+ if (type.equals("private")) {
+ FileOutputStream fs = new FileOutputStream(new File("private-ips.sql"));
+ DataOutputStream out = new DataOutputStream(fs);
+ for (int i = ipS1; i <= ipE1; i++) {
+ for (int j = ipS2; j <= ipE2; j++) {
+ for (int k = ipS3; k <= ipE3; k++) {
+ for (int l = ipS4; l <= ipE4; l++) {
+ out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('"
+ + i + "." + j + "." + k + "." + l + "'," + dcId + "," + podId + ");\r\n");
+ }
+ }
+ }
+ }
+ out.writeBytes("\r\n");
+ out.flush();
+ out.close();
+ } else {
+ FileOutputStream fs = new FileOutputStream(new File("public-ips.sql"));
+ DataOutputStream out = new DataOutputStream(fs);
+ for (int i = ipS1; i <= ipE1; i++) {
+ for (int j = ipS2; j <= ipE2; j++) {
+ for (int k = ipS3; k <= ipE3; k++) {
+ for (int l = ipS4; l <= ipE4; l++) {
+ out.writeBytes("INSERT INTO `vmops`.`user_ip_address` (ip_address, data_center_id) VALUES ('"
+ + i + "." + j + "." + k + "." + l + "'," + dcId + ");\r\n");
+ }
+ }
+ }
+ }
+ out.writeBytes("\r\n");
+ out.flush();
+ out.close();
+ }
+ } catch (Exception e) {
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/ProxyLoadTemp.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/ProxyLoadTemp.java b/test/src/com/cloud/test/utils/ProxyLoadTemp.java
index ff166a8..da72ed0 100644
--- a/test/src/com/cloud/test/utils/ProxyLoadTemp.java
+++ b/test/src/com/cloud/test/utils/ProxyLoadTemp.java
@@ -10,108 +10,108 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.util.ArrayList;
-
-import org.apache.log4j.Logger;
-
-
-
-
-public class ProxyLoadTemp {
- public static final Logger s_logger= Logger.getLogger(ProxyLoadTemp.class.getClass());
- public static int numThreads=0;
- public static ArrayList<ConsoleProxy> proxyList = new ArrayList<ConsoleProxy>();
- public static long begin;
- public static long end;
- public static long sum=0;
-
- public ProxyLoadTemp(){
- }
-
- public static void main (String[] args){
- begin= System.currentTimeMillis();
- Runtime.getRuntime().addShutdownHook(new ShutdownThread(new ProxyLoadTemp()));
- ConsoleProxy.proxyIp="172-16-1-101";
-
- try
- {
- BufferedReader consoleInput = new BufferedReader(new FileReader("console.input"));
- boolean eof = false;
- s_logger.info("Started reading file");
- while (!eof){
- String line = consoleInput.readLine();
- s_logger.info("Line is "+line);
- if (line == null){
- s_logger.info("Line "+numThreads+" is null");
- eof=true;
- }
- else{
- String[] result=null;
- try
- {
- s_logger.info("Starting parsing line "+line);
- result= parseLine(line, "[,]");
- s_logger.info("Line retrieved from the file is "+result[0]+" "+result[1]+" "+result[2]);
- ConsoleProxy proxy = new ConsoleProxy(result[0], result[1], result[2]);
- proxyList.add(proxy);
- new Thread(proxy).start();
- numThreads++;
-
- }
- catch (Exception ex){
- s_logger.warn(ex);
- }
- }
-
- }
- }catch(Exception e){
- s_logger.warn(e);
- }
-
- }
-
- public static class ShutdownThread extends Thread {
- ProxyLoadTemp temp;
- public ShutdownThread(ProxyLoadTemp temp) {
- this.temp = temp;
- }
- public void run() {
- s_logger.info("Program was running in "+numThreads+" threads");
-
- for (int j=0; j<proxyList.size(); j++){
- long av=0;
- if (proxyList.get(j).getConnectionsMade()!=0){
- av=proxyList.get(j).getResponseTime()/proxyList.get(j).getConnectionsMade();
- }
- s_logger.info("Information for "+j+" thread: Number of requests sent is "+proxyList.get(j).getConnectionsMade()+". Average response time is "+av+" milliseconds");
- sum=sum+av;
-
- }
- ProxyLoadTemp.end= System.currentTimeMillis();
- s_logger.info("Summary for all"+numThreads+" threads: Average response time is "+sum/numThreads+" milliseconds");
- s_logger.info("Test was running for "+(ProxyLoadTemp.end-ProxyLoadTemp.begin)/1000+" seconds");
- }
- }
-
-
- public static String[] parseLine(String line, String del) throws Exception
- {
- String del1=del.substring(1, del.length()-1);
- if (line.contains(del1)!=true)
- {
- throw new Exception();
- }
- else
- {
- String[] token = line.split(del);
- return token;
- }
-
- }
-
-
-}
+package com.cloud.test.utils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.util.ArrayList;
+
+import org.apache.log4j.Logger;
+
+
+
+
+public class ProxyLoadTemp {
+ public static final Logger s_logger= Logger.getLogger(ProxyLoadTemp.class.getClass());
+ public static int numThreads=0;
+ public static ArrayList<ConsoleProxy> proxyList = new ArrayList<ConsoleProxy>();
+ public static long begin;
+ public static long end;
+ public static long sum=0;
+
+ public ProxyLoadTemp(){
+ }
+
+ public static void main (String[] args){
+ begin= System.currentTimeMillis();
+ Runtime.getRuntime().addShutdownHook(new ShutdownThread(new ProxyLoadTemp()));
+ ConsoleProxy.proxyIp="172-16-1-101";
+
+ try
+ {
+ BufferedReader consoleInput = new BufferedReader(new FileReader("console.input"));
+ boolean eof = false;
+ s_logger.info("Started reading file");
+ while (!eof){
+ String line = consoleInput.readLine();
+ s_logger.info("Line is "+line);
+ if (line == null){
+ s_logger.info("Line "+numThreads+" is null");
+ eof=true;
+ }
+ else{
+ String[] result=null;
+ try
+ {
+ s_logger.info("Starting parsing line "+line);
+ result= parseLine(line, "[,]");
+ s_logger.info("Line retrieved from the file is "+result[0]+" "+result[1]+" "+result[2]);
+ ConsoleProxy proxy = new ConsoleProxy(result[0], result[1], result[2]);
+ proxyList.add(proxy);
+ new Thread(proxy).start();
+ numThreads++;
+
+ }
+ catch (Exception ex){
+ s_logger.warn(ex);
+ }
+ }
+
+ }
+ }catch(Exception e){
+ s_logger.warn(e);
+ }
+
+ }
+
+ public static class ShutdownThread extends Thread {
+ ProxyLoadTemp temp;
+ public ShutdownThread(ProxyLoadTemp temp) {
+ this.temp = temp;
+ }
+ public void run() {
+ s_logger.info("Program was running in "+numThreads+" threads");
+
+ for (int j=0; j<proxyList.size(); j++){
+ long av=0;
+ if (proxyList.get(j).getConnectionsMade()!=0){
+ av=proxyList.get(j).getResponseTime()/proxyList.get(j).getConnectionsMade();
+ }
+ s_logger.info("Information for "+j+" thread: Number of requests sent is "+proxyList.get(j).getConnectionsMade()+". Average response time is "+av+" milliseconds");
+ sum=sum+av;
+
+ }
+ ProxyLoadTemp.end= System.currentTimeMillis();
+ s_logger.info("Summary for all"+numThreads+" threads: Average response time is "+sum/numThreads+" milliseconds");
+ s_logger.info("Test was running for "+(ProxyLoadTemp.end-ProxyLoadTemp.begin)/1000+" seconds");
+ }
+ }
+
+
+ public static String[] parseLine(String line, String del) throws Exception
+ {
+ String del1=del.substring(1, del.length()-1);
+ if (line.contains(del1)!=true)
+ {
+ throw new Exception();
+ }
+ else
+ {
+ String[] token = line.split(del);
+ return token;
+ }
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/SignRequest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/SignRequest.java b/test/src/com/cloud/test/utils/SignRequest.java
index 4d8dc46..cbb7864 100644
--- a/test/src/com/cloud/test/utils/SignRequest.java
+++ b/test/src/com/cloud/test/utils/SignRequest.java
@@ -10,8 +10,8 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
+package com.cloud.test.utils;
+
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Iterator;
@@ -20,91 +20,91 @@ import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
-
-public class SignRequest {
- public static String url;
- public static String apikey;
- public static String secretkey;
- public static String command;
-
-
- public static void main (String[] args) {
- // Parameters
- List<String> argsList = Arrays.asList(args);
- Iterator<String> iter = argsList.iterator();
- while (iter.hasNext()) {
- String arg = iter.next();
- if (arg.equals("-a")) {
- apikey = iter.next();
-
- }
- if (arg.equals("-u")) {
- url = iter.next();
- }
-
- if (arg.equals("-s")) {
- secretkey = iter.next();
- }
- }
-
-
- if (url == null) {
- System.out.println("Please specify url with -u option. Example: -u \"command=listZones&id=1\"");
- System.exit(1);
- }
-
- if (apikey == null) {
- System.out.println("Please specify apikey with -a option");
- System.exit(1);
- }
-
- if (secretkey == null) {
- System.out.println("Please specify secretkey with -s option");
- System.exit(1);
- }
-
- TreeMap<String, String> param = new TreeMap<String, String>();
-
- String temp = "";
- param.put("apikey", apikey);
-
- StringTokenizer str1 = new StringTokenizer (url, "&");
- while(str1.hasMoreTokens()) {
- String newEl = str1.nextToken();
- StringTokenizer str2 = new StringTokenizer(newEl, "=");
- String name = str2.nextToken();
- String value= str2.nextToken();
- param.put(name, value);
- }
-
- //sort url hash map by key
- Set c = param.entrySet();
- Iterator it = c.iterator();
- while (it.hasNext()) {
- Map.Entry me = (Map.Entry)it.next();
- String key = (String) me.getKey();
- String value = (String) me.getValue();
- try {
- temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&";
- } catch (Exception ex) {
- System.out.println("Unable to set parameter " + value + " for the command " + param.get("command"));
- }
-
- }
- temp = temp.substring(0, temp.length()-1 );
+
+public class SignRequest {
+ public static String url;
+ public static String apikey;
+ public static String secretkey;
+ public static String command;
+
+
+ public static void main (String[] args) {
+ // Parameters
+ List<String> argsList = Arrays.asList(args);
+ Iterator<String> iter = argsList.iterator();
+ while (iter.hasNext()) {
+ String arg = iter.next();
+ if (arg.equals("-a")) {
+ apikey = iter.next();
+
+ }
+ if (arg.equals("-u")) {
+ url = iter.next();
+ }
+
+ if (arg.equals("-s")) {
+ secretkey = iter.next();
+ }
+ }
+
+
+ if (url == null) {
+ System.out.println("Please specify url with -u option. Example: -u \"command=listZones&id=1\"");
+ System.exit(1);
+ }
+
+ if (apikey == null) {
+ System.out.println("Please specify apikey with -a option");
+ System.exit(1);
+ }
+
+ if (secretkey == null) {
+ System.out.println("Please specify secretkey with -s option");
+ System.exit(1);
+ }
+
+ TreeMap<String, String> param = new TreeMap<String, String>();
+
+ String temp = "";
+ param.put("apikey", apikey);
+
+ StringTokenizer str1 = new StringTokenizer (url, "&");
+ while(str1.hasMoreTokens()) {
+ String newEl = str1.nextToken();
+ StringTokenizer str2 = new StringTokenizer(newEl, "=");
+ String name = str2.nextToken();
+ String value= str2.nextToken();
+ param.put(name, value);
+ }
+
+ //sort url hash map by key
+ Set c = param.entrySet();
+ Iterator it = c.iterator();
+ while (it.hasNext()) {
+ Map.Entry me = (Map.Entry)it.next();
+ String key = (String) me.getKey();
+ String value = (String) me.getValue();
+ try {
+ temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&";
+ } catch (Exception ex) {
+ System.out.println("Unable to set parameter " + value + " for the command " + param.get("command"));
+ }
+
+ }
+ temp = temp.substring(0, temp.length()-1 );
String requestToSign = temp.toLowerCase();
- System.out.println("After sorting: " + requestToSign);
+ System.out.println("After sorting: " + requestToSign);
String signature = UtilsForTest.signRequest(requestToSign, secretkey);
- System.out.println("After Base64 encoding: " + signature);
- String encodedSignature = "";
- try {
- encodedSignature = URLEncoder.encode(signature, "UTF-8");
- } catch (Exception ex) {
- System.out.println(ex);
+ System.out.println("After Base64 encoding: " + signature);
+ String encodedSignature = "";
+ try {
+ encodedSignature = URLEncoder.encode(signature, "UTF-8");
+ } catch (Exception ex) {
+ System.out.println(ex);
}
- System.out.println("After UTF8 encoding: " + encodedSignature);
+ System.out.println("After UTF8 encoding: " + encodedSignature);
String url = temp + "&signature=" + encodedSignature;
- System.out.println("After sort and add signature: " + url);
-
- }
-}
+ System.out.println("After sort and add signature: " + url);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/SqlDataGenerator.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/SqlDataGenerator.java b/test/src/com/cloud/test/utils/SqlDataGenerator.java
index efa9b58..5060cd8 100644
--- a/test/src/com/cloud/test/utils/SqlDataGenerator.java
+++ b/test/src/com/cloud/test/utils/SqlDataGenerator.java
@@ -10,35 +10,35 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.Formatter;
-
-public class SqlDataGenerator {
- public static void main (String[] args) {
- try {
- FileOutputStream fs = new FileOutputStream(new File("out.txt"));
-
- DataOutputStream out = new DataOutputStream(fs);
-
- for (int i = 20; i < 171; i++) {
- out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('192.168.2."+i+"',1,1);\r\n");
- }
- out.writeBytes("\r\n");
- for (int i = 1; i < 10000; i++) {
- StringBuilder imagePath = new StringBuilder();
- Formatter formatter = new Formatter(imagePath);
- formatter.format("%04x", i);
- out.writeBytes("INSERT INTO `vmops`.`dc_vnet_alloc` (vnet, data_center_id) VALUES ('"+imagePath.toString()+"',1);\r\n");
- }
-
- out.flush();
- out.close();
- } catch (Exception e) {
-
- }
- }
-}
+package com.cloud.test.utils;
+
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Formatter;
+
+public class SqlDataGenerator {
+ public static void main (String[] args) {
+ try {
+ FileOutputStream fs = new FileOutputStream(new File("out.txt"));
+
+ DataOutputStream out = new DataOutputStream(fs);
+
+ for (int i = 20; i < 171; i++) {
+ out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('192.168.2."+i+"',1,1);\r\n");
+ }
+ out.writeBytes("\r\n");
+ for (int i = 1; i < 10000; i++) {
+ StringBuilder imagePath = new StringBuilder();
+ Formatter formatter = new Formatter(imagePath);
+ formatter.format("%04x", i);
+ out.writeBytes("INSERT INTO `vmops`.`dc_vnet_alloc` (vnet, data_center_id) VALUES ('"+imagePath.toString()+"',1);\r\n");
+ }
+
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/TestClient.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/TestClient.java b/test/src/com/cloud/test/utils/TestClient.java
index 2086510..f2ce4ef 100644
--- a/test/src/com/cloud/test/utils/TestClient.java
+++ b/test/src/com/cloud/test/utils/TestClient.java
@@ -10,368 +10,368 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.log4j.Logger;
-import org.apache.log4j.NDC;
-
-import com.trilead.ssh2.ChannelCondition;
-import com.trilead.ssh2.Connection;
-import com.trilead.ssh2.SCPClient;
-import com.trilead.ssh2.Session;
-
-public class TestClient {
- private static long sleepTime = 180000L; // default 0
- private static boolean cleanUp = true;
- public static final Logger s_logger = Logger.getLogger(TestClient.class.getName());
- private static boolean repeat = true;
- private static int numOfUsers = 0;
- private static String[] users = null;
- private static boolean internet = true;
-
- private static final int MAX_RETRY_LINUX = 5;
- private static final int MAX_RETRY_WIN = 10;
-
- public static void main (String[] args) {
- String host = "http://localhost";
- String port = "8080";
- String testUrl = "/client/test";
- int numThreads = 1;
-
- 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("-t")) {
- numThreads = Integer.parseInt(iter.next());
- }
-
- if (arg.equals("-s")) {
- sleepTime = Long.parseLong(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("-u")) {
- numOfUsers = Integer.parseInt(iter.next());
- }
-
- if (arg.equals("-i")) {
- internet = Boolean.parseBoolean(iter.next());
- }
- }
-
- final String server = host+":"+port+testUrl;
- 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");
-
- if (numOfUsers > 0) {
- s_logger.info("Pre-generating users for test of size : " + numOfUsers);
- users = new String[numOfUsers];
- Random ran = new Random();
- for (int i = 0; i < numOfUsers; i++) {
- users[i] = Math.abs(ran.nextInt()) + "-user";
- }
- }
-
- 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();
- if (users != null) {
- username = users[Math.abs(ran.nextInt()) % numOfUsers];
- } else {
- username = Math.abs(ran.nextInt())+"-user";
- }
- NDC.push(username);
-
- String url = server+"?email="+username+"&password="+username+"&command=deploy";
- s_logger.info("Launching test for user: " + username + " with url: " + url);
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- boolean success = false;
- String reason = null;
- if (responseCode == 200) {
- if (internet) {
- s_logger.info("Deploy successful...waiting 5 minute before SSH tests");
- Thread.sleep(300000L); // Wait 60 seconds so the linux VM can boot up.
-
- s_logger.info("Begin Linux SSH test");
- reason = sshTest(method.getResponseHeader("linuxIP").getValue());
-
- if (reason == null) {
- s_logger.info("Linux SSH test successful");
- s_logger.info("Begin Windows SSH test");
- reason = sshWinTest(method.getResponseHeader("windowsIP").getValue());
- }
- }
- if (reason == null) {
- if (internet) {
- s_logger.info("Windows SSH test successful");
- } 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 (users == null) {
- s_logger.info("Sending cleanup command");
- url = server+"?email="+username+"&password="+username+"&command=cleanup";
- } else {
- s_logger.info("Sending stop DomR / destroy VM command");
- url = server+"?email="+username+"&password="+username+"&command=stopDomR";
- }
- method = new GetMethod(url);
- responseCode = client.executeMethod(method);
- if (responseCode == 200) {
- success = true;
- } else {
- reason = method.getStatusText();
- }
- } else {
- // Just stop but don't destroy the VMs/Routers
- s_logger.info("SSH test failed with reason '" + reason + "', stopping VMs");
- url = server+"?email="+username+"&password="+username+"&command=stop";
- responseCode = client.executeMethod(new GetMethod(url));
- }
- } else {
- // Just stop but don't destroy the VMs/Routers
- reason = method.getStatusText();
- s_logger.info("Deploy test failed with reason '" + reason + "', stopping VMs");
- url = server+"?email="+username+"&password="+username+"&command=stop";
- client.executeMethod(new GetMethod(url));
- }
-
- 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);
- }
- } catch (Exception e) {
- s_logger.warn("Error in thread", e);
- try {
- HttpClient client = new HttpClient();
- String url = server+"?email="+username+"&password="+username+"&command=stop";
- client.executeMethod(new GetMethod(url));
- } catch (Exception e1) {
- }
- } finally {
- NDC.clear();
- }
- } while (repeat);
- }
- }).start();
- }
- } catch (Exception e) {
- s_logger.error(e);
- }
- }
-
- private static String sshWinTest(String host) {
- if (host == null) {
- s_logger.info("Did not receive a host back from test, ignoring win ssh test");
- return null;
- }
-
- // We will retry 5 times before quitting
- int retry = 0;
-
- while (true) {
- try {
- if (retry > 0) {
- s_logger.info("Retry attempt : " + retry + " ...sleeping 300 seconds before next attempt");
- Thread.sleep(300000);
- }
-
- s_logger.info("Attempting to SSH into windows host " + host + " with retry attempt: " + retry);
-
- Connection conn = new Connection(host);
- conn.connect(null, 60000, 60000);
-
- s_logger.info("SSHed successfully into windows host " + host);
- boolean success = false;
- boolean isAuthenticated = conn.authenticateWithPassword("vmops", "vmops");
- if (isAuthenticated == false) {
- return "Authentication failed";
- }
- SCPClient scp = new SCPClient(conn);
-
- scp.put("wget.exe", "");
-
- Session sess = conn.openSession();
- s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
- sess.execCommand("wget http://172.16.0.220/dump.bin && dir dump.bin");
-
- InputStream stdout = sess.getStdout();
- InputStream stderr = sess.getStderr();
-
- byte[] buffer = new byte[8192];
- while (true) {
- if ((stdout.available() == 0) && (stderr.available() == 0)) {
- int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA
- | ChannelCondition.EOF, 120000);
-
- if ((conditions & ChannelCondition.TIMEOUT) != 0) {
- s_logger.info("Timeout while waiting for data from peer.");
- return null;
- }
-
- if ((conditions & ChannelCondition.EOF) != 0) {
- if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
- break;
- }
- }
- }
-
- while (stdout.available() > 0) {
- success = true;
- int len = stdout.read(buffer);
- if (len > 0) // this check is somewhat paranoid
- s_logger.info(new String(buffer, 0, len));
- }
-
- while (stderr.available() > 0) {
- int len = stderr.read(buffer);
- }
- }
- sess.close();
- conn.close();
-
- if (success) {
- return null;
- } else {
- retry++;
- if (retry == MAX_RETRY_WIN) {
- return "SSH Windows Network test fail";
- }
- }
- } catch (Exception e) {
- retry++;
- if (retry == MAX_RETRY_WIN) {
- return "SSH Windows Network test fail with error " + e.getMessage();
- }
- }
- }
- }
-
- private static String sshTest(String host) {
- if (host == null) {
- s_logger.info("Did not receive a host back from test, ignoring ssh test");
- return null;
- }
-
- // We will retry 5 times before quitting
- int retry = 0;
-
- while (true) {
- try {
- if (retry > 0) {
- s_logger.info("Retry attempt : " + retry + " ...sleeping 120 seconds before next attempt");
- Thread.sleep(120000);
- }
-
- s_logger.info("Attempting to SSH into linux host " + host + " with retry attempt: " + retry);
-
- Connection conn = new Connection(host);
- conn.connect(null, 60000, 60000);
-
- s_logger.info("SSHed successfully into linux host " + host);
-
- boolean isAuthenticated = conn.authenticateWithPassword("root", "password");
-
- if (isAuthenticated == false) {
- return "Authentication failed";
- }
- boolean success = false;
- Session sess = conn.openSession();
- s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
- sess.execCommand("wget http://172.16.0.220/dump.bin && ls -al dump.bin");
-
- InputStream stdout = sess.getStdout();
- InputStream stderr = sess.getStderr();
-
- byte[] buffer = new byte[8192];
- while (true) {
- if ((stdout.available() == 0) && (stderr.available() == 0)) {
- int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA
- | ChannelCondition.EOF, 120000);
-
- if ((conditions & ChannelCondition.TIMEOUT) != 0) {
- s_logger.info("Timeout while waiting for data from peer.");
- return null;
- }
-
- if ((conditions & ChannelCondition.EOF) != 0) {
- if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
- break;
- }
- }
- }
-
- while (stdout.available() > 0) {
- success = true;
- int len = stdout.read(buffer);
- if (len > 0) // this check is somewhat paranoid
- s_logger.info(new String(buffer, 0, len));
- }
-
- while (stderr.available() > 0) {
- int len = stderr.read(buffer);
- }
- }
-
- sess.close();
- conn.close();
-
- if (success) {
- return null;
- } else {
- retry++;
- if (retry == MAX_RETRY_LINUX) {
- return "SSH Linux Network test fail";
- }
- }
- } catch (Exception e) {
- retry++;
- if (retry == MAX_RETRY_LINUX) {
- return "SSH Linux Network test fail with error " + e.getMessage();
- }
- }
- }
- }
-}
+package com.cloud.test.utils;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
+
+import com.trilead.ssh2.ChannelCondition;
+import com.trilead.ssh2.Connection;
+import com.trilead.ssh2.SCPClient;
+import com.trilead.ssh2.Session;
+
+public class TestClient {
+ private static long sleepTime = 180000L; // default 0
+ private static boolean cleanUp = true;
+ public static final Logger s_logger = Logger.getLogger(TestClient.class.getName());
+ private static boolean repeat = true;
+ private static int numOfUsers = 0;
+ private static String[] users = null;
+ private static boolean internet = true;
+
+ private static final int MAX_RETRY_LINUX = 5;
+ private static final int MAX_RETRY_WIN = 10;
+
+ public static void main (String[] args) {
+ String host = "http://localhost";
+ String port = "8080";
+ String testUrl = "/client/test";
+ int numThreads = 1;
+
+ 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("-t")) {
+ numThreads = Integer.parseInt(iter.next());
+ }
+
+ if (arg.equals("-s")) {
+ sleepTime = Long.parseLong(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("-u")) {
+ numOfUsers = Integer.parseInt(iter.next());
+ }
+
+ if (arg.equals("-i")) {
+ internet = Boolean.parseBoolean(iter.next());
+ }
+ }
+
+ final String server = host+":"+port+testUrl;
+ 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");
+
+ if (numOfUsers > 0) {
+ s_logger.info("Pre-generating users for test of size : " + numOfUsers);
+ users = new String[numOfUsers];
+ Random ran = new Random();
+ for (int i = 0; i < numOfUsers; i++) {
+ users[i] = Math.abs(ran.nextInt()) + "-user";
+ }
+ }
+
+ 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();
+ if (users != null) {
+ username = users[Math.abs(ran.nextInt()) % numOfUsers];
+ } else {
+ username = Math.abs(ran.nextInt())+"-user";
+ }
+ NDC.push(username);
+
+ String url = server+"?email="+username+"&password="+username+"&command=deploy";
+ s_logger.info("Launching test for user: " + username + " with url: " + url);
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ boolean success = false;
+ String reason = null;
+ if (responseCode == 200) {
+ if (internet) {
+ s_logger.info("Deploy successful...waiting 5 minute before SSH tests");
+ Thread.sleep(300000L); // Wait 60 seconds so the linux VM can boot up.
+
+ s_logger.info("Begin Linux SSH test");
+ reason = sshTest(method.getResponseHeader("linuxIP").getValue());
+
+ if (reason == null) {
+ s_logger.info("Linux SSH test successful");
+ s_logger.info("Begin Windows SSH test");
+ reason = sshWinTest(method.getResponseHeader("windowsIP").getValue());
+ }
+ }
+ if (reason == null) {
+ if (internet) {
+ s_logger.info("Windows SSH test successful");
+ } 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 (users == null) {
+ s_logger.info("Sending cleanup command");
+ url = server+"?email="+username+"&password="+username+"&command=cleanup";
+ } else {
+ s_logger.info("Sending stop DomR / destroy VM command");
+ url = server+"?email="+username+"&password="+username+"&command=stopDomR";
+ }
+ method = new GetMethod(url);
+ responseCode = client.executeMethod(method);
+ if (responseCode == 200) {
+ success = true;
+ } else {
+ reason = method.getStatusText();
+ }
+ } else {
+ // Just stop but don't destroy the VMs/Routers
+ s_logger.info("SSH test failed with reason '" + reason + "', stopping VMs");
+ url = server+"?email="+username+"&password="+username+"&command=stop";
+ responseCode = client.executeMethod(new GetMethod(url));
+ }
+ } else {
+ // Just stop but don't destroy the VMs/Routers
+ reason = method.getStatusText();
+ s_logger.info("Deploy test failed with reason '" + reason + "', stopping VMs");
+ url = server+"?email="+username+"&password="+username+"&command=stop";
+ client.executeMethod(new GetMethod(url));
+ }
+
+ 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);
+ }
+ } catch (Exception e) {
+ s_logger.warn("Error in thread", e);
+ try {
+ HttpClient client = new HttpClient();
+ String url = server+"?email="+username+"&password="+username+"&command=stop";
+ client.executeMethod(new GetMethod(url));
+ } catch (Exception e1) {
+ }
+ } finally {
+ NDC.clear();
+ }
+ } while (repeat);
+ }
+ }).start();
+ }
+ } catch (Exception e) {
+ s_logger.error(e);
+ }
+ }
+
+ private static String sshWinTest(String host) {
+ if (host == null) {
+ s_logger.info("Did not receive a host back from test, ignoring win ssh test");
+ return null;
+ }
+
+ // We will retry 5 times before quitting
+ int retry = 0;
+
+ while (true) {
+ try {
+ if (retry > 0) {
+ s_logger.info("Retry attempt : " + retry + " ...sleeping 300 seconds before next attempt");
+ Thread.sleep(300000);
+ }
+
+ s_logger.info("Attempting to SSH into windows host " + host + " with retry attempt: " + retry);
+
+ Connection conn = new Connection(host);
+ conn.connect(null, 60000, 60000);
+
+ s_logger.info("SSHed successfully into windows host " + host);
+ boolean success = false;
+ boolean isAuthenticated = conn.authenticateWithPassword("vmops", "vmops");
+ if (isAuthenticated == false) {
+ return "Authentication failed";
+ }
+ SCPClient scp = new SCPClient(conn);
+
+ scp.put("wget.exe", "");
+
+ Session sess = conn.openSession();
+ s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
+ sess.execCommand("wget http://172.16.0.220/dump.bin && dir dump.bin");
+
+ InputStream stdout = sess.getStdout();
+ InputStream stderr = sess.getStderr();
+
+ byte[] buffer = new byte[8192];
+ while (true) {
+ if ((stdout.available() == 0) && (stderr.available() == 0)) {
+ int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA
+ | ChannelCondition.EOF, 120000);
+
+ if ((conditions & ChannelCondition.TIMEOUT) != 0) {
+ s_logger.info("Timeout while waiting for data from peer.");
+ return null;
+ }
+
+ if ((conditions & ChannelCondition.EOF) != 0) {
+ if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
+ break;
+ }
+ }
+ }
+
+ while (stdout.available() > 0) {
+ success = true;
+ int len = stdout.read(buffer);
+ if (len > 0) // this check is somewhat paranoid
+ s_logger.info(new String(buffer, 0, len));
+ }
+
+ while (stderr.available() > 0) {
+ int len = stderr.read(buffer);
+ }
+ }
+ sess.close();
+ conn.close();
+
+ if (success) {
+ return null;
+ } else {
+ retry++;
+ if (retry == MAX_RETRY_WIN) {
+ return "SSH Windows Network test fail";
+ }
+ }
+ } catch (Exception e) {
+ retry++;
+ if (retry == MAX_RETRY_WIN) {
+ return "SSH Windows Network test fail with error " + e.getMessage();
+ }
+ }
+ }
+ }
+
+ private static String sshTest(String host) {
+ if (host == null) {
+ s_logger.info("Did not receive a host back from test, ignoring ssh test");
+ return null;
+ }
+
+ // We will retry 5 times before quitting
+ int retry = 0;
+
+ while (true) {
+ try {
+ if (retry > 0) {
+ s_logger.info("Retry attempt : " + retry + " ...sleeping 120 seconds before next attempt");
+ Thread.sleep(120000);
+ }
+
+ s_logger.info("Attempting to SSH into linux host " + host + " with retry attempt: " + retry);
+
+ Connection conn = new Connection(host);
+ conn.connect(null, 60000, 60000);
+
+ s_logger.info("SSHed successfully into linux host " + host);
+
+ boolean isAuthenticated = conn.authenticateWithPassword("root", "password");
+
+ if (isAuthenticated == false) {
+ return "Authentication failed";
+ }
+ boolean success = false;
+ Session sess = conn.openSession();
+ s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
+ sess.execCommand("wget http://172.16.0.220/dump.bin && ls -al dump.bin");
+
+ InputStream stdout = sess.getStdout();
+ InputStream stderr = sess.getStderr();
+
+ byte[] buffer = new byte[8192];
+ while (true) {
+ if ((stdout.available() == 0) && (stderr.available() == 0)) {
+ int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA
+ | ChannelCondition.EOF, 120000);
+
+ if ((conditions & ChannelCondition.TIMEOUT) != 0) {
+ s_logger.info("Timeout while waiting for data from peer.");
+ return null;
+ }
+
+ if ((conditions & ChannelCondition.EOF) != 0) {
+ if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) {
+ break;
+ }
+ }
+ }
+
+ while (stdout.available() > 0) {
+ success = true;
+ int len = stdout.read(buffer);
+ if (len > 0) // this check is somewhat paranoid
+ s_logger.info(new String(buffer, 0, len));
+ }
+
+ while (stderr.available() > 0) {
+ int len = stderr.read(buffer);
+ }
+ }
+
+ sess.close();
+ conn.close();
+
+ if (success) {
+ return null;
+ } else {
+ retry++;
+ if (retry == MAX_RETRY_LINUX) {
+ return "SSH Linux Network test fail";
+ }
+ }
+ } catch (Exception e) {
+ retry++;
+ if (retry == MAX_RETRY_LINUX) {
+ return "SSH Linux Network test fail with error " + e.getMessage();
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/utils/UtilsForTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/UtilsForTest.java b/test/src/com/cloud/test/utils/UtilsForTest.java
index 4c09b11..a53a194 100644
--- a/test/src/com/cloud/test/utils/UtilsForTest.java
+++ b/test/src/com/cloud/test/utils/UtilsForTest.java
@@ -10,8 +10,8 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.utils;
-
+package com.cloud.test.utils;
+
import java.io.InputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
@@ -33,201 +33,201 @@ import org.w3c.dom.NodeList;
import com.cloud.utils.encoding.Base64;
import com.cloud.utils.exception.CloudRuntimeException;
-
-public class UtilsForTest {
-
- private static DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
-
- public static boolean verifyTags (Map<String, String> params) {
- boolean result = true;
- for (String value : params.keySet()) {
- if (params.get(value) == null) {
- result=false;
- }
- }
- return result;
- }
-
- public static boolean verifyTagValues (Map<String, String> params, Map<String, String> pattern) {
- boolean result = true;
-
- if (pattern != null) {
- for (String value : pattern.keySet()) {
- if (!pattern.get(value).equals(params.get(value))) {
- result=false;
- System.out.println("Tag " + value + " has " + params.get(value) + " while expected value is: " + pattern.get(value));
- }
- }
- }
- return result;
- }
-
-
- public static Map<String, String> parseXML(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) {
- System.out.println("no " + tagNames[i]
- + " tag in the response");
- returnValues.put(tagNames[i], null);
- } else {
- returnValues.put(tagNames[i], targetNodes.item(0)
- .getTextContent());
- }
- }
- } catch (Exception ex) {
+
+public class UtilsForTest {
+
+ private static DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+
+ public static boolean verifyTags (Map<String, String> params) {
+ boolean result = true;
+ for (String value : params.keySet()) {
+ if (params.get(value) == null) {
+ result=false;
+ }
+ }
+ return result;
+ }
+
+ public static boolean verifyTagValues (Map<String, String> params, Map<String, String> pattern) {
+ boolean result = true;
+
+ if (pattern != null) {
+ for (String value : pattern.keySet()) {
+ if (!pattern.get(value).equals(params.get(value))) {
+ result=false;
+ System.out.println("Tag " + value + " has " + params.get(value) + " while expected value is: " + pattern.get(value));
+ }
+ }
+ }
+ return result;
+ }
+
+
+ public static Map<String, String> parseXML(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) {
+ System.out.println("no " + tagNames[i]
+ + " tag in the response");
+ returnValues.put(tagNames[i], null);
+ } else {
+ returnValues.put(tagNames[i], targetNodes.item(0)
+ .getTextContent());
+ }
+ }
+ } catch (Exception ex) {
System.out.println("error processing XML");
- ex.printStackTrace();
- }
- return returnValues;
- }
-
-
- public static ArrayList<HashMap<String, String>> parseMulXML (InputStream is, String[] tagNames){
- ArrayList<HashMap<String, String>> returnValues = new ArrayList<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) {
- System.out.println("no " + tagNames[i]
- + " tag in XML response...returning null");
- } else {
- for (int j = 0; j < targetNodes.getLength(); j++) {
- HashMap<String, String> valueList = new HashMap<String,String> ();
- Node node = targetNodes.item(j);
- //parse child nodes
- NodeList child = node.getChildNodes();
- for (int c=0; c<node.getChildNodes().getLength(); c++){
- child.item(c).getNodeName();
- valueList.put(child.item(c).getNodeName(), child.item(c).getTextContent());
- }
- returnValues.add(valueList);
- }
-
- }
- }
- } catch (Exception ex) {
- System.out.println(ex);
- }
-
- return returnValues;
- }
-
-
- public static String createMD5String(String password) {
- MessageDigest md5;
- try {
- md5 = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new CloudRuntimeException("Error", e);
- }
-
- md5.reset();
- BigInteger pwInt = new BigInteger(1, md5.digest(password.getBytes()));
-
- // make sure our MD5 hash value is 32 digits long...
- StringBuffer sb = new StringBuffer();
- String pwStr = pwInt.toString(16);
- int padding = 32 - pwStr.length();
- for (int i = 0; i < padding; i++) {
- sb.append('0');
- }
- sb.append(pwStr);
- return sb.toString();
- }
-
-
-
-
-
-
-
- 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) {
- System.out.println("no " + tagNames[i]
- + " tag in XML response...returning null");
- } else {
- returnValues.put(tagNames[i], targetNodes.item(0)
- .getTextContent());
- }
- }
- } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return returnValues;
+ }
+
+
+ public static ArrayList<HashMap<String, String>> parseMulXML (InputStream is, String[] tagNames){
+ ArrayList<HashMap<String, String>> returnValues = new ArrayList<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) {
+ System.out.println("no " + tagNames[i]
+ + " tag in XML response...returning null");
+ } else {
+ for (int j = 0; j < targetNodes.getLength(); j++) {
+ HashMap<String, String> valueList = new HashMap<String,String> ();
+ Node node = targetNodes.item(j);
+ //parse child nodes
+ NodeList child = node.getChildNodes();
+ for (int c=0; c<node.getChildNodes().getLength(); c++){
+ child.item(c).getNodeName();
+ valueList.put(child.item(c).getNodeName(), child.item(c).getTextContent());
+ }
+ returnValues.add(valueList);
+ }
+
+ }
+ }
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+
+ return returnValues;
+ }
+
+
+ public static String createMD5String(String password) {
+ MessageDigest md5;
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ throw new CloudRuntimeException("Error", e);
+ }
+
+ md5.reset();
+ BigInteger pwInt = new BigInteger(1, md5.digest(password.getBytes()));
+
+ // make sure our MD5 hash value is 32 digits long...
+ StringBuffer sb = new StringBuffer();
+ String pwStr = pwInt.toString(16);
+ int padding = 32 - pwStr.length();
+ for (int i = 0; i < padding; i++) {
+ sb.append('0');
+ }
+ sb.append(pwStr);
+ return sb.toString();
+ }
+
+
+
+
+
+
+
+ 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) {
+ System.out.println("no " + tagNames[i]
+ + " tag in XML response...returning null");
+ } else {
+ returnValues.put(tagNames[i], targetNodes.item(0)
+ .getTextContent());
+ }
+ }
+ } catch (Exception ex) {
System.out.println("error processing XML");
- ex.printStackTrace();
- }
- return returnValues;
- }
-
-
- 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) {
- System.out.println("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) {
- System.out.println(ex);
- }
- return returnValues;
- }
-
-
-
- public static String signRequest(String request, String key) {
- try {
- Mac mac = Mac.getInstance("HmacSHA1");
- SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(),
- "HmacSHA1");
- mac.init(keySpec);
- mac.update(request.getBytes());
+ ex.printStackTrace();
+ }
+ return returnValues;
+ }
+
+
+ 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) {
+ System.out.println("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) {
+ System.out.println(ex);
+ }
+ return returnValues;
+ }
+
+
+
+ public static String signRequest(String request, String key) {
+ try {
+ Mac mac = Mac.getInstance("HmacSHA1");
+ SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(),
+ "HmacSHA1");
+ mac.init(keySpec);
+ mac.update(request.getBytes());
byte[] encryptedBytes = mac.doFinal();
- //System.out.println("HmacSHA1 hash: " + encryptedBytes);
- return Base64.encodeBytes(encryptedBytes);
- } catch (Exception ex) {
+ //System.out.println("HmacSHA1 hash: " + encryptedBytes);
+ return Base64.encodeBytes(encryptedBytes);
+ } catch (Exception ex) {
System.out.println("unable to sign request");
- ex.printStackTrace();
- }
- return null;
- }
-
-}
+ ex.printStackTrace();
+ }
+ return null;
+ }
+
+}