diff --git a/tests/ci/runtest-include.sh b/tests/ci/runtest-include.sh index 09ec774181..dfa5e52dd5 100644 --- a/tests/ci/runtest-include.sh +++ b/tests/ci/runtest-include.sh @@ -3,7 +3,8 @@ if [ -z $XDMOD_REALMS ]; then echo "XDMOD_REALMS is not set" echo "Default for core xdmod is: XDMOD_REALMS='jobs,storage,cloud,resourcespecifications'" - echo "Default for JobPerformance is: XDMOD_REALMS='jobs,storage,cloud,supremm,jobefficiency,resourcespecifications'" + echo "Default for JobPerformance is: XDMOD_REALMS='jobs,storage,cloud,resourcespecifications,supremm,jobefficiency'" + echo "Default for OnDemand is: XDMOD_REALMS='jobs,storage,cloud,resourcespecifications,ondemand'" exit 1 fi diff --git a/tests/regression/lib/Controllers/MetricExplorerChartsTest.php b/tests/regression/lib/Controllers/MetricExplorerChartsTest.php index 320852b90a..e3bb6aab90 100644 --- a/tests/regression/lib/Controllers/MetricExplorerChartsTest.php +++ b/tests/regression/lib/Controllers/MetricExplorerChartsTest.php @@ -4,6 +4,7 @@ use IntegrationTests\TestHarness\Utilities; use IntegrationTests\TestHarness\XdmodTestHelper; +use ReflectionClass; class MetricExplorerChartsTest extends \PHPUnit\Framework\TestCase { @@ -424,11 +425,7 @@ public function remainderChartProvider() private function generateFilterTests() { // Generate test scenario for filter tests. - $baseConfig = array( - array('realm' => 'Jobs', 'metric' => 'total_cpu_hours', 'date' => '2016-12-31'), - array('realm' => 'Storage', 'metric' => 'avg_logical_usage', 'date' => '2018-12-28'), - array('realm' => 'Cloud', 'metric' => 'cloud_core_time', 'date' => '2019-06-26') - ); + $baseConfig = static::getFilterTestBaseConfig(); $output = array(); @@ -475,9 +472,37 @@ private function generateFilterTests() return $output; } + /** + * This method is overridden by modules (SUPREMM, OnDemand). + */ + protected static function getFilterTestBaseConfig() + { + return [ + [ + 'realm' => 'Jobs', + 'metric' => 'total_cpu_hours', + 'date' => '2016-12-31' + ], + [ + 'realm' => 'Storage', + 'metric' => 'avg_logical_usage', + 'date' => '2018-12-28' + ], + [ + 'realm' => 'Cloud', + 'metric' => 'cloud_core_time', + 'date' => '2019-06-26' + ] + ]; + } + public function filterTestsProvider() { - $data_file = realpath(__DIR__ . '/../../../artifacts/xdmod/regression/chartFilterTests.json'); + $testClass = new ReflectionClass($this); + $data_file = realpath( + dirname($testClass->getFilename()) + . '/../../../artifacts/xdmod/regression/chartFilterTests.json' + ); if (file_exists($data_file)) { $inputs = json_decode(file_get_contents($data_file), true); } else { diff --git a/tests/regression/lib/Controllers/UsageExplorerCloudTest.php b/tests/regression/lib/Controllers/UsageExplorerCloudTest.php index 921d9ae2f3..3c6f3b19d2 100644 --- a/tests/regression/lib/Controllers/UsageExplorerCloudTest.php +++ b/tests/regression/lib/Controllers/UsageExplorerCloudTest.php @@ -7,45 +7,9 @@ /** * Test the usage explorer for cloud realm regressions. */ -class UsageExplorerCloudTest extends \PHPUnit\Framework\TestCase +class UsageExplorerCloudTest extends aUsageExplorerTest { - - /** - * @var \RegressionTestHelper - */ - private static $helper; - - /** - * Create the helper and authenticate. - */ - public static function setupBeforeClass(): void - { - self::$helper = new RegressionTestHelper(); - self::$helper->authenticate(); - } - - /** - * Log out and output any messages generated by tests. - */ - public static function tearDownAfterClass(): void - { - self::$helper->logout(); - self::$helper->outputMessages(); - } - - /** - * Test usage explorer CSV export. - * - * @group regression - * @group UsageExplorer - * @dataProvider csvExportProvider - */ - public function testCsvExport($testName, $input, $expectedFile, $userRole) - { - $this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole)); - } - - public function csvExportProvider(){ + public function csvExportProvider() { $statistics = array( 'cloud_num_sessions_ended', 'cloud_num_sessions_running', diff --git a/tests/regression/lib/Controllers/UsageExplorerJobsTest.php b/tests/regression/lib/Controllers/UsageExplorerJobsTest.php index 96682b467c..a14392c80d 100644 --- a/tests/regression/lib/Controllers/UsageExplorerJobsTest.php +++ b/tests/regression/lib/Controllers/UsageExplorerJobsTest.php @@ -7,43 +7,8 @@ /** * Test the usage explorer for jobs realm regressions. */ -class UsageExplorerJobsTest extends \PHPUnit\Framework\TestCase +class UsageExplorerJobsTest extends aUsageExplorerTest { - /** - * @var \RegressionTestHelper - */ - private static $helper; - - /** - * Create the helper and authenticate. - */ - public static function setupBeforeClass(): void - { - self::$helper = new RegressionTestHelper(); - self::$helper->authenticate(); - } - - /** - * Log out and output any messages generated by tests. - */ - public static function tearDownAfterClass(): void - { - self::$helper->logout(); - self::$helper->outputMessages(); - } - - /** - * Test usage explorer CSV export. - * - * @group regression - * @group UsageExplorer - * @dataProvider csvExportProvider - */ - public function testCsvExport($testName, $input, $expectedFile, $userRole) - { - $this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole)); - } - public function csvExportProvider() { $statistics = [ diff --git a/tests/regression/lib/Controllers/UsageExplorerResourcespecificationsTest.php b/tests/regression/lib/Controllers/UsageExplorerResourcespecificationsTest.php index 5977f8daf5..27b65cb44d 100644 --- a/tests/regression/lib/Controllers/UsageExplorerResourcespecificationsTest.php +++ b/tests/regression/lib/Controllers/UsageExplorerResourcespecificationsTest.php @@ -2,49 +2,13 @@ namespace RegressionTests\Controllers; -use PHPUnit\Framework\TestCase; use RegressionTests\TestHarness\RegressionTestHelper; /** * Test the usage explorer for jobs realm regressions. */ -class UsageExplorerResourcespecificationsTest extends TestCase +class UsageExplorerResourcespecificationsTest extends aUsageExplorerTest { - /** - * @var \RegressionTestHelper - */ - private static $helper; - - /** - * Create the helper and authenticate. - */ - public static function setUpBeforeClass(): void - { - self::$helper = new RegressionTestHelper(); - self::$helper->authenticate(); - } - - /** - * Log out and output any messages generated by tests. - */ - public static function tearDownAfterClass(): void - { - self::$helper->logout(); - self::$helper->outputMessages(); - } - - /** - * Test usage explorer CSV export. - * - * @group regression - * @group UsageExplorer - * @dataProvider csvExportProvider - */ - public function testCsvExport($testName, $input, $expectedFile, $userRole) - { - $this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole)); - } - public function csvExportProvider() { $statistics = [ diff --git a/tests/regression/lib/Controllers/UsageExplorerStorageTest.php b/tests/regression/lib/Controllers/UsageExplorerStorageTest.php index 6b109b70d9..512e48381b 100644 --- a/tests/regression/lib/Controllers/UsageExplorerStorageTest.php +++ b/tests/regression/lib/Controllers/UsageExplorerStorageTest.php @@ -7,43 +7,8 @@ /** * Test the usage explorer for storage realm regressions. */ -class UsageExplorerStorageTest extends \PHPUnit\Framework\TestCase +class UsageExplorerStorageTest extends aUsageExplorerTest { - /** - * @var \RegressionTestHelper - */ - private static $helper; - - /** - * Create the helper and authenticate. - */ - public static function setupBeforeClass(): void - { - self::$helper = new RegressionTestHelper(); - self::$helper->authenticate(); - } - - /** - * Log out and output any messages generated by tests. - */ - public static function tearDownAfterClass(): void - { - self::$helper->logout(); - self::$helper->outputMessages(); - } - - /** - * Test usage explorer CSV export. - * - * @group regression - * @group UsageExplorer - * @dataProvider csvExportProvider - */ - public function testCsvExport($testName, $input, $expectedFile, $userRole) - { - $this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole)); - } - public function csvExportProvider() { $statistics = [ diff --git a/tests/regression/lib/Controllers/aUsageExplorerTest.php b/tests/regression/lib/Controllers/aUsageExplorerTest.php new file mode 100644 index 0000000000..a1aa508497 --- /dev/null +++ b/tests/regression/lib/Controllers/aUsageExplorerTest.php @@ -0,0 +1,51 @@ +authenticate(); + } + + /** + * Log out and output any messages generated by tests. + */ + public static function tearDownAfterClass(): void + { + self::$helper->logout(); + self::$helper->outputMessages(); + } + + /** + * Test usage explorer CSV export. + * + * @group regression + * @group UsageExplorer + * @dataProvider csvExportProvider + */ + public function testCsvExport($testName, $input, $expectedFile, $userRole) + { + $this->assertTrue(self::$helper->checkCsvExport($testName, $input, $expectedFile, $userRole)); + } + + /** + * @return array test data from RegressionTestHelper::generateTests(). + */ + abstract public function csvExportProvider(); +} diff --git a/tests/regression/runtests.sh b/tests/regression/runtests.sh index bfd51ba2d0..f67cdee762 100755 --- a/tests/regression/runtests.sh +++ b/tests/regression/runtests.sh @@ -1,6 +1,7 @@ #!/bin/bash BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $BASEDIR/../ci/runtest-include.sh +XDMOD_SRC_DIR=${XDMOD_SRC_DIR:-$BASEDIR/../..} +source $XDMOD_SRC_DIR/tests/ci/runtest-include.sh echo "Regression tests beginning:" `date +"%a %b %d %H:%M:%S.%3N %Y"` set -e @@ -8,7 +9,7 @@ export XDMOD_REALMS cd $(dirname $0) -if [ ! -e ../ci/testing.json ]; +if [ ! -e $XDMOD_SRC_DIR/tests/ci/testing.json ]; then echo "ERROR missing testing.json file." >&2 echo >&2 @@ -16,7 +17,7 @@ then false fi -phpunit="$(readlink -f ../../vendor/bin/phpunit)" +phpunit="$(readlink -f $XDMOD_SRC_DIR/vendor/bin/phpunit)" if [ ! -x "$phpunit" ]; then echo phpunit not found, run \"composer install\" 1>&2