Пример #1
0
 def test_get_product_usage_data(self):
     addr = "rcs.example.com"
     limit = 2
     # Create dummy data
     dummy_data = self.create_product_usage_data(addr, 5)
     self.assertEqual(len(dummy_data), 5)
     found_data = upload._get_product_usage_data(addr, limit)
     self.assertEqual(len(found_data), 2)
Пример #2
0
if __name__ == "__main__":
    parser = OptionParser(description="Timing test for querying/updating ProductUsage data")
    parser.add_option("--limit", action="store", help="How many items to test with", default="10000")
    (opts, args) = parser.parse_args()

    # Init db connection and splice classes
    config.init(settings.SPLICE_CONFIG_FILE)
    init_logging() # Redo logging config so we can control where we log data for these runs

    limit = int(opts.limit)
    addr = __file__

    a = time.time()
    # Perform a query and get time
    usage_items = upload._get_product_usage_data(addr, limit)
    b = time.time()

    object_ids = [x.id for x in usage_items]
    c = time.time()
    # Test writes
    upload._mark_sent(object_ids, addr)
    d = time.time()

    # Cleanup
    upload._unmark_sent(object_ids, addr)
    e = time.time()

    print "%s seconds to fetch %s items" % (b-a, len(object_ids))
    print "%s seconds to form list of object ids for %s items" % (c-b, len(object_ids))
    print "%s seconds to update tracker for %s items" % (d-c, len(object_ids))