summaryrefslogtreecommitdiff
path: root/tko/migrations/003_add_test_timestamps.py
blob: e9148cb4b32f7de9a136d7c7cdbed9e477bacb91 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def migrate_up(manager):
	manager.execute_script(ADD_COLUMN_SQL)
	manager.execute_script(ALTER_VIEWS_UP_SQL)


def migrate_down(manager):
	manager.execute_script(DROP_COLUMN_SQL)
	manager.execute_script(ALTER_VIEWS_DOWN_SQL)


ADD_COLUMN_SQL = """\
ALTER TABLE tests ADD COLUMN finished_time datetime NULL;
"""

DROP_COLUMN_SQL = """\
ALTER TABLE tests DROP finished_time;
"""

ALTER_VIEWS_UP_SQL = """\
ALTER VIEW test_view AS
SELECT	tests.test_idx,
	tests.job_idx,
	tests.test,
	tests.subdir,
	tests.kernel_idx,
	tests.status,
	tests.reason,
	tests.machine_idx,
	tests.finished_time AS test_finished_time,
	jobs.tag AS job_tag,
	jobs.label AS job_label,
	jobs.username AS job_username,
	jobs.queued_time AS job_queued_time,
	jobs.started_time AS job_started_time,
	jobs.finished_time AS job_finished_time,
	machines.hostname AS machine_hostname,
	machines.machine_group,
	machines.owner AS machine_owner,
	kernels.kernel_hash,
	kernels.base AS kernel_base, 
	kernels.printable AS kernel_printable,
	status.word AS status_word
FROM tests
INNER JOIN jobs ON jobs.job_idx = tests.job_idx
INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
INNER JOIN status ON status.status_idx = tests.status;

-- perf_view (to make life easier for people trying to mine performance data)
ALTER VIEW perf_view AS
SELECT	tests.test_idx,
	tests.job_idx,
	tests.test,
	tests.subdir,
	tests.kernel_idx,
	tests.status,
	tests.reason,
	tests.machine_idx,
	tests.finished_time AS test_finished_time,
	jobs.tag AS job_tag,
	jobs.label AS job_label,
	jobs.username AS job_username,
	jobs.queued_time AS job_queued_time,
	jobs.started_time AS job_started_time,
	jobs.finished_time AS job_finished_time,
	machines.hostname AS machine_hostname,
	machines.machine_group,
	machines.owner AS machine_owner,
	kernels.kernel_hash,
	kernels.base AS kernel_base, 
	kernels.printable AS kernel_printable,
	status.word AS status_word,
	iteration_result.iteration,
	iteration_result.attribute AS iteration_key,
	iteration_result.value AS iteration_value
FROM tests
INNER JOIN jobs ON jobs.job_idx = tests.job_idx
INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
INNER JOIN status ON status.status_idx = tests.status
INNER JOIN iteration_result ON iteration_result.test_idx = tests.kernel_idx;
"""


ALTER_VIEWS_DOWN_SQL = """\
ALTER VIEW test_view AS
SELECT	tests.test_idx,
	tests.job_idx,
	tests.test,
	tests.subdir,
	tests.kernel_idx,
	tests.status,
	tests.reason,
	tests.machine_idx,
	jobs.tag AS job_tag,
	jobs.label AS job_label,
	jobs.username AS job_username,
	jobs.queued_time AS job_queued_time,
	jobs.started_time AS job_started_time,
	jobs.finished_time AS job_finished_time,
	machines.hostname AS machine_hostname,
	machines.machine_group,
	machines.owner AS machine_owner,
	kernels.kernel_hash,
	kernels.base AS kernel_base, 
	kernels.printable AS kernel_printable,
	status.word AS status_word
FROM tests
INNER JOIN jobs ON jobs.job_idx = tests.job_idx
INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
INNER JOIN status ON status.status_idx = tests.status;

-- perf_view (to make life easier for people trying to mine performance data)
ALTER VIEW perf_view AS
SELECT	tests.test_idx,
	tests.job_idx,
	tests.test,
	tests.subdir,
	tests.kernel_idx,
	tests.status,
	tests.reason,
	tests.machine_idx,
	jobs.tag AS job_tag,
	jobs.label AS job_label,
	jobs.username AS job_username,
	jobs.queued_time AS job_queued_time,
	jobs.started_time AS job_started_time,
	jobs.finished_time AS job_finished_time,
	machines.hostname AS machine_hostname,
	machines.machine_group,
	machines.owner AS machine_owner,
	kernels.kernel_hash,
	kernels.base AS kernel_base, 
	kernels.printable AS kernel_printable,
	status.word AS status_word,
	iteration_result.iteration,
	iteration_result.attribute AS iteration_key,
	iteration_result.value AS iteration_value
FROM tests
INNER JOIN jobs ON jobs.job_idx = tests.job_idx
INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
INNER JOIN status ON status.status_idx = tests.status
INNER JOIN iteration_result ON iteration_result.test_idx = tests.kernel_idx;
"""