Exemplo n.º 1
0
def add_test_to_kvm(username, commit_hash, platforms, regression_tests):
    """
    Create new tests and add it to CustomizedTests based on parameters.
    :param username: git username required to find fork
    :type username: str
    :param commit_hash: commit hash of the repo user selected to run test
    :type commit_hash: str
    :param platforms: platforms user selected to run test
    :type platforms: list
    :param regression_tests: regression tests user selected to run tests
    :type regression_tests: list
    """
    fork_url = ('https://github.com/{user}/{repo}.git').format(
        user=username, repo=g.github['repository']
    )
    fork = Fork.query.filter(Fork.github == fork_url).first()
    if fork is None:
        fork = Fork(fork_url)
        g.db.add(fork)
        g.db.commit()
    for platform in platforms:
        platform = TestPlatform.from_string(platform)
        test = Test(platform, TestType.commit, fork.id, 'master', commit_hash)
        g.db.add(test)
        g.db.commit()
        for regression_test in regression_tests:
            customized_test = CustomizedTest(test.id, regression_test)
            g.db.add(customized_test)
        test_fork = TestFork(g.user.id, test.id)
        g.db.add(test_fork)
        g.db.commit()
Exemplo n.º 2
0
 def create_forktest(self, commit_hash, platform, regression_tests=None):
     """Create a test on fork based on commit and platform."""
     from flask import g
     fork_url = f"https://github.com/{self.user.name}/{g.github['repository']}.git"
     fork = Fork(fork_url)
     g.db.add(fork)
     g.db.commit()
     test = Test(platform, TestType.commit, fork.id, 'master', commit_hash)
     g.db.add(test)
     g.db.commit()
     user = User.query.filter(User.email == self.user.email).first()
     test_fork = TestFork(user.id, test.id)
     g.db.add(test_fork)
     g.db.commit()
     if regression_tests is not None:
         for regression_test in regression_tests:
             customized_test = CustomizedTest(test.id, regression_test)
             g.db.add(customized_test)
             g.db.commit()
