Exemplo n.º 1
0
    def opsyscomponents(self):
        self.begin('Components')
        opsysobjs = self.ses.query(OpSys).all()

        for comp in data.COMPS.keys():
            for obj in opsysobjs:
                if randutils.tosslow():
                    continue
                compobj = OpSysComponent(name=comp)
                compobj.opsys = obj
                for release in randutils.pickmost(obj.releases):
                    release_assoc = OpSysReleaseComponent()
                    release_assoc.release = release
                    compobj.opsysreleases.append(release_assoc)
                self.add(compobj)
        self.commit()
Exemplo n.º 2
0
    def opsyscomponents(self):
        self.begin('Components')
        opsysobjs = self.ses.query(OpSys).all()

        for comp in data.COMPS:
            for obj in opsysobjs:
                if randutils.tosslow():
                    continue
                compobj = OpSysComponent(name=comp)
                compobj.opsys = obj
                for release in randutils.pickmost(obj.releases):
                    release_assoc = OpSysReleaseComponent()
                    release_assoc.release = release
                    compobj.opsysreleases.append(release_assoc)
                self.add(compobj)
        self.commit()
Exemplo n.º 3
0
    def opsyscomponents(self) -> None:
        self.begin('Components')
        opsysobjs = self.ses.query(OpSys).all()

        for comp in data.COMPS:
            for obj in opsysobjs:
                if randutils.tosslow():
                    continue
                compobj = OpSysComponent(name=comp)
                compobj.opsys = obj
                for release in randutils.pickmost(obj.releases):
                    release_assoc = OpSysReleaseComponent()
                    release_assoc.release = release
                    # OpSysComponent.releases is a backref from OpSysReleaseComponent.
                    compobj.releases.append(release_assoc)  # pylint: disable=no-member
                self.add(compobj)
        self.commit()
Exemplo n.º 4
0
    def reports(self, count=100):
        comps = self.ses.query(OpSysComponent).all()
        releases = self.ses.query(OpSysRelease).all()
        arches = self.ses.query(Arch).all()
        symbols = self.ses.query(SymbolSource).all()
        packages = self.ses.query(Package).all()
        bugs = self.ses.query(RhbzBug).all()

        for rel in releases:
            self.begin('Reports for %s %s' % (rel.opsys.name, rel.version))
            since = rel.releasedate
            if since is None:
                since = datetime.now().date() + fuzzy_timedelta(
                    months=random.randrange(-6, 0))
            till = self.get_release_end_date(since, rel.opsys)

            for i in range(count):
                report = Report()
                report.type = 'USERSPACE'
                report.count = random.randrange(1, 20)
                occ_date = self.get_occurence_date(since, till)
                if occ_date > datetime.now():
                    # skipping reports from the future
                    continue
                report.first_occurence = report.last_occurence = occ_date
                report.component = random.choice(comps)
                self.add(report)

                report_bt = ReportBacktrace()
                report_bt.report = report
                self.add(report_bt)

                bthash = ReportBtHash()
                bthash.type = 'NAMES'
                bthash.hash = randutils.randhash()
                bthash.backtrace = report_bt
                self.add(bthash)

                for j in range(random.randrange(1, 40)):
                    btframe = ReportBtFrame()
                    btframe.backtrace = report_bt
                    btframe.order = j
                    btframe.symbolsource = random.choice(symbols)

                report_bt.crashfn = btframe.symbolsource.symbol.name

                current = []
                last_occ = occ_date
                crashed_pkgs = random.sample(packages, random.randrange(1,4))
                related_pkgs = random.sample(packages, random.randrange(1,4))

                for j in range(report.count):
                    if j > 1:
                        occ_date = self.get_occurence_date(since, till)
                        if occ_date > datetime.now():
                            continue

                    if occ_date > last_occ:
                        last_occ = occ_date

                    arch = random.choice(arches)
                    day = occ_date.date()
                    week = day - timedelta(days=day.weekday())
                    month = day.replace(day=1)
                    smode = random.choice(['DISABLED', 'PERMISSIVE', 'ENFORCING'])

                    stat_map = [(ReportArch, [('arch', arch)]),
                                (ReportOpSysRelease, [('opsysrelease', rel)]),
                                (ReportHistoryMonthly, [('opsysrelease', rel),
                                    ('month', month)]),
                                (ReportHistoryWeekly, [('opsysrelease', rel),
                                    ('week', week)]),
                                (ReportHistoryDaily, [('opsysrelease', rel),
                                    ('day', day)]),
                                (ReportSelinuxMode, [('mode', smode)]),
                                ]

                    # add crashed and related packages
                    for typ in ['CRASHED', 'RELATED']:
                        for pkg in locals()['{0}_pkgs'.format(typ.lower())]:
                            if randutils.toss():
                                stat_map.append(
                                    (ReportPackage,
                                        [('installed_package', pkg),
                                        ('running_package', pkg),
                                        ('type', typ)])
                                    )

                    if randutils.tosshigh():
                        stat_map.append((ReportUptime, [('uptime_exp',
                            int(math.log(random.randrange(1, 100000))))]))

                    if randutils.toss():
                        stat_map.append((ReportOpSysRelease,
                            [('opsysrelease', random.choice(releases))]))

                    if randutils.tosslow():
                        stat_map.append((ReportRhbz,
                            [('rhbzbug', random.choice(bugs))]))

                    for table, cols in stat_map:
                        fn = lambda x: type(x) == table
                        for report_stat in filter(fn, current):
                            matching = True
                            for name, value in cols:
                                if getattr(report_stat, name) != value:
                                    matching = False
                            if matching:
                                report_stat.count += 1
                                break
                        else:
                            report_stat = table()
                            report_stat.report = report
                            for name, value in cols:
                                setattr(report_stat, name, value)
                            report_stat.count = 1
                            current.append(report_stat)

                self.extend(current)
                report.last_occurence = last_occ
            self.commit()
