You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2012/07/16 19:36:25 UTC

git commit: Simplifying the process of running the simulator.

Updated Branches:
  refs/heads/master ca4309283 -> b627f5a85


Simplifying the process of running the simulator.

    * ant run-simulator - will seed the simulator jar and start CS
    * ant run-marvin -Dmarvin.config="/path/config/file" - will
    * configure a
    cloudstack as per the given configuration. marvin.config - defaults
to a
    two host simulator in an advanced zone

    You can then connect your debugger over localhost:8787 or use the CS
ui
    at localhost:8080/client for testing.

From: Prasanna Santhanam(Prasanna.Santhanam@citrix.com)


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/b627f5a8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/b627f5a8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/b627f5a8

Branch: refs/heads/master
Commit: b627f5a85bb0d44f247a46b14d1df91a079d823d
Parents: ca43092
Author: Edison Su <su...@gmail.com>
Authored: Mon Jul 16 10:27:51 2012 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Mon Jul 16 10:34:49 2012 -0700

----------------------------------------------------------------------
 build/build-marvin.xml                             |   12 +
 build/build-tests.xml                              |   27 +++-
 build/simulator.properties                         |   11 +
 tools/marvin/marvin/sandbox/README.txt             |   15 ++-
 .../marvin/sandbox/demo/simulator/simulator.cfg    |  159 +++++++++++++++
 tools/marvin/marvin/sandbox/run-marvin.sh          |   66 ++++++
 tools/marvin/marvin/sandbox/testSetupSuccess.py    |   81 ++++++++
 7 files changed, 368 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/build/build-marvin.xml
----------------------------------------------------------------------
diff --git a/build/build-marvin.xml b/build/build-marvin.xml
index 687eb5c..daa77b9 100644
--- a/build/build-marvin.xml
+++ b/build/build-marvin.xml
@@ -56,4 +56,16 @@
         </exec>
         <echo message="distributable tarball at: ${marvin.dist.dir}/Marvin-*.tar.gz"/>
     </target>
+
+    <target name="install-marvin" depends="package-marvin" description="installs marvin on the local machine">
+        <echo message="Uninstalling Marvin" />
+        <exec dir="${marvin.dist.dir}" executable="pip">
+            <arg line="uninstall -y marvin"/>
+        </exec>
+        <echo message="Installing Marvin" />
+        <exec dir="${marvin.dist.dir}" executable="pip">
+            <arg value="install" />
+            <arg value="Marvin-0.1.0.tar.gz" />
+        </exec>
+    </target>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/build/build-tests.xml
----------------------------------------------------------------------
diff --git a/build/build-tests.xml b/build/build-tests.xml
index fdffe32..e8649f2 100755
--- a/build/build-tests.xml
+++ b/build/build-tests.xml
@@ -49,6 +49,10 @@
   <property name="agent-simulator.jar" value="cloud-agent-simulator.jar" />
   <property name="testclient.jar" value="cloud-test.jar" />
 
+  <property name="simulator.setup.dir" value="${base.dir}/setup/db/" />
+  <property name="marvin.sandbox.dir" value="${base.dir}/tools/marvin/marvin/sandbox/" />
+  <property name="marvin.config" value="${base.dir}/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg" />
+  <property name="marvin.config.abspath" location="${marvin.config}" />
 
   <!-- =================== Agent Simulator ==================== -->
   <path id="agent-simulator.classpath">
@@ -98,12 +102,33 @@
     <copy todir="${agent-simulator.dist.dir}/conf">
       <fileset dir="${agent.dir}/conf">
         <include name="log4j-cloud.xml" />
-        <include name="simulator.properties" />
       </fileset>
     </copy>
   </target>
   <!-- =================== Agent Simulator ==================== -->
 
