Пример #1
0
    def _expected_command(self,
                          root,
                          test_id,
                          pytestSubclass,
                          run_under_coverage=True,
                          processes=0,
                          xdist_ip_addresses=None):
        """
        Returns the command that is expected to be run for the given test spec
        and store.
        """
        report_dir = Env.REPORT_DIR / root
        shard = os.environ.get('SHARD')
        if shard:
            report_dir = report_dir / 'shard_' + shard

        expected_statement = ["python", "-Wd", "-m", "pytest"]
        if pytestSubclass == "SystemTestSuite":
            expected_statement.append("--ds={}".format('{}.envs.{}'.format(
                root, Env.TEST_SETTINGS)))
        expected_statement.append("--junitxml={}".format(report_dir /
                                                         "nosetests.xml"))

        if xdist_ip_addresses:
            expected_statement.append('--dist=loadscope')
            for ip in xdist_ip_addresses.split(','):
                if processes <= 0:
                    processes = 1

                if pytestSubclass == "SystemTestSuite":
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format(
                        root)
                elif pytestSubclass == "LibTestSuite":
                    if 'pavelib/paver_tests' in test_id:
                        django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format(
                            root)
                    else:
                        django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'"

                xdist_string = '--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \
                               '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \
                               '//chdir="/edx/app/edxapp/edx-platform"' \
                               .format(processes, ip, django_env_var_cmd)
                expected_statement.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                expected_statement.append('--rsyncdir {}'.format(rsync_dir))
        else:
            if processes == -1:
                expected_statement.append('-n auto')
                expected_statement.append('--dist=loadscope')
            elif processes != 0:
                expected_statement.append('-n {}'.format(processes))
                expected_statement.append('--dist=loadscope')

        expected_statement.extend(["-p no:randomly", test_id])

        if run_under_coverage:
            expected_statement.append('--cov')
            expected_statement.append('--cov-report=')
        return expected_statement
Пример #2
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            '--junitxml={}'.format(self.xunit_report),
        ])
        cmd.extend(self.passthrough_options + self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            cmd.append("--verbose")
        if self.disable_capture:
            cmd.append("-s")

        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            if self.processes <= 0:
                xdist_remote_processes = 1
            else:
                xdist_remote_processes = self.processes
            for ip in self.xdist_ip_addresses.split(','):
                # Propogate necessary env vars to xdist containers
                if 'pavelib/paver_tests' in self.test_id:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='lms.envs.test'"
                else:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'"

                env_var_cmd = u'{} DISABLE_COURSEENROLLMENT_HISTORY={}' \
                    .format(django_env_var_cmd, self.disable_courseenrollment_history)

                xdist_string = u'--tx {}*ssh="jenkins@{} -o StrictHostKeyChecking=no"' \
                               '//python="source edx-venv/bin/activate; {}; python"' \
                               '//chdir="edx-platform"' \
                               .format(xdist_remote_processes, ip, env_var_cmd)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append(u'--rsyncdir {}'.format(rsync_dir))
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append(u'-n {}'.format(self.processes))
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append("-p no:randomly")
        if self.eval_attr:
            cmd.append(u"-a '{}'".format(self.eval_attr))

        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)
Пример #3
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            '--junitxml={}'.format(self.xunit_report),
        ])
        cmd.extend(self.passthrough_options + self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            cmd.append("--verbose")
        if self.disable_capture:
            cmd.append("-s")

        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            if self.processes <= 0:
                xdist_remote_processes = 1
            else:
                xdist_remote_processes = self.processes
            for ip in self.xdist_ip_addresses.split(','):
                # Propogate necessary env vars to xdist containers
                if 'pavelib/paver_tests' in self.test_id:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='lms.envs.test'"
                else:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'"

                env_var_cmd = u'{} DISABLE_COURSEENROLLMENT_HISTORY={}' \
                    .format(django_env_var_cmd, self.disable_courseenrollment_history)

                xdist_string = u'--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \
                               '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \
                               '//chdir="/edx/app/edxapp/edx-platform"' \
                               .format(xdist_remote_processes, ip, env_var_cmd)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append(u'--rsyncdir {}'.format(rsync_dir))
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append(u'-n {}'.format(self.processes))
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append("-p no:randomly")
        if self.eval_attr:
            cmd.append(u"-a '{}'".format(self.eval_attr))

        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)