Exemplo n.º 5
0
    def reports(self, count=100):
        comps = self.ses.query(OpSysComponent).all()
        releases = self.ses.query(OpSysRelease).all()
        arches = self.ses.query(Arch).all()
        symbols = self.ses.query(SymbolSource).all()
        bugs = self.ses.query(BzBug).all()

        for rel in releases:
            self.begin('Reports for %s %s' % (rel.opsys.name, rel.version))
            since = rel.releasedate
            if since is None:
                since = datetime.now().date() + fuzzy_timedelta(
                    months=random.randrange(-6, 0))
            till = self.get_release_end_date(since, rel.opsys)

            for _ in range(count):
                report = Report()
                report.type = 'USERSPACE'
                report.count = random.randrange(1, 20)
                occ_date = self.get_occurrence_date(since, till)
                if occ_date > datetime.now():
                    # skipping reports from the future
                    continue
                report.first_occurrence = report.last_occurrence = occ_date
                report.component = random.choice(comps)
                self.add(report)

                report_bt = ReportBacktrace()
                report_bt.report = report
                self.add(report_bt)

                bthash = ReportBtHash()
                bthash.type = 'NAMES'
                bthash.hash = randutils.randhash()
                bthash.backtrace = report_bt
                self.add(bthash)

                for j in range(random.randrange(1, 40)):
                    btframe = ReportBtFrame()
                    btframe.backtrace = report_bt
                    btframe.order = j
                    btframe.symbolsource = random.choice(symbols)

                report_bt.crashfn = btframe.symbolsource.symbol.name

                current = []
                last_occ = occ_date

                for j in range(report.count):
                    if j > 1:
                        occ_date = self.get_occurrence_date(since, till)
                        if occ_date > datetime.now():
                            continue

                    if occ_date > last_occ:
                        last_occ = occ_date

                    arch = random.choice(arches)
                    day = occ_date.date()
                    week = day - timedelta(days=day.weekday())
                    month = day.replace(day=1)
                    smode = random.choice(['DISABLED', 'PERMISSIVE', 'ENFORCING'])

                    stat_map = [(ReportArch, [('arch', arch)]),
                                (ReportOpSysRelease, [('opsysrelease', rel)]),
                                (ReportHistoryMonthly, [('opsysrelease', rel),
                                                        ('month', month)]),
                                (ReportHistoryWeekly, [('opsysrelease', rel),
                                                       ('week', week)]),
                                (ReportHistoryDaily, [('opsysrelease', rel),
                                                      ('day', day)]),
                                (ReportSelinuxMode, [('mode', smode)]),
                               ]

                    # add crashed and related packages
                    for typ in ['CRASHED', 'RELATED']:
                        for pkg in locals()['{0}_pkgs'.format(typ.lower())]:
                            if randutils.toss():
                                stat_map.append(
                                    (ReportPackage,
                                     [('installed_package', pkg),
                                      ('running_package', pkg),
                                      ('type', typ)])
                                    )

                    if randutils.tosshigh():
                        stat_map.append((ReportUptime, [('uptime_exp',
                                                         int(math.log(random.randrange(1, 100000))))]))

                    if randutils.toss():
                        stat_map.append((ReportOpSysRelease,
                                         [('opsysrelease', random.choice(releases))]))

                    if randutils.tosslow():
                        stat_map.append((ReportBz,
                                         [('bzbug', random.choice(bugs))]))

                    for table, cols in stat_map:
                        for report_stat in current:
                            if not isinstance(report_stat, table):
                                continue
                            matching = True
                            for name, value in cols:
                                if getattr(report_stat, name) != value:
                                    matching = False
                            if matching:
                                report_stat.count += 1
                                break
                        else:
                            report_stat = table()
                            report_stat.report = report
                            for name, value in cols:
                                setattr(report_stat, name, value)
                            report_stat.count = 1
                            current.append(report_stat)

                self.extend(current)
                report.last_occurrence = last_occ
            self.commit()