Example #1
0
def _check_remoting_info():
    if sadm_prompt.prompter.get_mode() == sadm_prompt.AUTOCONFIRM_MODE:
        return
    if not config.needs_remoting_info():
        return
    descr = buildinfo.BuildInfo()
    remoteInfo = ''
    print('''
Machines that automate sandbox operations should be remotely accessible for
configuration and troubleshooting purposes. Please provide the following
information to facilitate this.
''')
    config.username_for_remote_access = sadm_prompt.prompt('Username for remote login', config.username_for_remote_access)
    config.ipaddr = sadm_prompt.prompt('IP address', config.ipaddr)
    config.ssh_port = sadm_prompt.prompt('Port for ssh', config.ssh_port)
    config.remote_desktop_port = sadm_prompt.prompt('Port for remote desktop', config.remote_desktop_port)
    config.remoting_instructions = sadm_prompt.prompt('''
Other instructions for accessing this machine remotely (such as where to get the password etc.)''', config.remoting_instructions)
    if config.ssh_port:
        remoteInfo += 'ssh to %s:%s as %s\n' % (config.ipaddr, config.ssh_port, config.username_for_remote_access)
    if config.remote_desktop_port:
        remoteInfo += 'remote desktop to %s:%s\n' % (config.ipaddr, config.remote_desktop_port)
    if config.remoting_instructions:
        remoteInfo += '%s' % config.remoting_instructions
    build_machines = tempfile.mkdtemp()
    wr = vcs.get_working_repository()
    vcs.checkout(os.path.join(wr.master_reporoot, 'BuildMachines').replace('\\','/'), build_machines)
    if os.name == 'nt':
        site = os.environ['COMPUTERNAME'].lower()
    else:
        site = os.environ['HOSTNAME'].lower()
    fldr = os.path.join(build_machines, site)
    if not os.path.isdir(fldr):
        os.makedirs(fldr)
    fp = open(os.path.join(fldr, REMOTE_INFO_FILE), 'w')
    fp.write(remoteInfo)
    fp.close()
    vcs.add(build_machines)
    try:
        vcs.checkin(build_machines, 'Update remote info for %s' % site, quiet=True)
    except:
        pass
Example #2
0
def checkin(sb, folder_to_publish, dry_run):
    msg = str(sb.get_build_id())
    if buildinfo.get_natural_platform_variant() != sb.get_targeted_platform_variant():
        msg += ' ' + sb.get_targeted_platform_variant()
    msg = '%s from %s' % (msg, str(buildinfo.BuildInfo()))
    cmd = 'bzr ci -m "%s"' % msg
    vprint(cmd, verbosity=1)
    err = 0
    if not dry_run:
        try:
            vcs.checkin(folder_to_publish, msg)
            push_loc = '%s%s/%s/built.%s' % (DEFAULT_ARCHIVE_REPO, sb.get_branch(),  # fix_julie repo structure knowledge
                                             sb.get_top_component(),
                                             sb.get_targeted_platform_variant())
            vcs.push(folder_to_publish, push_loc)
        except:
            txt = traceback.format_exc()
            if 'PointlessCommit' in txt:
                vprint('No changes need to be committed.', verbosity=1)
            else:
                raise
    return err
Example #3
0
def checkin_component(msg, comp, sb, validate_status=True):
    if validate_status:
        bad_status = get_component_status(comp, status_filter=_items_that_wont_checkin)
        if bad_status:
            print(format_component_status(sb, bad_status))
            print('Some items are not ready for checkin.')
            return
    aspects = get_vcs_component_aspects(comp, sb)
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME):
            continue
        path = sb.get_component_path(comp, a)
        if vcs.get_status(path):
            try:
                x = vcs.checkin(path, msg)
            except:
                print(sys.exc_info()[1])
Example #4
0
def checkin_component(msg, comp, sb, validate_status=True):
    if validate_status:
        bad_status = get_component_status(
            comp, status_filter=_items_that_wont_checkin)
        if bad_status:
            print(format_component_status(sb, bad_status))
            print('Some items are not ready for checkin.')
            return
    aspects = get_vcs_component_aspects(comp, sb)
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME):
            continue
        path = sb.get_component_path(comp, a)
        if vcs.get_status(path):
            try:
                x = vcs.checkin(path, msg)
            except:
                print(sys.exc_info()[1])