+  <!-- Run Simulator Tests  -->
+  <target name="setup-simulator"  depends="clean-all">
+      <mkdir dir="${simulator.setup.dir}/override">
+      </mkdir>
+      <copy overwrite="true" file="${simulator.setup.dir}/templates.simulator.sql" tofile="${simulator.setup.dir}/override/templates.sql" />
+
+      <mkdir dir="${build.dir}/override">
+      </mkdir>
+      <copy overwrite="true" file="${build.dir}/replace.properties" tofile="${build.dir}/override/replace.properties" />
+      <!-- Replace the COMPONENT-SPEC for components-simulator.xml -->
+      <copy overwrite="true" file="${build.dir}/simulator.properties" tofile="${build.dir}/override/replace.properties" />
+  </target>
+
+  <target name="run-simulator" depends="setup-simulator, build-all-with-simulator, deploy-server, deploydb-simulator, debug">
+  </target>
+
+  <target name="run-marvin" depends="install-marvin">
+      <exec dir="${marvin.sandbox.dir}/" executable="bash">
+          <arg line="run-marvin.sh -d localhost -m localhost -c ${marvin.config.abspath}" />
+      </exec>
+  </target>
+  <!--   -->
 
   <!-- =================== QA Testing Client ==================== -->
   <target name="-init-test" depends="-init">

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/build/simulator.properties
----------------------------------------------------------------------
diff --git a/build/simulator.properties b/build/simulator.properties
new file mode 100644
index 0000000..80fe90d
--- /dev/null
+++ b/build/simulator.properties
@@ -0,0 +1,11 @@
+DBUSER=cloud
+DBPW=cloud
+MSLOG=vmops.log
+APISERVERLOG=api.log
+DBHOST=localhost
+DBROOTPW=
+AGENTLOGDIR=logs
+AGENTLOG=logs/agent.log
+MSMNTDIR=/mnt
+COMPONENTS-SPEC=components-simulator.xml
+AWSAPILOG=awsapi.log

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/tools/marvin/marvin/sandbox/README.txt
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/sandbox/README.txt b/tools/marvin/marvin/sandbox/README.txt
index 7efc190..55c5cd3 100644
--- a/tools/marvin/marvin/sandbox/README.txt
+++ b/tools/marvin/marvin/sandbox/README.txt
@@ -3,12 +3,12 @@ Welcome to the marvin sandbox
 
 In here you should find a few common deployment models of CloudStack that you
 can configure with properties files to suit your own deployment. One deployment
-model for each of - advanced zone, basic zone and a demo are given.  
+model for each of - advanced zone, basic zone and a simulator demo are given.  
 
 $ ls -
 basic/
 advanced/
-demo/
+simulator/
 
 Each property file is divided into logical sections and should be familiar to
 those who have deployed CloudStack before. Once you have your properties file
@@ -17,3 +17,14 @@ python script provided in the respective folder.
 
 The demo files are from the tutorial for testing with python that can be found
 on the wiki.cloudstack.org
