VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/core/schedqueue.py@ 92892

Last change on this file since 92892 was 83364, checked in by vboxsync, 5 years ago

TestManager: Adding test box selection to the scheduling group form (left over from r107843 where test boxes gained the ability to service more than one scheduling group).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1# -*- coding: utf-8 -*-
2# "$Id: schedqueue.py 83364 2020-03-23 09:47:01Z vboxsync $"
3
4"""
5Test Manager - Test Case Queue.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2020 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 83364 $"
30
31## Standard python imports.
32#import unittest
33
34from testmanager.core.base import ModelDataBase, ModelLogicBase, TMExceptionBase #, ModelDataBaseTestCase
35
36
37class SchedQueueEntry(ModelDataBase):
38 """
39 SchedQueue listing entry
40
41 Note! This could be turned into a SchedQueueDataEx class if we start
42 fetching all the fields from the scheduing queue.
43 """
44
45 def __init__(self):
46 ModelDataBase.__init__(self)
47
48 self.idItem = None
49 self.tsLastScheduled = None
50 self.sSchedGroup = None
51 self.sTestGroup = None
52 self.sTestCase = None
53 self.fUpToDate = None
54 self.iPerSchedGroupRowNumber = None;
55
56 def initFromDbRow(self, aoRow):
57 """
58 Re-initializes the object from a SchedQueueLogic::fetchForListing select.
59 Returns self. Raises exception if aoRow is None.
60 """
61 if aoRow is None:
62 raise TMExceptionBase('TestCaseQueue row not found.')
63
64 self.idItem = aoRow[0]
65 self.tsLastScheduled = aoRow[1]
66 self.sSchedGroup = aoRow[2]
67 self.sTestGroup = aoRow[3]
68 self.sTestCase = aoRow[4]
69 self.fUpToDate = aoRow[5]
70 self.iPerSchedGroupRowNumber = aoRow[6];
71 return self
72
73
74class SchedQueueLogic(ModelLogicBase):
75 """
76 SchedQueues logic.
77 """
78 def __init__(self, oDb):
79 ModelLogicBase.__init__(self, oDb)
80
81 def fetchForListing(self, iStart, cMaxRows, tsNow, aiSortColumns = None):
82 """
83 Fetches SchedQueues entries.
84
85 Returns an array (list) of SchedQueueEntry items, empty list if none.
86 Raises exception on error.
87 """
88 _, _ = tsNow, aiSortColumns
89 self._oDb.execute('''
90SELECT SchedQueues.idItem,
91 SchedQueues.tsLastScheduled,
92 SchedGroups.sName,
93 TestGroups.sName,
94 TestCases.sName,
95 SchedGroups.tsExpire = 'infinity'::TIMESTAMP
96 AND TestGroups.tsExpire = 'infinity'::TIMESTAMP
97 AND TestGroups.tsExpire = 'infinity'::TIMESTAMP
98 AND TestCaseArgs.tsExpire = 'infinity'::TIMESTAMP
99 AND TestCases.tsExpire = 'infinity'::TIMESTAMP AS fUpToDate,
100 ROW_NUMBER() OVER (PARTITION BY SchedQueues.idSchedGroup
101 ORDER BY SchedQueues.tsLastScheduled,
102 SchedQueues.idItem) AS iPerSchedGroupRowNumber
103FROM SchedQueues
104 INNER JOIN SchedGroups
105 ON SchedGroups.idSchedGroup = SchedQueues.idSchedGroup
106 AND SchedGroups.tsExpire > SchedQueues.tsConfig
107 AND SchedGroups.tsEffective <= SchedQueues.tsConfig
108 INNER JOIN TestGroups
109 ON TestGroups.idTestGroup = SchedQueues.idTestGroup
110 AND TestGroups.tsExpire > SchedQueues.tsConfig
111 AND TestGroups.tsEffective <= SchedQueues.tsConfig
112 INNER JOIN TestCaseArgs
113 ON TestCaseArgs.idGenTestCaseArgs = SchedQueues.idGenTestCaseArgs
114 INNER JOIN TestCases
115 ON TestCases.idTestCase = TestCaseArgs.idTestCase
116 AND TestCases.tsExpire > SchedQueues.tsConfig
117 AND TestCases.tsEffective <= SchedQueues.tsConfig
118ORDER BY iPerSchedGroupRowNumber,
119 SchedGroups.sName DESC
120LIMIT %s OFFSET %s''' % (cMaxRows, iStart,))
121 aoRows = []
122 for _ in range(self._oDb.getRowCount()):
123 aoRows.append(SchedQueueEntry().initFromDbRow(self._oDb.fetchOne()))
124 return aoRows
125
126#
127# Unit testing.
128#
129
130## @todo SchedQueueEntry isn't a typical ModelDataBase child (not fetching all
131## fields; is an extended data class mixing data from multiple tables), so
132## this won't work yet.
133#
134## pylint: disable=missing-docstring
135#class TestCaseQueueDataTestCase(ModelDataBaseTestCase):
136# def setUp(self):
137# self.aoSamples = [SchedQueueEntry(),]
138#
139#
140#if __name__ == '__main__':
141# unittest.main()
142# # not reached.
143#
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