Example #5
0
    def test_dependencies(self):
        tmpdir = tempfile.mkdtemp()
        #print('running test in temporary repo %s' % tmpdir)
        cwd = os.getcwd()
        try:
            template1 = '[%s]' % metadata.DEPENDENCIES_SECTION
            template2 = template1 + '''
%s: code,%s.trunk.1.1 use: reusable
%s: code,%s.trunk.1.1 use: reusable
'''
            template3 = template1 + '''
%s: code,%s.trunk.2.1 use: reusable
%s: code,%s.trunk.1.1 use: reusable
'''
            files = {
                'a': template2 % ('b', 'b', 'c', 'c'),
                'b': template1,
                'c': template3 % ('b', 'b', 'd', 'd'),
                'd': template1
            }
            testRepos = ['a', 'b', 'c', 'd']
            for t in testRepos:
                repoPath = os.path.join(tmpdir, 'trunk', t)
                os.makedirs(os.path.join(tmpdir, 'trunk', t))
                branchPath = repoPath + '/code'
                #print('init %s' % branchPath)
                vcs.init(branchPath, False)
                filePath = branchPath + '/' + metadata.METADATA_FILE
                save(filePath, files[t])
                os.chdir(branchPath)
                #print('adding %s' % filePath)
                vcs.add(filePath)
                #print('checking in %s' % filePath)
                vcs.checkin(filePath, 'Test', True)
                vcs.tag('%s.trunk.1.1 use: reusable' % t)
                if t == 'b':
                    #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
                    filePath = branchPath + '/dependencies2.txt'
                    save(filePath, files[t])
                    vcs.add(filePath)
                    vcs.checkin(filePath, 'Test', True)
                    vcs.tag('%s.trunk.2.1 use: reusable' % t)
                #subprocess.Popen(['bzr', 'tags'])
            working_repo = vcs.WorkingRepository()
            working_repo._init(tmpdir, tmpdir, tmpdir)
            prob = metadata.get_components_inv_dep_order(working_repo, 'win_x64', 'a', tmpdir, 'trunk', '')
            comp = [
                component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'),
                component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'),
                component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'),
                component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code')
                ]
            if False:
                for c in comp:
                    print("comp = " + str(c))
                for c in prob:
                    print("prob = " + str(c))
            # prob will have buildscripts; comp doesn't
            prob = [p for p in prob if p.name != 'buildscripts']
            self.assertEquals(len(comp), len(prob))
            for i in range(len(comp)):
                self.assertEquals(comp[i].name, prob[i].name)
        finally:
            os.chdir(cwd)
            shutil.rmtree(tmpdir)
Example #6
0
def report(sb, state):
    rr = sb.get_report_root()
    root = sb.get_root()
    need_checkin = vcs.folder_is_tied_to_vcs(rr)
    try:
        # Get latest version of reports so we are less likely to cause merge
        # conflicts.
        wr = vcs.get_working_repository()
        use_master = False
        if not need_checkin:
            url = os.path.join(
                wr.master_reporoot,
                sb.get_branch(),
                sb.get_top_component(),
                'report',
            ).replace('\\', '/')
            publish.create_branch(url, False)
            use_master = True
        wr.create_or_update_checkout(rr,
                                     sb.get_top_component(),
                                     'report',
                                     sb.get_branch(),
                                     None,
                                     use_master=use_master)
        need_checkin = vcs.folder_is_tied_to_vcs(rr)
        # Report our results.
        bi = buildinfo.BuildInfo()
        machineFolder = os.path.join(rr, bi.host).replace('\\', '/')
        summary = EvalSummary(sb.get_build_id(),
                              sb.get_sandboxtype().get_style(), bi.host,
                              state.phase, state.reason, state.start_time,
                              state.timestamps,
                              sb.get_targeted_platform_variant(), bi.os,
                              bi.bitness, bi.version)
        db = Dashboard(rr)
        db.add_summary(summary)
        if os.path.exists(os.path.join(root, 'eval-log.txt')):
            shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)
        # Check in our changes.
        if need_checkin:
            status = vcs.get_status(rr)
            if 'unknown' in status:
                vcs.add(rr)
            vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
            try:
                vcs.push(rr)
            except BzrCommandError, e:
                if 'diverged' in ("%s" % e):
                    print "\nAttemping to resolve diverged report aspect"
                    print "\nNuking report dir %s" % rr
                    if not ioutil.nuke(rr):
                        print "\nAuto resolving diverged report aspect failed!"

                    bi = BranchInfo(branchname=sb.get_branch(),
                                    componentname=sb.get_top_component(),
                                    aspectname='report')
                    aspectdir = bi.get_branchdir(wr.local_reporoot)
                    print "\nNuking report repo %s" % aspectdir
                    if not ioutil.nuke(aspectdir):
                        print "\nAuto resolving diverged report aspect failed!"

                    # Use the master because we have a problem here.
                    wr.create_local_branch(sb.get_top_component(),
                                           'report',
                                           sb.get_branch(),
                                           use_master=True)
                    wr.create_or_update_checkout(rr,
                                                 sb.get_top_component(),
                                                 'report',
                                                 sb.get_branch(),
                                                 None,
                                                 use_master=True)

                    db = Dashboard(rr)
                    db.add_summary(summary)
                    if os.path.exists(os.path.join(root, 'eval-log.txt')):
                        shutil.copy2(os.path.join(root, 'eval-log.txt'),
                                     machineFolder)

                    status = vcs.get_status(rr)
                    if 'unknown' in status:
                        vcs.add(rr)
                    vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
                    vcs.push(rr)
                    print "\nAuto resolve diverged report aspect success!"
                else:
                    raise e
    except:
        traceback.print_exc()
