def testComboConfigMachineAccess(self): #print '++++++++++ DEBUG: starting testComboConfigMachineAccess' mgr = ClusterMgr() s = """{ "name" : "combo-cluster", "idbversion" : "3.5.1-5", "boxtype" : "cal-precise64", "rolespec" : { "pm" : { "count" : 2, "dbroots_per" : 1 } } } """ cfg = ConfigSpec(s) c = mgr.alloc_new('combo',cfg,'vagrant') # this should get aliased to pm1 c.machine('um1') # this still doesn't exist even after the alias with self.assertRaisesRegexp(ValueError,"Machine name.*not in.*"): c.machine('um3') mgr.destroy(c)
def testDatdup(self): '''Test cluster with datdup specified''' #print '++++++++++ DEBUG: starting testDatdup' mgr = ClusterMgr() s = """{ "name" : "a-cluster", "idbversion" : "4.0.0-0", "boxtype" : "cal-precise64", "datdup" : true, "rolespec" : { "pm" : { "count" : 4, "memory" : 1024, "dbroots_per" : 1 }, "um" : { "count" : 1, "memory" : 2048 } } } """ cfg = ConfigSpec(s) c = mgr.alloc_new('testdatdup',cfg,'vagrant') self.assertEqual( mgr.list_clusters()[0][0], 'testdatdup' ) mgr.destroy(c)
def test_basic001(self): # reset list of syscalls #print '++++++++++ DEBUG: starting test_basic001' global mycmds mycmds = [] mgr = ClusterMgr() c1 = mgr.alloc_new('testsub1',self._defcfg,'vagrant') utils.syscall_cb = mysyscb c1.start() tr = TestRunner() testsuite = tests.call_by_name('basic001') result = tr.run(c1, testsuite) print 'Status:', 'Pass' if result.passfail() else 'Fail' # now check that the right system calls were executed callpats = [ 'vagrant.*up', 'ssh.*echo', 'ssh.*dbFunctional.sh' ] self.check_syscalls(callpats) utils.syscall_cb = None mgr.destroy(c1)
def testBasic(self): #print '++++++++++ DEBUG: starting testBasic' if True: # put in a code block so that TestReport closed before we validate tr = TestReport('/tmp/trtest.log') mgr = ClusterMgr() cfg1 = configs.multi_1um_2pm('3.5.1-5') cfg1['boxtype'] = 'cal-precise64' c = mgr.alloc_new('test-report',cfg1,'vagrant') tr.new_config(c) ts = TestSuite('my001','a unit test test suite') t = datetime.now() res = TestResult( t, t, True) tr.new_result(ts, res) ts = TestSuite('my002','another test suite') res = TestResult( t, t, False) tr.new_result(ts, res) mgr.destroy(c) # have to explicitly call this to make sure the file is closed tr.finish() ref_file = '%s/test1-testlog' % os.path.dirname(__file__) self.assertTrue( testutils.file_compare(ref_file, '/tmp/trtest.log'))
def test1(self): #print '++++++++++ DEBUG: starting test1' s = """{ "name" : "a-cluster", "idbversion" : "Latest", "boxtype" : "cal-precise64", "rolespec" : { "pm" : { "count" : 4, "memory" : 1024, "dbroots_per" : 1 } }, "hadoop" : { "instance-templates" : "1 hadoop-namenode+hadoop-jobtracker,2 hadoop-datanode+hadoop-tasktracker" } } """ mgr = ClusterMgr() c = mgr.alloc_new('my-clustername',ConfigSpec(s),'vagrant') w = WhirrConfigWriter(c) w.write_config(self._basedir) ref_file = '%s/testwhirr-props' % os.path.dirname(__file__) self.assertTrue( testutils.file_compare(ref_file, self._propcmp)) ref_file = '%s/testwhirr-nodes' % os.path.dirname(__file__) self.assertTrue( testutils.file_compare(ref_file, self._nodecmp)) mgr.destroy(c)
def testDupName(self): #print '++++++++++ DEBUG: starting testDupName' mgr = ClusterMgr() c1 = mgr.alloc_new('testdup',self._defcfg,'vagrant') c2 = mgr.alloc_new('testdup',self._defcfg,'vagrant') mgr.destroy(c1) mgr.destroy(c2)
def testSubnetAlloc(self): #print '++++++++++ DEBUG: starting testSubnetAlloc' mgr = ClusterMgr() c1 = mgr.alloc_new('testsub1',self._defcfg,'vagrant') c2 = mgr.alloc_new('testsub2',self._defcfg,'vagrant') self.assertEqual( c1.get_vmi()._subnet, '192.168.1' ) self.assertEqual( c2.get_vmi()._subnet, '192.168.2' ) mgr.destroy(c1) mgr.destroy(c2)
def testAttach(self): #print '++++++++++ DEBUG: starting testAttach' mgr = ClusterMgr() c = mgr.alloc_new('testAttach',self._defcfg,'vagrant') c1 = mgr.attach( 'testAttach' ) self.assertEquals( c1.id() , c.id() ) with self.assertRaisesRegexp(Exception,"Error attaching to cluster.*"): c2 = mgr.attach( 'no-cluster' ) mgr.destroy(c)
def test_basic002(self): # reset list of syscalls #print '++++++++++ DEBUG: starting test_basic002' global mycmds mycmds = [] mgr = ClusterMgr() c1 = mgr.alloc_new('testbasic002',self._defcfg,'vagrant') utils.syscall_cb = mysyscb c1.start() tr = TestRunner() testsuite = tests.call_by_name('basic002') result = tr.run(c1, testsuite) print 'Status:', 'Pass' if result.passfail() else 'Fail' # now check that the right system calls were executed callpats = [ 'vagrant.*up', 'ssh.*echo', 'ssh.*upgradeTest2.sh', 'ssh.*calpontConsole shutdown y', 'ssh.*sleep 5', 'ssh.*infinidb_not_running.sh', 'ssh.*calpontConsole startsystem', 'ssh.*sleep 5', 'ssh.*upgradeTest2.sh', 'ssh.*calpontConsole restartsystem y', 'ssh.*sleep 5', 'ssh.*upgradeTest2.sh', 'ssh.*calpontConsole stopsystem y', 'ssh.*sleep 5', 'ssh.*calpontConsole startsystem', 'ssh.*sleep 5', 'ssh.*upgradeTest2.sh', 'ssh.*calpontConsole shutdown y', 'ssh.*sleep 5', 'ssh.*infinidb_not_running.sh', 'vagrant halt', 'vboxmanage startvm.*headless', 'vboxmanage startvm.*headless', 'ssh.*healthcheck', 'ssh.*upgradeTest2.sh', ] self.check_syscalls(callpats) utils.syscall_cb = None mgr.destroy(c1)