VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/db/tmdb-r21-testsets-4.pgsql@ 61476

最後變更 在這個檔案從61476是 61476,由 vboxsync 提交於 9 年 前

grumble. old conversion stupidity: NewTestSets_sBaseFilename_key

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 12.3 KB
 
1-- $Id: tmdb-r21-testsets-4.pgsql 61476 2016-06-05 21:10:15Z vboxsync $
2--- @file
3-- VBox Test Manager Database - Adds an idSchedGroup to TestSets in
4-- preparation for testboxes belonging to multiple scheduling queues.
5--
6
7--
8-- Copyright (C) 2013-2016 Oracle Corporation
9--
10-- This file is part of VirtualBox Open Source Edition (OSE), as
11-- available from http://www.alldomusa.eu.org. This file is free software;
12-- you can redistribute it and/or modify it under the terms of the GNU
13-- General Public License (GPL) as published by the Free Software
14-- Foundation, in version 2 as it comes in the "COPYING" file of the
15-- VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16-- hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17--
18-- The contents of this file may alternatively be used under the terms
19-- of the Common Development and Distribution License Version 1.0
20-- (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21-- VirtualBox OSE distribution, in which case the provisions of the
22-- CDDL are applicable instead of those of the GPL.
23--
24-- You may elect to license modified versions of this file under the
25-- terms and conditions of either the GPL or the CDDL or both.
26--
27
28--
29-- Cleanup after failed runs.
30--
31DROP TABLE IF EXISTS OldTestSets;
32
33--
34-- Die on error from now on.
35--
36\set ON_ERROR_STOP 1
37\set AUTOCOMMIT 0
38
39
40-- Total grid lock (don't want to deadlock below).
41LOCK TABLE TestBoxStatuses IN ACCESS EXCLUSIVE MODE;
42LOCK TABLE TestSets IN ACCESS EXCLUSIVE MODE;
43LOCK TABLE TestBoxes IN ACCESS EXCLUSIVE MODE;
44LOCK TABLE TestResults IN ACCESS EXCLUSIVE MODE;
45LOCK TABLE TestResultFailures IN ACCESS EXCLUSIVE MODE;
46LOCK TABLE TestResultFiles IN ACCESS EXCLUSIVE MODE;
47LOCK TABLE TestResultMsgs IN ACCESS EXCLUSIVE MODE;
48LOCK TABLE TestResultValues IN ACCESS EXCLUSIVE MODE;
49LOCK TABLE SchedGroups IN ACCESS EXCLUSIVE MODE;
50LOCK TABLE SchedQueues IN ACCESS EXCLUSIVE MODE;
51LOCK TABLE SchedGroupMembers IN ACCESS EXCLUSIVE MODE;
52
53\d+ TestSets;
54
55--
56-- Rename the table, drop foreign keys refering to it, and drop constrains
57-- within the table itself. The latter is mostly for naming and we do it
58-- up front in case the database we're running against has different names
59-- due to previous conversions.
60--
61ALTER TABLE TestSets RENAME TO OldTestSets;
62
63ALTER TABLE TestResultFailures DROP CONSTRAINT IF EXISTS idtestsetfk;
64ALTER TABLE TestResultFailures DROP CONSTRAINT IF EXISTS TestResultFailures_idTestSet_fkey;
65ALTER TABLE SchedQueues DROP CONSTRAINT IF EXISTS SchedQueues_idTestSetGangLeader_fkey;
66ALTER TABLE TestBoxStatuses DROP CONSTRAINT IF EXISTS TestBoxStatuses_idTestSet_fkey;
67ALTER TABLE TestResultFiles DROP CONSTRAINT IF EXISTS TestResultFiles_idTestSet_fkey;
68ALTER TABLE TestResultMsgs DROP CONSTRAINT IF EXISTS TestResultMsgs_idTestSet_fkey;
69ALTER TABLE TestResults DROP CONSTRAINT IF EXISTS TestResults_idTestSet_fkey;
70ALTER TABLE TestResultValues DROP CONSTRAINT IF EXISTS TestResultValues_idTestSet_fkey;
71
72ALTER TABLE OldTestSets DROP CONSTRAINT testsets_igangmemberno_check;
73
74ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_idBuildCategory_fkey;
75ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_idGenTestBox_fkey;
76ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_idGenTestCase_fkey;
77ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_idGenTestCaseArgs_fkey;
78ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_idTestResult_fkey;
79ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_idTestSetGangLeader_fkey;
80
81ALTER TABLE OldTestSets DROP CONSTRAINT IF EXISTS TestSets_sBaseFilename_key;
82ALTER TABLE OldTestSets DROP CONSTRAINT IF EXISTS NewTestSets_sBaseFilename_key;
83ALTER TABLE OldTestSets DROP CONSTRAINT TestSets_pkey;
84
85DROP INDEX IF EXISTS TestSetsGangIdx;
86DROP INDEX IF EXISTS TestSetsBoxIdx;
87DROP INDEX IF EXISTS TestSetsBuildIdx;
88DROP INDEX IF EXISTS TestSetsTestCaseIdx;
89DROP INDEX IF EXISTS TestSetsTestVarIdx;
90DROP INDEX IF EXISTS TestSetsDoneCreatedBuildCatIdx;
91DROP INDEX IF EXISTS TestSetsGraphBoxIdx;
92
93
94-- This output should be free of indexes, constraints and references from other tables.
95\d+ OldTestSets;
96
97\prompt "Is the above table completely free of indexes, constraints and references? Ctrl-C if not." dummy
98
99--
100-- Create the new table (no foreign keys).
101--
102CREATE TABLE TestSets (
103 --- The ID of this test set.
104 idTestSet INTEGER DEFAULT NEXTVAL('TestSetIdSeq') NOT NULL,
105
106 --- The test config timestamp, used when reading test config.
107 tsConfig TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
108 --- When this test set was scheduled.
109 -- idGenTestBox is valid at this point.
110 tsCreated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
111 --- When this test completed, i.e. testing stopped. This should only be set once.
112 tsDone TIMESTAMP WITH TIME ZONE DEFAULT NULL,
113 --- The current status.
114 enmStatus TestStatus_T DEFAULT 'running'::TestStatus_T NOT NULL,
115
116 --- The build we're testing.
117 -- Non-unique foreign key: Builds(idBuild)
118 idBuild INTEGER NOT NULL,
119 --- The build category of idBuild when the test started.
120 -- This is for speeding up graph data collection, i.e. avoid idBuild
121 -- the WHERE part of the selection.
122 idBuildCategory INTEGER NOT NULL,
123 --- The test suite build we're using to do the testing.
124 -- This is NULL if the test suite zip wasn't referred or if a test suite
125 -- build source wasn't configured.
126 -- Non-unique foreign key: Builds(idBuild)
127 idBuildTestSuite INTEGER DEFAULT NULL,
128
129 --- The exact testbox configuration.
130 idGenTestBox INTEGER NOT NULL,
131 --- The testbox ID for joining with (valid: tsStarted).
132 -- Non-unique foreign key: TestBoxes(idTestBox)
133 idTestBox INTEGER NOT NULL,
134 --- The scheduling group ID the test was scheduled thru (valid: tsStarted).
135 -- Non-unique foreign key: SchedGroups(idSchedGroup)
136 idSchedGroup INTEGER NOT NULL,
137
138 --- The testgroup (valid: tsConfig).
139 -- Non-unique foreign key: TestBoxes(idTestGroup)
140 -- Note! This also gives the member ship entry, since a testcase can only
141 -- have one membership per test group.
142 idTestGroup INTEGER NOT NULL,
143
144 --- The exact test case config we executed in this test run.
145 idGenTestCase INTEGER NOT NULL,
146 --- The test case ID for joining with (valid: tsConfig).
147 -- Non-unique foreign key: TestBoxes(idTestCase)
148 idTestCase INTEGER NOT NULL,
149
150 --- The arguments (and requirements++) we executed this test case with.
151 idGenTestCaseArgs INTEGER NOT NULL,
152 --- The argument variation ID (valid: tsConfig).
153 -- Non-unique foreign key: TestCaseArgs(idTestCaseArgs)
154 idTestCaseArgs INTEGER NOT NULL,
155
156 --- The root of the test result tree.
157 -- @note This will only be NULL early in the transaction setting up the testset.
158 -- @note If the test reports more than one top level test result, we'll
159 -- fail the whole test run and let the test developer fix it.
160 idTestResult INTEGER DEFAULT NULL,
161
162 --- The base filename used for storing files related to this test set.
163 -- This is a path relative to wherever TM is dumping log files. In order
164 -- to not become a file system test case, we will try not to put too many
165 -- hundred thousand files in a directory. A simple first approach would
166 -- be to just use the current date (tsCreated) like this:
167 -- TM_FILE_DIR/year/month/day/TestSets.idTestSet
168 --
169 -- The primary log file for the test is this name suffixed by '.log'.
170 --
171 -- The files in the testresultfile table gets their full names like this:
172 -- TM_FILE_DIR/sBaseFilename-testresultfile.id-TestResultStrTab(testresultfile.idStrFilename)
173 --
174 -- @remarks We store this explicitly in case we change the directly layout
175 -- at some later point.
176 sBaseFilename text NOT NULL,
177
178 --- The gang member number number, 0 is the leader.
179 iGangMemberNo SMALLINT DEFAULT 0 NOT NULL, -- CHECK (iGangMemberNo >= 0 AND iGangMemberNo < 1024),
180 --- The test set of the gang leader, NULL if no gang involved.
181 -- @note This is set by the gang leader as well, so that we can find all
182 -- gang members by WHERE idTestSetGangLeader = :id.
183 idTestSetGangLeader INTEGER DEFAULT NULL
184
185);
186
187-- Convert the data.
188INSERT INTO TestSets (
189 idTestSet,
190 tsConfig,
191 tsCreated,
192 tsDone,
193 enmStatus,
194 idBuild,
195 idBuildCategory,
196 idBuildTestSuite,
197 idGenTestBox,
198 idTestBox,
199 idSchedGroup,
200 idTestGroup,
201 idGenTestCase,
202 idTestCase,
203 idGenTestCaseArgs,
204 idTestCaseArgs,
205 idTestResult,
206 sBaseFilename,
207 iGangMemberNo,
208 idTestSetGangLeader
209 )
210SELECT OldTestSets.idTestSet,
211 OldTestSets.tsConfig,
212 OldTestSets.tsCreated,
213 OldTestSets.tsDone,
214 OldTestSets.enmStatus,
215 OldTestSets.idBuild,
216 OldTestSets.idBuildCategory,
217 OldTestSets.idBuildTestSuite,
218 OldTestSets.idGenTestBox,
219 OldTestSets.idTestBox,
220 TestBoxes.idSchedGroup,
221 OldTestSets.idTestGroup,
222 OldTestSets.idGenTestCase,
223 OldTestSets.idTestCase,
224 OldTestSets.idGenTestCaseArgs,
225 OldTestSets.idTestCaseArgs,
226 OldTestSets.idTestResult,
227 OldTestSets.sBaseFilename,
228 OldTestSets.iGangMemberNo,
229 OldTestSets.idTestSetGangLeader
230FROM OldTestSets
231 INNER JOIN TestBoxes
232 ON OldTestSets.idGenTestBox = TestBoxes.idGenTestBox;
233
234-- Restore the primary key and unique constraints.
235ALTER TABLE TestSets ADD PRIMARY KEY (idTestSet);
236ALTER TABLE TestSets ADD UNIQUE (sBaseFilename);
237
238-- Restore check constraints.
239ALTER TABLE TestSets ADD CONSTRAINT TestSets_iGangMemberNo_Check CHECK (iGangMemberNo >= 0 AND iGangMemberNo < 1024);
240
241-- Restore foreign keys in the table.
242ALTER TABLE TestSets ADD FOREIGN KEY (idBuildCategory) REFERENCES BuildCategories(idBuildCategory);
243ALTER TABLE TestSets ADD FOREIGN KEY (idGenTestBox) REFERENCES TestBoxes(idGenTestBox);
244ALTER TABLE TestSets ADD FOREIGN KEY (idGenTestCase) REFERENCES TestCases(idGenTestCase);
245ALTER TABLE TestSets ADD FOREIGN KEY (idGenTestCaseArgs) REFERENCES TestCaseArgs(idGenTestCaseArgs);
246ALTER TABLE TestSets ADD FOREIGN KEY (idTestResult) REFERENCES TestResults(idTestResult);
247ALTER TABLE TestSets ADD FOREIGN KEY (idTestSetGangLeader) REFERENCES TestSets(idTestSet);
248
249-- Restore indexes.
250CREATE INDEX TestSetsGangIdx ON TestSets (idTestSetGangLeader);
251CREATE INDEX TestSetsBoxIdx ON TestSets (idTestBox, idTestResult);
252CREATE INDEX TestSetsBuildIdx ON TestSets (idBuild, idTestResult);
253CREATE INDEX TestSetsTestCaseIdx ON TestSets (idTestCase, idTestResult);
254CREATE INDEX TestSetsTestVarIdx ON TestSets (idTestCaseArgs, idTestResult);
255CREATE INDEX TestSetsDoneCreatedBuildCatIdx ON TestSets (tsDone DESC NULLS FIRST, tsCreated ASC, idBuildCategory);
256CREATE INDEX TestSetsGraphBoxIdx ON TestSets (idTestBox, tsCreated DESC, tsDone ASC NULLS LAST, idBuildCategory, idTestCase);
257
258-- Restore foreign key references to the table.
259ALTER TABLE TestResults ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
260ALTER TABLE TestResultValues ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
261ALTER TABLE TestResultFiles ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
262ALTER TABLE TestResultMsgs ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
263ALTER TABLE TestResultFailures ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
264
265ALTER TABLE TestBoxStatuses ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
266ALTER TABLE SchedQueues ADD FOREIGN KEY (idTestSetGangLeader) REFERENCES TestSets(idTestSet) MATCH FULL;
267
268-- Drop the old table.
269DROP TABLE OldTestSets;
270
271\prompt "Update python files while everything is locked. Hurry!" dummy
272
273-- Grant access to the new table.
274GRANT ALL PRIVILEGES ON TABLE TestSets TO testmanager;
275
276COMMIT;
277
278\d TestSets;
279
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette