Пример #1
0
    def test_make_report_old_pin_missing(self, tmpdir):
        """Verify that we can make a report when the old pin is missing."""
        p = tmpdir.mkdir('test')
        path = str(p)
        repo = Repo.init(path)
        file = p / 'test.txt'
        file.write_text(u'Testing1', encoding='utf-8')
        repo.index.add(['test.txt'])
        repo.index.commit('Testing 1')
        file.write_text(u'Testing2', encoding='utf-8')
        repo.index.add(['test.txt'])
        repo.index.commit('Testing 2')

        new_pins = [("test", "http://example.com", "HEAD")]
        old_pins = []

        report = osa_differ.make_report(str(tmpdir), old_pins, new_pins)

        assert report == ''
Пример #2
0
    def test_make_report(self, tmpdir):
        """Verify that we can make a report."""
        p = tmpdir.mkdir('test')
        path = str(p)
        repo = Repo.init(path)
        file = p / 'test.txt'
        file.write_text(u'Testing1', encoding='utf-8')
        repo.index.add(['test.txt'])
        repo.index.commit('Testing 1')
        file.write_text(u'Testing2', encoding='utf-8')
        repo.index.add(['test.txt'])
        repo.index.commit('Testing 2')

        new_pins = [("test", "http://example.com", "HEAD")]
        old_pins = [("test", "http://example.com", "HEAD~1")]

        report = osa_differ.make_report(str(tmpdir), old_pins, new_pins)

        assert "1 commit was found in `test <http://example.com>`" in report
        assert "Testing 2" in report
Пример #3
0
def run_rpc_differ():
    """The script starts here."""
    args = parse_arguments()

    # Create the storage directory if it doesn't exist already.
    try:
        storage_directory = osa_differ.prepare_storage_dir(args.directory)
    except OSError:
        print("ERROR: Couldn't create the storage directory {0}. "
              "Please create it manually.".format(args.directory))
        sys.exit(1)

    # Assemble some variables for the RPC repository.
    rpc_old_commit = args.old_commit[0]
    rpc_new_commit = args.new_commit[0]
    rpc_repo_dir = "{0}/rpc-openstack".format(storage_directory)

    # Generate RPC report header.
    report_rst = make_rpc_report(rpc_repo_dir,
                                 rpc_old_commit,
                                 rpc_new_commit,
                                 args)

    # Get the list of RPC roles from the newer and older commits.
    role_yaml = osa_differ.get_roles(rpc_repo_dir, rpc_old_commit)
    role_yaml_latest = osa_differ.get_roles(rpc_repo_dir, rpc_new_commit)

    # Generate the role report.
    report_rst += ("RPC-OpenStack Roles\n"
                   "-------------------")
    report_rst += osa_differ.make_report(storage_directory,
                                         role_yaml,
                                         role_yaml_latest,
                                         args.update)

    report_rst += "\n"

    # Generate OpenStack-Ansible report.
    osa_old_commit, osa_new_commit = get_osa_commits(rpc_repo_dir,
                                                     rpc_old_commit,
                                                     rpc_new_commit)

    osa_repo_dir = "{0}/openstack-ansible".format(storage_directory)
    report_rst += osa_differ.make_osa_report(osa_repo_dir,
                                             osa_old_commit,
                                             osa_new_commit,
                                             args)

    # Get the list of OpenStack-Ansible roles from the newer and older commits.
    role_yaml = osa_differ.get_roles(osa_repo_dir, osa_old_commit)
    role_yaml_latest = osa_differ.get_roles(osa_repo_dir, osa_new_commit)

    # Generate the role report.
    report_rst += ("OpenStack-Ansible Roles\n"
                   "-----------------------")
    report_rst += osa_differ.make_report(storage_directory,
                                         role_yaml,
                                         role_yaml_latest,
                                         args.update)

    # Get the list of OpenStack projects from newer commit and older commit.
    yaml_files = [
        'playbooks/defaults/repo_packages/openstack_services.yml',
        'playbooks/defaults/repo_packages/openstack_other.yml'
    ]
    project_yaml = osa_differ.get_projects(osa_repo_dir,
                                           yaml_files,
                                           osa_old_commit)
    project_yaml_latest = osa_differ.get_projects(osa_repo_dir,
                                                  yaml_files,
                                                  osa_new_commit)

    # Generate the project report.
    report_rst += ("OpenStack-Ansible Projects\n"
                   "--------------------------")
    report_rst += osa_differ.make_report(storage_directory,
                                         project_yaml,
                                         project_yaml_latest,
                                         args.update)

    # Publish report according to the user's request.
    output = publish_report(report_rst,
                            args,
                            rpc_old_commit,
                            rpc_new_commit)
    print(output)
