예제 #1
0
    def find_testcases(cls, test_program):
        # Collect all test cases
        args = [ test_program, '--gtest_list_tests' ]
        proc = LocalSubprocess(args)
        proc.start()
        returncode = proc.wait()
        if returncode != 0:
            raise JubaSkipTest('%s cannot list testcases' % test_program)

        # read input
        stri = StringIO(proc.stdout)
        testcases = []
        current_test = None
        re_test = re.compile('^([a-zA-Z0-9_]+\.)')
        re_testcase = re.compile('^  ([a-zA-Z0-9_]+)')
        while True:
            line = stri.readline()
            if line == '': break
            if line.find('Running main') != -1: continue
            match = re_test.match(line)
            if match:
                current_test = match.group(1)

            match = re_testcase.match(line)
            if match and current_test:
                testcases.append('%s%s' % (current_test, match.group(1)))
        return testcases
예제 #2
0
 def test_kill(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     rawp = p._process
     p = None  # run destructor
     time.sleep(1)
     self.assertIsNotNone(rawp.poll())
예제 #3
0
파일: process.py 프로젝트: rimms/jubatest
 def test_kill(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     rawp = p._process
     p = None # run destructor
     time.sleep(1)
     self.assertIsNotNone(rawp.poll())
예제 #4
0
    def find_testcases(cls, test_program):
        # Collect all test cases
        args = [ test_program, '--gtest_list_tests' ]
        proc = LocalSubprocess(args)
        proc.start()
        returncode = proc.wait()
        if returncode != 0:
            raise JubaSkipTest('%s cannot list testcases' % test_program)

        # read input
        stri = StringIO(proc.stdout)
        testcases = []
        current_test = None
        re_test = re.compile('^([a-zA-Z0-9_]+\.)')
        re_testcase = re.compile('^  ([a-zA-Z0-9_]+)')
        while True:
            line = stri.readline()
            if line == '': break
            if line.find('Running main') != -1: continue
            match = re_test.match(line)
            if match:
                current_test = match.group(1)

            match = re_testcase.match(line)
            if match and current_test:
                testcases.append('%s%s' % (current_test, match.group(1)))
        return testcases
예제 #5
0
 def gtest(self, service, test):
     args = [ self.test_program, '--gtest_filter=%s' % test ]
     env = { 'JUBATUS_HOST': self.client_node.get_host(),
             'JUBATUS_PORT': str(self.target.get_host_port()[1]),
             'JUBATUS_CLUSTER_NAME': self.name }
     env.update(os.environ)
     proc = LocalSubprocess(args, env)
     proc.start()
     returncode = proc.wait()
     # Report gtest result when error occured
     self.assertEqual(0, returncode, proc.stdout)
예제 #6
0
 def gtest(self, service, test_program, test):
     self.lazySetUp(service)
     args = [ test_program, '--gtest_filter=%s' % test ]
     env = { 'JUBATUS_HOST': self.client_node.get_host(),
             'JUBATUS_PORT': str(self.target.get_host_port()[1]),
             'JUBATUS_CLUSTER_NAME': self.name }
     env.update(os.environ)
     proc = LocalSubprocess(args, env)
     proc.start()
     returncode = proc.wait()
     # Report gtest result when error occured
     self.assertEqual(0, returncode, proc.stdout)
예제 #7
0
    def check_jubadump(self, target, cli, storage_type):
        cli.save("jubadump_test")
        model_data = target.get_saved_model("jubadump_test")
        proc = LocalSubprocess(
            ['jubadump', '--input', '/dev/stdin', '--type', storage_type])
        proc.start()

        # assert that command exits with status = 0
        self.assertEqual(proc.wait(model_data), 0)

        # assert that command prints valid JSON
        self.assertEqual(type(json.loads(proc.stdout)), dict)
예제 #8
0
  def check_jubadump(self, target, cli):
    cli.save("jubadump_test")
    model_data = target.get_saved_model("jubadump_test")
    proc = LocalSubprocess(['jubadump', '--input', '/dev/stdin'])
    proc.start()

    # assert that command exits with status = 0
    exit_status = proc.wait(model_data)
    self.assertEqual(exit_status, 0, 'jubadump exit with status {0}: {1}'.format(exit_status, proc.stderr))

    # assert that command prints valid JSON
    self.assertEqual(type(json.loads(proc.stdout)), dict)
예제 #9
0
 def test_is_running(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     self.assertTrue(p.is_running())
     time.sleep(0.5)
     p.stop(True)
     time.sleep(0.5)
     self.assertFalse(p.is_running())
예제 #10
0
 def gtest(self, service, test_program, test):
     self.lazySetUp(service)
     args = [ test_program, '--gtest_filter=%s' % test ]
     env = { 'JUBATUS_HOST': self.client_node.get_host(),
             'JUBATUS_PORT': str(self.target.get_host_port()[1]),
             'JUBATUS_CLUSTER_NAME': self.name,
             'JUBATUS_TIMEOUT': str(5),
             'JUBATUS_SERVERS_COUNT': str(self.servers_count()),
           }
     env.update(os.environ)
     proc = LocalSubprocess(args, env)
     proc.start()
     returncode = proc.wait()
     # Report gtest result when error occured
     self.assertEqual(0, returncode, proc.stdout)
예제 #11
0
 def test_start_stdout(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     p.start()
     for i in range(10):  # expecting this command to complete in a second
         time.sleep(0.1)
         if not p.is_running():
             break
     p.wait()
     self.assertEqual(b'foo', p.stdout)
     self.assertFalse(p.is_running())
예제 #12
0
파일: process.py 프로젝트: rimms/jubatest
 def test_is_running(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     self.assertTrue(p.is_running())
     time.sleep(0.5)
     p.stop(True)
     time.sleep(0.5)
     self.assertFalse(p.is_running())
예제 #13
0
파일: process.py 프로젝트: kumagi/jubatest
 def test_start_stdout(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     p.start()
     for i in range(10): # expecting this command to complete in a second
         time.sleep(0.1)
         if not p.is_running():
             break
     p.wait()
     self.assertEqual('foo', p.stdout)
     self.assertFalse(p.is_running())
예제 #14
0
 def test_wait(self):
     p = LocalSubprocess(['sleep', '1'])
     p.start()
     self.assertIsNotNone(p.wait())
예제 #15
0
 def test_stop_before_start_fail(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     self.assertRaises(JubaTestFixtureFailedError, p.stop)
예제 #16
0
 def test_stop(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     time.sleep(0.5)
     p.stop()
예제 #17
0
파일: process.py 프로젝트: kumagi/jubatest
 def test_start_again_fail(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     p.start()
     p.stop(True)
     self.assertRaises(JubaTestFixtureFailedError, p.start)
예제 #18
0
파일: process.py 프로젝트: kumagi/jubatest
 def test_start_again_fail(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     p.start()
     p.stop(True)
     self.assertRaises(JubaTestFixtureFailedError, p.start)
예제 #19
0
파일: process.py 프로젝트: kumagi/jubatest
 def test_wait(self):
     p = LocalSubprocess(['sleep', '1'])
     p.start()
     self.assertIsNotNone(p.wait())
예제 #20
0
파일: process.py 프로젝트: kumagi/jubatest
 def test_stop(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     time.sleep(0.5)
     self.assertTrue(p.stop())