Exemplo n.º 3
0
    def setUp(self):
        self.app.preprocess_request()
        g.db = create_session(self.app.config['DATABASE_URI'],
                              drop_tables=True)
        # enable Foreign keys for unit tests
        g.db.execute('pragma foreign_keys=on')

        general_data = [
            GeneralData('last_commit',
                        "1978060bf7d2edd119736ba3ba88341f3bec3323"),
            GeneralData(f'fetch_commit_{TestPlatform.linux.value}',
                        "1978060bf7d2edd119736ba3ba88341f3bec3323"),
            GeneralData(f'fetch_commit_{TestPlatform.windows.value}',
                        "1978060bf7d2edd119736ba3ba88341f3bec3323")
        ]
        g.db.add_all(general_data)

        self.ccextractor_version = CCExtractorVersion(
            "1.2.3", "2013-02-27T19:35:32Z",
            "1978060bf7d2edd119736ba3ba88341f3bec3323")
        g.db.add(self.ccextractor_version)

        fork = Fork(
            f"https://github.com/{g.github['repository_owner']}/{g.github['repository']}.git"
        )
        g.db.add(fork)
        g.db.commit()

        dummy_user = User(signup_information['existing_user_name'],
                          signup_information['existing_user_role'],
                          signup_information['existing_user_email'],
                          signup_information['existing_user_pwd'])
        g.db.add(dummy_user)
        g.db.commit()

        test = [
            Test(TestPlatform.linux, TestType.pull_request, 1, "master",
                 "1978060bf7d2edd119736ba3ba88341f3bec3323", 1),
            Test(TestPlatform.linux, TestType.pull_request, 1, "master",
                 "abcdefgh", 1)
        ]
        g.db.add_all(test)
        g.db.commit()

        categories = [
            Category("Broken", "Samples that are broken"),
            Category("DVB", "Samples that contain DVB subtitles"),
            Category("DVD", "Samples that contain DVD subtitles"),
            Category("MP4", "Samples that are stored in the MP4 format"),
            Category("General", "General regression samples")
        ]
        g.db.add_all(categories)
        g.db.commit()

        samples = [
            Sample("sample1", "ts", "sample1"),
            Sample("sample2", "ts", "sample2")
        ]
        g.db.add_all(samples)
        g.db.commit()

        upload = [
            Upload(1, 1, 1, Platform.windows),
            Upload(1, 2, 1, Platform.linux)
        ]
        g.db.add_all(upload)
        g.db.commit()

        regression_tests = [
            RegressionTest(1, "-autoprogram -out=ttxt -latin1 -2",
                           InputType.file, OutputType.file, 3, 10),
            RegressionTest(2, "-autoprogram -out=ttxt -latin1 -ucla",
                           InputType.file, OutputType.file, 1, 10)
        ]
        g.db.add_all(regression_tests)
        g.db.commit()

        categories[0].regression_tests.append(regression_tests[0])
        categories[2].regression_tests.append(regression_tests[1])
        regression_test_outputs = [
            RegressionTestOutput(1, "sample_out1", ".srt", ""),
            RegressionTestOutput(2, "sample_out2", ".srt", "")
        ]
        g.db.add_all(regression_test_outputs)
        g.db.commit()

        rtof = RegressionTestOutputFiles("bluedabadee", 2)
        g.db.add(rtof)
        g.db.commit()

        test_result_progress = [
            TestProgress(1, TestStatus.preparation, "Test 1 preparation"),
            TestProgress(1, TestStatus.building, "Test 1 building"),
            TestProgress(1, TestStatus.testing, "Test 1 testing"),
            TestProgress(1, TestStatus.completed, "Test 1 completed"),
            TestProgress(2, TestStatus.preparation, "Test 2 preparation"),
            TestProgress(2, TestStatus.building, "Test 2 building"),
            TestProgress(2, TestStatus.testing, "Test 2 testing"),
            TestProgress(2, TestStatus.completed, "Test 2 completed")
        ]
        g.db.add_all(test_result_progress)
        g.db.commit()

        test_results = [
            TestResult(1, 1, 200, 0, 0),
            TestResult(1, 2, 601, 0, 0),
            TestResult(2, 1, 200, 200, 0),
            TestResult(2, 2, 601, 0, 0)
        ]
        g.db.add_all(test_results)
        g.db.commit()

        test_result_files = [
            TestResultFile(1, 1, 1, "sample_out1"),
            TestResultFile(1, 2, 2, "sample_out2"),
            TestResultFile(2, 1, 1, "sample_out1"),
            TestResultFile(2, 2, 2, "sample_out2", "out2")
        ]
        g.db.add_all(test_result_files)
        g.db.commit()

        forbidden_mime = ForbiddenMimeType("application/javascript")
        forbidden_ext = [ForbiddenExtension("js"), ForbiddenExtension("com")]
        g.db.add(forbidden_mime)
        g.db.add_all(forbidden_ext)
        g.db.commit()
