def test_report_local_fail(self): port = 8232 server = test_server.TestServer(port) server.count = 4 server.start() log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost","user","pass","","http", port) xml_file = os.path.join("testopia_run_files","seq_report_fail.xml") params = {} sequence_lib = stasis.TestSequenceLibrary(self.cv, self.sv, case_lib) sequence = sequence_lib.load(xml_file) log_reporter = stasis.LogTestCaseReporter(2, logfile=log_file) sequence.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) sequence.addReporter(testopia_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 2 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" ERROR ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_report_local_fail(self): if self.port is None: port = 8133 count = 8 server = test_server.TestServer(port, count) thread = threading.Thread(None, server.start_server) thread.start() else: port = self.port log_file = os.tempnam(None, "stasis-") case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost", "user", "pass", "/", "http", port) xml_file = "seq_report_fail.xml" params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(xml_file) log_reporter = stasis.LogTestCaseReporter(3, logfile=log_file) series.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) series.addReporter(testopia_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() case_fail_count = 0 fail_count = 0 fd = open(log_file, 'r') for line in fd.readlines(): if re.search("CASE_FAIL_", line): case_fail_count += 1 if re.search(" FAIL ", line): fail_count += 1 fd.close() self.assertEqual(fail_count, 2) self.assertEqual(case_fail_count, 4)
def test_report_live(self): log_file = os.tempnam(None, "stasis-") case_lib = stasis.TestCaseLibrary(self.cv) if self.case_run_id is None: case_run_id = raw_input("case_run_id: ") else: case_run_id = self.case_run_id if self.url is None: if self.user is None: user = raw_input("Enter testopia user name: ") else: user = self.user if self.password is None: passwd = raw_input("Password for %s: " % user) else: passwd = self.password if self.server is None: server = raw_input("Server: ") else: server = self.server url = stasis.buildUrl(server, user, passwd) else: url = self.url params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(None, case_run_id) log_reporter = stasis.LogTestCaseReporter(3, logfile=log_file) series.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) sequence.addReporter(testopia_reporter) dispatcher = stasis.RunDispatcher(series) dispatcher.run() begin_count = 0 pass_count = 0 total = 3 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_sequence_save_ini(self): if self.port is None: port = 8817 count = 12 server = test_server.TestServer(port, count) thread = threading.Thread(None, server.start_server) thread.start() else: port = self.port ini_file = os.tempnam(None, "stasis_") case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost", "user", "pass", "/", "http", port) params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(32, url) print "INI FILE: %s" % ini_file fd = open(ini_file, 'w') parser = ConfigParser.SafeConfigParser() for tc in series: tc.addConfSection(parser) parser.write(fd) fd.close() fd = open(ini_file, 'r') found_file_2 = False found_file_22 = False found_function = False line_count = 0 section_count = 0 lines = fd.readlines() fd.close() for line in lines: line_count += 1 if re.search(' = case_pass_22', line): found_file_22 = True elif re.search(' = case_pass_2', line): found_file_2 = True elif re.search(' = test_case_pass_func', line): found_function = True elif re.search('\[.*/', line): section_count += 1 self.assertEqual(line_count, 108) self.assertEqual(section_count, 9) self.assert_(found_file_2) self.assert_(found_file_22) self.assert_(found_function)
def test_report_live(self): log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) #uri = os.path.join(os.getcwd(),"testopia") #hostname = "bugzillastage.provo.novell.com" #hostname = "localhost:%s" % self.port if self.case_run_id is None: case_run_id = raw_input("case_run_id: ") else: case_run_id = self.case_run_id if self.user is None: user = raw_input("Password for %s: " % user) else: user = self.passwd if self.password is None: passwd = raw_input("Password for %s: " % user) else: passwd = self.passwd #password = "******" url = stasis.buildUrl("bugzillastage.provo.novell.com", user, passwd) params = {} sequence_lib = stasis.TestopiaSequenceLibrary(self.cv, case_lib, url) sequence = sequence_lib.load(case_run_id) log_reporter = stasis.LogTestCaseReporter(2, logfile=log_file) sequence.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) sequence.addReporter(testopia_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 2 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_run_seqence_live(self): log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) if self.case_run_id is None: case_run_id = raw_input("case_run_id: ") else: case_run_id = self.case_run_id user = "******" if self.password is None: passwd = raw_input("Password for %s: " % user) else: passwd = self.passwd url = stasis.buildUrl("bugzillastage.provo.novell.com", user, passwd) params = {} sequence_lib = stasis.TestopiaSequenceLibrary(self.cv, case_lib, url) sequence = sequence_lib.load(case_run_id) log_reporter = stasis.LogTestCaseReporter(2, logfile=log_file) sequence.addReporter(log_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 2 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_run_seqence_local(self): if self.port is None: port = 8113 count = 12 server = test_server.TestServer(port, count) thread = threading.Thread(None, server.start_server) thread.start() else: port = self.port log_file = os.tempnam(None, "stasis-") print "Log file: %s" % (log_file) case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost", "user", "pass", "/", "http", port) params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(32, url) log_reporter = stasis.LogTestCaseReporter(debug=TestStasisTestopiaLocal.debug, \ logfile=log_file) series.addReporter(log_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() case_pass_count = 0 pass_count = 0 total = 3 fd = open(log_file, 'r') for line in fd.readlines(): if re.search("CASE_PASS_", line): case_pass_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(case_pass_count, total)