-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenerate-test-data.py
102 lines (85 loc) · 3.07 KB
/
generate-test-data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from pathlib import Path
from faker import Faker
fake = Faker()
day = "16/May/2023:00:03:15 +0000"
def fake_apps():
return fake.random_element(
elements=(
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/net.lutris.Lutris/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/org.stellarium.Stellarium/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/org.libretro.RetroArch/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/org.x.Warpinator/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/net.rpcs3.RPCS3/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/net.pcsx2.PCSX2/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/org.citra_emu.citra/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/org.qgis.qgis/x86_64/stable",
),
(
"/repo/deltas/p1/IypJ6rKkrBepGnmgBqfxTzTjJYU64QcY1VsZH2Z6Y/superblock",
"app/org.qgis.qgis/x86_64/stable",
),
(
"/repo/deltas/oe/6ouxwlSuSPUaySy1Mrm0giFJrK2Kh9HoQpfZBzitI-PQssorSbAXMJAjQ8vOWWDwq10hKxB2zz0R1UPSs_0b8/superblock",
"app/org.mozilla.firefox/x86_64/stable",
),
)
)
def fake_ip() -> str:
return fake.random_element(
elements=(
fake.ipv4(),
fake.ipv6(),
)
)
def fake_user_agent() -> str:
return fake.random_element(
elements=(
"libostree/2022.6 flatpak/1.12.4",
"libostree/2020.8 flatpak/1.14.0",
"libostree/2022.5 flatpak/1.12.8",
"libostree/2022.2 flatpak/1.12.7",
"libostree/2022.7 flatpak/1.14.4",
"libostree/2022.1 flatpak/1.12.8",
"libostree/2023.2 flatpak/1.15.4",
"libostree/2023.1 flatpak/1.15.4",
)
)
def fake_is_update() -> str:
return fake.random_element(
elements=(
"",
"abcdefg", # doesn't matter
)
)
def data_row() -> str:
app = fake_apps()
return f'{fake_ip()} "-" "-" [{day}] "GET {app[0]} HTTP/1.1" 200 {fake.random_number(digits=12)} "" "{fake_user_agent()}" "{app[1]}" "{fake_is_update()}" {fake.country_code()}'
Path("test").mkdir(parents=True, exist_ok=True)
# write to file
with open("test/test-data.log", "w") as f:
for i in range(1000):
f.write(data_row() + "\n")
print("done")