Пример #4
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            '--junitxml={}'.format(self.xunit_report),
        ])
        cmd.extend(self.passthrough_options + self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            cmd.append("--verbose")
        if self.disable_capture:
            cmd.append("-s")

        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            if self.processes <= 0:
                xdist_remote_processes = 1
            else:
                xdist_remote_processes = self.processes
            for ip in self.xdist_ip_addresses.split(','):
                # The django settings runtime command does not propagate to xdist remote workers
                if 'pavelib/paver_tests' in self.test_id:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='lms.envs.test'"
                else:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'"
                xdist_string = u'--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \
                               '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \
                               '//chdir="/edx/app/edxapp/edx-platform"' \
                               .format(xdist_remote_processes, ip, django_env_var_cmd)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append(u'--rsyncdir {}'.format(rsync_dir))
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append(u'-n {}'.format(self.processes))
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append("-p no:randomly")
        if self.eval_attr:
            cmd.append(u"-a '{}'".format(self.eval_attr))

        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)
Пример #5
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            '--ds={}'.format('{}.envs.{}'.format(self.root, self.settings)),
            "--junitxml={}".format(self.xunit_report),
        ])
        cmd.extend(self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            cmd.append("--verbose")

        if self.disable_capture:
            cmd.append("-s")
        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            if self.processes <= 0:
                xdist_remote_processes = 1
            else:
                xdist_remote_processes = self.processes
            for ip in self.xdist_ip_addresses.split(','):
                # The django settings runtime command does not propagate to xdist remote workers
                django_env_var_cmd = u'export DJANGO_SETTINGS_MODULE={}' \
                                     .format('{}.envs.{}'.format(self.root, self.settings))
                xdist_string = u'--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \
                               '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \
                               '//chdir="/edx/app/edxapp/edx-platform"' \
                               .format(xdist_remote_processes, ip, django_env_var_cmd)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append(u'--rsyncdir {}'.format(rsync_dir))
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append(u'-n {}'.format(self.processes))
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append('-p no:randomly')
        if self.eval_attr:
            cmd.append(u"-a '{}'".format(self.eval_attr))

        cmd.extend(self.passthrough_options)
        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)
Пример #6
0
    def _under_coverage_cmd(self, cmd):
        """
        If self.run_under_coverage is True, it returns the arg 'cmd'
        altered to be run under coverage. It returns the command
        unaltered otherwise.
        """
        if self.run_under_coverage:
            if self.xdist_ip_addresses:
                for module in Env.covered_modules():
                    cmd.append('--cov')
                    cmd.append(module)
            else:
                cmd.append('--cov')
            cmd.append('--cov-report=')

        return cmd
Пример #7
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            '--ds={}'.format('{}.envs.{}'.format(self.root, self.settings)),
            "--junitxml={}".format(self.xunit_report),
        ])
        cmd.extend(self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            cmd.append("--verbose")

        if self.disable_capture:
            cmd.append("-s")

        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            for ip in self.xdist_ip_addresses.split(' '):
                xdist_string = '--tx ssh=ubuntu@{}//python="source /edx/app/edxapp/edxapp_env; ' \
                               'python"//chdir="/edx/app/edxapp/edx-platform"'.format(ip)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append('--rsyncdir {}'.format(rsync_dir))
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append('-n {}'.format(self.processes))
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append('-p no:randomly')
        if self.eval_attr:
            cmd.append("-a '{}'".format(self.eval_attr))

        cmd.extend(self.passthrough_options)
        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)
Пример #8
0
    def _expected_command(self, root, test_id, pytestSubclass, run_under_coverage=True,
                          processes=0, xdist_ip_addresses=None):
        """
        Returns the command that is expected to be run for the given test spec
        and store.
        """
        report_dir = Env.REPORT_DIR / root
        shard = os.environ.get('SHARD')
        if shard:
            report_dir = report_dir / 'shard_' + shard

        expected_statement = [
            "python",
            "-Wd",
            "-m",
            "pytest"
        ]
        if pytestSubclass == "SystemTestSuite":
            expected_statement.append("--ds={}".format('{}.envs.{}'.format(root, Env.TEST_SETTINGS)))
        expected_statement.append("--junitxml={}".format(report_dir / "nosetests.xml"))

        if xdist_ip_addresses:
            expected_statement.append('--dist=loadscope')
            for ip in xdist_ip_addresses.split(','):
                if processes <= 0:
                    processes = 1

                if pytestSubclass == "SystemTestSuite":
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format(root)
                elif pytestSubclass == "LibTestSuite":
                    if 'pavelib/paver_tests' in test_id:
                        django_env_var_cmd = "export DJANGO_SETTINGS_MODULE={}.envs.test".format(root)
                    else:
                        django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'"

                xdist_string = '--tx {}*ssh="ubuntu@{} -o StrictHostKeyChecking=no"' \
                               '//python="source /edx/app/edxapp/edxapp_env; {}; python"' \
                               '//chdir="/edx/app/edxapp/edx-platform"' \
                               .format(processes, ip, django_env_var_cmd)
                expected_statement.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                expected_statement.append('--rsyncdir {}'.format(rsync_dir))
        else:
            if processes == -1:
                expected_statement.append('-n auto')
                expected_statement.append('--dist=loadscope')
            elif processes != 0:
                expected_statement.append('-n {}'.format(processes))
                expected_statement.append('--dist=loadscope')

        expected_statement.extend([
            "-p no:randomly",
            test_id
        ])

        if run_under_coverage:
            if xdist_ip_addresses:
                for module in Env.covered_modules():
                    expected_statement.append('--cov')
                    expected_statement.append(module)
            else:
                expected_statement.append('--cov')
            expected_statement.append('--cov-report=')
        return expected_statement
