diff --git a/build/build-marvin.xml b/build/build-marvin.xml index 687eb5cd976..daa77b91301 100644 --- a/build/build-marvin.xml +++ b/build/build-marvin.xml @@ -56,4 +56,16 @@ + + + + + + + + + + + + diff --git a/build/build-tests.xml b/build/build-tests.xml index fdffe326bab..e8649f2e487 100755 --- a/build/build-tests.xml +++ b/build/build-tests.xml @@ -49,6 +49,10 @@ + + + + @@ -98,12 +102,33 @@ - + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/simulator.properties b/build/simulator.properties new file mode 100644 index 00000000000..80fe90dc35a --- /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 diff --git a/tools/marvin/marvin/sandbox/README.txt b/tools/marvin/marvin/sandbox/README.txt index 7efc190baf6..55c5cd390c7 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 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 00000000000..7816e19762d --- /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 + } + ] +} diff --git a/tools/marvin/marvin/sandbox/run-marvin.sh b/tools/marvin/marvin/sandbox/run-marvin.sh new file mode 100644 index 00000000000..015a43b5648 --- /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 diff --git a/tools/marvin/marvin/sandbox/testSetupSuccess.py b/tools/marvin/marvin/sandbox/testSetupSuccess.py new file mode 100644 index 00000000000..8a0034cfa9b --- /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