VirtualBox

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

Last change on this file since 76553 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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