+
+A common deployment model of a simulator.cfg that can be used for debugging is
+included. This will configure an advanced zone with simulators that can be used
+for debugging purposes when you do not have hardware to debug with.
+
+To do this:
+$ cd cloudstack-oss/
+$ ant run-simulator #This will start up the mgmt server with the simulator seeded
+
+## In another shell
+$ ant run-simulator

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg b/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg
new file mode 100644
index 0000000..7816e19
--- /dev/null
+++ b/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg
@@ -0,0 +1,159 @@
+{
+    "zones": [
+        {
+            "name": "Sandbox-simulator", 
+            "guestcidraddress": "10.1.1.0/24", 
+            "providers": [
+                {
+                    "broadcastdomainrange": "ZONE", 
+                    "name": "VirtualRouter"
+                }
+            ], 
+            "dns1": "10.147.28.6", 
+            "vlan": "100-200", 
+            "ipranges": [
+                {
+                    "startip": "10.147.31.2", 
+                    "endip": "10.147.31.200", 
+                    "netmask": "255.255.255.0", 
+                    "vlan": "31", 
+                    "gateway": "10.147.31.1"
+                }
+            ], 
+            "networktype": "Advanced", 
+            "pods": [
+                {
+                    "endip": "10.147.29.200", 
+                    "name": "POD0", 
+                    "startip": "10.147.29.2", 
+                    "netmask": "255.255.255.0", 
+                    "clusters": [
+                        {
+                            "clustername": "C0", 
+                            "hypervisor": "simulator", 
+                            "hosts": [
+                                {
+                                    "username": "root", 
+                                    "url": "http://sim/c0/h0", 
+                                    "password": "password"
+                                },
+                                {
+                                    "username": "root", 
+                                    "url": "http://sim/c0/h1", 
+                                    "password": "password"
+                                }
+                            ], 
+                            "clustertype": "CloudManaged", 
+                            "primaryStorages": [
+                                {
+                                    "url": "nfs://10.147.28.6:/export/home/sandbox/primary", 
+                                    "name": "PS0"
+                                }
+                            ]
+                        }
+                    ], 
+                    "gateway": "10.147.29.1"
+                }
+            ], 
+            "internaldns1": "10.147.28.6", 
+            "secondaryStorages": [
+                {
+                    "url": "nfs://10.147.28.6:/export/home/sandbox/secondary"
+                }
+            ]
+        }
+    ], 
+    "dbSvr": {
+        "dbSvr": "localhost", 
+        "passwd": "cloud", 
+        "db": "cloud", 
+        "port": 3306, 
+        "user": "cloud"
+    }, 
+    "logger": [
+        {
+            "name": "TestClient", 
+            "file": "/var/log/testclient.log"
+        }, 
+        {
+            "name": "TestCase", 
+            "file": "/var/log/testcase.log"
+        }
+    ], 
+    "globalConfig": [
+        {
+            "name": "storage.cleanup.interval", 
+            "value": "300"
+        }, 
+        {
+            "name": "vm.op.wait.interval", 
+            "value": "5"
+        }, 
+        {
+            "name": "default.page.size", 
+            "value": "10000"
+        }, 
+        {
+            "name": "instance.name", 
+            "value": "QA"
+        }, 
+        {
+            "name": "workers", 
+            "value": "10"
+        }, 
+        {
+            "name": "use.user.concentrated.pod.allocation", 
+            "value": "false"
+        }, 
+        {
+            "name": "account.cleanup.interval", 
+            "value": "600"
+        }, 
+        {
+            "name": "guest.domain.suffix", 
+            "value": "sandbox.simulator"
+        }, 
+        {
+            "name": "expunge.delay", 
+            "value": "60"
+        }, 
+        {
+            "name": "network.gc.wait", 
+            "value": "60"
+        }, 
+        {
+            "name": "network.gc.interval", 
+            "value": "60"
+        }, 
+        {
+            "name": "vm.allocation.algorithm", 
+            "value": "random"
+        }, 
+        {
+            "name": "expunge.interval", 
+            "value": "60"
+        }, 
+        {
+            "name": "expunge.workers", 
+            "value": "3"
+        }, 
+        {
+            "name": "check.pod.cidrs", 
+            "value": "true"
+        }, 
+        {
+            "name": "secstorage.allowed.internal.sites", 
+            "value": "10.147.28.0/24"
+        }, 
+        {
+            "name": "direct.agent.load.size", 
+            "value": "1000"
+        }
+    ], 
+    "mgtSvr": [
+        {
+            "mgtSvrIp": "localhost", 
+            "port": 8096
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/tools/marvin/marvin/sandbox/run-marvin.sh
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/sandbox/run-marvin.sh b/tools/marvin/marvin/sandbox/run-marvin.sh
new file mode 100644
index 0000000..015a43b
--- /dev/null
+++ b/tools/marvin/marvin/sandbox/run-marvin.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+usage() {
+  printf "Usage: %s:\n
+	[-m mgmt-server ] \n
+	[-c config-file ] \n
+	[-d db node url ]\n" $(basename $0) >&2
+}
+
+failed() {
+	exit $1
+}
+
+#defaults
+FMT=$(date +"%d_%I_%Y_%s")
+MGMT_SVR="localhost"
+CONFIG="demo/simulator/simulator-smoke.cfg"
+DB_SVR="localhost"
+
+while getopts 'd:m:c:' OPTION
+do
+  case $OPTION in
+  d)    dflag=1
+		DB_SVR="$OPTARG"
+		;;
+  m)    mflag=1
+		MGMT_SVR="$OPTARG"
+		;;
+  c)    cflag=1
+		CONFIG="$OPTARG"
+		;;
+  ?)	usage
+		failed 2
+		;;
+  esac
+done
+
+$(mysql -uroot -Dcloud -h$MGMT_SVR -s -N -r -e"update configuration set value='8096' where name='integration.api.port'")
+version_tuple=$(python -c 'import sys; print(sys.version_info[:2])')
+
+if [[ $version_tuple == "(2, 7)" ]]
+then
+    python -m marvin.deployAndRun -c $CONFIG -t /tmp/t.log -r /tmp/r.log -d /tmp
+    sleep 60
+    python -m marvin.deployAndRun -c $CONFIG -t /tmp/t.log -r /tmp/r.log -f testSetupSuccess.py -l
+    cat /tmp/r.log
+    echo "Done"
+else
+    echo "Python version 2.7 not detected on system. Aborting"
+fi

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b627f5a8/tools/marvin/marvin/sandbox/testSetupSuccess.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/sandbox/testSetupSuccess.py b/tools/marvin/marvin/sandbox/testSetupSuccess.py
new file mode 100644
index 0000000..8a0034c
--- /dev/null
+++ b/tools/marvin/marvin/sandbox/testSetupSuccess.py
@@ -0,0 +1,81 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import marvin
+import unittest
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from time import sleep as delay
+
+class TestSetupSuccess(cloudstackTestCase):
+    """
+    Test to verify if the cloudstack is ready to launch tests upon
+    1. Verify that system VMs are up and running in all zones
+    2. Verify that built-in templates are Ready in all zones
+    """
+    @classmethod
+    def setUpClass(cls):
+        cls.apiClient = super(TestSetupSuccess, cls).getClsTestClient().getApiClient()
+        
+        zones = listZones.listZonesCmd()
+        cls.zones_list = cls.apiClient.listZones(zones)
+        cls.retry = 50
+        
+    def test_systemVmReady(self):
+        """
+        system VMs need to be ready and Running for each zone in cloudstack
+        """
+        for z in self.zones_list:
+            retry = self.retry
+            while retry != 0:
+                self.debug("looking for system VMs in zone: %s, %s"%(z.id, z.name))
+                sysvms = listSystemVms.listSystemVmsCmd()
+                sysvms.zoneid = z.id
+                sysvms.state = 'Running'
+                sysvms_list = self.apiClient.listSystemVms(sysvms)
+                if sysvms_list is not None and len(sysvms_list) == 2:
+                    assert len(sysvms_list) == 2
+                    self.debug("found %d system VMs running {%s}"%(len(sysvms_list), sysvms_list))
+                    break
+                retry = retry - 1
+                delay(60) #wait a minute for retry
+            self.assertNotEqual(retry, 0, "system VMs not Running in zone %s"%z.name)
+    
+    def test_templateBuiltInReady(self):
+        """
+        built-in templates CentOS to be ready
+        """
+        for z in self.zones_list:
+            retry = self.retry
+            while retry != 0:
+                self.debug("Looking for at least one ready builtin template")
+                templates = listTemplates.listTemplatesCmd()
+                templates.templatefilter = 'featured'
+                templates.listall = 'true'
+                templates_list = self.apiClient.listTemplates(templates)
+                if templates_list is not None:
+                    builtins = [tmpl for tmpl in templates_list if tmpl.templatetype == 'BUILTIN' and tmpl.isready == True]
+                    if len(builtins) > 0:
+                        self.debug("Found %d builtins ready for use %s"%(len(builtins), builtins))
+                        break
+                retry = retry - 1
+                delay(60) #wait a minute for retry
+            self.assertNotEqual(retry, 0, "builtIn templates not ready in zone %s"%z.name)
+            
+    @classmethod
+    def tearDownClass(cls):
+        pass