This repository was archived by the owner on May 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathtest.lua
More file actions
85 lines (75 loc) · 2.03 KB
/
test.lua
File metadata and controls
85 lines (75 loc) · 2.03 KB
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
local crayon = require("crayon")
-- A clean server should be running on the test_port with:
-- docker run -it -p 6006:6006 -p 6007:6007 --name crayon_lua_test alband/crayon
local test_port = 6007
local cc = crayon.CrayonClient("localhost", test_port)
-- Check empty
local xp_list = cc:get_experiment_names()
for k,v in pairs(xp_list) do
error("The server should be empty")
end
-- Check create / add scalar
local foo = cc:create_experiment("foo")
foo:add_scalar_value("bar", 3)
foo:add_scalar_value("bar", 4, 123)
xp_list = cc:get_experiment_names()
for k,v in pairs(xp_list) do
if v ~= "foo" then
error("The server should not contain xp: "..v)
end
end
local bar_values = foo:get_scalar_values("bar")
for i,v in ipairs(bar_values) do
if i==2 and v[1] ~= 123 then
error("wall_time was not set properly")
end
if v[2] ~= i-1 then
error("step was not incremented properly")
end
if v[3] ~= i+2 then
error("value was not set properly")
end
end
-- Check open
local foo_bis = cc:open_experiment("foo")
for k,v in pairs(xp_list) do
if v ~= "foo" then
error("The server should not contain xp: "..v)
end
end
local bar_values = foo_bis:get_scalar_values("bar")
for i,v in ipairs(bar_values) do
if i==2 and v[1] ~= 123 then
error("wall_time was not set properly")
end
if v[2] ~= i-1 then
error("step was not incremented properly")
end
if v[3] ~= i+2 then
error("value was not set properly")
end
end
-- Check get backup
local zip_file = "back.zip"
foo:to_zip(zip_file)
-- Check upload backup
local foo2 = cc:create_experiment("foo2", zip_file)
for k,v in pairs(xp_list) do
if v ~= "foo" and v~= "foo2" then
error("The server should not contain xp: "..v)
end
end
local bar_values = foo2:get_scalar_values("bar")
for i,v in ipairs(bar_values) do
if i==2 and v[1] ~= 123 then
error("wall_time was not set properly")
end
if v[2] ~= i-1 then
error("step was not incremented properly")
end
if v[3] ~= i+2 then
error("value was not set properly")
end
end
os.remove(zip_file)
print("Success !")