Пример #4
0
def run_rpc_differ():
    """The script starts here."""
    args = parse_arguments()

    # Set up DEBUG logging if needed
    if args.debug:
        log.setLevel(logging.DEBUG)
    elif args.verbose:
        log.setLevel(logging.INFO)

    # Create the storage directory if it doesn't exist already.
    try:
        storage_directory = osa_differ.prepare_storage_dir(args.directory)
    except OSError:
        print("ERROR: Couldn't create the storage directory {0}. "
              "Please create it manually.".format(args.directory))
        sys.exit(1)

    # Assemble some variables for the RPC repository.
    rpc_old_commit = args.old_commit[0]
    rpc_new_commit = args.new_commit[0]
    rpc_repo_dir = "{0}/rpc-openstack".format(storage_directory)

    # Generate RPC report header.
    report_rst = make_rpc_report(rpc_repo_dir, rpc_old_commit, rpc_new_commit,
                                 args)

    # Get the list of RPC roles from the newer and older commits.
    role_yaml = osa_differ.get_roles(rpc_repo_dir, rpc_old_commit)
    role_yaml_latest = osa_differ.get_roles(rpc_repo_dir, rpc_new_commit)

    # Generate the role report.
    report_rst += ("\nRPC-OpenStack Roles\n" "-------------------")
    report_rst += osa_differ.make_report(storage_directory, role_yaml,
                                         role_yaml_latest, args.update)

    report_rst += "\n"

    # Generate OpenStack-Ansible report.
    repo = Repo(rpc_repo_dir)
    osa_old_commit = get_osa_commit(repo, rpc_old_commit)
    osa_new_commit = get_osa_commit(repo, rpc_new_commit)
    log.debug("OSA Commits old:{old} new:{new}".format(old=osa_old_commit,
                                                       new=osa_new_commit))

    osa_repo_dir = "{0}/openstack-ansible".format(storage_directory)
    # NOTE:
    # An exception is thrown by osa_differ if these two commits
    # are the the same, but it is sometimes necessary to compare
    # two RPC tags that have the same OSA SHA. For example,
    # comparing two tags that only have differences between the
    # two RPCO commit, but no differences between the OSA SHAs
    # that correspond to those two commits.
    # To handle this case, the exception will be caught and flow
    # of execution will continue normally.
    try:
        report_rst += osa_differ.make_osa_report(osa_repo_dir, osa_old_commit,
                                                 osa_new_commit, args)
    except exceptions.InvalidCommitRangeException:
        pass

    # Get the list of OpenStack-Ansible roles from the newer and older commits.
    role_yaml = osa_differ.get_roles(osa_repo_dir, osa_old_commit)
    role_yaml_latest = osa_differ.get_roles(osa_repo_dir, osa_new_commit)

    # Generate the role report.
    report_rst += ("\nOpenStack-Ansible Roles\n" "-----------------------")
    report_rst += osa_differ.make_report(storage_directory, role_yaml,
                                         role_yaml_latest, args.update)

    project_yaml = osa_differ.get_projects(osa_repo_dir, osa_old_commit)
    project_yaml_latest = osa_differ.get_projects(osa_repo_dir, osa_new_commit)

    # Generate the project report.
    report_rst += ("OpenStack-Ansible Projects\n" "--------------------------")
    report_rst += osa_differ.make_report(storage_directory, project_yaml,
                                         project_yaml_latest, args.update)

    # Publish report according to the user's request.
    output = publish_report(report_rst, args, rpc_old_commit, rpc_new_commit)
    print(output)