Skip to content

Commit f617e8c

Browse files
committed
Simplify how modules extend regression tests.
1 parent effb79a commit f617e8c

7 files changed

+92
-120
lines changed

tests/ci/runtest-include.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
if [ -z $XDMOD_REALMS ]; then
44
echo "XDMOD_REALMS is not set"
55
echo "Default for core xdmod is: XDMOD_REALMS='jobs,storage,cloud,resourcespecifications'"
6-
echo "Default for JobPerformance is: XDMOD_REALMS='jobs,storage,cloud,supremm,jobefficiency,resourcespecifications'"
6+
echo "Default for JobPerformance is: XDMOD_REALMS='jobs,storage,cloud,resourcespecifications,supremm,jobefficiency'"
7+
echo "Default for OnDemand is: XDMOD_REALMS='jobs,storage,cloud,resourcespecifications,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
{
@@ -424,11 +425,7 @@ public function remainderChartProvider()
424425
private function generateFilterTests()
425426
{
426427
// Generate test scenario for filter tests.
427-
$baseConfig = array(
428-
array('realm' => 'Jobs', 'metric' => 'total_cpu_hours', 'date' => '2016-12-31'),
429-
array('realm' => 'Storage', 'metric' => 'avg_logical_usage', 'date' => '2018-12-28'),
430-
array('realm' => 'Cloud', 'metric' => 'cloud_core_time', 'date' => '2019-06-26')
431-
);
428+
$baseConfig = static::getFilterTestBaseConfig();
432429

433430
$output = array();
434431

@@ -475,9 +472,37 @@ private function generateFilterTests()
475472
return $output;
476473
}
477474

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

tests/regression/lib/Controllers/UsageExplorerCloudTest.php

+2-38
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,9 @@
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(): void
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(): void
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-
48-
public function csvExportProvider(){
12+
public function csvExportProvider() {
4913
$statistics = array(
5014
'cloud_num_sessions_ended',
5115
'cloud_num_sessions_running',

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(): void
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(): void
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(): void
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(): void
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(): void
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(): void
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:-${BASEDIR}}
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)