Skip to content

Commit 75ffc12

Browse files
committed
Simplify how modules extend regression tests.
1 parent 7f50efc commit 75ffc12

7 files changed

+90
-118
lines changed

tests/ci/runtest-include.sh

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if [ -z $XDMOD_REALMS ]; then
44
echo "XDMOD_REALMS is not set"
55
echo "Default for core xdmod is: XDMOD_REALMS='jobs,storage,cloud'"
66
echo "Default for JobPerformance is: XDMOD_REALMS='jobs,storage,cloud,supremm,jobefficiency'"
7+
echo "Default for OnDemand is: XDMOD_REALMS='jobs,storage,cloud,ondemand'"
78
exit 1
89
fi
910

tests/regression/lib/Controllers/MetricExplorerChartsTest.php

+31-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use IntegrationTests\TestHarness\Utilities;
66
use IntegrationTests\TestHarness\XdmodTestHelper;
7+
use ReflectionClass;
78

89
class MetricExplorerChartsTest extends \PHPUnit_Framework_TestCase
910
{
@@ -425,11 +426,7 @@ public function remainderChartProvider()
425426
private function generateFilterTests()
426427
{
427428
// Generate test scenario for filter tests.
428-
$baseConfig = array(
429-
array('realm' => 'Jobs', 'metric' => 'total_cpu_hours', 'date' => '2016-12-31'),
430-
array('realm' => 'Storage', 'metric' => 'avg_logical_usage', 'date' => '2018-12-28'),
431-
array('realm' => 'Cloud', 'metric' => 'cloud_core_time', 'date' => '2019-06-26')
432-
);
429+
$baseConfig = static::getFilterTestBaseConfig();
433430

434431
$output = array();
435432

@@ -476,9 +473,37 @@ private function generateFilterTests()
476473
return $output;
477474
}
478475

476+
/**
477+
* This method is overridden by modules (SUPREMM, OnDemand).
478+
*/
479+
protected static function getFilterTestBaseConfig()
480+
{
481+
return [
482+
[
483+
'realm' => 'Jobs',
484+
'metric' => 'total_cpu_hours',
485+
'date' => '2016-12-31'
486+
],
487+
[
488+
'realm' => 'Storage',
489+
'metric' => 'avg_logical_usage',
490+
'date' => '2018-12-28'
491+
],
492+
[
493+
'realm' => 'Cloud',
494+
'metric' => 'cloud_core_time',
495+
'date' => '2019-06-26'
496+
]
497+
];
498+
}
499+
479500
public function filterTestsProvider()
480501
{
481-
$data_file = realpath(__DIR__ . '/../../../artifacts/xdmod/regression/chartFilterTests.json');
502+
$testClass = new ReflectionClass($this);
503+
$data_file = realpath(
504+
dirname($testClass->getFilename())
505+
. '/../../../artifacts/xdmod/regression/chartFilterTests.json'
506+
);
482507
if (file_exists($data_file)) {
483508
$inputs = json_decode(file_get_contents($data_file), true);
484509
} else {

tests/regression/lib/Controllers/UsageExplorerCloudTest.php

+1-37
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,8 @@
77
/**
88
* Test the usage explorer for cloud realm regressions.
99
*/
10-
class UsageExplorerCloudTest extends \PHPUnit_Framework_TestCase
10+
class UsageExplorerCloudTest extends aUsageExplorerTest
1111
{
12-
13-
/**
14-
* @var \RegressionTestHelper
15-
*/
16-
private static $helper;
17-
18-
/**
19-
* Create the helper and authenticate.
20-
*/
21-
public static function setUpBeforeClass()
22-
{
23-
self::$helper = new RegressionTestHelper();
24-
self::$helper->authenticate();
25-
}
26-
27-
/**
28-
* Log out and output any messages generated by tests.
29-
*/
30-
public static function tearDownAfterClass()
31-
{
32-
self::$helper->logout();
33-
self::$helper->outputMessages();
34-
}
35-
36-
/**
37-
* Test usage explorer CSV export.
38-
*
39-
* @group regression
40-
* @group UsageExplorer
41-
* @dataProvider csvExportProvider
42-
*/
43-
public function testCsvExport($testName, $input, $expectedFile, $userRole)
44-
{
45-
$this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole));
46-
}
47-
4812
public function csvExportProvider(){
4913
$statistics = array(
5014
'cloud_num_sessions_ended',

tests/regression/lib/Controllers/UsageExplorerJobsTest.php

+1-36
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,8 @@
77
/**
88
* Test the usage explorer for jobs realm regressions.
99
*/
10-
class UsageExplorerJobsTest extends \PHPUnit_Framework_TestCase
10+
class UsageExplorerJobsTest extends aUsageExplorerTest
1111
{
12-
/**
13-
* @var \RegressionTestHelper
14-
*/
15-
private static $helper;
16-
17-
/**
18-
* Create the helper and authenticate.
19-
*/
20-
public static function setUpBeforeClass()
21-
{
22-
self::$helper = new RegressionTestHelper();
23-
self::$helper->authenticate();
24-
}
25-
26-
/**
27-
* Log out and output any messages generated by tests.
28-
*/
29-
public static function tearDownAfterClass()
30-
{
31-
self::$helper->logout();
32-
self::$helper->outputMessages();
33-
}
34-
35-
/**
36-
* Test usage explorer CSV export.
37-
*
38-
* @group regression
39-
* @group UsageExplorer
40-
* @dataProvider csvExportProvider
41-
*/
42-
public function testCsvExport($testName, $input, $expectedFile, $userRole)
43-
{
44-
$this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole));
45-
}
46-
4712
public function csvExportProvider()
4813
{
4914
$statistics = [

tests/regression/lib/Controllers/UsageExplorerStorageTest.php

+1-36
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,8 @@
77
/**
88
* Test the usage explorer for storage realm regressions.
99
*/
10-
class UsageExplorerStorageTest extends \PHPUnit_Framework_TestCase
10+
class UsageExplorerStorageTest extends aUsageExplorerTest
1111
{
12-
/**
13-
* @var \RegressionTestHelper
14-
*/
15-
private static $helper;
16-
17-
/**
18-
* Create the helper and authenticate.
19-
*/
20-
public static function setUpBeforeClass()
21-
{
22-
self::$helper = new RegressionTestHelper();
23-
self::$helper->authenticate();
24-
}
25-
26-
/**
27-
* Log out and output any messages generated by tests.
28-
*/
29-
public static function tearDownAfterClass()
30-
{
31-
self::$helper->logout();
32-
self::$helper->outputMessages();
33-
}
34-
35-
/**
36-
* Test usage explorer CSV export.
37-
*
38-
* @group regression
39-
* @group UsageExplorer
40-
* @dataProvider csvExportProvider
41-
*/
42-
public function testCsvExport($testName, $input, $expectedFile, $userRole)
43-
{
44-
$this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole));
45-
}
46-
4712
public function csvExportProvider()
4813
{
4914
$statistics = [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace RegressionTests\Controllers;
4+
5+
use RegressionTests\TestHarness\RegressionTestHelper;
6+
7+
/**
8+
* Test the usage explorer for realm regressions.
9+
*/
10+
abstract class aUsageExplorerTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \RegressionTestHelper
14+
*/
15+
private static $helper;
16+
17+
/**
18+
* Create the helper and authenticate.
19+
*/
20+
public static function setUpBeforeClass()
21+
{
22+
self::$helper = new RegressionTestHelper();
23+
self::$helper->authenticate();
24+
}
25+
26+
/**
27+
* Log out and output any messages generated by tests.
28+
*/
29+
public static function tearDownAfterClass()
30+
{
31+
self::$helper->logout();
32+
self::$helper->outputMessages();
33+
}
34+
35+
/**
36+
* Test usage explorer CSV export.
37+
*
38+
* @group regression
39+
* @group UsageExplorer
40+
* @dataProvider csvExportProvider
41+
*/
42+
public function testCsvExport($testName, $input, $expectedFile, $userRole)
43+
{
44+
$this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole));
45+
}
46+
47+
/**
48+
* @return array test data from RegressionTestHelper::generateTests().
49+
*/
50+
abstract public function csvExportProvider();
51+
}

tests/regression/runtests.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
#!/bin/bash
22
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3-
source $BASEDIR/../ci/runtest-include.sh
3+
XDMOD_SRC_DIR=${XDMOD_SRC_DIR:-${BASE_DIR}}
4+
source $XDMOD_SRC_DIR/tests/ci/runtest-include.sh
45
echo "Regression tests beginning:" `date +"%a %b %d %H:%M:%S.%3N %Y"`
56
set -e
67

78
export XDMOD_REALMS
89

910
cd $(dirname $0)
1011

11-
if [ ! -e ../ci/testing.json ];
12+
if [ ! -e $XDMOD_SRC_DIR/tests/ci/testing.json ];
1213
then
1314
echo "ERROR missing testing.json file." >&2
1415
echo >&2
1516
cat README.md >&2
1617
false
1718
fi
1819

19-
phpunit="$(readlink -f ../../vendor/bin/phpunit)"
20+
phpunit="$(readlink -f $XDMOD_SRC_DIR/vendor/bin/phpunit)"
2021

2122
if [ ! -x "$phpunit" ]; then
2223
echo phpunit not found, run \"composer install\" 1>&2

0 commit comments

Comments
 (0)