예제 #1
0
    def __init__(self, test_list, contest_id=None, workers=1, cpu_limits=None):
        self.start_time = datetime.datetime.now()
        self.last_end_time = self.start_time

        self.framework = FunctionalTestFramework()
        self.load_cms_conf()

        self.ps = ProgramStarter(cpu_limits)

        # Map from task name to (task id, task_module).
        self.task_id_map = {}

        # String to append to objects' names to avoid collisions. Will be the
        # first positive integer i for which admin_<i> is not already
        # registered, and we will hope that if the admin name doesn't clash, no
        # other name will.
        self.suffix = None

        self.num_users = 0
        self.workers = workers

        if CONFIG["TEST_DIR"] is not None:
            # Set up our expected environment.
            os.chdir("%(TEST_DIR)s" % CONFIG)
            os.environ["PYTHONPATH"] = "%(TEST_DIR)s" % CONFIG

        self.start_generic_services()
        self.suffix = self.framework.initialize_aws()

        if contest_id is None:
            self.contest_id = self.create_contest()
        else:
            self.contest_id = int(contest_id)
        self.user_id = self.create_or_get_user()

        self.failures = []
        self.test_list = test_list
        self.n_tests = len(test_list)
        self.n_submissions = sum(len(test.languages) for test in test_list)
        self.n_user_tests = sum(
            len(test.languages) for test in test_list if test.user_tests)
        logging.info("Have %s submissions and %s user_tests in %s tests...",
                     self.n_submissions, self.n_user_tests, self.n_tests)
예제 #2
0
파일: testrunner.py 프로젝트: ioi-2017/cms
    def __init__(self, test_list, contest_id=None,
                 workers=1, evaluations=4):
        self.start_time = datetime.datetime.now()

        self.ps = ProgramStarter()

        # Map from task name to (task id, task_module).
        self.task_id_map = {}

        # Random bit to append to object's names to avoid collisions.
        self.rand = random.randint(0, 999999999)

        self.num_users = 0
        self.workers = workers
        self.evaluations = evaluations

        # Load config from cms.conf.
        TestRunner.load_cms_conf()

        if CONFIG["TEST_DIR"] is not None:
            # Set up our expected environment.
            os.chdir("%(TEST_DIR)s" % CONFIG)
            os.environ["PYTHONPATH"] = "%(TEST_DIR)s" % CONFIG

        self.start_generic_services()
        initialize_aws(self.rand)

        if contest_id is None:
            self.contest_id = self.create_contest()
        else:
            self.contest_id = int(contest_id)
        self.user_id = self.create_or_get_user()

        self.failures = []
        self.test_list = test_list
        self.n_tests = len(test_list)
        self.n_submissions = sum(len(test.languages) for test in test_list)
        self.n_user_tests = sum(len(test.languages) for test in test_list
                                if test.user_tests)
        logging.info("Have %s submissions and %s user_tests in %s tests...",
                     self.n_submissions, self.n_user_tests, self.n_tests)