Пример #9
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            f'--junitxml={self.xunit_report}',
        ])
        cmd.extend(self.passthrough_options + self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            # currently only two verbosity settings are supported, so using `-vvv`
            # in place of `--verbose`, because it is needed to see migrations.
            cmd.append("-vvv")
        if self.disable_capture:
            cmd.append("-s")

        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            if self.processes <= 0:
                xdist_remote_processes = 1
            else:
                xdist_remote_processes = self.processes
            for ip in self.xdist_ip_addresses.split(','):
                # Propogate necessary env vars to xdist containers
                if 'pavelib/paver_tests' in self.test_id:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='lms.envs.test'"
                else:
                    django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'"

                env_var_cmd = '{} DISABLE_COURSEENROLLMENT_HISTORY={}' \
                    .format(django_env_var_cmd, self.disable_courseenrollment_history)

                xdist_string = '--tx {}*ssh="jenkins@{} -o StrictHostKeyChecking=no"' \
                               '//python="source edx-venv-{}/edx-venv/bin/activate; {}; python"' \
                               '//chdir="edx-platform"' \
                               .format(xdist_remote_processes, ip, Env.PYTHON_VERSION, env_var_cmd)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append(f'--rsyncdir {rsync_dir}')
            # "--rsyncdir" throws off the configuration root, set it explicitly
            if 'common/lib' in self.test_id:
                cmd.append('--rootdir=common/lib')
                cmd.append('-c common/lib/pytest.ini')
            elif 'pavelib/paver_tests' in self.test_id:
                cmd.append('--rootdir=pavelib/paver_tests')
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append(f'-n {self.processes}')
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append("-p no:randomly")
        if self.eval_attr:
            cmd.append(f"-a '{self.eval_attr}'")

        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)
Пример #10
0
    def cmd(self):
        if self.django_toxenv:
            cmd = ['tox', '-e', self.django_toxenv, '--']
        else:
            cmd = []
        cmd.extend([
            'python',
            '-Wd',
            '-m',
            'pytest',
            '--ds={}'.format('{}.envs.{}'.format(self.root, self.settings)),
            "--junitxml={}".format(self.xunit_report),
        ])
        cmd.extend(self.test_options_flags)
        if self.verbosity < 1:
            cmd.append("--quiet")
        elif self.verbosity > 1:
            # currently only two verbosity settings are supported, so using `-vvv`
            # in place of `--verbose`, because it is needed to see migrations.
            cmd.append("-vvv")

        if self.disable_capture:
            cmd.append("-s")

        if not self.disable_migrations:
            cmd.append("--migrations")

        if self.xdist_ip_addresses:
            cmd.append('--dist=loadscope')
            if self.processes <= 0:
                xdist_remote_processes = 1
            else:
                xdist_remote_processes = self.processes
            for ip in self.xdist_ip_addresses.split(','):
                # Propogate necessary env vars to xdist containers
                env_var_cmd = u'export DJANGO_SETTINGS_MODULE={} DISABLE_COURSEENROLLMENT_HISTORY={} PYTHONHASHSEED=0'\
                    .format('{}.envs.{}'.format(self.root, self.settings),
                            self.disable_courseenrollment_history)
                xdist_string = u'--tx {}*ssh="jenkins@{} -o StrictHostKeyChecking=no"' \
                               '//python="source edx-venv-{}/edx-venv/bin/activate; {}; python"' \
                               '//chdir="edx-platform"' \
                               .format(xdist_remote_processes, ip, Env.PYTHON_VERSION, env_var_cmd)
                cmd.append(xdist_string)
            for rsync_dir in Env.rsync_dirs():
                cmd.append(u'--rsyncdir {}'.format(rsync_dir))
        else:
            if self.processes == -1:
                cmd.append('-n auto')
                cmd.append('--dist=loadscope')
            elif self.processes != 0:
                cmd.append(u'-n {}'.format(self.processes))
                cmd.append('--dist=loadscope')

        if not self.randomize:
            cmd.append('-p no:randomly')
        if self.eval_attr:
            cmd.append(u"-a '{}'".format(self.eval_attr))

        cmd.extend(self.passthrough_options)
        cmd.append(self.test_id)

        return self._under_coverage_cmd(cmd)