Example #7
0
def report(sb, state):
    rr = sb.get_report_root()
    root = sb.get_root()
    need_checkin = vcs.folder_is_tied_to_vcs(rr)
    try:
        # Get latest version of reports so we are less likely to cause merge
        # conflicts.
        wr = vcs.get_working_repository()
        use_master = False
        if not need_checkin:
            url = os.path.join(wr.master_reporoot, sb.get_branch(), sb.get_top_component(), 'report', ). replace('\\', '/')
            publish.create_branch(url, False)
            use_master = True
        wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=use_master)
        need_checkin = vcs.folder_is_tied_to_vcs(rr)
        # Report our results.
        bi = buildinfo.BuildInfo()
        machineFolder = os.path.join(rr, bi.host).replace('\\', '/')
        summary = EvalSummary(sb.get_build_id(), sb.get_sandboxtype().get_style(), bi.host,
                              state.phase, state.reason, state.start_time,
                              state.timestamps, sb.get_targeted_platform_variant(),
                              bi.os, bi.bitness, bi.version)
        db = Dashboard(rr)
        db.add_summary(summary)
        if os.path.exists(os.path.join(root, 'eval-log.txt')):
            shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)
        # Check in our changes.
        if need_checkin:
            status = vcs.get_status(rr)
            if 'unknown' in status:
                vcs.add(rr)
            vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
            try:
                vcs.push(rr)
            except BzrCommandError, e:
                if 'diverged' in ("%s" % e):
                    print "\nAttemping to resolve diverged report aspect"
                    print "\nNuking report dir %s" % rr
                    if not ioutil.nuke(rr):
                        print "\nAuto resolving diverged report aspect failed!"

                    bi = BranchInfo(branchname=sb.get_branch(), componentname=sb.get_top_component(), aspectname='report')
                    aspectdir = bi.get_branchdir(wr.local_reporoot)
                    print "\nNuking report repo %s" % aspectdir
                    if not ioutil.nuke(aspectdir):
                        print "\nAuto resolving diverged report aspect failed!"

                    # Use the master because we have a problem here.
                    wr.create_local_branch(sb.get_top_component(), 'report', sb.get_branch(), use_master=True)
                    wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=True)

                    db = Dashboard(rr)
                    db.add_summary(summary)
                    if os.path.exists(os.path.join(root, 'eval-log.txt')):
                        shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)

                    status = vcs.get_status(rr)
                    if 'unknown' in status:
                        vcs.add(rr)
                    vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
                    vcs.push(rr)
                    print "\nAuto resolve diverged report aspect success!"
                else:
                    raise e
    except:
        traceback.print_exc()
Example #8
0
    def test_dependencies(self):
        tmpdir = tempfile.mkdtemp()
        #print('running test in temporary repo %s' % tmpdir)
        cwd = os.getcwd()
        try:
            template1 = '[%s]' % metadata.DEPENDENCIES_SECTION
            template2 = template1 + '''
%s: code,%s.trunk.1.1 use: reusable
%s: code,%s.trunk.1.1 use: reusable
'''
            template3 = template1 + '''
%s: code,%s.trunk.2.1 use: reusable
%s: code,%s.trunk.1.1 use: reusable
'''
            files = {
                'a': template2 % ('b', 'b', 'c', 'c'),
                'b': template1,
                'c': template3 % ('b', 'b', 'd', 'd'),
                'd': template1
            }
            testRepos = ['a', 'b', 'c', 'd']
            for t in testRepos:
                repoPath = os.path.join(tmpdir, 'trunk', t)
                os.makedirs(os.path.join(tmpdir, 'trunk', t))
                branchPath = repoPath + '/code'
                #print('init %s' % branchPath)
                vcs.init(branchPath, False)
                filePath = branchPath + '/' + metadata.METADATA_FILE
                save(filePath, files[t])
                os.chdir(branchPath)
                #print('adding %s' % filePath)
                vcs.add(filePath)
                #print('checking in %s' % filePath)
                vcs.checkin(filePath, 'Test', True)
                vcs.tag('%s.trunk.1.1 use: reusable' % t)
                if t == 'b':
                    #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
                    filePath = branchPath + '/dependencies2.txt'
                    save(filePath, files[t])
                    vcs.add(filePath)
                    vcs.checkin(filePath, 'Test', True)
                    vcs.tag('%s.trunk.2.1 use: reusable' % t)
                #subprocess.Popen(['bzr', 'tags'])
            working_repo = vcs.WorkingRepository()
            working_repo._init(tmpdir, tmpdir, tmpdir)
            prob = metadata.get_components_inv_dep_order(
                working_repo, 'win_x64', 'a', tmpdir, 'trunk', '')
            comp = [
                component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable',
                                    'code'),
                component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable',
                                    'code'),
                component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable',
                                    'code'),
                component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable',
                                    'code')
            ]
            if False:
                for c in comp:
                    print("comp = " + str(c))
                for c in prob:
                    print("prob = " + str(c))
            # prob will have buildscripts; comp doesn't
            prob = [p for p in prob if p.name != 'buildscripts']
            self.assertEquals(len(comp), len(prob))
            for i in range(len(comp)):
                self.assertEquals(comp[i].name, prob[i].name)
        finally:
            os.chdir(cwd)
            shutil.rmtree(tmpdir)