def testBasic(self): # turn on unit-test mode so that we don't actually run vagrant commands common.props['vmi.vagrantvmi.unit-test'] = True cfg1 = configs.multi_1um_2pm('3.5.1-5') cfg1['boxtype'] = 'cal-precise64' cfg2 = configs.multi_1um_2pm('3.5.1-5') cfg2['boxtype'] = 'cal-lucid64' runlist = [ (cfg1, 'vagrant', tests.basic001()), (cfg2, 'vagrant', tests.basic001()) ] mgrfile = '/tmp/%s_test_testmgr.log' % getpass.getuser() mgr = TestManager(mgrfile) # need to disable real system calls for unit-test utils.syscall_cb = mysyscb self.assertTrue( mgr.run_all(runlist) ) self.assertEqual(mgr.test_report().passing(), 6) self.assertEqual(mgr.test_report().failing(), 0) self.assertEqual(mgr.test_report().total(), 6) utils.syscall_cb = None os.remove(mgrfile)
def testBasicEm(self): # turn on unit-test mode so that we don't actually run vagrant commands common.props['vmi.vagrantvmi.unit-test'] = True cfg1 = configs.multi_1um_2pm('4.5.0-1') cfg1['boxtype'] = 'cal-precise64' cfg1['binary'] = True cfg1['em'] = { 'present' : True, 'invm' : True, 'emhost' : 'localhost', 'emport' : 9090, 'boxtype' : 'cal-centos6', 'oamserver_role' : "pm1", "role" : "em1" } runlist = [ (cfg1, 'vagrant', tests.basic001()) ] mgrfile = '/tmp/%s_test_testmgr.log' % getpass.getuser() mgr = TestManager(mgrfile) # need to disable real system calls for unit-test utils.syscall_cb = mysyscb ret = mgr.run_all(runlist) self.assertTrue( ret ) self.assertEqual(mgr.test_report().passing(), 10) self.assertEqual(mgr.test_report().failing(), 0) self.assertEqual(mgr.test_report().total(), 10) utils.syscall_cb = None os.remove(mgrfile)
def main(argv=None): try: opts, args = getopt.getopt(sys.argv[1:], "lr:s", []) except getopt.GetoptError as err: # print help information and exit: print str(err) # will print something like "option -a not recognized" usage() sys.exit(2) numrand = 0 enterprise = True for o, a in opts: if o == "-l": for r in runlists.list_all(): print '%-20s : %s' % (r[0], r[1]) return 0 elif o == "-r": numrand = int(a) elif o == "-s": enterprise = False else: assert False, "unhandled option" if len(args) < 3: usage() version = args[0] functor = args[1] logfile = args[2] if not runlists.__dict__.has_key(functor): print "No functor name %s in runlist" % functor mgr = TestManager(logfile) final_list = runlists.call_by_name(functor, version, 'vagrant', num=numrand, enterprise=enterprise) return mgr.run_all(final_list)