Skip to content
Open
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
4 changes: 4 additions & 0 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The integration test framework is designed to be used to run tests against
an installed and working XDMoD instance.

Run the tests with ./runtests.sh
46 changes: 46 additions & 0 deletions tests/integration/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

$dir = __DIR__;

// Autoloader for test classes.
spl_autoload_register(
function ($className) use ($dir) {
// Replace the IntegrationTests namespace prefix with the path to the
// integration tests lib directory.
$classPath = preg_replace(
'/IntegrationTests\\\\?/',
"$dir/lib/",
$className
);
// Replace namespace separators with directory separators.
$classPath = str_replace('\\', '/', $classPath) . '.php';
if (is_readable($classPath)) {
return require_once $classPath;
}
// Replace the IntegrationTests namespace prefix with the path to
// the main integration tests lib directory.
$classPath = preg_replace(
'/IntegrationTests\\\\?/',
"$dir/../../../xdmod/tests/integration/lib/",
$className
);
// Replace namespace separators with directory separators.
$classPath = str_replace('\\', '/', $classPath) . '.php';
if (is_readable($classPath)) {
return require_once $classPath;
}
// Autoload the AppKernels module classes
$classPath = (
"$dir/../../classes/"
. str_replace('\\', '/', $className)
. '.php'
);
if (is_readable($classPath)) {
return require_once $classPath;
}
return false;
}
);

// Autoloader for XDMoD classes.
require_once __DIR__ . '/../../../xdmod/configuration/linker.php';
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace IntegrationTests\REST\internal_dashboard;

use IntegrationTests\TestHarness\XdmodTestHelper;

