2020-04-04 22:15:24 +02:00
|
|
|
using Random
|
|
|
|
## CREATE
|
|
|
|
FDBNAME = "test1"
|
|
|
|
|
|
|
|
FILEDB = open(FDBNAME, "w")
|
|
|
|
# create 100 users
|
|
|
|
unum = 100
|
|
|
|
users = []
|
|
|
|
uuids = UUID.(1:unum)
|
|
|
|
for uuid in uuids
|
|
|
|
u = User(provider, "Nicolò", "Balzarotti", "3935027690", nothing,
|
|
|
|
"\$argon2id\$v=19\$m=65536,t=2,p=1\$c1FCl+2ur/YcMwcfNCsBkw\$xqCwQ/VeJNTkrEduNO7SyhQSDSW5hJMxjBaBFpIr26Q",
|
|
|
|
false, false, false, uuid, 0)
|
|
|
|
push!(users, u)
|
2020-02-28 09:55:03 +01:00
|
|
|
end
|
2020-04-04 22:15:24 +02:00
|
|
|
for user in users
|
|
|
|
write(FILEDB, Action(create, user))
|
2020-02-28 09:55:03 +01:00
|
|
|
end
|
2020-04-04 22:15:24 +02:00
|
|
|
# Randomly modify those users
|
|
|
|
for i in 1:100_000
|
|
|
|
u = rand(users)
|
|
|
|
u.online = rand(Bool)
|
|
|
|
u.version += 1
|
|
|
|
write(FILEDB, Action(modify, u))
|
2020-02-28 09:55:03 +01:00
|
|
|
end
|
2020-04-04 22:15:24 +02:00
|
|
|
# Delete half of them
|
|
|
|
todelete = users[randperm(length(users))][1:(length(users) ÷ 2)]
|
|
|
|
for u in todelete
|
|
|
|
write(FILEDB, Action(delete, u))
|
2020-02-28 09:55:03 +01:00
|
|
|
end
|
2020-04-04 22:15:24 +02:00
|
|
|
close(FILEDB)
|
|
|
|
x = restore(FDBNAME, User)
|
|
|
|
InMemoryLoggedDB.replay(x)
|