Ejemplo n.º 1
0
    def test_sizing_multiprocess(self):
        counters = SharedCounters('OK', 'FAILED')

        with catch_sleep():
            @scenario()
            async def sizer(session):
                if random.randint(0, 10) == 1:
                    counters['FAILED'] += 1
                    raise AssertionError()
                else:
                    counters['OK'] += 1

            with set_args('molotov', '--sizing', '-p', '2',
                          '--sizing-tolerance', '5',
                          '--console-update', '0',
                          '-s', 'sizer',
                          'molotov.tests.test_run') as (stdout, stderr):
                try:
                    main()
                except SystemExit:
                    pass
            stdout, stderr = stdout.read().strip(), stderr.read().strip()

            # stdout, stderr, rc = self._test_molotov()
            ratio = (float(counters['FAILED'].value) /
                     float(counters['OK'].value) * 100.)
            self.assertTrue(ratio >= 5., ratio)
Ejemplo n.º 2
0
    def test_codeworks(self):
        quickstart._input = self._input

        with set_args('molostart'):
            quickstart.main()

        result = os.listdir(self.location)
        result.sort()
        self.assertEqual(result, ['Makefile', 'loadtest.py', 'molotov.json'])

        os.chdir(self.location)
        with set_args('molotov', '-cxv', '--max-runs', '1'):
            try:
                run.main()
            except SystemExit:
                pass
Ejemplo n.º 3
0
    def test_sizing_multiprocess(self):
        counters = SharedCounters('OK', 'FAILED')

        with catch_sleep():
            @scenario()
            async def sizer(session):
                if random.randint(0, 10) == 1:
                    counters['FAILED'] += 1
                    raise AssertionError()
                else:
                    counters['OK'] += 1

            with set_args('molotov', '--sizing', '-p', '2',
                          '--sizing-tolerance', '5',
                          '--console-update', '0',
                          '-s', 'sizer',
                          'molotov.tests.test_run') as (stdout, stderr):
                try:
                    main()
                except SystemExit:
                    pass
            stdout, stderr = stdout.read().strip(), stderr.read().strip()

            # stdout, stderr, rc = self._test_molotov()
            ratio = (float(counters['FAILED'].value) /
                     float(counters['OK'].value) * 100.)
            self.assertTrue(ratio >= 5., ratio)
Ejemplo n.º 4
0
 def _test_molotov(self, *args):
     with set_args('molotov', *args) as (stdout, stderr):
         try:
             main()
         except SystemExit:
             pass
     return stdout.read().strip(), stderr.read().strip()
Ejemplo n.º 5
0
    def test_codeworks(self):
        quickstart._input = self._input

        with set_args('molostart'):
            quickstart.main()

        result = os.listdir(self.tempdir)
        result.sort()
        self.assertEqual(result, ['Makefile', 'loadtest.py', 'molotov.json'])

        os.chdir(self.tempdir)
        with set_args('molotov', '-cxv', '--max-runs', '1'):
            try:
                run.main()
            except SystemExit:
                pass
Ejemplo n.º 6
0
    def test_main(self):
        with set_args('moloslave', _REPO, 'test') as out:
            main()
            time.sleep(.2)

        output = out[0].read()
        self.assertTrue('Preparing 1 worker...\nOK' in output, output)
Ejemplo n.º 7
0
    def test_codeworks(self):
        quickstart._input = self._input

        with set_args("molostart"):
            quickstart.main()

        result = os.listdir(self.location)
        result.sort()
        self.assertEqual(result, ["Makefile", "loadtest.py", "molotov.json"])

        os.chdir(self.location)
        with set_args("molotov", "-cxv", "--max-runs", "1"):
            try:
                run.main()
            except SystemExit:
                pass
Ejemplo n.º 8
0
 def test_version(self):
     with set_args('moloslave', '--version') as out:
         try:
             main()
         except SystemExit:
             pass
     version = out[0].read().strip()
     self.assertTrue(version, __version__)
Ejemplo n.º 9
0
 def test_main(self):
     with set_args('moloslave', _REPO, 'test') as out:
         main()
     if os.environ.get("TRAVIS") is not None:
         return
     output = out[0].read()
     self.assertTrue('Preparing 1 worker...' in output, output)
     self.assertTrue('OK' in output, output)
Ejemplo n.º 10
0
    def test_generate(self):
        quickstart._input = self._input

        with set_args('molostart'):
            quickstart.main()

        result = os.listdir(self.location)
        result.sort()
        self.assertEqual(result, ['Makefile', 'loadtest.py', 'molotov.json'])

        # second runs stops
        with set_args('molostart'):
            try:
                quickstart.main()
                raise AssertionError()
            except SystemExit:
                pass
Ejemplo n.º 11
0
 def test_main(self):
     with set_args("moloslave", _REPO, "test") as out:
         main()
     if os.environ.get("TRAVIS") is not None:
         return
     output = out[0].read()
     self.assertTrue("Preparing 1 worker..." in output, output)
     self.assertTrue("OK" in output, output)
