1<?php
2
3/*
4	Phoronix Test Suite
5	URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
6	Copyright (C) 2016, Phoronix Media
7	Copyright (C) 2016, Michael Larabel
8
9	This program is free software; you can redistribute it and/or modify
10	it under the terms of the GNU General Public License as published by
11	the Free Software Foundation; either version 3 of the License, or
12	(at your option) any later version.
13
14	This program is distributed in the hope that it will be useful,
15	but WITHOUT ANY WARRANTY; without even the implied warranty of
16	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17	GNU General Public License for more details.
18
19	You should have received a copy of the GNU General Public License
20	along with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23
24class phoromatic_testing implements pts_webui_interface
25{
26	public static function page_title()
27	{
28		return 'Testing';
29	}
30	public static function page_header()
31	{
32		return null;
33	}
34	public static function preload($PAGE)
35	{
36		return true;
37	}
38	public static function render_page_process($PATH)
39	{
40		$main = null;
41		echo phoromatic_webui_header_logged_in();
42
43		$main = '<h1>Phoromatic Testing Options</h1><h2>Test Schedules</h2>
44			<p>Test schedules are used for tests that are intended to be run on a recurring basis -- either daily or other defined time period -- or whenever a trigger/event occurs, like a new Git commit to a software repository being tracked. Test schedules can be run on any given system(s)/group(s) and can be later edited.</p>';
45
46			if(!PHOROMATIC_USER_IS_VIEWER)
47			{
48				$main .= '
49				<hr />
50				<h2>Create A Schedule</h2>
51				<p><a href="?sched">Create a schedule</a> followed by adding tests/suites to run for that schedule on the selected systems.</p>';
52			}
53
54			$main .= '<hr /><h2>Current Schedules</h2>';
55
56			$main .= '<div class="pts_phoromatic_info_box_area">
57					<ul>
58						<li><h1>Active Test Schedules</h1></li>';
59
60					$stmt = phoromatic_server::$db->prepare('SELECT Title, ScheduleID, Description, RunTargetSystems, RunTargetGroups, RunAt, ActiveOn FROM phoromatic_schedules WHERE AccountID = :account_id AND State >= 1 ORDER BY Title ASC');
61					$stmt->bindValue(':account_id', $_SESSION['AccountID']);
62					$result = $stmt->execute();
63					$row = $result->fetchArray();
64
65					if($row == false)
66					{
67						$main .= '<li class="light" style="text-align: center;">No Schedules Found</li>';
68					}
69					else
70					{
71						do
72						{
73							$stmt_tests = phoromatic_server::$db->prepare('SELECT COUNT(*) AS TestCount FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TestProfile ASC');
74							$stmt_tests->bindValue(':account_id', $_SESSION['AccountID']);
75							$stmt_tests->bindValue(':schedule_id', $row['ScheduleID']);
76							$result_tests = $stmt_tests->execute();
77							$row_tests = $result_tests->fetchArray();
78							$test_count = !empty($row_tests) ? $row_tests['TestCount'] : 0;
79
80							$group_count = empty($row['RunTargetGroups']) ? 0 : count(explode(',', $row['RunTargetGroups']));
81							$main .= '<a href="?schedules/' . $row['ScheduleID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . pts_strings::plural_handler(count(phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $row['ScheduleID'])), 'System') . '</td><td>' . pts_strings::plural_handler($group_count, 'Group') . '</td><td>' . pts_strings::plural_handler($test_count, 'Test') . '</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID']), 'Result') . ' Total</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID'], 'TODAY'), 'Result') . ' Today</td><td><strong>' . phoromatic_schedule_activeon_string($row['ActiveOn'], $row['RunAt']) . '</strong></td></tr></table></li></a>';
82						}
83						while($row = $result->fetchArray());
84					}
85
86
87			$main .= '</ul>
88			</div>';
89
90			$stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND State >= 0 AND TicketIssueTime > :time_cutoff ORDER BY TicketIssueTime DESC LIMIT 30');
91			$stmt->bindValue(':account_id', $_SESSION['AccountID']);
92			$stmt->bindValue(':time_cutoff', (time() - (60 * 60 * 24 * 14)));
93			$result = $stmt->execute();
94			$right = '<ul><li>Benchmark Tickets</li>';
95
96			if($result)
97			{
98				$main .= '<div class="pts_phoromatic_info_box_area">
99						<ul>
100							<li><h1>Active Benchmark Tickets</h1></li>';
101
102				$row = $result->fetchArray();
103
104				if(!empty($row))
105				{
106					do
107					{
108						$main .= '<a href="?benchmark/' . $row['TicketID'] . '"><li>' . $row['Title'] . '</li></a>';
109					}
110					while($row = $result->fetchArray());
111				}
112				else
113				{
114					$main .= '<li class="light" style="text-align: center;">No Tickets Found</li>';
115				}
116			}
117			$main .= '</ul>
118			</div>';
119
120			if(!PHOROMATIC_USER_IS_VIEWER)
121			{
122				$main .= '
123				<hr />
124				<h2>Run A Benchmark</h2>
125				<p><a href="?benchmark">Run a benchmark</a> is the area where you can run a one-time benchmark on selected system(s) and is also where to go for setting up a stress-run benchmark.</p>
126				<hr />
127				<h2>Create A Suite</h2>
128				<p><a href="?build_suite">Build a suite</a>, which is a collection of predefined test profiles.</p>
129				<hr />
130				<h2>View Local Suites</h2>
131				<p><a href="?local_suites">See local suites</a> available for your benchmarking needs.</p>';
132			}
133
134
135			echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
136			echo phoromatic_webui_footer();
137	}
138}
139
140?>
141