summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Sippola <juhasippola@outlook.com>2015-09-21 16:20:56 +0300
committerTony Sarajärvi <tony.sarajarvi@theqtcompany.com>2015-09-23 09:39:14 +0000
commit0624492bcf28308982e4e3116adcfbc8da29799e (patch)
treeaa64d2e5df3cd8114ccbbb0de95b112ab60782d9
parent2eca1988760d8ab51d0cb2a2616ffa022a1647ea (diff)
Qt Metrics 2 (v0.28): Branch archiving
Added buttons to archive (and restore) a branch on the admin pages. Added field 'archived' to the branch table in the database. Change-Id: Idefddd15df02014ce70c5c4f981eb5938c4bf5f7 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@theqtcompany.com>
-rw-r--r--non-puppet/qtmetrics2/index.php50
-rw-r--r--non-puppet/qtmetrics2/scripts/admin.js73
-rw-r--r--non-puppet/qtmetrics2/src/Database.php78
-rw-r--r--non-puppet/qtmetrics2/src/DatabaseAdmin.php35
-rw-r--r--non-puppet/qtmetrics2/src/test/DatabaseAdminTest.php59
-rw-r--r--non-puppet/qtmetrics2/src/test/DatabaseTest.php211
-rw-r--r--non-puppet/qtmetrics2/templates/about.html4
-rw-r--r--non-puppet/qtmetrics2/templates/admin_branches.html75
-rw-r--r--non-puppet/qtmetrics2/testparser.pl1
9 files changed, 449 insertions, 137 deletions
diff --git a/non-puppet/qtmetrics2/index.php b/non-puppet/qtmetrics2/index.php
index 02a232f..fc4e3fb 100644
--- a/non-puppet/qtmetrics2/index.php
+++ b/non-puppet/qtmetrics2/index.php
@@ -34,7 +34,7 @@
/**
* Qt Metrics API
- * @since 15-09-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -713,6 +713,54 @@ $app->delete('/api/branch/:branch', function($branch) use($app)
})->name('delete_branch');
/**
+ * API route: /api/branch/archive (PUT) - authenticated
+ */
+
+$app->add(new HttpBasicAuthRoute('Protected Area', 'api/branch/archive'));
+$app->put('/api/branch/archive/:branch', function($branch) use($app)
+{
+ $branch = strip_tags($branch);
+ $branches = array();
+ $query = Factory::db()->getBranches();
+ foreach($query as $item) {
+ $branches[] = $item['name'];
+ }
+ if (in_array($branch, $branches)) {
+ $result = Factory::dbAdmin()->archiveBranch($branch);
+ if ($result)
+ $app->response()->status(200);
+ else
+ $app->response()->status(404);
+ } else {
+ $app->response()->status(404);
+ }
+})->name('archive_branch');
+
+/**
+ * API route: /api/branch/restore (PUT) - authenticated
+ */
+
+$app->add(new HttpBasicAuthRoute('Protected Area', 'api/branch/restore'));
+$app->put('/api/branch/restore/:branch', function($branch) use($app)
+{
+ $branch = strip_tags($branch);
+ $branches = array();
+ $query = Factory::db()->getBranches();
+ foreach($query as $item) {
+ $branches[] = $item['name'];
+ }
+ if (in_array($branch, $branches)) {
+ $result = Factory::dbAdmin()->restoreBranch($branch);
+ if ($result)
+ $app->response()->status(200);
+ else
+ $app->response()->status(404);
+ } else {
+ $app->response()->status(404);
+ }
+})->name('restore_branch');
+
+/**
* API route: /api/data (DELETE) - authenticated
*/
diff --git a/non-puppet/qtmetrics2/scripts/admin.js b/non-puppet/qtmetrics2/scripts/admin.js
index 090ae9c..589294b 100644
--- a/non-puppet/qtmetrics2/scripts/admin.js
+++ b/non-puppet/qtmetrics2/scripts/admin.js
@@ -34,33 +34,80 @@
/**
* Admin functions
- * @since 19-08-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
// Catch action confirmation from the modal
$('.modal .modal-footer button').on('click', function (e) {
- var buttonDiv;
+ var branchTag;
+ var branchName;
+ var removeButtonDiv;
+ var archiveButtonDiv;
var $target = $(e.target);
$(this).closest('.modal').on('hidden.bs.modal', function (e) {
// Remove branch
if ($target[0].id.search("confirm_branch_remove") === 0) {
- var branchTag = $target[0].id.substring($target[0].id.lastIndexOf('_') + 1);
- var branchName = $target[0].name;
- buttonDiv = '#' + branchTag + 'Button';
- $(buttonDiv).html("Removing...");
- // Send delete request and handle the response
+ branchTag = $target[0].id.substring($target[0].id.lastIndexOf('_') + 1);
+ branchName = $target[0].name;
+ removeButtonDiv = '#' + branchTag + 'RemoveButton';
+ archiveButtonDiv = '#' + branchTag + 'ArchiveButton';
+ $(removeButtonDiv).html("Removing...");
+ // Send request and handle the response
$.ajax({
url: "api/branch/" + branchName,
type: 'DELETE',
success: function(result) {
console.log(this.type + ": " + this.url + " done");
- $(buttonDiv).html("Removed");
+ $(removeButtonDiv).html("Removed");
+ $(archiveButtonDiv).html("");
+ },
+ error: function (request, status, error) {
+ console.log(this.type + ": " + this.url + " error (" + error + ")");
+ $(removeButtonDiv).html("Error!");
+ }
+ });
+ }
+
+ // Archive branch
+ if ($target[0].id.search("confirm_branch_archive") === 0) {
+ branchTag = $target[0].id.substring($target[0].id.lastIndexOf('_') + 1);
+ branchName = $target[0].name;
+ archiveButtonDiv = '#' + branchTag + 'ArchiveButton';
+ $(archiveButtonDiv).html("Archiving...");
+ // Send request and handle the response
+ $.ajax({
+ url: "api/branch/archive/" + branchName,
+ type: 'PUT',
+ success: function(result) {
+ console.log(this.type + ": " + this.url + " done");
+ $(archiveButtonDiv).html("Archived");
+ },
+ error: function (request, status, error) {
+ console.log(this.type + ": " + this.url + " error (" + error + ")");
+ $(archiveButtonDiv).html("Error!");
+ }
+ });
+ }
+
+ // Restore branch
+ if ($target[0].id.search("confirm_branch_restore") === 0) {
+ branchTag = $target[0].id.substring($target[0].id.lastIndexOf('_') + 1);
+ branchName = $target[0].name;
+ archiveButtonDiv = '#' + branchTag + 'ArchiveButton';
+ $(archiveButtonDiv).html("Restoring...");
+ // Send request and handle the response
+ $.ajax({
+ url: "api/branch/restore/" + branchName,
+ type: 'PUT',
+ success: function(result) {
+ console.log(this.type + ": " + this.url + " done");
+ $(archiveButtonDiv).html("Restored");
},
error: function (request, status, error) {
console.log(this.type + ": " + this.url + " error (" + error + ")");
- $(buttonDiv).html("Error!");
+ $(archiveButtonDiv).html("Error!");
}
});
}
@@ -69,19 +116,19 @@ $('.modal .modal-footer button').on('click', function (e) {
if ($target[0].id.search("confirm_data_remove") === 0) {
var dataDate = $target[0].id.substring($target[0].id.lastIndexOf('_') + 1);
var dataState = $target[0].name;
- buttonDiv = '#' + dataState + '-' + dataDate + 'Button';
- $(buttonDiv).html("Removing...");
+ removeButtonDiv = '#' + dataState + '-' + dataDate + 'Button';
+ $(removeButtonDiv).html("Removing...");
// Send delete request and handle the response
$.ajax({
url: "api/data/" + dataState + "/" + dataDate,
type: 'DELETE',
success: function(result) {
console.log(this.type + ": " + this.url + " done");
- $(buttonDiv).html("Removed");
+ $(removeButtonDiv).html("Removed");
},
error: function (request, status, error) {
console.log(this.type + ": " + this.url + " error (" + error + ")");
- $(buttonDiv).html("Error!");
+ $(removeButtonDiv).html("Error!");
}
});
}
diff --git a/non-puppet/qtmetrics2/src/Database.php b/non-puppet/qtmetrics2/src/Database.php
index c589a3d..675779f 100644
--- a/non-puppet/qtmetrics2/src/Database.php
+++ b/non-puppet/qtmetrics2/src/Database.php
@@ -34,7 +34,7 @@
/**
* Database class
- * @since 15-09-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -76,15 +76,18 @@ class Database {
/**
* Get list of branches
- * @return array (string name)
+ * @return array (string name, bool archived)
*/
public function getBranches()
{
$result = array();
- $query = $this->db->prepare("SELECT name FROM branch ORDER BY name");
+ $query = $this->db->prepare("SELECT name, archived FROM branch ORDER BY name");
$query->execute(array());
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $result[] = array('name' => $row['name']);
+ $result[] = array(
+ 'name' => $row['name'],
+ 'archived' => $row['archived']
+ );
}
return $result;
}
@@ -219,10 +222,12 @@ class Database {
$query = $this->db->prepare("
SELECT build_key AS latest_build
FROM project_run
+ INNER JOIN branch ON project_run.branch_id = branch.id
WHERE
project_id = (SELECT id FROM project WHERE name = ?) AND
branch_id = (SELECT id FROM branch WHERE name = ?) AND
- state_id = (SELECT id FROM state WHERE name = ?)
+ state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY timestamp DESC
LIMIT 1
");
@@ -279,12 +284,13 @@ class Database {
project_run.timestamp,
project_run.duration
FROM project_run
- INNER JOIN branch ON branch_id = branch.id
+ INNER JOIN branch ON project_run.branch_id = branch.id
WHERE
project_id = (SELECT id FROM project WHERE name = ?) AND
state_id = (SELECT id FROM state WHERE name = ?) AND
branch_id = (SELECT id FROM branch WHERE name = ?) AND
- build_key = ?;
+ build_key = ? AND
+ branch.archived = 0;
");
$query->execute(array(
$runProject,
@@ -335,7 +341,8 @@ class Database {
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
project_run.branch_id = (SELECT id from branch WHERE name = ?) AND
- project_run.build_key = ?;
+ project_run.build_key = ? AND
+ branch.archived = 0;
");
$query->execute(array(
$conf,
@@ -389,7 +396,8 @@ class Database {
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
project_run.branch_id = (SELECT id from branch WHERE name = ?) AND
- project_run.build_key = ?
+ project_run.build_key = ? AND
+ branch.archived = 0
GROUP BY project.name;
");
$query->execute(array(
@@ -445,7 +453,8 @@ class Database {
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
project_run.branch_id = (SELECT id from branch WHERE name = ?) AND
- project_run.build_key = ?
+ project_run.build_key = ? AND
+ branch.archived = 0
GROUP BY project.name;
");
$query->execute(array(
@@ -497,7 +506,8 @@ class Database {
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
project_run.branch_id = (SELECT id from branch WHERE name = ?) AND
- project_run.build_key = ?;
+ project_run.build_key = ? AND
+ branch.archived = 0;
");
$query->execute(array(
$testset,
@@ -541,11 +551,13 @@ class Database {
INNER JOIN project ON testset.project_id = project.id
INNER JOIN conf_run ON testset_run.conf_run_id = conf_run.id
INNER JOIN project_run ON conf_run.project_run_id = project_run.id
+ INNER JOIN branch ON project_run.branch_id = branch.id
INNER JOIN state ON project_run.state_id = state.id
WHERE
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
- project_run.timestamp >= ?
+ project_run.timestamp >= ? AND
+ branch.archived = 0
GROUP BY testset.name
ORDER BY failed DESC, testset.name ASC
LIMIT ?;
@@ -591,13 +603,15 @@ class Database {
INNER JOIN project ON testset.project_id = project.id
INNER JOIN conf_run ON testset_run.conf_run_id = conf_run.id
INNER JOIN project_run ON conf_run.project_run_id = project_run.id
+ INNER JOIN branch ON project_run.branch_id = branch.id
INNER JOIN state ON project_run.state_id = state.id
WHERE
project.name = ? AND
testset.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
- project_run.timestamp >= ?
+ project_run.timestamp >= ? AND
+ branch.archived = 0
GROUP BY testset.name
ORDER BY project.name;
");
@@ -640,10 +654,12 @@ class Database {
INNER JOIN project ON testset.project_id = project.id
INNER JOIN conf_run ON testset_run.conf_run_id = conf_run.id
INNER JOIN project_run ON conf_run.project_run_id = project_run.id
+ INNER JOIN branch ON project_run.branch_id = branch.id
WHERE
project_run.timestamp >= ? AND
testset_run.run > 1 AND
- testset_run.result LIKE '%passed'
+ testset_run.result LIKE '%passed' AND
+ branch.archived = 0
ORDER BY project.name, testset.name;
");
$query->execute(array(
@@ -715,10 +731,12 @@ class Database {
INNER JOIN project ON testset.project_id = project.id
INNER JOIN conf_run ON testset_run.conf_run_id = conf_run.id
INNER JOIN project_run ON conf_run.project_run_id = project_run.id
+ INNER JOIN branch ON project_run.branch_id = branch.id
WHERE
project.name = ? AND
testset.name = ? AND
- project_run.timestamp >= ?
+ project_run.timestamp >= ? AND
+ branch.archived = 0
GROUP BY testset.name
ORDER BY project.name;
');
@@ -756,7 +774,8 @@ class Database {
INNER JOIN branch ON project_run.branch_id = branch.id
WHERE
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, project_run.timestamp DESC;
");
$query->execute(array(
@@ -798,7 +817,8 @@ class Database {
INNER JOIN branch ON project_run.branch_id = branch.id
WHERE
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, conf, project_run.timestamp DESC;
");
$query->execute(array(
@@ -847,7 +867,8 @@ class Database {
WHERE
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
- conf.target_id IN (SELECT id FROM platform WHERE os = ?)
+ conf.target_id IN (SELECT id FROM platform WHERE os = ?) AND
+ branch.archived = 0
ORDER BY branch.name, conf, project_run.timestamp DESC;
");
$query->execute(array(
@@ -897,7 +918,8 @@ class Database {
WHERE
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
- conf.name = ?
+ conf.name = ? AND
+ branch.archived = 0
ORDER BY branch.name, conf, project_run.timestamp DESC;
");
$query->execute(array(
@@ -951,7 +973,8 @@ class Database {
testset.name = ? AND
project.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, conf.name, project_run.timestamp DESC;
");
$query->execute(array(
@@ -1003,7 +1026,8 @@ class Database {
WHERE
project.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
GROUP BY branch.name, project_run.build_key, conf.name
ORDER BY branch.name, conf.name, project_run.build_key DESC;
");
@@ -1058,7 +1082,8 @@ class Database {
testset_run.result LIKE '%failed' AND
conf.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, project.name, testset.name, project_run.build_key DESC;
");
$query->execute(array(
@@ -1115,7 +1140,8 @@ class Database {
project.name = ? AND
conf.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, testset.name, project_run.build_key DESC;
");
$query->execute(array(
@@ -1175,7 +1201,8 @@ class Database {
project.name = ? AND
conf.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, testfunction.name, project_run.build_key DESC;
");
$query->execute(array(
@@ -1237,7 +1264,8 @@ class Database {
project.name = ? AND
conf.name = ? AND
project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
- project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ project_run.state_id = (SELECT id FROM state WHERE name = ?) AND
+ branch.archived = 0
ORDER BY branch.name, testrow.name, project_run.build_key DESC;
");
$query->execute(array(
diff --git a/non-puppet/qtmetrics2/src/DatabaseAdmin.php b/non-puppet/qtmetrics2/src/DatabaseAdmin.php
index a5965ad..30ababb 100644
--- a/non-puppet/qtmetrics2/src/DatabaseAdmin.php
+++ b/non-puppet/qtmetrics2/src/DatabaseAdmin.php
@@ -34,7 +34,7 @@
/**
* DatabaseAdmin class
- * @since 17-08-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -129,6 +129,7 @@ class DatabaseAdmin {
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$result[] = array(
'name' => $branch['name'],
+ 'archived' => $branch['archived'],
'runCount' => $row['runCount'],
'latestRun' => $row['latestRun']
);
@@ -447,6 +448,38 @@ class DatabaseAdmin {
}
/**
+ * Set archived flag for the branch
+ * @param string $branch
+ * @return bool
+ */
+ public function archiveBranch($branch)
+ {
+ $query = $this->db->prepare("
+ UPDATE branch SET archived = 1 WHERE name = ?
+ ");
+ $result = $query->execute(array(
+ $branch
+ ));
+ return $result;
+ }
+
+ /**
+ * Clear archived flag for the branch
+ * @param string $branch
+ * @return bool
+ */
+ public function restoreBranch($branch)
+ {
+ $query = $this->db->prepare("
+ UPDATE branch SET archived = 0 WHERE name = ?
+ ");
+ $result = $query->execute(array(
+ $branch
+ ));
+ return $result;
+ }
+
+ /**
* Delete all build runs from selected date in selected state
* @param string $state
* @param string $date
diff --git a/non-puppet/qtmetrics2/src/test/DatabaseAdminTest.php b/non-puppet/qtmetrics2/src/test/DatabaseAdminTest.php
index a3a8c1e..3e1b1e0 100644
--- a/non-puppet/qtmetrics2/src/test/DatabaseAdminTest.php
+++ b/non-puppet/qtmetrics2/src/test/DatabaseAdminTest.php
@@ -38,7 +38,7 @@ require_once(__DIR__.'/../Factory.php');
* DatabaseAdmin unit test class
* Some of the tests require the test data as inserted into database with qtmetrics_insert.sql
* @example To run (in qtmetrics root directory): php <path-to-phpunit>/phpunit.phar ./src/test
- * @since 19-08-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -108,6 +108,7 @@ class DatabaseAdminTest extends PHPUnit_Framework_TestCase
$this->assertNotEmpty($result);
foreach($result as $row) {
$this->assertArrayHasKey('name', $row);
+ $this->assertArrayHasKey('archived', $row);
$this->assertArrayHasKey('runCount', $row);
$this->assertArrayHasKey('latestRun', $row);
$items[] = $row['name'];
@@ -353,7 +354,7 @@ class DatabaseAdminTest extends PHPUnit_Framework_TestCase
$db = Factory::db();
$dbAdmin = Factory::dbAdmin();
// Check that xxx_run tables have data initially
- if ($step == 'first') {
+ if ($step === 'first') {
$result = $dbAdmin->getTablesStatistics();
foreach($result as $row) {
if (strpos($row['name'],'_run') !== false) {
@@ -407,7 +408,7 @@ class DatabaseAdminTest extends PHPUnit_Framework_TestCase
}
$this->assertNotContains($branch, $branches);
// Check that xxx_run tables are empty
- if ($step == 'last') {
+ if ($step === 'last') {
$result = $dbAdmin->getTablesStatistics();
foreach($result as $row) {
if (strpos($row['name'],'_run') !== false) {
@@ -429,6 +430,54 @@ class DatabaseAdminTest extends PHPUnit_Framework_TestCase
}
/**
+ * Test archiveBranch and restoreBranch
+ * @dataProvider testArchiveRestoreBranchData
+ */
+ public function testArchiveRestoreBranch($branch, $originalArchived)
+ {
+ $db = Factory::db();
+ $dbAdmin = Factory::dbAdmin();
+ // Set restored to start testing
+ $result = $dbAdmin->restoreBranch($branch);
+ $result = $db->getBranches();
+ foreach($result as $row) {
+ if ($row['name'] === $branch)
+ $this->assertEquals(0, $row['archived']);
+ }
+ // Test archiveBranch
+ $result = $dbAdmin->archiveBranch($branch);
+ $this->assertTrue($result);
+ $result = $db->getBranches();
+ foreach($result as $row) {
+ if ($row['name'] === $branch)
+ $this->assertEquals(1, $row['archived']);
+ }
+ // Test restoreBranch
+ $result = $dbAdmin->restoreBranch($branch);
+ $this->assertTrue($result);
+ $result = $db->getBranches();
+ foreach($result as $row) {
+ if ($row['name'] === $branch)
+ $this->assertEquals(0, $row['archived']);
+ }
+ // Revert to original value (to not prevent other testing)
+ if ($originalArchived)
+ $result = $dbAdmin->archiveBranch($branch);
+ else
+ $result = $dbAdmin->restoreBranch($branch);
+ }
+ public function testArchiveRestoreBranchData()
+ {
+ return array(
+ array('dev', 0),
+ array('stable', 0),
+ array('release', 1),
+ array('master', 0),
+ array('1.2.3', 0)
+ );
+ }
+
+ /**
* Test deleteRunsData and deleteProjectRunData
* @dataProvider testDeleteRunsDataData
*/
@@ -437,7 +486,7 @@ class DatabaseAdminTest extends PHPUnit_Framework_TestCase
if (self::DELETE_TEST_TYPE === self::DELETE_RUN_DATA) {
$db = Factory::db();
$dbAdmin = Factory::dbAdmin();
- if ($step == 'first') {
+ if ($step === 'first') {
// Check that xxx_run tables have data
$result = $dbAdmin->getTablesStatistics();
foreach($result as $row) {
@@ -464,7 +513,7 @@ class DatabaseAdminTest extends PHPUnit_Framework_TestCase
$dates[] = substr($row['timestamp'], 0, strlen('2015-08-01'));
}
$this->assertNotContains($date, $dates);
- if ($step == 'last') {
+ if ($step === 'last') {
// Check that xxx_run tables are empty
$result = $dbAdmin->getTablesStatistics();
foreach($result as $row) {
diff --git a/non-puppet/qtmetrics2/src/test/DatabaseTest.php b/non-puppet/qtmetrics2/src/test/DatabaseTest.php
index 69f5058..e8725f8 100644
--- a/non-puppet/qtmetrics2/src/test/DatabaseTest.php
+++ b/non-puppet/qtmetrics2/src/test/DatabaseTest.php
@@ -38,7 +38,7 @@ require_once(__DIR__.'/../Factory.php');
* Database unit test class
* Some of the tests require the test data as inserted into database with qtmetrics_insert.sql
* @example To run (in qtmetrics root directory): php <path-to-phpunit>/phpunit.phar ./src/test
- * @since 15-09-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -73,7 +73,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getBranches
* @dataProvider testGetBranchesData
*/
- public function testGetBranches($exp_branch)
+ public function testGetBranches($exp_branch, $exp_archived)
{
$items = array();
$db = Factory::db();
@@ -81,14 +81,19 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$this->assertNotEmpty($result);
foreach($result as $row) {
$this->assertArrayHasKey('name', $row);
+ $this->assertArrayHasKey('archived', $row);
$items[] = $row['name'];
+ if ($row['name'] === $exp_branch)
+ $this->assertEquals($exp_archived, $row['archived']);
}
$this->assertContains($exp_branch, $items);
}
public function testGetBranchesData()
{
return array(
- array('dev')
+ array('dev', 0),
+ array('stable', 0),
+ array('release', 1)
);
}
@@ -222,7 +227,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestProjectBranchBuildKeys
* @dataProvider testGetLatestProjectBranchBuildKeysData
*/
- public function testGetLatestProjectBranchBuildKeys($project, $state, $exp_branch, $exp_build_key)
+ public function testGetLatestProjectBranchBuildKeys($project, $state, $exp_branch, $exp_build_key, $exp_archived)
{
$branches = array();
$db = Factory::db();
@@ -236,15 +241,18 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$branches[] = $row['name'];
}
}
- $this->assertContains($exp_branch, $branches);
+ if ($exp_archived)
+ $this->assertNotContains($exp_branch, $branches);
+ else
+ $this->assertContains($exp_branch, $branches);
}
public function testGetLatestProjectBranchBuildKeysData()
{
return array(
- array('Qt5', 'state', 'master', '4777'), // based on test data
- array('Qt5', 'state', 'dev', 'BuildKeyInStringFormat12345'),
- array('Qt5', 'state', 'release', '157'),
- array('Qt5', 'state', 'stable', '1348')
+ array('Qt5', 'state', 'master', '4777', 0), // based on test data
+ array('Qt5', 'state', 'dev', 'BuildKeyInStringFormat12345', 0),
+ array('Qt5', 'state', 'release', '157', 1),
+ array('Qt5', 'state', 'stable', '1348', 0)
);
}
@@ -252,20 +260,24 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestProjectBranchBuildKey
* @dataProvider testGetLatestProjectBranchBuildKeyData
*/
- public function testGetLatestProjectBranchBuildKey($project, $branch, $state, $exp_build_key)
+ public function testGetLatestProjectBranchBuildKey($project, $branch, $state, $exp_build_key, $exp_archived)
{
$db = Factory::db();
$result = $db->getLatestProjectBranchBuildKey($project, $branch, $state);
- $this->assertNotEmpty($result);
- $this->assertEquals($exp_build_key, $result);
+ if ($exp_archived) {
+ $this->assertEmpty($result);
+ } else {
+ $this->assertNotEmpty($result);
+ $this->assertEquals($exp_build_key, $result);
+ }
}
public function testGetLatestProjectBranchBuildKeyData()
{
return array(
- array('Qt5', 'master', 'state', '4777'), // based on test data
- array('Qt5', 'dev', 'state', 'BuildKeyInStringFormat12345'),
- array('Qt5', 'release', 'state', '157'),
- array('Qt5', 'stable', 'state', '1348')
+ array('Qt5', 'master', 'state', '4777', 0), // based on test data
+ array('Qt5', 'dev', 'state', 'BuildKeyInStringFormat12345', 0),
+ array('Qt5', 'release', 'state', '157', 1),
+ array('Qt5', 'stable', 'state', '1348', 0)
);
}
@@ -273,7 +285,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestProjectBranchBuildResults
* @dataProvider testGetLatestProjectBranchBuildResultsData
*/
- public function testGetLatestProjectBranchBuildResults($project, $state, $exp_branch, $exp_results)
+ public function testGetLatestProjectBranchBuildResults($project, $state, $exp_branch, $exp_results, $exp_archived)
{
$branches = array();
$db = Factory::db();
@@ -288,12 +300,16 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$this->assertContains($row['result'], $exp_results);
$branches[] = $row['name'];
}
- $this->assertContains($exp_branch, $branches);
+ if ($exp_archived)
+ $this->assertNotContains($exp_branch, $branches);
+ else
+ $this->assertContains($exp_branch, $branches);
}
public function testGetLatestProjectBranchBuildResultsData()
{
return array(
- array('Qt5', 'state', 'dev', array('SUCCESS', 'FAILURE', 'ABORTED'))
+ array('Qt5', 'state', 'dev', array('SUCCESS', 'FAILURE', 'ABORTED'), 0),
+ array('Qt5', 'state', 'release', array('SUCCESS', 'FAILURE', 'ABORTED'), 1)
);
}
@@ -301,7 +317,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestConfBranchBuildResults
* @dataProvider testGetLatestConfBranchBuildResultsData
*/
- public function testGetLatestConfBranchBuildResults($conf, $project, $state, $exp_branch, $exp_results)
+ public function testGetLatestConfBranchBuildResults($conf, $project, $state, $exp_branch, $exp_results, $exp_archived)
{
$branches = array();
$db = Factory::db();
@@ -318,15 +334,18 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$this->assertContains($row['result'], $exp_results);
$branches[] = $row['name'];
}
- $this->assertContains($exp_branch, $branches);
+ if ($exp_archived)
+ $this->assertNotContains($exp_branch, $branches);
+ else
+ $this->assertContains($exp_branch, $branches);
}
public function testGetLatestConfBranchBuildResultsData()
{
return array(
- array('linux-g++-32_developer-build_Ubuntu_10.04_x86', 'Qt5', 'state', 'dev', array('SUCCESS', 'FAILURE', 'ABORTED')),
- array('win32-msvc2010_developer-build_angle_Windows_7', 'Qt5', 'state', 'master', array('SUCCESS', 'FAILURE', 'ABORTED')),
- array('win32-msvc2010_developer-build_angle_Windows_7', 'Qt5', 'state', 'release', array('SUCCESS', 'FAILURE', 'ABORTED')),
- array('win32-msvc2010_developer-build_angle_Windows_7', 'Qt5', 'state', 'stable', array('SUCCESS', 'FAILURE', 'ABORTED'))
+ array('linux-g++-32_developer-build_Ubuntu_10.04_x86', 'Qt5', 'state', 'dev', array('SUCCESS', 'FAILURE', 'ABORTED'), 0),
+ array('win32-msvc2010_developer-build_angle_Windows_7', 'Qt5', 'state', 'master', array('SUCCESS', 'FAILURE', 'ABORTED'), 0),
+ array('win32-msvc2010_developer-build_angle_Windows_7', 'Qt5', 'state', 'release', array('SUCCESS', 'FAILURE', 'ABORTED'), 1),
+ array('win32-msvc2010_developer-build_angle_Windows_7', 'Qt5', 'state', 'stable', array('SUCCESS', 'FAILURE', 'ABORTED'), 0)
);
}
@@ -334,7 +353,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestProjectBranchTestsetResults
* @dataProvider testGetLatestProjectBranchTestsetResultsData
*/
- public function testGetLatestProjectBranchTestsetResults($runProject, $runState, $exp_branches)
+ public function testGetLatestProjectBranchTestsetResults($runProject, $runState, $exp_branches, $exp_achived_branches)
{
$confs = array();
$db = Factory::db();
@@ -348,12 +367,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('passed', $row);
$this->assertArrayHasKey('failed', $row);
$this->assertContains($row['branch'], $exp_branches);
+ $this->assertNotContains($row['branch'], $exp_achived_branches);
}
}
public function testGetLatestProjectBranchTestsetResultsData()
{
return array(
- array('Qt5', 'state', array('dev', 'stable', 'master'))
+ array('Qt5', 'state', array('dev', 'stable', 'master'), array('release'))
);
}
@@ -361,7 +381,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestTestsetProjectBranchTestsetResults
* @dataProvider testGetLatestTestsetProjectBranchTestsetResultsData
*/
- public function testGetLatestTestsetProjectBranchTestsetResults($testsetProject, $runProject, $runState, $exp_branches)
+ public function testGetLatestTestsetProjectBranchTestsetResults($testsetProject, $runProject, $runState, $exp_branches, $exp_achived_branches)
{
$confs = array();
$db = Factory::db();
@@ -375,12 +395,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('passed', $row);
$this->assertArrayHasKey('failed', $row);
$this->assertContains($row['branch'], $exp_branches);
+ $this->assertNotContains($row['branch'], $exp_achived_branches);
}
}
public function testGetLatestTestsetProjectBranchTestsetResultsData()
{
return array(
- array('qtbase', 'Qt5', 'state', array('dev', 'stable', 'master'))
+ array('qtbase', 'Qt5', 'state', array('dev', 'stable', 'master'), array('release'))
);
}
@@ -388,7 +409,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getLatestTestsetConfBuildResults
* @dataProvider testGetLatestTestsetConfBuildResultsData
*/
- public function testGetLatestTestsetConfBuildResults($testset, $testsetProject, $runProject, $runState, $exp_conf, $exp_branches, $exp_results)
+ public function testGetLatestTestsetConfBuildResults($testset, $testsetProject, $runProject, $runState, $exp_conf, $exp_branches, $exp_achived_branches, $exp_results)
{
$confs = array();
$db = Factory::db();
@@ -399,6 +420,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('branch', $row);
$this->assertArrayHasKey('result', $row);
$this->assertContains($row['branch'], $exp_branches);
+ $this->assertNotContains($row['branch'], $exp_achived_branches);
$this->assertContains($row['result'], $exp_results);
$confs[] = $row['name'];
}
@@ -407,9 +429,18 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
public function testGetLatestTestsetConfBuildResultsData()
{
return array(
- array('tst_qftp', 'qtbase', 'Qt5', 'state', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', array('dev', 'stable', 'master'), array('passed', 'failed', 'ipassed', 'ifailed')),
- array('tst_qftp', 'qtbase', 'Qt5', 'state', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', array('dev', 'stable', 'master'), array('passed', 'failed', 'ipassed', 'ifailed')),
- array('tst_qfont', 'qtbase', 'Qt5', 'state', 'macx-clang_developer-build_OSX_10.8', array('dev', 'stable', 'master'), array('passed', 'failed', 'ipassed', 'ifailed'))
+ array('tst_qftp', 'qtbase', 'Qt5', 'state', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64',
+ array('dev', 'stable', 'master'),
+ array('release'),
+ array('passed', 'failed', 'ipassed', 'ifailed')),
+ array('tst_qftp', 'qtbase', 'Qt5', 'state', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64',
+ array('dev', 'stable', 'master'),
+ array('release'),
+ array('passed', 'failed', 'ipassed', 'ifailed')),
+ array('tst_qfont', 'qtbase', 'Qt5', 'state', 'macx-clang_developer-build_OSX_10.8',
+ array('dev', 'stable', 'master'),
+ array('release'),
+ array('passed', 'failed', 'ipassed', 'ifailed'))
);
}
@@ -572,7 +603,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getProjectBuildsByBranch
* @dataProvider testGetProjectBuildsByBranchData
*/
- public function testGetProjectBuildsByBranch($runProject, $runState, $exp_branch, $exp_key, $has_data)
+ public function testGetProjectBuildsByBranch($runProject, $runState, $exp_branch, $exp_key, $exp_archived, $has_data)
{
$branches = array();
$keys = array();
@@ -587,8 +618,12 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
}
if ($has_data) {
$this->assertNotEmpty($result);
- $this->assertContains($exp_branch, $branches);
- $this->assertContains($exp_key, $keys);
+ if ($exp_archived) {
+ $this->assertNotContains($exp_branch, $branches);
+ } else {
+ $this->assertContains($exp_branch, $branches);
+ $this->assertContains($exp_key, $keys);
+ }
} else {
$this->assertEmpty($result);
}
@@ -596,12 +631,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
public function testGetProjectBuildsByBranchData()
{
return array(
- array('Qt5', 'state', 'dev', '1023', 1),
- array('Qt5', 'state', 'stable', '1348', 1),
- array('Qt5', 'state', 'stable', '1348', 1),
- array('Qt5', 'state', 'stable', '1348', 1),
- array('Qt5', 'state', 'dev', 'BuildKeyInStringFormat12345', 1),
- array('Qt5', 'invalid', '', '', 0)
+ array('Qt5', 'state', 'dev', '1023', 0, 1),
+ array('Qt5', 'state', 'stable', '1348', 0, 1),
+ array('Qt5', 'state', 'stable', '1348', 0, 1),
+ array('Qt5', 'state', 'stable', '1348', 0, 1),
+ array('Qt5', 'state', 'dev', 'BuildKeyInStringFormat12345', 0, 1),
+ array('Qt5', 'state', 'release', '157', 1, 1),
+ array('Qt5', 'invalid', '', '', 0, 0)
);
}
@@ -609,7 +645,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getConfBuildsByBranch
* @dataProvider testGetConfBuildsByBranchData
*/
- public function testGetConfBuildsByBranch($runProject, $runState, $exp_branch, $exp_conf, $exp_key, $exp_result, $has_data)
+ public function testGetConfBuildsByBranch($runProject, $runState, $exp_branch, $exp_conf, $exp_key, $exp_result, $exp_archived, $has_data)
{
$branches = array();
$confs = array();
@@ -633,10 +669,14 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
}
if ($has_data) {
$this->assertNotEmpty($result);
- $this->assertContains($exp_branch, $branches);
- $this->assertContains($exp_conf, $confs);
- $this->assertContains($exp_key, $keys);
- $this->assertContains($exp_result, $results);
+ if ($exp_archived) {
+ $this->assertNotContains($exp_branch, $branches);
+ } else {
+ $this->assertContains($exp_branch, $branches);
+ $this->assertContains($exp_conf, $confs);
+ $this->assertContains($exp_key, $keys);
+ $this->assertContains($exp_result, $results);
+ }
} else {
$this->assertEmpty($result);
}
@@ -644,11 +684,12 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
public function testGetConfBuildsByBranchData()
{
return array(
- array('Qt5', 'state', 'dev', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', '1023', 'FAILURE', 1),
- array('Qt5', 'state', 'stable', 'win32-msvc2010_developer-build_angle_Windows_7', '1348', 'SUCCESS', 1),
- array('Qt5', 'state', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 1),
- array('Qt5', 'state', 'dev', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'BuildKeyInStringFormat12345', 'FAILURE', 1),
- array('Qt5', 'invalid', '', '', '', '', 0)
+ array('Qt5', 'state', 'dev', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', '1023', 'FAILURE', 0, 1),
+ array('Qt5', 'state', 'stable', 'win32-msvc2010_developer-build_angle_Windows_7', '1348', 'SUCCESS', 0, 1),
+ array('Qt5', 'state', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 0, 1),
+ array('Qt5', 'state', 'dev', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'BuildKeyInStringFormat12345', 'FAILURE', 0, 1),
+ array('Qt5', 'state', 'release', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', '157', 'SUCCESS', 1, 1),
+ array('Qt5', 'invalid', '', '', '', '', 0, 0)
);
}
@@ -656,7 +697,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getConfOsBuildsByBranch
* @dataProvider testGetConfOsBuildsByBranchData
*/
- public function testGetConfOsBuildsByBranch($runProject, $runState, $targetOs, $exp_branch, $exp_conf, $exp_key, $exp_result, $has_data, $has_conf)
+ public function testGetConfOsBuildsByBranch($runProject, $runState, $targetOs, $exp_branch, $exp_conf, $exp_key, $exp_result, $exp_archived, $has_data, $has_conf)
{
$branches = array();
$confs = array();
@@ -680,13 +721,17 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
}
if ($has_data) {
$this->assertNotEmpty($result);
- $this->assertContains($exp_branch, $branches);
- if ($has_conf)
- $this->assertContains($exp_conf, $confs);
- else
- $this->assertNotContains($exp_conf, $confs);
- $this->assertContains($exp_key, $keys);
- $this->assertContains($exp_result, $results);
+ if ($exp_archived) {
+ $this->assertNotContains($exp_branch, $branches);
+ } else {
+ $this->assertContains($exp_branch, $branches);
+ if ($has_conf)
+ $this->assertContains($exp_conf, $confs);
+ else
+ $this->assertNotContains($exp_conf, $confs);
+ $this->assertContains($exp_key, $keys);
+ $this->assertContains($exp_result, $results);
+ }
} else {
$this->assertEmpty($result);
}
@@ -694,12 +739,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
public function testGetConfOsBuildsByBranchData()
{
return array(
- array('Qt5', 'state', 'linux', 'dev', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', '1023', 'FAILURE', 1, 1),
- array('Qt5', 'state', 'linux', 'dev', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'BuildKeyInStringFormat12345', 'FAILURE', 1, 1),
- array('Qt5', 'state', 'windows', 'stable', 'win32-msvc2010_developer-build_angle_Windows_7', '1348', 'SUCCESS', 1, 1),
- array('Qt5', 'state', 'osx', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 1, 1),
- array('Qt5', 'state', 'linux', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 1, 0),
- array('Qt5', 'state', 'invalid', '', '', '', '', 0, 0)
+ array('Qt5', 'state', 'linux', 'dev', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', '1023', 'FAILURE', 0, 1, 1),
+ array('Qt5', 'state', 'linux', 'dev', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'BuildKeyInStringFormat12345', 'FAILURE', 0, 1, 1),
+ array('Qt5', 'state', 'windows', 'stable', 'win32-msvc2010_developer-build_angle_Windows_7', '1348', 'SUCCESS', 0, 1, 1),
+ array('Qt5', 'state', 'osx', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 0, 1, 1),
+ array('Qt5', 'state', 'linux', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 0, 1, 0),
+ array('Qt5', 'state', 'linux', 'release', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', '157', 'SUCCESS', 1, 1, 1),
+ array('Qt5', 'state', 'invalid', '', '', '', '', 0, 0, 0)
);
}
@@ -707,7 +753,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
* Test getConfBuildByBranch
* @dataProvider testGetConfBuildByBranchData
*/
- public function testGetConfBuildByBranch($runProject, $runState, $conf, $exp_branch, $exp_conf, $exp_key, $exp_result, $has_data, $has_conf)
+ public function testGetConfBuildByBranch($runProject, $runState, $conf, $exp_branch, $exp_conf, $exp_key, $exp_result, $exp_archived, $has_data, $has_conf)
{
$branches = array();
$confs = array();
@@ -731,13 +777,17 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
}
if ($has_data) {
$this->assertNotEmpty($result);
- $this->assertContains($exp_branch, $branches);
- if ($has_conf)
- $this->assertContains($exp_conf, $confs);
- else
- $this->assertNotContains($exp_conf, $confs);
- $this->assertContains($exp_key, $keys);
- $this->assertContains($exp_result, $results);
+ if ($exp_archived) {
+ $this->assertNotContains($exp_branch, $branches);
+ } else {
+ $this->assertContains($exp_branch, $branches);
+ if ($has_conf)
+ $this->assertContains($exp_conf, $confs);
+ else
+ $this->assertNotContains($exp_conf, $confs);
+ $this->assertContains($exp_key, $keys);
+ $this->assertContains($exp_result, $results);
+ }
} else {
$this->assertEmpty($result);
}
@@ -745,12 +795,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
public function testGetConfBuildByBranchData()
{
return array(
- array('Qt5', 'state', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', 'dev', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', '1023', 'FAILURE', 1, 1),
- array('Qt5', 'state', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'dev', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'BuildKeyInStringFormat12345', 'FAILURE', 1, 1),
- array('Qt5', 'state', 'win32-msvc2010_developer-build_angle_Windows_7', 'stable', 'win32-msvc2010_developer-build_angle_Windows_7', '1348', 'SUCCESS', 1, 1),
- array('Qt5', 'state', 'macx-clang_developer-build_OSX_10.8', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 1, 1),
- array('Qt5', 'state', 'win32-msvc2010_developer-build_angle_Windows_7', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 1, 0),
- array('Qt5', 'state', 'invalid', '', '', '', '', 0, 0)
+ array('Qt5', 'state', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', 'dev', 'linux-g++_developer-build_qtnamespace_qtlibinfix_Ubuntu_11.10_x64', '1023', 'FAILURE', 0, 1, 1),
+ array('Qt5', 'state', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'dev', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'BuildKeyInStringFormat12345', 'FAILURE', 0, 1, 1),
+ array('Qt5', 'state', 'win32-msvc2010_developer-build_angle_Windows_7', 'stable', 'win32-msvc2010_developer-build_angle_Windows_7', '1348', 'SUCCESS', 0, 1, 1),
+ array('Qt5', 'state', 'macx-clang_developer-build_OSX_10.8', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 0, 1, 1),
+ array('Qt5', 'state', 'win32-msvc2010_developer-build_angle_Windows_7', 'stable', 'macx-clang_developer-build_OSX_10.8', '1348', 'SUCCESS', 0, 1, 0),
+ array('Qt5', 'state', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', 'release', 'linux-g++-32_developer-build_Ubuntu_10.04_x86', '157', 'SUCCESS', 1, 1, 0),
+ array('Qt5', 'state', 'invalid', '', '', '', '', 0, 0, 0)
);
}
diff --git a/non-puppet/qtmetrics2/templates/about.html b/non-puppet/qtmetrics2/templates/about.html
index a89ca85..6c97bd1 100644
--- a/non-puppet/qtmetrics2/templates/about.html
+++ b/non-puppet/qtmetrics2/templates/about.html
@@ -34,7 +34,7 @@
/**
* About window content
- * @since 16-09-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -52,4 +52,4 @@ and the global Qt developer community are the target audience. For detailed desc
<p>See the <strong><a href="https://wiki.qt.io/Qt_Metrics_2_Backlog" target="_blank">backlog</a></strong>
for development items currently identified or in progress.</p>
-<p><small>Version 0.27 (16-Sep-2015)</small></p>
+<p><small>Version 0.28 (17-Sep-2015)</small></p>
diff --git a/non-puppet/qtmetrics2/templates/admin_branches.html b/non-puppet/qtmetrics2/templates/admin_branches.html
index 1b8fc9a..6c718d1 100644
--- a/non-puppet/qtmetrics2/templates/admin_branches.html
+++ b/non-puppet/qtmetrics2/templates/admin_branches.html
@@ -34,7 +34,7 @@
/**
* Admin page: Branches
- * @since 19-08-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -92,6 +92,7 @@
<thead>
<tr>
<th>branch</th>
+<th></th>
<th class="rightBorder"></th>
<th class="center">latest run</th>
<th class="center">total runs</th>
@@ -103,11 +104,22 @@
{% for branch in branches %}
<tr>
{# Branch name #}
-<td>{{ branch.name }}</td>
+{% if branch.archived %}
+<td><span class="glyphicon glyphicon-eye-close gray"></span> <span class="gray">{{ branch.name }}</span></td>
+{% else %}
+<td><span class="glyphicon glyphicon-eye-open"></span> {{ branch.name }}</td>
+{% endif %}
{% set branchTag = branch.name|replace({'.': '-'}) %}{# '.' not allowed in id #}
-{# Button (opens a confirmation modal) #}
-<td id="{{ branchTag }}Button" class="rightBorder"><button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#{{ branchTag }}Modal">Remove</button></td>
+{# Archive button (opens a confirmation modal) #}
+{% if branch.archived %}
+<td id="{{ branchTag }}ArchiveButton"><button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#{{ branchTag }}RestoreModal">Restore</button></td>
+{% else %}
+<td id="{{ branchTag }}ArchiveButton"><button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#{{ branchTag }}ArchiveModal">Archive</button></td>
+{% endif %}
+
+{# Remove button (opens a confirmation modal) #}
+<td id="{{ branchTag }}RemoveButton" class="rightBorder"><button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#{{ branchTag }}RemoveModal">Remove</button></td>
{# Latest project_run #}
<td class="center">{{ branch.latestRun }}</td>
@@ -134,25 +146,68 @@
</div> {# .panel-body #}
</div> {# .panel... #}
-{# Modals for remove confirmation #}
-{% set message = "Removing the branch will also delete all related items from the xxx_run tables. THIS OPERATION CANNOT BE UNDONE!" %}
+{# Modals for remove/archive/restore confirmations #}
+{% set removeMessage = "Removing the branch will delete it from the database permanently. This will also delete all related items from the xxx_run tables. THIS OPERATION CANNOT BE UNDONE!" %}
+{% set archiveMessage = "Archiving the branch will tag it so that it will not show up on the views. This will NOT delete the branch nor its related items from the database. Archived branch can be restored or removed." %}
+{% set restoreMessage = "Restoring the branch will clear the archived tag so that the branch will show up on the views again." %}
{% for branch in branches %}
{% set branchTag = branch.name|replace({'.': '-'}) %}{# '.' not allowed in id #}
-<div class="modal fade" id="{{ branchTag }}Modal" tabindex="-1" role="dialog" aria-labelledby="{{ branchTag }}ModalLabel" aria-hidden="true">
+
+{# Remove confirmation #}
+<div class="modal fade" id="{{ branchTag }}RemoveModal" tabindex="-1" role="dialog" aria-labelledby="{{ branchTag }}RemoveModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-<h4 class="modal-title" id="{{ branchTag }}ModalLabel">Remove branch "{{ branch.name }}"</h4>
+<h4 class="modal-title" id="{{ branchTag }}RemoveModalLabel">Remove branch "{{ branch.name }}"</h4>
</div>
-<div class="modal-body">{{ message }}</div>
+<div class="modal-body">{{ removeMessage }}</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id="cancel_branch_remove_{{ branch.name }}">Cancel</button>
-<button type="button" class="btn btn-danger remove_branch" data-dismiss="modal" id="confirm_branch_remove_{{ branchTag }}" name="{{ branch.name }}">Remove</button>
+<button type="button" class="btn btn-danger" data-dismiss="modal" id="confirm_branch_remove_{{ branchTag }}" name="{{ branch.name }}">Remove</button>
+</div>
+</div>
+</div>
+</div> {# .modal #}
+
+{# Archive confirmation #}
+{% if not branch.archived %}
+<div class="modal fade" id="{{ branchTag }}ArchiveModal" tabindex="-1" role="dialog" aria-labelledby="{{ branchTag }}ArchiveModalLabel" aria-hidden="true">
+<div class="modal-dialog">
+<div class="modal-content">
+<div class="modal-header">
+<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+<h4 class="modal-title" id="{{ branchTag }}ArchiveModalLabel">Archive branch "{{ branch.name }}"</h4>
+</div>
+<div class="modal-body">{{ archiveMessage }}</div>
+<div class="modal-footer">
+<button type="button" class="btn btn-default" data-dismiss="modal" id="cancel_branch_archive_{{ branch.name }}">Cancel</button>
+<button type="button" class="btn btn-primary" data-dismiss="modal" id="confirm_branch_archive_{{ branchTag }}" name="{{ branch.name }}">Archive</button>
</div>
</div>
</div>
</div> {# .modal #}
+{% endif %}
+
+{# Restore confirmation #}
+{% if branch.archived %}
+<div class="modal fade" id="{{ branchTag }}RestoreModal" tabindex="-1" role="dialog" aria-labelledby="{{ branchTag }}RestoreModalLabel" aria-hidden="true">
+<div class="modal-dialog">
+<div class="modal-content">
+<div class="modal-header">
+<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+<h4 class="modal-title" id="{{ branchTag }}RestoreModalLabel">Restore branch "{{ branch.name }}"</h4>
+</div>
+<div class="modal-body">{{ restoreMessage }}</div>
+<div class="modal-footer">
+<button type="button" class="btn btn-default" data-dismiss="modal" id="cancel_branch_restore_{{ branch.name }}">Cancel</button>
+<button type="button" class="btn btn-primary" data-dismiss="modal" id="confirm_branch_restore_{{ branchTag }}" name="{{ branch.name }}">Restore</button>
+</div>
+</div>
+</div>
+</div> {# .modal #}
+{% endif %}
+
{% endfor %}{# branch #}
</div> {# .col... #}
diff --git a/non-puppet/qtmetrics2/testparser.pl b/non-puppet/qtmetrics2/testparser.pl
index 89ce1c9..d924c8d 100644
--- a/non-puppet/qtmetrics2/testparser.pl
+++ b/non-puppet/qtmetrics2/testparser.pl
@@ -1251,6 +1251,7 @@ sub sql_create_tables
"CREATE TABLE IF NOT EXISTS branch (
id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
+ archived BOOL NOT NULL DEFAULT 0,
UNIQUE INDEX unique_branch (name),
CONSTRAINT branch_pk PRIMARY KEY (id)
) ENGINE MyISAM"