Ejemplo n.º 12
0
    def test_generate(self):
        quickstart._input = self._input

        with set_args('molostart'):
            quickstart.main()

        result = os.listdir(self.tempdir)
        result.sort()
        self.assertEqual(result, ['Makefile', 'loadtest.py', 'molotov.json'])

        # second runs stops
        with set_args('molostart'):
            try:
                quickstart.main()
                raise AssertionError()
            except SystemExit:
                pass
Ejemplo n.º 13
0
 def test_version(self):
     with set_args('moloslave', '--version') as out:
         try:
             main()
         except SystemExit:
             pass
     version = out[0].read().strip()
     self.assertTrue(version, __version__)
Ejemplo n.º 14
0
    def test_generate(self):
        quickstart._input = self._input

        with set_args("molostart"):
            quickstart.main()

        result = os.listdir(self.location)
        result.sort()
        self.assertEqual(result, ["Makefile", "loadtest.py", "molotov.json"])

        # second runs stops
        with set_args("molostart"):
            try:
                quickstart.main()
                raise AssertionError()
            except SystemExit:
                pass
Ejemplo n.º 15
0
 def test_version(self):
     with set_args("moloslave", "--version", "--directory",
                   self.dir) as out:
         try:
             main()
         except SystemExit:
             pass
     version = out[0].read().strip()
     self.assertTrue(version, __version__)
Ejemplo n.º 16
0
 def _test_molotov(self, *args):
     if '--duration' not in args and '-d' not in args:
         args = list(args) + ['--duration', '10']
     rc = 0
     with set_args('molotov', *args) as (stdout, stderr):
         try:
             main()
         except SystemExit as e:
             rc = e.code
     return stdout.read().strip(), stderr.read().strip(), rc
Ejemplo n.º 17
0
    def test_version(self):
        quickstart._input = self._input

        with set_args('molostart', '--version') as out:
            try:
                quickstart.main()
            except SystemExit:
                pass
        output = out[0].read().strip()
        self.assertEqual(output, __version__)
Ejemplo n.º 18
0
    def test_version(self):
        quickstart._input = self._input

        with set_args('molostart', '--version') as out:
            try:
                quickstart.main()
            except SystemExit:
                pass
        output = out[0].read().strip()
        self.assertEqual(output, __version__)
Ejemplo n.º 19
0
 def _test_molotov(self, *args):
     if "--duration" not in args and "-d" not in args:
         args = list(args) + ["--duration", "10"]
     rc = 0
     with set_args("molotov", *args) as (stdout, stderr):
         try:
             main()
         except SystemExit as e:
             rc = e.code
     return stdout.read().strip(), stderr.read().strip(), rc
Ejemplo n.º 20
0
 def _test_molotov(self, *args):
     if '--duration' not in args and '-d' not in args:
         args = list(args) + ['--duration', '10']
     rc = 0
     with set_args('molotov', *args) as (stdout, stderr):
         try:
             main()
         except SystemExit as e:
             rc = e.code
     return stdout.read().strip(), stderr.read().strip(), rc
Ejemplo n.º 21
0
    def test_sizing_multiprocess(self):
        counters = SharedCounters("OK", "FAILED")

        with catch_sleep():

            @scenario()
            async def sizer(session):
                if random.randint(0, 10) == 1:
                    counters["FAILED"] += 1
                    raise AssertionError()
                else:
                    counters["OK"] += 1

            with set_args(
                    "molotov",
                    "--sizing",
                    "-p",
                    "2",
                    "--sizing-tolerance",
                    "5",
                    "--console-update",
                    "0",
                    "-s",
                    "sizer",
                    "molotov.tests.test_run",
            ) as (stdout, stderr):
                try:
                    main()
                except SystemExit:
                    pass
            stdout, stderr = stdout.read().strip(), stderr.read().strip()

            # stdout, stderr, rc = self._test_molotov()
            ratio = (float(counters["FAILED"].value) /
                     float(counters["OK"].value) * 100.0)
            self.assertTrue(ratio >= 4.75, ratio)
Ejemplo n.º 22
0
 def test_fail(self):
     with set_args("moloslave", _REPO, "fail", "--directory", self.dir):
         self.assertRaises(Exception, main)
Ejemplo n.º 23
0
 def test_main(self):
     with set_args("molotov", "-cq", "-d", "1", "molotov/tests/example.py"):
         main()
Ejemplo n.º 24
0
 def test_fail(self):
     with set_args("moloslave", _REPO, "fail"):
         self.assertRaises(Exception, main)
Ejemplo n.º 25
0
 def test_main(self):
     with set_args('moloslave', _REPO, 'test') as out:
         main()
     output = out[0].read()
     self.assertTrue('Preparing 1 workers...OK' in output)
Ejemplo n.º 26
0
 def test_fail(self):
     with set_args('moloslave', _REPO, 'fail'):
         self.assertRaises(Exception, main)
Ejemplo n.º 27
0
 def test_main(self):
     with set_args('molotov', '-cq', '-d', '1', 'molotov/tests/example.py'):
         main()
Ejemplo n.º 28
0
 def test_fail(self):
     with set_args('moloslave', _REPO, 'fail'):
         self.assertRaises(Exception, main)
Ejemplo n.º 29
0
 def test_main(self):
     with set_args('molotov', '-cq', '-d', '1', 'molotov/tests/example.py'):
         main()