Exemplo n.º 4
0
 def setUp(self):
     self.app.preprocess_request()
     g.db = create_session(self.app.config['DATABASE_URI'],
                           drop_tables=True)
     g.db.execute('pragma foreign_keys=on')  # Enable Foreign for unit tests
     commit_name_linux = 'fetch_commit_' + TestPlatform.linux.value
     commit_name_windows = 'fetch_commit_' + TestPlatform.windows.value
     general_data = [
         GeneralData('last_commit',
                     '1978060bf7d2edd119736ba3ba88341f3bec3323'),
         GeneralData(commit_name_linux,
                     '1978060bf7d2edd119736ba3ba88341f3bec3323'),
         GeneralData(commit_name_windows,
                     '1978060bf7d2edd119736ba3ba88341f3bec3323')
     ]
     g.db.add_all(general_data)
     self.ccextractor_version = CCExtractorVersion(
         '1.2.3', '2013-02-27T19:35:32Z',
         '1978060bf7d2edd119736ba3ba88341f3bec3323')
     g.db.add(self.ccextractor_version)
     fork_url = ('https://github.com/{user}/{repo}.git').format(
         user=g.github['repository_owner'], repo=g.github['repository'])
     fork = Fork(fork_url)
     g.db.add(fork)
     g.db.commit()
     dummy_user = User(signup_information['existing_user_name'],
                       signup_information['existing_user_role'],
                       signup_information['existing_user_email'],
                       signup_information['existing_user_pwd'])
     g.db.add(dummy_user)
     g.db.commit()
     test = [
         Test(TestPlatform.linux, TestType.pull_request, 1, 'master',
              '1978060bf7d2edd119736ba3ba88341f3bec3323', 1),
         Test(TestPlatform.linux, TestType.pull_request, 1, 'master',
              'abcdefgh', 1)
     ]
     g.db.add_all(test)
     g.db.commit()
     categories = [
         Category('Broken', 'Samples that are broken'),
         Category('DVB', 'Samples that contain DVB subtitles'),
         Category('DVD', 'Samples that contain DVD subtitles'),
         Category('MP4', 'Samples that are stored in the MP4 format'),
         Category('General', 'General regression samples')
     ]
     g.db.add_all(categories)
     g.db.commit()
     samples = [
         Sample('sample1', 'ts', 'sample1'),
         Sample('sample2', 'ts', 'sample2')
     ]
     g.db.add_all(samples)
     g.db.commit()
     upload = [
         Upload(1, 1, 1, Platform.windows),
         Upload(1, 2, 1, Platform.linux)
     ]
     g.db.add_all(upload)
     g.db.commit()
     regression_tests = [
         RegressionTest(1, '-autoprogram -out=ttxt -latin1 -2',
                        InputType.file, OutputType.file, 3, 10),
         RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla',
                        InputType.file, OutputType.file, 1, 10)
     ]
     g.db.add_all(regression_tests)
     g.db.commit()
     categories[0].regression_tests.append(regression_tests[0])
     categories[2].regression_tests.append(regression_tests[1])
     regression_test_outputs = [
         RegressionTestOutput(1, 'sample_out1', '.srt', ''),
         RegressionTestOutput(2, 'sample_out2', '.srt', '')
     ]
     g.db.add_all(regression_test_outputs)
     g.db.commit()
     test_result_progress = [
         TestProgress(1, TestStatus.preparation, "Test 1 preperation"),
         TestProgress(1, TestStatus.building, "Test 1 building"),
         TestProgress(1, TestStatus.testing, "Test 1 testing"),
         TestProgress(1, TestStatus.completed, "Test 1 completed"),
         TestProgress(2, TestStatus.preparation, "Test 2 preperation"),
         TestProgress(2, TestStatus.building, "Test 2 building"),
         TestProgress(2, TestStatus.testing, "Test 2 testing"),
         TestProgress(2, TestStatus.completed, "Test 2 completed")
     ]
     g.db.add_all(test_result_progress)
     g.db.commit()
     test_results = [
         TestResult(1, 1, 200, 0, 0),
         TestResult(1, 2, 601, 0, 0),
         TestResult(2, 1, 200, 200, 0),
         TestResult(2, 2, 601, 0, 0)
     ]
     g.db.add_all(test_results)
     g.db.commit()
     test_result_files = [
         TestResultFile(1, 1, 1, 'sample_out1'),
         TestResultFile(1, 2, 2, 'sample_out2'),
         TestResultFile(2, 1, 1, 'sample_out1'),
         TestResultFile(2, 2, 2, 'sample_out2', 'out2')
     ]
     g.db.add_all(test_result_files)
     g.db.commit()
     forbidden_mime = ForbiddenMimeType('application/javascript')
     forbidden_ext = [ForbiddenExtension('js'), ForbiddenExtension('com')]
     g.db.add(forbidden_mime)
     g.db.add_all(forbidden_ext)
     g.db.commit()