Skip to content

Simplify regression test code. #371

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

Draft
wants to merge 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,18 @@

namespace RegressionTests\Controllers;

use IntegrationTests\TestHarness\Utilities;
use IntegrationTests\TestHarness\XdmodTestHelper;
use RegressionTests\Controllers\MetricExplorerChartsTest;

class MetricExplorerSupremmChartsTest extends MetricExplorerChartsTest
{
public function filterTestsProvider()
protected static function getFilterTestBaseConfig()
{
$data_file = realpath(__DIR__ . '/../../../artifacts/regression/chartFilterTests.json');
if (file_exists($data_file)) {
$inputs = json_decode(file_get_contents($data_file), true);
} else {
// Generate test permutations. The expected values for the data points are not set.
// this causes the test function to record the values and they are then written
// to a file in the tearDownAfterClass function.
$baseConfig = array(
array('realm' => 'SUPREMM', 'metric' => 'wall_time', 'date' => '2016-12-29')
);

$inputs = $this->generateFilterTests($baseConfig);
}

$helper = new XdmodTestHelper();
$helper->authenticate('cd');

$enabledRealms = Utilities::getRealmsToTest();

$output = array();
foreach ($inputs as $test)
{
if (in_array(strtolower($test['settings']['realm']), $enabledRealms)) {
$output[] = array($helper, $test['settings'], $test['expected']);
}
}

return $output;
return [
[
'realm' => 'SUPREMM',
'metric' => 'wall_time',
'date' => '2016-12-29'
]
];
}
}
37 changes: 1 addition & 36 deletions tests/regression/lib/Controllers/UsageExplorerSupremmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,8 @@
/**
* Test the usage explorer for jobs realm regressions.
*/
class UsageExplorerJobsTest extends 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
15 changes: 9 additions & 6 deletions tests/regression/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="true"
bootstrap="bootstrap.php"
colors="true"
testSuiteLoaderFile="phpunit/src/Runner/StandardTestSuiteLoader.php"
verbose="true">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="true"
bootstrap="bootstrap.php"
colors="true"
testSuiteLoaderFile="phpunit/src/Runner/StandardTestSuiteLoader.php"
verbose="true"
>
<coverage/>
</phpunit>
83 changes: 1 addition & 82 deletions tests/regression/runtests.sh
Original file line number Diff line number Diff line change
@@ -1,82 +1 @@
#!/bin/bash

set -e

REGUSER=""
PI=""
CD=""
CS=""
PUB=""
WAREHOUSE=""

if [ "$1" = "--junit-output-dir" ];
then
REGUSER="--log-junit $2/xdmod-supremm-regression-user.xml"
PI="--log-junit $2/xdmod-supremm-regression-principalinvestigator.xml"
CD="--log-junit $2/xdmod-supremm-regression-centerdirector.xml"
CS="--log-junit $2/xdmod-supremm-regression-centerstaff.xml"
PUB="--log-junit $2/xdmod-supremm-regression-public.xml"
WAREHOUSE="--log-junit $2/xdmod-supremm-regression-warehouse.xml"
fi

cd $(dirname $0)

if [ ! -e ../../../xdmod/tests/ci/testing.json ];
then
echo "ERROR missing .secrets.json file." >&2
echo >&2
cat README.md >&2
exit 126
fi

phpunit="$(readlink -f ../../../xdmod/vendor/bin/phpunit)"

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

export REG_TEST_BASE=${REG_TEST_BASE:-/../../../../../xdmod-supremm/tests/artifacts/regression/current/}

function run_warehouse_raw_data_tests {
# Need to ignore the values of deidentified usernames when comparing the
# actual and expected data because the values will be different depending
# on whether XDMOD_TEST_MODE is set to 'upgrade' or 'fresh_install' since
# these two testing pipelines produce different hashes for the usernames.
REG_TEST_USER_ROLE=usr \
REG_TEST_REGEX='/[0-9a-f]{40}/' \
REG_TEST_REPLACE='<username>' \
$phpunit $WAREHOUSE --group warehouseRawData .
}

if [ "$REG_TEST_ALL" == "1" ]; then
set +e
REG_TEST_USER_ROLE=cd $phpunit $CD --exclude-group warehouseRawData .

#REG_TEST_USER_ROLE=usr $phpunit $REGUSER ./lib/Controllers/UsageExplorerSupremmTest.php
#REG_TEST_USER_ROLE=pi $phpunit $PI ./lib/Controllers/UsageExplorerSupremmTest.php
#REG_TEST_USER_ROLE=cs $phpunit $CS ./lib/Controllers/UsageExplorerSupremmTest.php
#$phpunit $PUB ./lib/Controllers/UsageExplorerSupremmTest.php

run_warehouse_raw_data_tests
else
REG_TEST_USER_ROLE=cd $phpunit $CD --exclude-group warehouseRawData . & cdpid=$!

#REG_TEST_USER_ROLE=usr $phpunit $REGUSER ./lib/Controllers/UsageExplorerSupremmTest.php & usrpid=$!
#REG_TEST_USER_ROLE=pi $phpunit $PI ./lib/Controllers/UsageExplorerSupremmTest.php & pipid=$!
#REG_TEST_USER_ROLE=cs $phpunit $CS ./lib/Controllers/UsageExplorerSupremmTest.php & cspid=$!
#$phpunit $PUB ./lib/Controllers/UsageExplorerSupremmTest.php & pubpid=$!

run_warehouse_raw_data_tests & warehousepid=$!

EXIT_STATUS=0
for pid in $usrpid $pipid $cdpid $cspid $pubpid $warehousepid;
do
wait "$pid"
if [ "$?" -ne "0" ];
then
EXIT_STATUS=1
fi
done
exit $EXIT_STATUS
fi
source $XDMOD_SRC_DIR/tests/regression/runtests.sh