Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify how modules extend regression tests. #1815

Draft
wants to merge 4 commits into
base: xdmod11.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/ci/runtest-include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
37 changes: 31 additions & 6 deletions tests/regression/lib/Controllers/MetricExplorerChartsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use IntegrationTests\TestHarness\Utilities;
use IntegrationTests\TestHarness\XdmodTestHelper;
use ReflectionClass;

class MetricExplorerChartsTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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 {
Expand Down
40 changes: 2 additions & 38 deletions tests/regression/lib/Controllers/UsageExplorerCloudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
37 changes: 1 addition & 36 deletions tests/regression/lib/Controllers/UsageExplorerJobsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
37 changes: 1 addition & 36 deletions tests/regression/lib/Controllers/UsageExplorerStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
51 changes: 51 additions & 0 deletions tests/regression/lib/Controllers/aUsageExplorerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace RegressionTests\Controllers;

use RegressionTests\TestHarness\RegressionTestHelper;

/**
* Test the usage explorer for realm regressions.
*/
abstract class aUsageExplorerTest extends \PHPUnit\Framework\TestCase
{
/**
* @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));
}

/**
* @return array test data from RegressionTestHelper::generateTests().
*/
abstract public function csvExportProvider();
}
7 changes: 4 additions & 3 deletions tests/regression/runtests.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#!/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

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
cat README.md >&2
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
Expand Down