class DashboardAppKernelTest extends \PHPUnit_Framework_TestCase
{
public function __construct()
{
$xdmodConfig = array( "decodetextasjson" => true );
$this->xdmodhelper = new \TestHarness\XdmodTestHelper($xdmodConfig);
$this->xdmodhelper = new XdmodTestHelper($xdmodConfig);

$this->endpoint = 'rest/v0.1/akrr/';
$this->xdmodhelper->authenticate("mgr");
Expand All @@ -20,8 +22,8 @@ private function validateAkrrResourceEntries($searchparams)
$result = $this->xdmodhelper->get($this->endpoint . 'resources', $searchparams);
$this->assertEquals(200, $result[1]['http_code']);

$this->assertArrayHasKey('success', $result[0]);
$this->assertEquals($result[0]['success'], true);
$this->assertArrayHasKey('status', $result[0]);
$this->assertEquals($result[0]['status'], 'success');

$data = $result[0]['data'];
foreach ($data as $item) {
Expand All @@ -45,15 +47,15 @@ private function validateAkrrKernelEntries($searchparams)
$result = $this->xdmodhelper->get($this->endpoint . 'kernels', $searchparams);
$this->assertEquals(200, $result[1]['http_code']);

$this->assertArrayHasKey('message', $result[0]);
$this->assertEquals($result[0]['message'], 'success');
$this->assertArrayHasKey('status', $result[0]);
$this->assertEquals($result[0]['status'], 'success');

$data = $result[0]['data'];
foreach ($data as $item) {
$this->assertArrayHasKey('nodes_list', $data[0]);
$this->assertArrayHasKey('name', $data[0]);
$this->assertArrayHasKey('enabled', $data[0]);
$this->assertArrayHasKey('id', $data[0]);
$this->assertArrayHasKey('nodes_list', $item);
$this->assertArrayHasKey('name', $item);
$this->assertArrayHasKey('enabled', $item);
$this->assertArrayHasKey('id', $item);
}

return $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions tests/integration_tests/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions tests/integration_tests/bootstrap.php

This file was deleted.

3 changes: 0 additions & 3 deletions tests/unit/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
The integration test framework is designed to be used to run tests against
an installed and working XDMoD instance.

The test harness in the xdmod repository must be configured correctly as
per the instructions in the readme file: xdmod/open_xdmod/modules/xdmod/integration_tests/README.md

Run the tests with ./runtests.sh
54 changes: 45 additions & 9 deletions tests/unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,59 @@

$dir = __DIR__;

// Autoloader for main framework test classes.
// Autoloader for test classes.
spl_autoload_register(
function ($className) use ($dir) {
$classPath
= $dir
. '/../../../xdmod/open_xdmod/modules/xdmod/integration_tests/lib/'
// Replace the UnitTests namespace prefix with the path to the unit
// tests lib directory.
$classPath = preg_replace(
'/UnitTests\\\\?/',
"$dir/lib/",
$className
);
// Replace the IntegrationTests namespace prefix with the path to the
// integration tests lib directory.
$classPath = preg_replace(
'/IntegrationTests\\\\?/',
"$dir/../integration/lib/",
$classPath
);
// Replace namespace separators with directory separators.
$classPath = str_replace('\\', '/', $classPath) . '.php';
if (is_readable($classPath)) {
return require_once $classPath;
}
// Replace the UnitTests namespace prefix with the path to the main
// unit tests lib directory.
$classPath = preg_replace(
'/UnitTests\\\\?/',
"$dir/../../../xdmod/tests/unit/lib/",
$className
);
// Replace the IntegrationTests namespace prefix with the path to
// the main integration tests lib directory.
$classPath = preg_replace(
'/IntegrationTests\\\\?/',
"$dir/../../../xdmod/tests/integration/lib/",
$classPath
);
// Replace namespace separators with directory separators.
$classPath = str_replace('\\', '/', $classPath) . '.php';
if (is_readable($classPath)) {
return require_once $classPath;
}
// Autoload the AppKernels module classes
$classPath = (
"$dir/../../classes/"
. str_replace('\\', '/', $className)
. '.php';

. '.php'
);
if (is_readable($classPath)) {
return require_once $classPath;
} else {
return false;
}
return false;
}
);

// Autoloader for XDMoD classes.
// require_once __DIR__ . '/../../configuration/linker.php';
require_once '/usr/share/xdmod/configuration/linker.php';
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?php

namespace AppKernelTest;
namespace UnitTests;

use PHPUnit\Framework\TestCase;

require_once __DIR__ . "/../../classes/AppKernel/AppKernelDb.php";
require_once __DIR__ . "/../../../classes/AppKernel/AppKernelDb.php";

use AppKernel\AppKernelDb;
use AppKernel\ProcessingUnit;
use AppKernel\AppKernelDefinition;
use AppKernel\InstanceMetric;
use AppKernel\InstanceData;

function create_instance_data($ak_name, $deployment_num_proc_units, $deployment_time, $status)
{
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$db = $ak_db->getDB();

$db_ak_id = $db->query(
Expand Down Expand Up @@ -43,7 +44,7 @@ public function processingUnitProvider()
$proc_unit_node_1to4 = array_slice($proc_unit_node_1to32, 0, 3);
$proc_unit_node_2to8 = array_slice($proc_unit_node_1to32, 1, 3);

$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$metrics_id = intval(
$ak_db->getDB()->query(
'SELECT metric_id FROM mod_appkernel.metric WHERE name="Wall Clock Time"'
Expand Down Expand Up @@ -75,7 +76,7 @@ public function processingUnitProvider()
*/
public function testProcessingUnit($start_date, $end_date, array $resource_ids, array $metrics, $expected)
{
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$actual = $ak_db->getProcessingUnits($start_date, $end_date, $resource_ids, $metrics);

if ($expected === null) {
Expand Down Expand Up @@ -245,7 +246,7 @@ public function testGetUniqueAppKernels(
$n_expected = null,
$expected = null
) {
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$actual = $ak_db->getUniqueAppKernels($resource_ids, $node_counts, $core_counts);

if ($expected === null && $n_expected === null) {
Expand Down Expand Up @@ -284,7 +285,7 @@ public function testGetUniqueAppKernels(

public function getMetricsProvider()
{
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$db = $ak_db->getDB();
# Get metric id
$ak_exec_exists_id = intval(
Expand Down Expand Up @@ -356,7 +357,7 @@ public function testGetMetrics(
$n_expected = null,
$expected = null
) {
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$actual = $ak_db->getMetrics($ak_def_id, $start_date, $end_date, $resource_ids, $pu_counts);

if ($n_expected === null && $expected !== null) {
Expand Down Expand Up @@ -434,7 +435,7 @@ public function loadAppKernelInstancesProvider()
*/
public function testLoadAppKernelInstances($ak_def_id, $resource_id, $n_expected = null, $expected = null)
{
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();
$actual = $ak_db->loadAppKernelInstances($ak_def_id, $resource_id);
$db = $ak_db->getDB();

Expand Down Expand Up @@ -472,7 +473,7 @@ public function testLoadAppKernelInstances($ak_def_id, $resource_id, $n_expected

public function testNewControlRegions()
{
$ak_db = new \AppKernel\AppKernelDb();
$ak_db = new AppKernelDb();

// update initial control for 5 points
$ak_db->newControlRegions(
Expand Down
1 change: 0 additions & 1 deletion tests/unit/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
Expand Down