gstepanov | 993c74b | 2015-02-05 15:20:38 +0200 | [diff] [blame] | 1 | import os |
koder aka kdanilov | 4a72f12 | 2015-02-09 12:25:54 +0200 | [diff] [blame] | 2 | import sys |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 3 | import uuid |
| 4 | import random |
| 5 | import itertools |
| 6 | |
| 7 | from petname import Generate as pet_generate |
koder aka kdanilov | 4a72f12 | 2015-02-09 12:25:54 +0200 | [diff] [blame] | 8 | from storage_api import create_storage |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 9 | |
Yulia Portnova | 929dbe8 | 2015-02-06 12:49:54 +0200 | [diff] [blame] | 10 | from report import ssize_to_kb |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 11 | |
koder aka kdanilov | 98385d8 | 2015-02-04 17:09:28 +0200 | [diff] [blame] | 12 | types = ["GA", "master"] + [pet_generate(2, '-') for _ in range(2)] |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 13 | random.shuffle(types) |
| 14 | tp = itertools.cycle(types) |
| 15 | |
koder aka kdanilov | 4a72f12 | 2015-02-09 12:25:54 +0200 | [diff] [blame] | 16 | sz = ["1k", "4k", "64k", "256k", "1m"] |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 17 | op_type = ["randread", "read", "randwrite", "write"] |
| 18 | is_sync = ["s", "a"] |
| 19 | |
koder aka kdanilov | 4a72f12 | 2015-02-09 12:25:54 +0200 | [diff] [blame] | 20 | storage = create_storage(sys.argv[1], "", "") |
koder aka kdanilov | 98385d8 | 2015-02-04 17:09:28 +0200 | [diff] [blame] | 21 | combinations = list(itertools.product(op_type, is_sync, sz)) |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 22 | |
| 23 | for i in range(30): |
| 24 | row = {"build_id": pet_generate(2, " "), |
| 25 | "type": next(tp), |
| 26 | "iso_md5": uuid.uuid4().get_hex()} |
| 27 | |
Yulia Portnova | 929dbe8 | 2015-02-06 12:49:54 +0200 | [diff] [blame] | 28 | for op_type, is_sync, sz in combinations: |
| 29 | ((random.random() - 0.5) * 0.2 + 1) |
| 30 | row[" ".join([op_type, is_sync, sz])] = ( |
| 31 | ((random.random() - 0.5) * 0.2 + 1) * (ssize_to_kb(sz) ** 0.5), |
| 32 | ((random.random() - 0.5) * 0.2 + 1) * (ssize_to_kb(sz) ** 0.5) * 0.15) |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 33 | |
gstepanov | 993c74b | 2015-02-05 15:20:38 +0200 | [diff] [blame] | 34 | print len(row) |
koder aka kdanilov | 3cbbc9d | 2015-02-04 15:37:58 +0200 | [diff] [blame] | 35 | storage.store(row) |