コード例 #1
0
ファイル: test_import.py プロジェクト: malditha/report_server
    def test_import_interval_2_with_real_dupe01(self):

        # interval set at 2... for each checkin two total checkins will be created.
        # 2 real checkins should be created.. and 2 dupes..
        # A second real checkin occurs but one hour of each checkin is a dupe.
        # Total should be six

        fact1 = {"memory_dot_memtotal": "604836",
                 "lscpu_dot_cpu_socket(s)": "1", "lscpu_dot_cpu(s)": "1"}

        time = datetime.strptime("10102012:0530", constants.mn_fmt)
        time2 = datetime.strptime("10102012:0639", constants.mn_fmt)

        uuid = products_dict[RHEL][1]
        prod = products_dict[RHEL][0]
        TestData.create_product_usage(self.ss, fact1, time, consumer=uuid,
                                      instance='mac01', products=prod)
        TestData.create_product_usage(self.ss, fact1, time2, consumer=uuid,
                                      instance='mac01', products=prod)
        TestData.create_product_usage(self.ss, fact1, time, consumer=uuid,
                                      instance='mac02', products=prod)
        TestData.create_product_usage(self.ss, fact1, time2, consumer=uuid,
                                      instance='mac02', products=prod)
        # run import
        results = import_data(checkin_interval=2, force_import=True)

        # verify 1 items in db
        lookup = ReportData.objects.all()
        self.assertEqual(len(lookup), 6)
コード例 #2
0
ファイル: test_import.py プロジェクト: malditha/report_server
    def import_bulk_load_base(self, items_to_load):
        # turn off bulk load option

        time = datetime.strptime("10102012:0530", constants.mn_fmt)
        fact1 = {"memory_dot_memtotal": "604836",
                 "lscpu_dot_cpu_socket(s)": "1", "lscpu_dot_cpu(s)": "1"}
        timedelt = timedelta(hours=1)
        uuid = products_dict[RHEL][1]
        instance = 'mac01'
        products = products_dict[RHEL][0]
        bulk_load = {}
        for i in range(items_to_load):
            time += timedelt
            this_hash = hash(
                str(uuid) + str(instance) + str(time) + str(products))
            td = TestData.create_product_usage(self.ss, fact1, time, consumer=uuid, instance=instance, products=products, save=False)
            bulk_load[this_hash] = td
        # print(len(bulk_load))
        my_list = []
        for key, value in bulk_load.items():
            my_list.append(value)

        timer_start = datetime.now()
        results = import_data(product_usage=my_list, force_import=True)
        lookup = ReportData.objects.all()
        self.assertEqual(len(lookup), items_to_load)

        timer_stop = datetime.now()
コード例 #3
0
ファイル: api.py プロジェクト: splice/report_server
    def import_hook(self, product_usage):
        _LOG.info("called create_hook")
        items_not_imported, start_stop_time = import_util.import_data(product_usage, force_import=True)
        _LOG.info("items_not_imported length: " + str(len(items_not_imported)))
        for i in items_not_imported:
            thisDict = i.to_dict()
            thisItem = QuarantinedReportData(**thisDict)
            thisItem.save()

        return items_not_imported
コード例 #4
0
ファイル: test_import.py プロジェクト: malditha/report_server
    def test_import(self):
        fact1 = {"memory_dot_memtotal": "604836",
                 "lscpu_dot_cpu_socket(s)": "1", "lscpu_dot_cpu(s)": "1"}

        time = datetime.strptime("10102012:05", constants.hr_fmt)
        uuid = products_dict[RHEL][1]
        prod = products_dict[RHEL][0]
        pu = TestData.create_product_usage(self.ss, fact1, time, consumer=uuid,
                                           instance='mac01', products=prod)
        # run import
        results = import_data(force_import=True)

        # verify 1 items in db
        lookup = ReportData.objects.all()
        self.assertEqual(len(lookup), 1)
コード例 #5
0
def main():
    SpliceServer.drop_collection()
    ProductUsage.drop_collection()
    ReportData.drop_collection()
    ss1 = TestData.create_splice_server("test01", "east")
    
    uuid_rhel_jboss = products_dict[RHEL][1]
    prod_rhel = products_dict[RHEL][0]
    prod_jboss = products_dict[JBoss][0]
    
    uuid_ha = products_dict[HA][1]
    prod_ha = products_dict[HA][0]
    
    uuid_edu = products_dict[EDU][1]
    prod_edu = products_dict[EDU][0]
    
    now = datetime.now()
    delta_day = timedelta(days=4)
    delta_hour = timedelta(days=3)
    
    
    for i in range(1, 10):
        this_time = now - (delta_hour * i)
        create_set_of_usage(
            prod_rhel, uuid_rhel_jboss, get_times(this_time), ss1, 7)
    
    for i in range(1, 10):
        this_time = now - (delta_hour * i)
        create_set_of_usage(
            prod_jboss, uuid_rhel_jboss, get_times(this_time), ss1, 4)
    
    for i in range(1, 4):
        this_time = now - (delta_hour * i)
        create_set_of_usage(prod_ha, uuid_ha, get_times(this_time), ss1, 7)
    
    for i in range(5, 10):
        this_time = now - (delta_hour * i)
        create_set_of_usage(
            prod_edu, uuid_edu, get_times(this_time), ss1, 5)
    # run import
    results = import_data(force_import=True)
    
    # verify 1 items in db
    lookup = ReportData.objects.all()
コード例 #6
0
ファイル: test_import.py プロジェクト: malditha/report_server
    def test_import_interval_2_with_real_dupe02(self):

        fact1 = {"memory_dot_memtotal": "604836",
                 "lscpu_dot_cpu_socket(s)": "1", "lscpu_dot_cpu(s)": "1"}

        time = datetime.strptime("10102012:0530", constants.mn_fmt)
        time2 = datetime.strptime("10102012:0731", constants.mn_fmt)
        time3 = datetime.strptime("10102012:0831", constants.mn_fmt)
        uuid = products_dict[RHEL][1]
        prod = products_dict[RHEL][0]
        TestData.create_product_usage(self.ss, fact1, time, consumer=uuid,
                                      instance='mac01', products=prod)
        TestData.create_product_usage(self.ss, fact1, time2, consumer=uuid,
                                      instance='mac01', products=prod)
        TestData.create_product_usage(self.ss, fact1, time3, consumer=uuid,
                                      instance='mac01', products=prod)
        TestData.create_product_usage(self.ss, fact1, time3, consumer=uuid,
                                      instance='mac02', products=prod)
        # run import
        results = import_data(checkin_interval=2, force_import=True)

        # verify 1 items in db
        lookup = ReportData.objects.all()
        self.assertEqual(len(lookup), 7)
コード例 #7
0
ファイル: views.py プロジェクト: malditha/report_server
def execute_import(request):
    quarantined, results = import_data()
    response_data = {}
    response_data['time'] = results
    
    return create_response(response_data)