VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/db/tmdb-r11-testsets-2.pgsql@ 98523

Last change on this file since 98523 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
1-- $Id: tmdb-r11-testsets-2.pgsql 98103 2023-01-17 14:15:46Z vboxsync $
2--- @file
3-- VBox Test Manager Database - Adds an idBuildCategories to TestSets.
4--
5
6--
7-- Copyright (C) 2013-2023 Oracle and/or its affiliates.
8--
9-- This file is part of VirtualBox base platform packages, as
10-- available from https://www.virtualbox.org.
11--
12-- This program is free software; you can redistribute it and/or
13-- modify it under the terms of the GNU General Public License
14-- as published by the Free Software Foundation, in version 3 of the
15-- License.
16--
17-- This program is distributed in the hope that it will be useful, but
18-- WITHOUT ANY WARRANTY; without even the implied warranty of
19-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20-- General Public License for more details.
21--
22-- You should have received a copy of the GNU General Public License
23-- along with this program; if not, see <https://www.gnu.org/licenses>.
24--
25-- The contents of this file may alternatively be used under the terms
26-- of the Common Development and Distribution License Version 1.0
27-- (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28-- in the VirtualBox distribution, in which case the provisions of the
29-- CDDL are applicable instead of those of the GPL.
30--
31-- You may elect to license modified versions of this file under the
32-- terms and conditions of either the GPL or the CDDL or both.
33--
34-- SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35--
36
37--
38-- Drop all indexes (might already be dropped).
39--
40DROP INDEX TestSetsGangIdx;
41DROP INDEX TestSetsBoxIdx;
42DROP INDEX TestSetsBuildIdx;
43DROP INDEX TestSetsTestCaseIdx;
44DROP INDEX TestSetsTestVarIdx;
45DROP INDEX TestSetsCreated;
46DROP INDEX TestSetsDone;
47
48--
49-- Drop foreign keys on this table.
50--
51ALTER TABLE SchedQueues DROP CONSTRAINT SchedQueues_idTestSetGangLeader_fkey;
52ALTER TABLE TestBoxStatuses DROP CONSTRAINT TestBoxStatuses_idTestSet_fkey;
53ALTER TABLE TestResults DROP CONSTRAINT idTestSetFk; -- old name
54ALTER TABLE TestResults DROP CONSTRAINT TestResults_idTestSet_fkey;
55ALTER TABLE TestResultValues DROP CONSTRAINT TestResultValues_idTestSet_fkey;
56
57--
58-- Cleanup after failed runs.
59--
60DROP TABLE NewTestSets;
61DROP TABLE OldTestSets;
62
63-- Die on error from now on.
64\set ON_ERROR_STOP 1
65\set AUTOCOMMIT 0
66
67\d+ TestSets;
68
69--
70-- Create the new version of the table and filling with the content of the old.
71--
72CREATE TABLE NewTestSets (
73 --- The ID of this test set.
74 idTestSet INTEGER DEFAULT NEXTVAL('TestSetIdSeq') NOT NULL, -- PRIMARY KEY
75
76 --- The test config timestamp, used when reading test config.
77 tsConfig TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
78 --- When this test set was scheduled.
79 -- idGenTestBox is valid at this point.
80 tsCreated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
81 --- When this test completed, i.e. testing stopped. This should only be set once.
82 tsDone TIMESTAMP WITH TIME ZONE DEFAULT NULL,
83 --- The current status.
84 enmStatus TestStatus_T DEFAULT 'running'::TestStatus_T NOT NULL,
85
86 --- The build we're testing.
87 -- Non-unique foreign key: Builds(idBuild)
88 idBuild INTEGER NOT NULL,
89 --- The build category of idBuild when the test started.
90 -- This is for speeding up graph data collection, i.e. avoid idBuild
91 -- the WHERE part of the selection.
92 idBuildCategory INTEGER , -- NOT NULL REFERENCES BuildCategories(idBuildCategory)
93 --- The test suite build we're using to do the testing.
94 -- This is NULL if the test suite zip wasn't referred or if a test suite
95 -- build source wasn't configured.
96 -- Non-unique foreign key: Builds(idBuild)
97 idBuildTestSuite INTEGER DEFAULT NULL,
98
99 --- The exact testbox configuration.
100 idGenTestBox INTEGER NOT NULL, -- REFERENCES TestBoxes(idGenTestBox)
101 --- The testbox ID for joining with (valid: tsStarted).
102 -- Non-unique foreign key: TestBoxes(idTestBox)
103 idTestBox INTEGER NOT NULL,
104
105 --- The testgroup (valid: tsConfig).
106 -- Non-unique foreign key: TestBoxes(idTestGroup)
107 -- Note! This also gives the member ship entry, since a testcase can only
108 -- have one membership per test group.
109 idTestGroup INTEGER NOT NULL,
110
111 --- The exact test case config we executed in this test run.
112 idGenTestCase INTEGER NOT NULL, -- REFERENCES TestCases(idGenTestCase)
113 --- The test case ID for joining with (valid: tsConfig).
114 -- Non-unique foreign key: TestBoxes(idTestCase)
115 idTestCase INTEGER NOT NULL,
116
117 --- The arguments (and requirements++) we executed this test case with.
118 idGenTestCaseArgs INTEGER NOT NULL, -- REFERENCES TestCaseArgs(idGenTestCaseArgs)
119 --- The argument variation ID (valid: tsConfig).
120 -- Non-unique foreign key: TestCaseArgs(idTestCaseArgs)
121 idTestCaseArgs INTEGER NOT NULL,
122
123 --- The root of the test result tree.
124 -- @note This will only be NULL early in the transaction setting up the testset.
125 -- @note If the test reports more than one top level test result, we'll
126 -- fail the whole test run and let the test developer fix it.
127 idTestResult INTEGER DEFAULT NULL, -- REFERENCES TestResults(idTestResult)
128
129 --- The base filename used for storing files related to this test set.
130 -- This is a path relative to wherever TM is dumping log files. In order
131 -- to not become a file system test case, we will try not to put too many
132 -- hundred thousand files in a directory. A simple first approach would
133 -- be to just use the current date (tsCreated) like this:
134 -- TM_FILE_DIR/year/month/day/TestSets.idTestSet
135 --
136 -- The primary log file for the test is this name suffixed by '.log'.
137 --
138 -- The files in the testresultfile table gets their full names like this:
139 -- TM_FILE_DIR/sBaseFilename-testresultfile.id-TestResultStrTab(testresultfile.idStrFilename)
140 --
141 -- @remarks We store this explicitly in case we change the directly layout
142 -- at some later point.
143 sBaseFilename text UNIQUE NOT NULL,
144
145 --- The gang member number number, 0 is the leader.
146 iGangMemberNo SMALLINT DEFAULT 0 NOT NULL, --CHECK (iGangMemberNo >= 0 AND iGangMemberNo < 1024),
147 --- The test set of the gang leader, NULL if no gang involved.
148 -- @note This is set by the gang leader as well, so that we can find all
149 -- gang members by WHERE idTestSetGangLeader = :id.
150 idTestSetGangLeader INTEGER DEFAULT NULL -- REFERENCES TestSets(idTestSet)
151
152);
153COMMIT;
154\d+ NewTestSets
155
156-- Note! Using left out join here to speed up things (no hashing).
157SELECT COUNT(*) FROM TestSets a LEFT OUTER JOIN Builds b ON (a.idBuild = b.idBuild AND b.tsExpire = 'infinity'::TIMESTAMP);
158SELECT COUNT(*) FROM TestSets;
159
160INSERT INTO NewTestSets (idTestSet, tsConfig, tsCreated, tsDone, enmStatus, idBuild, idBuildCategory, idBuildTestSuite,
161 idGenTestBox, idTestBox, idTestGroup, idGenTestCase, idTestCase, idGenTestCaseArgs, idTestCaseArgs,
162 idTestResult, sBaseFilename, iGangMemberNo, idTestSetGangLeader )
163 SELECT a.idTestSet, a.tsConfig, a.tsCreated, tsDone, a.enmStatus, a.idBuild, b.idBuildCategory, a.idBuildTestSuite,
164 a.idGenTestBox, a.idTestBox, a.idTestGroup, a.idGenTestCase, a.idTestCase, a.idGenTestCaseArgs, a.idTestCaseArgs,
165 a.idTestResult, a.sBaseFilename, a.iGangMemberNo, a.idTestSetGangLeader
166 FROM TestSets a LEFT OUTER JOIN Builds b ON (a.idBuild = b.idBuild AND b.tsExpire = 'infinity'::TIMESTAMP);
167COMMIT;
168SELECT COUNT(*) FROM NewTestSets;
169
170-- Note! 2-3 builds are missing from the Builds table, so fudge it.
171UPDATE NewTestSets
172 SET idBuildCategory = 1
173 WHERE idBuildCategory IS NULL;
174
175-- Switch the tables.
176ALTER TABLE TestSets RENAME TO OldTestSets;
177ALTER TABLE NewTestSets RENAME TO TestSets;
178COMMIT;
179
180-- Index the table.
181CREATE INDEX TestSetsGangIdx ON TestSets (idTestSetGangLeader);
182CREATE INDEX TestSetsBoxIdx ON TestSets (idTestBox, idTestResult);
183CREATE INDEX TestSetsBuildIdx ON TestSets (idBuild, idTestResult);
184CREATE INDEX TestSetsTestCaseIdx ON TestSets (idTestCase, idTestResult);
185CREATE INDEX TestSetsTestVarIdx ON TestSets (idTestCaseArgs, idTestResult);
186CREATE INDEX TestSetsCreated ON TestSets (tsCreated);
187CREATE INDEX TestSetsDone ON TestSets (tsDone);
188COMMIT;
189
190-- Drop the old table.
191DROP TABLE OldTestSets;
192COMMIT;
193
194-- Add the constraints constraint.
195ALTER TABLE TestSets ADD CONSTRAINT TestSets_iGangMemberNo_Check CHECK (iGangMemberNo >= 0 AND iGangMemberNo < 1024);
196ALTER TABLE TestSets ADD PRIMARY KEY (idTestSet);
197ALTER TABLE TestSets ADD FOREIGN KEY (idBuildCategory) REFERENCES BuildCategories(idBuildCategory);
198ALTER TABLE TestSets ADD FOREIGN KEY (idGenTestBox) REFERENCES TestBoxes(idGenTestBox);
199ALTER TABLE TestSets ADD FOREIGN KEY (idGenTestCase) REFERENCES TestCases(idGenTestCase);
200ALTER TABLE TestSets ADD FOREIGN KEY (idGenTestCaseArgs) REFERENCES TestCaseArgs(idGenTestCaseArgs);
201ALTER TABLE TestSets ADD FOREIGN KEY (idTestResult) REFERENCES TestResults(idTestResult);
202ALTER TABLE TestSets ADD FOREIGN KEY (idTestSetGangLeader) REFERENCES TestSets(idTestSet);
203COMMIT;
204
205-- Restore foreign keys.
206LOCK TABLE SchedQueues, TestBoxStatuses, TestResults, TestResultValues IN EXCLUSIVE MODE;
207ALTER TABLE SchedQueues ADD FOREIGN KEY (idTestSetGangLeader) REFERENCES TestSets(idTestSet) MATCH FULL;
208ALTER TABLE TestBoxStatuses ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
209ALTER TABLE TestResults ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
210ALTER TABLE TestResultValues ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet) MATCH FULL;
211COMMIT;
212
213\d+ TestSets;
214
Note: See TracBrowser for help on using the repository browser.

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