Exemplo n.º 1
0
def test_example_report_status3(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    # Check for all entries that should be present
    for C in CS:
        for G in GS:
            S = 'HEADs'
            B = 'PR-blah'  # PR1-PR11-PR111-PR1111-blah
            r = StatusReport(
                status=(2 if C == 'clang' else 'initial_success'),
                project='Project #1',
                strategy=S,
                branchtype="pullreq" if B.startswith('PR') else "regular",
                branch=B.split('-')[-1] if B.startswith('PR') else B,
                buildname='-'.join(['.'.join([B, S]), C, G]),
                bldvars=[
                    BldVariable(project='Project #1',
                                varname='ghcver',
                                varvalue=G),
                    BldVariable(project='Project #1',
                                varname='c_compiler',
                                varvalue=C),
                ],
                blddesc=PR_Grouped(B[3:]) if B.startswith('PR-') else
                (MainBranch('R1', B) if B == 'master' else BranchReq(
                    'Project #1', B)),
            )
            assert r in reps
Exemplo n.º 2
0
def test_example_report_do_list(example_report):
    "Check email actions with no whitelisting or blacklisting."
    reps = example_report
    recipients = sorted([
        '*****@*****.**',
        '*****@*****.**',
        '*****@*****.**',
        'john@_company.com',
        'sam@not_a_company.com',
    ])
    assert SendEmail(recipients=recipients,
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=[]) in reps
    assert SendEmail(recipients=['*****@*****.**'],
                     notification=Notify(what='variable_failing',
                                         subject='Repo1',
                                         params=BldVariable(
                                             project='Repo1',
                                             varname='ghcver',
                                             varvalue='ghc881')),
                     sent_to=[]) in reps
    assert SendEmail(recipients=['*****@*****.**', 'george@_company.com'],
                     notification=Notify(what='main_good',
                                         subject='Repo1',
                                         params='master'),
                     sent_to=[]) in reps
Exemplo n.º 3
0
def test_example_report_statusMany(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    # Check for all entries that should be present
    for C in CS:
        for G in GS:
            for S in SS:
                for B in BS:
                    r = StatusReport(
                        status=('succeeded' if C == 'gnucc' and G == 'ghc844'
                                and S == 'submodules' and B == 'master' else
                                'fixed' if C == 'gnucc' and G == 'ghc865'
                                and S == 'HEADs' and B == 'master' else
                                'succeeded' if C == 'gnucc' and G == 'ghc844'
                                and S == 'HEADs' and B == 'master' else
                                2 if C == 'clang' else 'initial_success'),
                        project='Project #1',
                        strategy=S,
                        branchtype="pullreq"
                        if B.startswith('PR') else "regular",
                        branch=B.split('-')[-1] if B.startswith('PR') else B,
                        buildname='-'.join(['.'.join([B, S]), C, G]),
                        bldvars=[
                            BldVariable(project='Project #1',
                                        varname='ghcver',
                                        varvalue=G),
                            BldVariable(project='Project #1',
                                        varname='c_compiler',
                                        varvalue=C),
                        ],
                        blddesc=(PR_Grouped(B[3:]) if B.startswith('PR-') else
                                 BranchReq('Project #1', B)),
                    )
                    assert r in reps
Exemplo n.º 4
0
def test_example_report_take_actions(send_email, inp_configs, example_report):
    "Check email actions with no whitelisting or blacklisting."

    send_email.side_effect = lambda r, s, m: r

    rep = hh.perform_hh_actions(inp_configs, example_report)

    for each in rep:
        if isinstance(each, SendEmail):
            print('')
            print(each)

    recipients = sorted([
        '*****@*****.**',
        '*****@*****.**',
        'john@_company.com',
        '*****@*****.**',
        'sam@not_a_company.com',
    ])
    recipients_with_owner = sorted(recipients + ['george@_company.com'])
    assert SendEmail(recipients=recipients,
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=recipients) in rep
    assert SendEmail(recipients=["*****@*****.**"],
                     notification=Notify(what='variable_failing',
                                         subject='Repo1',
                                         params=BldVariable(
                                             project='Repo1',
                                             varname='ghcver',
                                             varvalue='ghc881')),
                     sent_to=["*****@*****.**"]) in rep
    assert SendEmail(recipients=["*****@*****.**", "george@_company.com"],
                     notification=Notify(what='main_good',
                                         subject='Repo1',
                                         params='master'),
                     sent_to=["*****@*****.**",
                              "george@_company.com"]) in rep
    assert SendEmail(recipients=filter(lambda r: 'betty' not in r,
                                       recipients_with_owner),
                     notification=Notify(what='main_submodules_good',
                                         subject='Project #1',
                                         params='master'),
                     sent_to=filter(lambda r: 'betty' not in r,
                                    recipients_with_owner)) in rep
    send_email.assert_has_calls([
        call(recipients, ANY, ANY),
        call(list(filter(lambda r: 'betty' not in r, recipients_with_owner)),
             ANY, ANY),
        call(["*****@*****.**", "george@_company.com"], ANY, ANY),
        call(["*****@*****.**"], ANY, ANY),
    ],
                                any_order=True)
    assert send_email.call_count == 4
Exemplo n.º 5
0
def test_example_report_do_list_b(testing_dir,
                                  generated_inp_config_bldconfigs):
    "Check email blacklist only disables blacklisted."
    for each in generated_inp_config_bldconfigs.result_sets:
        each.builder._build_results = {
            "R1": texres.build_results,
            "R10": [],
            "Repo1": tdups.build_results,
        }[[R.repo_name for R in each.inp_desc.RL if R.project_repo][0]]
    reps = generate_report(
        testing_dir,
        generated_inp_config_bldconfigs,
        tdups.prior + texres.prior,
        reporting_logic_defs='''
                             email_domain_blacklist("not_a_company.com").
                           ''',
    )

    for each in reps:
        if isinstance(each, SendEmail):
            print('')
            print(each)

    recipients = sorted([
        '*****@*****.**',
        '*****@*****.**',
        '*****@*****.**',
        'john@_company.com',
    ])
    assert SendEmail(recipients=recipients,
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=[]) in reps
    assert SendEmail(recipients=['*****@*****.**'],
                     notification=Notify(what='variable_failing',
                                         subject='Repo1',
                                         params=BldVariable(
                                             project='Repo1',
                                             varname='ghcver',
                                             varvalue='ghc881')),
                     sent_to=[]) in reps
    assert SendEmail(recipients=['*****@*****.**', 'george@_company.com'],
                     notification=Notify(what='main_good',
                                         subject='Repo1',
                                         params='master'),
                     sent_to=[]) in reps
Exemplo n.º 6
0
def test_example_internal_bugfix9_pullreq_HEADs(generated_bldconfigs):
    for each in [
            BldConfig("Project #1", "pullreq", "bugfix9", "HEADs",
                      PR_Grouped("bugfix9"), [
                          BldRepoRev("R1", "master", "project_primary"),
                          BldRepoRev("R2", "bugfix9", "23"),
                          BldRepoRev("R3", "master", "project_primary"),
                          BldRepoRev("R5", "bugfix9", "project_primary"),
                          BldRepoRev("R6", "master", "project_primary"),
                          BldRepoRev("R4", "bugfix9", "8192"),
                      ], [
                          BldVariable("Project #1", "ghcver", G),
                          BldVariable("Project #1", "c_compiler", C),
                      ]) for G in GS for C in CS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 7
0
def test_example_internal_dev_regular_HEADs(generated_bldconfigs):
    for each in [
            BldConfig("Project #1", "regular", "dev", "HEADs",
                      BranchReq("Project #1", "dev"), [
                          BldRepoRev("R1", "master", "project_primary"),
                          BldRepoRev("R2", "master", "project_primary"),
                          BldRepoRev("R3", "master", "project_primary"),
                          BldRepoRev("R5", "dev", "project_primary"),
                          BldRepoRev("R6", "master", "project_primary"),
                          BldRepoRev("R4", "master", "project_primary"),
                      ], [
                          BldVariable("Project #1", "ghcver", G),
                          BldVariable("Project #1", "c_compiler", C),
                      ]) for G in GS for C in CS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 8
0
def test_example_report_do_list_w(testing_dir,
                                  generated_inp_config_bldconfigs):
    "Check email whitelist auto-disable all and only allow whitelisted."
    for each in generated_inp_config_bldconfigs.result_sets:
        each.builder._build_results = {
            "R1": texres.build_results,
            "R10": [],
            "Repo1": tdups.build_results,
        }[[R.repo_name for R in each.inp_desc.RL if R.project_repo][0]]
    reps = generate_report(
        testing_dir,
        generated_inp_config_bldconfigs,
        tdups.prior + texres.prior,
        reporting_logic_defs='''
                             email_domain_whitelist("_company.com").
                           ''',
    )

    for each in reps:
        if isinstance(each, SendEmail):
            print('')
            print(each)

    recipients = sorted([
        'john@_company.com',
    ])
    assert SendEmail(recipients=recipients,
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=[]) in reps
Exemplo n.º 9
0
def test_example_internal_blah_pullreq_HEADs(generated_bldconfigs):
    # See note for the submodules strategy test.
    for each in [
            BldConfig("Project #1", "pullreq", "blah", "HEADs",
                      PR_Grouped("blah"), [
                          BldRepoRev("R1", "blah", "1", "ignored"),
                          BldRepoRev("R2", "blah", "1111", 9999),
                          BldRepoRev("R3", "blah", "11"),
                          BldRepoRev("R5", "blah", "project_primary"),
                          BldRepoRev("R6", "blah", "111"),
                          BldRepoRev("R7", "master", "project_primary"),
                      ], [
                          BldVariable("Project #1", "ghcver", G),
                          BldVariable("Project #1", "c_compiler", C),
                      ]) for G in GS for C in CS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 10
0
def test_example_internal_master_regular_submodules(generated_bldconfigs):
    for each in [
            BldConfig(
                "Project #1", "regular", "master", "submodules",
                BranchReq("Project #1", "master"), [
                    BldRepoRev("R1", "master", "project_primary"),
                    BldRepoRev("R2", "r2_master_head", "project_primary"),
                    BldRepoRev("R3", "r3_master_head^3", "project_primary"),
                    BldRepoRev("R5", "master", "project_primary"),
                    BldRepoRev("R6", "master", "project_primary"),
                    BldRepoRev("R4", "r4_master_head^1", "project_primary"),
                ], [
                    BldVariable("Project #1", "ghcver", G),
                    BldVariable("Project #1", "c_compiler", C),
                ]) for G in GS for C in CS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 11
0
def test_example_report_varfail_do_email_again(generate_hydra_results):
    """Express a prior send of an email to the target; this ensures that
       these prior sends are retained.
    """
    bldcfgs, reps = generate_hydra_results(
        build_results=build_results,
        prior=prior + [
            SendEmail(recipients=['*****@*****.**'],
                      notification=Notify(what='variable_failing',
                                          subject='Project #1',
                                          params=BldVariable(
                                              project='Project #1',
                                              varname='c_compiler',
                                              varvalue='clang')),
                      sent_to=['*****@*****.**'])
        ],
    )

    for each in reps:
        print('')
        print(each)
    print('')
    print(len(reps))
    recipients = sorted([
        '*****@*****.**', '*****@*****.**', 'john@_company.com',
        'sam@not_a_company.com', '*****@*****.**'
    ])
    assert SendEmail(recipients=recipients,
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=[]) not in reps
    assert SendEmail(recipients=recipients,
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=['*****@*****.**']) in reps
Exemplo n.º 12
0
def test_example_report_status1(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    # Check for a single entry
    assert StatusReport(
        status=2,
        project='Project #1',
        strategy="HEADs",
        branchtype="pullreq",
        branch="blah",
        buildname='PR-blah.HEADs-clang-ghc844',
        bldvars=[
            BldVariable(project='Project #1',
                        varname='ghcver',
                        varvalue='ghc844'),
            BldVariable(project='Project #1',
                        varname='c_compiler',
                        varvalue='clang'),
        ],
        blddesc=PR_Grouped('blah'),
    ) in reps
Exemplo n.º 13
0
def test_example_internal_regular_master_HEADs(generated_bldconfigs):
    for each in [
            BldConfig("Repo1", "regular", "master", "HEADs",
                      BranchReq("Repo1", "master"), [
                          BldRepoRev("Repo1", "master", "project_primary"),
                          BldRepoRev("Repo2", "master", "project_primary"),
                          BldRepoRev("Repo3", "master", "project_primary"),
                          BldRepoRev("Repo4", "master", "project_primary"),
                      ], [
                          BldVariable("Repo1", "ghcver", G),
                      ]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 14
0
def test_example_internal_blah_pullreq_submods(generated_bldconfigs):
    # Note that R1 has a pullreq for the blah branch, and this pullreq
    # has submodule specifications that are respected for the
    # "submodules" strategy, therefore the blah PR's for R2 and R3 are
    # ignored.  They will be used for the "heads" strategy though.
    for each in [
            BldConfig(
                "Project #1", "pullreq", "blah", "submodules",
                PR_Grouped("blah"), [
                    BldRepoRev("R1", "blah", "1", "X"),
                    BldRepoRev("R2", "r2_master_head^22", "project_primary"),
                    BldRepoRev("R3", "r3_master_head", "project_primary"),
                    BldRepoRev("R5", "blah", "project_primary"),
                    BldRepoRev("R6", "blah", "111"),
                    BldRepoRev("R7", "r7_master_head^4", "project_primary",
                               "Y"),
                ], [
                    BldVariable("Project #1", "ghcver", G),
                    BldVariable("Project #1", "c_compiler", C),
                ]) for G in GS for C in CS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 15
0
def test_example_report_status1(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(
        status='initial_success',
        project='Repo1',
        strategy='HEADs',
        branchtype="regular",
        branch="develop",
        buildname='develop.HEADs-ghc844',
        bldvars=[
            BldVariable(project='Repo1', varname='ghcver', varvalue='ghc844')
        ],
        blddesc=BranchReq('Repo1', 'develop'),
    ) in reps
Exemplo n.º 16
0
def test_example_report_status12(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(
        status=1,
        project='Repo1',
        strategy='submodules',
        branchtype="regular",
        branch="master",
        buildname='master.submodules-ghc881',
        bldvars=[
            BldVariable(project='Repo1', varname='ghcver', varvalue='ghc881')
        ],
        blddesc=BranchReq('Repo1', 'master'),
    ) in reps
Exemplo n.º 17
0
def test_example_report_status13(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(
        status='bad_config',
        project='Repo1',
        strategy='submodules',
        branchtype="regular",
        branch="develop",
        buildname='develop.submodules-ghc844',
        bldvars=[
            BldVariable(project='Repo1', varname='ghcver', varvalue='ghc844')
        ],
        blddesc=BranchReq('Repo1', 'develop'),
    ) in reps
Exemplo n.º 18
0
def test_example_report_status4_2(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(status=1,
                        project='Repo1',
                        strategy='standard',
                        branchtype="pullreq",
                        branch="master",
                        buildname='PR2-master.standard-ghc881',
                        bldvars=[
                            BldVariable(project='Repo1',
                                        varname='ghcver',
                                        varvalue='ghc881')
                        ],
                        blddesc=PR_Solo('Repo1', '2')) in reps
Exemplo n.º 19
0
def test_example_internal_regular_develop_submodules(generated_bldconfigs):
    for each in [
            BldConfig(
                "Repo1", "regular", "develop", "submodules",
                BranchReq("Repo1", "develop"), [
                    BldRepoRev("Repo1", "develop", "project_primary"),
                    BldRepoRev("Repo2", "r2_develop_head", "project_primary"),
                    BldRepoRev("Repo3", "r3_develop_head", "project_primary"),
                    BldRepoRev("Repo4", "r4_master_head", "project_primary"),
                ], [
                    BldVariable("Repo1", "ghcver", G),
                ]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 20
0
def test_example_report_status5(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(status=1,
                        project='Repo1',
                        strategy='standard',
                        branchtype="regular",
                        branch="develop",
                        buildname='develop.standard-ghc881',
                        bldvars=[
                            BldVariable(project='Repo1',
                                        varname='ghcver',
                                        varvalue='ghc881')
                        ],
                        blddesc=BranchReq('Repo1', 'develop')) in reps
Exemplo n.º 21
0
def test_example_report_status3(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(status=1,
                        project='Repo1',
                        strategy='standard',
                        branchtype="pullreq",
                        branch="foo",
                        buildname='PR-foo.standard-ghc881',
                        bldvars=[
                            BldVariable(project='Repo1',
                                        varname='ghcver',
                                        varvalue='ghc881')
                        ],
                        blddesc=PR_Grouped('foo')) in reps
Exemplo n.º 22
0
def test_example_report_status8(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    assert StatusReport(status='initial_success',
                        project='Repo1',
                        strategy='standard',
                        branchtype="regular",
                        branch="master",
                        buildname='master.standard-ghc865',
                        bldvars=[
                            BldVariable(project='Repo1',
                                        varname='ghcver',
                                        varvalue='ghc865')
                        ],
                        blddesc=BranchReq('Repo1', 'master')) in reps
Exemplo n.º 23
0
def test_example_internal_pr101r3_prReq8r1_standard(generated_bldconfigs):
    for each in [
            BldConfig(projectname="Repo1",
                      branchtype="pullreq",
                      branchname="dog",
                      strategy="standard",
                      description=PR_Grouped("dog"),
                      blds=[
                          BldRepoRev("Repo1", "dog", "Req8"),
                          BldRepoRev("Repo2", "master", "project_primary"),
                          BldRepoRev("Repo3", "dog", "101"),
                      ],
                      bldvars=[BldVariable("Repo1", "ghcver", G)]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 24
0
def test_example_internal_regular_develop_standard(generated_bldconfigs):
    for each in [
            BldConfig(projectname="Repo1",
                      branchtype="regular",
                      branchname="develop",
                      strategy="standard",
                      description=BranchReq("Repo1", "develop"),
                      blds=[
                          BldRepoRev("Repo1", "develop", "project_primary"),
                          BldRepoRev("Repo2", "develop", "project_primary"),
                          BldRepoRev("Repo3", "develop", "project_primary"),
                      ],
                      bldvars=[BldVariable("Repo1", "ghcver", G)]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 25
0
def test_example_internal_dev_regular_HEADs(generated_bldconfigs):
    for each in [
            BldConfig(projectname="R10",
                      branchtype="regular",
                      branchname="dev",
                      strategy="HEADs",
                      description=BranchReq("R10", "dev"),
                      blds=[
                          BldRepoRev("R10", "master", "project_primary"),
                          BldRepoRev("R3", "master", "project_primary"),
                          BldRepoRev("R4", "master", "project_primary"),
                      ],
                      bldvars=[BldVariable("R10", "ghcver", G)]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 26
0
def test_example_internal_bugfix9_pullreq_HEADs(generated_bldconfigs):
    for each in [
            BldConfig(projectname="R10",
                      branchtype="pullreq",
                      branchname="bugfix9",
                      strategy="HEADs",
                      description=PR_Grouped("bugfix9"),
                      blds=[
                          BldRepoRev("R10", "master", "project_primary"),
                          BldRepoRev("R3", "master", "project_primary"),
                          BldRepoRev("R4", "bugfix9", "8192"),
                      ],
                      bldvars=[BldVariable("R10", "ghcver", G)]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs
Exemplo n.º 27
0
def test_example_report_status9(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    # This one had a prior success
    assert StatusReport(
        status=1,
        project='Repo1',
        strategy='HEADs',
        branchtype="regular",
        branch="master",
        buildname='master.HEADs-ghc881',
        bldvars=[
            BldVariable(project='Repo1', varname='ghcver', varvalue='ghc881')
        ],
        blddesc=BranchReq('Repo1', 'master'),
    ) in reps
Exemplo n.º 28
0
def test_example_report_varfail_do_email(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    print('')
    print(len(reps))
    assert SendEmail(recipients=sorted([
        '*****@*****.**', '*****@*****.**', '*****@*****.**',
        'john@_company.com', 'sam@not_a_company.com'
    ]),
                     notification=Notify(what='variable_failing',
                                         subject='Project #1',
                                         params=BldVariable(
                                             project='Project #1',
                                             varname='c_compiler',
                                             varvalue='clang')),
                     sent_to=[]) in reps
Exemplo n.º 29
0
def test_example_report_status12(example_hydra_results):
    bldcfgs, reps = example_hydra_results
    for each in reps:
        print(each)
        print('')
    assert StatusReport(status='bad_config',
                        project='Repo1',
                        strategy='standard',
                        branchtype="pullreq",
                        branch="develop",
                        buildname='PR-develop.standard-ghc865',
                        bldvars=[
                            BldVariable(project='Repo1',
                                        varname='ghcver',
                                        varvalue='ghc865')
                        ],
                        blddesc=PR_Grouped('develop')) in reps
Exemplo n.º 30
0
def test_example_internal_master_regular_submodules(generated_bldconfigs):
    for each in [
            BldConfig(projectname="R10",
                      branchtype="regular",
                      branchname="master",
                      strategy="submodules",
                      description=MainBranch("R10", "master"),
                      blds=[
                          BldRepoRev("R10", "master", "project_primary"),
                          BldRepoRev("R3", "r3_master_head^9",
                                     "project_primary"),
                          BldRepoRev("R4", "r4_master_head^1",
                                     "project_primary"),
                      ],
                      bldvars=[BldVariable("R10", "ghcver", G)]) for G in GS
    ]:
        assert each in generated_bldconfigs.cfg_build_configs