From 32af93e03463968d0dd7da672de374ff5971c553 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Wed, 28 Sep 2016 12:44:03 +0200 Subject: [PATCH] Cleanup testing - test folder restructured - removes old phpunit tests - adds a basic selenium test - some travis adjustments --- .travis.yml | 40 +- phpunit.xml | 26 +- tests/Bootstrap.php | 107 ---- .../Controller/IndexControllerTest.php | 51 -- tests/ClientTest/Model/ClientTableTest.php | 59 --- .../Controller/IndexControllerTest.php | 52 -- .../Controller/IndexControllerTest.php | 52 -- .../Controller/IndexControllerTest.php | 52 -- tests/FileTest/Model/FileTableTest.php | 59 --- .../Controller/IndexControllerTest.php | 52 -- tests/FilesetTest/Model/FilesetTableTest.php | 59 --- .../Controller/IndexControllerTest.php | 52 -- tests/JobTest/Model/JobTableTest.php | 58 --- .../Controller/IndexControllerTest.php | 52 -- tests/LogTest/Model/LogTableTest.php | 57 --- .../Controller/IndexControllerTest.php | 52 -- tests/MediaTest/Model/MediaTableTest.php | 58 --- .../Controller/IndexControllerTest.php | 51 -- tests/PoolTest/Model/PoolTableTest.php | 57 --- .../Controller/IndexControllerTest.php | 52 -- .../Controller/IndexControllerTest.php | 52 -- tests/StorageTest/Model/StorageTableTest.php | 59 --- tests/phpunit/Bootstrap.php | 100 ++++ tests/selenium/webui-selenium-test.py | 128 +++++ tests/travis/config_db.sh | 5 - tests/travis/pgsql/grant_privileges.sql | 53 -- tests/travis/pgsql/make_tables.sql | 477 ------------------ 27 files changed, 247 insertions(+), 1725 deletions(-) delete mode 100644 tests/Bootstrap.php delete mode 100644 tests/ClientTest/Controller/IndexControllerTest.php delete mode 100644 tests/ClientTest/Model/ClientTableTest.php delete mode 100644 tests/DashboardTest/Controller/IndexControllerTest.php delete mode 100644 tests/DirectorTest/Controller/IndexControllerTest.php delete mode 100644 tests/FileTest/Controller/IndexControllerTest.php delete mode 100644 tests/FileTest/Model/FileTableTest.php delete mode 100644 tests/FilesetTest/Controller/IndexControllerTest.php delete mode 100644 tests/FilesetTest/Model/FilesetTableTest.php delete mode 100644 tests/JobTest/Controller/IndexControllerTest.php delete mode 100644 tests/JobTest/Model/JobTableTest.php delete mode 100644 tests/LogTest/Controller/IndexControllerTest.php delete mode 100644 tests/LogTest/Model/LogTableTest.php delete mode 100644 tests/MediaTest/Controller/IndexControllerTest.php delete mode 100644 tests/MediaTest/Model/MediaTableTest.php delete mode 100644 tests/PoolTest/Controller/IndexControllerTest.php delete mode 100644 tests/PoolTest/Model/PoolTableTest.php delete mode 100644 tests/RestoreTest/Controller/IndexControllerTest.php delete mode 100644 tests/StorageTest/Controller/IndexControllerTest.php delete mode 100644 tests/StorageTest/Model/StorageTableTest.php create mode 100644 tests/phpunit/Bootstrap.php create mode 100644 tests/selenium/webui-selenium-test.py delete mode 100755 tests/travis/config_db.sh delete mode 100644 tests/travis/pgsql/grant_privileges.sql delete mode 100644 tests/travis/pgsql/make_tables.sql diff --git a/.travis.yml b/.travis.yml index 0b088b64..d3d6aef9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,36 +1,8 @@ language: php - php: - - 5.3 - - 5.4 - - 5.5 - - hhvm - -env: - - DB=postgres - -before_install: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -before_script: - - psql -c 'create database bareos;' -U postgres - - psql bareos < tests/travis/pgsql/make_tables.sql -U postgres - - psql bareos < tests/travis/pgsql/grant_privileges.sql -U postgres - - tests/travis/config_db.sh - -branches: - only: - - master - -script: - -after_script: - -matrix: - allow_failures: - - php: hhvm - fast_finish: true - -notifications: - email: false + - '5.3' + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - nightly diff --git a/phpunit.xml b/phpunit.xml index ec85ab94..e8b49683 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,16 +1,16 @@ - - - - ./tests/JobTest - ./tests/DashboardTest - ./tests/DirectorTest - ./tests/ClientTest - ./tests/PoolTest - ./tests/MediaTest - ./tests/StorageTest - ./tests/RestoreTest - - + + + + + + + + diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php deleted file mode 100644 index 5bbce754..00000000 --- a/tests/Bootstrap.php +++ /dev/null @@ -1,107 +0,0 @@ - array('module_paths' => $zf2ModulePaths,), - 'modules' => array('Job') - ); - - $serviceManager = new ServiceManager(new ServiceManagerConfig()); - $serviceManager->setService('ApplicationConfig', $config); - $serviceManager->get('ModuleManager')->loadModules(); - static::$serviceManager = $serviceManager; - } - - public static function chroot() - { - $rootPath = dirname(static::findParentPath('module')); - chdir($rootPath); - } - - public static function getServiceManager() - { - return static::$serviceManager; - } - - protected static function initAutoloader() - { - $vendorPath = static::findParentPath('vendor'); - - $zf2Path = getenv('ZF2_PATH'); - - if (!$zf2Path) { - if (defined('ZF2_PATH')) { - $zf2Path = ZF2_PATH; - } - elseif (is_dir($vendorPath . '/ZF2/library')) { - $zf2Path = $vendorPath . '/ZF2/library'; - } - elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) { - $zf2Path = $vendorPath . '/zendframework/zendframework/library'; - } - } - - if (!$zf2Path) { - throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or' . ' define a ZF2_PATH environment variable.'); - } - - if (file_exists($vendorPath . '/autoload.php')) { - include $vendorPath . '/autoload.php'; - } - - include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; - - AutoloaderFactory::factory(array( - 'Zend\Loader\StandardAutoloader' => array( - 'autoregister_zf' => true, - 'namespaces' => array( - __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, - ), - ), - )); - } - - protected static function findParentPath($path) - { - $dir = __DIR__; - $previousDir = '.'; - while (!is_dir($dir . '/' . $path)) { - $dir = dirname($dir); - if ($previousDir === $dir) - return false; - $previousDir = $dir; - } - return $dir . '/' . $path; - } - -} - -Bootstrap::init(); -Bootstrap::chroot(); - diff --git a/tests/ClientTest/Controller/IndexControllerTest.php b/tests/ClientTest/Controller/IndexControllerTest.php deleted file mode 100644 index 7874b73b..00000000 --- a/tests/ClientTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,51 +0,0 @@ -. - * - */ - -namespace ClientTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class ClientControllerTest extends AbstractHttpControllerTestCase -{ - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/client'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Client'); - $this->assertControllerName('Client\Controller\Client'); - $this->assertControllerClass('ClientController'); - $this->assertMatchedRouteName('client'); - } - -} diff --git a/tests/ClientTest/Model/ClientTableTest.php b/tests/ClientTest/Model/ClientTableTest.php deleted file mode 100644 index e4b8af3d..00000000 --- a/tests/ClientTest/Model/ClientTableTest.php +++ /dev/null @@ -1,59 +0,0 @@ -. - * - */ - -namespace ClientTest\Model; - -use Client\Model\ClientTable; -use Client\Model\Client; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class ClientTableTest extends PHPUnit_Framework_TestCase -{ - - public function testFetchAllReturnsAllClients() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $clientTable = new ClientTable($mockTableGateway); - - $this->assertSame($resultSet, $clientTable->fetchAll()); - - } - -} diff --git a/tests/DashboardTest/Controller/IndexControllerTest.php b/tests/DashboardTest/Controller/IndexControllerTest.php deleted file mode 100644 index 5586e9d9..00000000 --- a/tests/DashboardTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace DashboardTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class DashboardControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/dashboard'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Dashboard'); - $this->assertControllerName('Dashboard\Controller\Dashboard'); - $this->assertControllerClass('DashboardController'); - $this->assertMatchedRouteName('dashboard'); - } - -} diff --git a/tests/DirectorTest/Controller/IndexControllerTest.php b/tests/DirectorTest/Controller/IndexControllerTest.php deleted file mode 100644 index fa20cf5d..00000000 --- a/tests/DirectorTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace DirectorTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class DirectorControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/director'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Director'); - $this->assertControllerName('Director\Controller\Director'); - $this->assertControllerClass('DirectorController'); - $this->assertMatchedRouteName('director'); - } - -} diff --git a/tests/FileTest/Controller/IndexControllerTest.php b/tests/FileTest/Controller/IndexControllerTest.php deleted file mode 100644 index 2b7eb2a8..00000000 --- a/tests/FileTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace FileTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class FileControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/file'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('File'); - $this->assertControllerName('File\Controller\File'); - $this->assertControllerClass('FileController'); - $this->assertMatchedRouteName('file'); - } - -} diff --git a/tests/FileTest/Model/FileTableTest.php b/tests/FileTest/Model/FileTableTest.php deleted file mode 100644 index bc1322a6..00000000 --- a/tests/FileTest/Model/FileTableTest.php +++ /dev/null @@ -1,59 +0,0 @@ -. - * - */ - -namespace FileTest\Model; - -use File\Model\FileTable; -use File\Model\File; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class FileTableTest extends PHPUnit_Framework_TestCase -{ - - public function testFetchAllReturnsAllJobs() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $fileTable = new FileTable($mockTableGateway); - - $this->assertSame($resultSet, $fileTable->fetchAll()); - - } - -} diff --git a/tests/FilesetTest/Controller/IndexControllerTest.php b/tests/FilesetTest/Controller/IndexControllerTest.php deleted file mode 100644 index b1671319..00000000 --- a/tests/FilesetTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace FilesetTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class FilesetControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/fileset'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Fileset'); - $this->assertControllerName('Fileset\Controller\Fileset'); - $this->assertControllerClass('FilesetController'); - $this->assertMatchedRouteName('fileset'); - } - -} diff --git a/tests/FilesetTest/Model/FilesetTableTest.php b/tests/FilesetTest/Model/FilesetTableTest.php deleted file mode 100644 index 8cad5822..00000000 --- a/tests/FilesetTest/Model/FilesetTableTest.php +++ /dev/null @@ -1,59 +0,0 @@ -. - * - */ - -namespace FilesetTest\Model; - -use Fileset\Model\FilesetTable; -use Fileset\Model\Fileset; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class FilesetTableTest extends PHPUnit_Framework_TestCase -{ - - public function testFetchAllReturnsAllFilesets() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $filesetTable = new FilesetTable($mockTableGateway); - - $this->assertSame($resultSet, $filesetTable->fetchAll()); - - } - -} diff --git a/tests/JobTest/Controller/IndexControllerTest.php b/tests/JobTest/Controller/IndexControllerTest.php deleted file mode 100644 index 94eda572..00000000 --- a/tests/JobTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace JobTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class JobControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/job'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Job'); - $this->assertControllerName('Job\Controller\Job'); - $this->assertControllerClass('JobController'); - $this->assertMatchedRouteName('job'); - } - -} diff --git a/tests/JobTest/Model/JobTableTest.php b/tests/JobTest/Model/JobTableTest.php deleted file mode 100644 index 8e765e2f..00000000 --- a/tests/JobTest/Model/JobTableTest.php +++ /dev/null @@ -1,58 +0,0 @@ -. - * - */ - -namespace JobTest\Model; - -use Job\Model\JobTable; -use Job\Model\Job; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class JobTableTest extends PHPUnit_Framework_TestCase -{ - public function testFetchAllReturnsAllJobs() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $jobTable = new JobTable($mockTableGateway); - - $this->assertSame($resultSet, $jobTable->fetchAll()); - - } - -} diff --git a/tests/LogTest/Controller/IndexControllerTest.php b/tests/LogTest/Controller/IndexControllerTest.php deleted file mode 100644 index 581ebf52..00000000 --- a/tests/LogTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace LogTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class LogControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/log'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Log'); - $this->assertControllerName('Log\Controller\Log'); - $this->assertControllerClass('LogController'); - $this->assertMatchedRouteName('log'); - } - -} diff --git a/tests/LogTest/Model/LogTableTest.php b/tests/LogTest/Model/LogTableTest.php deleted file mode 100644 index af8264ff..00000000 --- a/tests/LogTest/Model/LogTableTest.php +++ /dev/null @@ -1,57 +0,0 @@ -. - * - */ - -namespace LogTest\Model; - -use Log\Model\LogTable; -use Log\Model\Log; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class LogTableTest extends PHPUnit_Framework_TestCase -{ - public function testFetchAllReturnsAllLogs() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $logTable = new LogTable($mockTableGateway); - - $this->assertSame($resultSet, $logTable->fetchAll()); - - } -} diff --git a/tests/MediaTest/Controller/IndexControllerTest.php b/tests/MediaTest/Controller/IndexControllerTest.php deleted file mode 100644 index 1024b80e..00000000 --- a/tests/MediaTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace MediaTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class MediaControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/media'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Media'); - $this->assertControllerName('Media\Controller\Media'); - $this->assertControllerClass('MediaController'); - $this->assertMatchedRouteName('media'); - } - -} diff --git a/tests/MediaTest/Model/MediaTableTest.php b/tests/MediaTest/Model/MediaTableTest.php deleted file mode 100644 index 252d25b0..00000000 --- a/tests/MediaTest/Model/MediaTableTest.php +++ /dev/null @@ -1,58 +0,0 @@ -. - * - */ - -namespace MediaTest\Model; - -use Media\Model\MediaTable; -use Media\Model\Media; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class MediaTableTest extends PHPUnit_Framework_TestCase -{ - public function testFetchAllReturnsAllMedia() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - - $mediaTable = new MediaTable($mockTableGateway); - - $this->assertSame($resultSet, $mediaTable->fetchAll()); - - } -} diff --git a/tests/PoolTest/Controller/IndexControllerTest.php b/tests/PoolTest/Controller/IndexControllerTest.php deleted file mode 100644 index 1fab26bb..00000000 --- a/tests/PoolTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,51 +0,0 @@ -. - * - */ - -namespace PoolTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class PoolControllerTest extends AbstractHttpControllerTestCase -{ - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/pool'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Pool'); - $this->assertControllerName('Pool\Controller\Pool'); - $this->assertControllerClass('PoolController'); - $this->assertMatchedRouteName('pool'); - } - -} diff --git a/tests/PoolTest/Model/PoolTableTest.php b/tests/PoolTest/Model/PoolTableTest.php deleted file mode 100644 index be594a2d..00000000 --- a/tests/PoolTest/Model/PoolTableTest.php +++ /dev/null @@ -1,57 +0,0 @@ -. - * - */ - -namespace PoolTest\Model; - -use Pool\Model\PoolTable; -use Pool\Model\Job; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class PoolTableTest extends PHPUnit_Framework_TestCase -{ - public function testFetchAllReturnsAllPools() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $poolTable = new PoolTable($mockTableGateway); - - $this->assertSame($resultSet, $poolTable->fetchAll()); - - } -} diff --git a/tests/RestoreTest/Controller/IndexControllerTest.php b/tests/RestoreTest/Controller/IndexControllerTest.php deleted file mode 100644 index d8f16b2c..00000000 --- a/tests/RestoreTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace RestoreTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class RestoreControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/restore'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Restore'); - $this->assertControllerName('Restore\Controller\Restore'); - $this->assertControllerClass('RestoreController'); - $this->assertMatchedRouteName('restore'); - } - -} diff --git a/tests/StorageTest/Controller/IndexControllerTest.php b/tests/StorageTest/Controller/IndexControllerTest.php deleted file mode 100644 index 4c0f18dd..00000000 --- a/tests/StorageTest/Controller/IndexControllerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -namespace StorageTest\Controller; - -use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; - -class StorageControllerTest extends AbstractHttpControllerTestCase -{ - - protected $traceError = true; - - public function setUp() - { - $this->setApplicationConfig( - include './config/application.config.php' - ); - } - - public function testIndexActionCanBeAccessed() - { - $this->dispatch('/storage'); - $this->assertResponseStatusCode(200); - $this->assertModuleName('Storage'); - $this->assertControllerName('Storage\Controller\Storage'); - $this->assertControllerClass('StorageController'); - $this->assertMatchedRouteName('storage'); - } - -} diff --git a/tests/StorageTest/Model/StorageTableTest.php b/tests/StorageTest/Model/StorageTableTest.php deleted file mode 100644 index b76af865..00000000 --- a/tests/StorageTest/Model/StorageTableTest.php +++ /dev/null @@ -1,59 +0,0 @@ -. - * - */ - -namespace StorageTest\Model; - -use Storage\Model\StorageTable; -use Storage\Model\Storage; -use Zend\Db\ResultSet\ResultSet; -use PHPUnit_Framework_TestCase; - -class StorageTableTest extends PHPUnit_Framework_TestCase -{ - - public function testFetchAllReturnsAllJobs() - { - $resultSet = new ResultSet(); - - $mockTableGateway = $this->getMock( - 'Zend\Db\TableGateway\TableGateway', - array('select'), - array(), - '', - false - ); - - $mockTableGateway->expects($this->once()) - ->method('select') - ->with() - ->will($this->returnValue($resultSet)); - - $storageTable = new StorageTable($mockTableGateway); - - $this->assertSame($resultSet, $storageTable->fetchAll()); - - } - -} diff --git a/tests/phpunit/Bootstrap.php b/tests/phpunit/Bootstrap.php new file mode 100644 index 00000000..72e593cc --- /dev/null +++ b/tests/phpunit/Bootstrap.php @@ -0,0 +1,100 @@ + array( + 'module_paths' => $zf2ModulePaths, + ), + 'modules' => array( + 'Application' + ) + ); + + $serviceManager = new ServiceManager(new ServiceManagerConfig()); + $serviceManager->setService('ApplicationConfig', $config); + $serviceManager->get('ModuleManager')->loadModules(); + static::$serviceManager = $serviceManager; + } + + public static function chroot() + { + $rootPath = dirname(static::findParentPath('module')); + chdir($rootPath); + } + + public static function getServiceManager() + { + return static::$serviceManager; + } + + protected static function initAutoloader() + { + $vendorPath = static::findParentPath('vendor'); + + if (file_exists($vendorPath.'/autoload.php')) { + include $vendorPath.'/autoload.php'; + } + + if (! class_exists('Zend\Loader\AutoloaderFactory')) { + throw new RuntimeException( + 'Unable to load ZF2. Run `php composer.phar install`' + ); + } + + AutoloaderFactory::factory(array( + 'Zend\Loader\StandardAutoloader' => array( + 'autoregister_zf' => true, + 'namespaces' => array( + __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, + ), + ), + )); + } + + protected static function findParentPath($path) + { + $dir = __DIR__; + $previousDir = '.'; + while (!is_dir($dir . '/' . $path)) { + $dir = dirname($dir); + if ($previousDir === $dir) { + return false; + } + $previousDir = $dir; + } + return $dir . '/' . $path; + } +} + +Bootstrap::init(); +Bootstrap::chroot(); + diff --git a/tests/selenium/webui-selenium-test.py b/tests/selenium/webui-selenium-test.py new file mode 100644 index 00000000..9b373f59 --- /dev/null +++ b/tests/selenium/webui-selenium-test.py @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.support.ui import Select +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import NoAlertPresentException +import unittest, time, re, sys, os +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities + + +class Bareos(unittest.TestCase): + + def setUp(self): + d = DesiredCapabilities.FIREFOX + d['loggingPrefs'] = { 'browser':'ALL' } + fp = webdriver.FirefoxProfile() + fp.set_preference('webdriver.log.file', '/tmp/firefox_console') + self.driver = webdriver.Firefox(capabilities=d,firefox_profile=fp) + self.driver.implicitly_wait(30) + self.base_url = "http://%s" % targethost + self.verificationErrors = [] + self.accept_next_alert = True + + def test_bareos(self): + if os.getenv('PRODVERSION').startswith("16.2"): + driver = self.driver + + if os.getenv('DIST') == "windows": + driver.get(self.base_url + "/") + else: + driver.get(self.base_url + "/bareos-webui/") + + Select(driver.find_element_by_name("director")).select_by_visible_text("localhost-dir") + driver.find_element_by_name("consolename").clear() + + if os.getenv('DIST') == "windows": + driver.find_element_by_name("consolename").send_keys("admin") + else: + driver.find_element_by_name("consolename").send_keys("citest") + + driver.find_element_by_name("password").clear() + + if os.getenv('DIST') == "windows": + driver.find_element_by_name("password").send_keys("admin") + else: + driver.find_element_by_name("password").send_keys("citestpass") + driver.find_element_by_id("submit").click() + driver.find_element_by_link_text("Director").click() + driver.find_element_by_link_text("Messages").click() + driver.find_element_by_link_text("Schedules").click() + driver.find_element_by_link_text("Scheduler status").click() + driver.find_element_by_link_text("Storages").click() + driver.find_element_by_link_text("Clients").click() + driver.find_element_by_link_text("Restore").click() + + if os.getenv('DIST') == "windows": + driver.find_element_by_partial_link_text("admin").click() + else: + driver.find_element_by_partial_link_text("citest").click() + + driver.find_element_by_link_text("Logout").click() + + elif os.getenv('PRODVERSION') == "15.2": + driver = self.driver + driver.get(self.base_url + "/bareos-webui/") + Select(driver.find_element_by_name("director")).select_by_visible_text("localhost-dir") + driver.find_element_by_name("consolename").clear() + driver.find_element_by_name("consolename").send_keys("citest") + driver.find_element_by_name("password").clear() + driver.find_element_by_name("password").send_keys("citestpass") + driver.find_element_by_id("submit").click() + driver.find_element_by_link_text("Director").click() + driver.find_element_by_link_text("Messages").click() + driver.find_element_by_link_text("Schedule").click() + driver.find_element_by_link_text("Scheduler status").click() + driver.find_element_by_link_text("Storages").click() + driver.find_element_by_link_text("Clients").click() + driver.find_element_by_link_text("Restore").click() + driver.find_element_by_partial_link_text("citest").click() + driver.find_element_by_link_text("Logout").click() + else: + driver = self.driver + driver.get(self.base_url + "/bareos-webui/") + Select(driver.find_element_by_name("director")).select_by_visible_text("localhost-dir") + driver.find_element_by_name("consolename").clear() + driver.find_element_by_name("consolename").send_keys("citest") + driver.find_element_by_name("password").clear() + driver.find_element_by_name("password").send_keys("citestpass") + driver.find_element_by_id("submit").click() + driver.find_element_by_link_text("Director").click() + driver.find_element_by_link_text("Messages").click() + driver.find_element_by_link_text("Schedules").click() + driver.find_element_by_link_text("Scheduler status").click() + driver.find_element_by_link_text("Storages").click() + driver.find_element_by_link_text("Clients").click() + driver.find_element_by_link_text("Restore").click() + driver.find_element_by_partial_link_text("citest").click() + driver.find_element_by_link_text("Logout").click() + + def is_element_present(self, how, what): + try: self.driver.find_element(by=how, value=what) + except NoSuchElementException, e: return False + return True + + def is_alert_present(self): + try: self.driver.switch_to_alert() + except NoAlertPresentException, e: return False + return True + + def close_alert_and_get_its_text(self): + try: + alert = self.driver.switch_to_alert() + alert_text = alert.text + if self.accept_next_alert: + alert.accept() + else: + alert.dismiss() + return alert_text + finally: self.accept_next_alert = True + + def tearDown(self): + self.driver.quit() + self.assertEqual([], self.verificationErrors) + +if __name__ == "__main__": + targethost = os.environ.get('VM_IP') + unittest.main() diff --git a/tests/travis/config_db.sh b/tests/travis/config_db.sh deleted file mode 100755 index 319859b3..00000000 --- a/tests/travis/config_db.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cp config/autoload/local.php.dist config/autoload/local.php; - -exit 0; diff --git a/tests/travis/pgsql/grant_privileges.sql b/tests/travis/pgsql/grant_privileges.sql deleted file mode 100644 index c6da1490..00000000 --- a/tests/travis/pgsql/grant_privileges.sql +++ /dev/null @@ -1,53 +0,0 @@ -CREATE ROLE bareos WITH LOGIN; -CREATE USER bareos bareos; - --- For tables -GRANT ALL ON UnSavedFiles TO bareos; -GRANT ALL ON BaseFiles TO bareos; -GRANT ALL ON JobMedia TO bareos; -GRANT ALL ON File TO bareos; -GRANT ALL ON Job TO bareos; -GRANT ALL ON Media TO bareos; -GRANT ALL ON Client TO bareos; -GRANT ALL ON Pool TO bareos; -GRANT ALL ON Fileset TO bareos; -GRANT ALL ON Path TO bareos; -GRANT ALL ON Filename TO bareos; -GRANT ALL ON Counters TO bareos; -GRANT ALL ON Version TO bareos; -GRANT ALL ON CdImages TO bareos; -GRANT ALL ON MediaType TO bareos; -GRANT ALL ON Storage TO bareos; -GRANT ALL ON Device TO bareos; -GRANT ALL ON Status TO bareos; -GRANT ALL ON Location TO bareos; -GRANT ALL ON LocationLog TO bareos; -GRANT ALL ON Log TO bareos; -GRANT ALL ON JobHisto TO bareos; -GRANT ALL ON PathHierarchy TO bareos; -GRANT ALL ON PathVisibility TO bareos; -GRANT ALL ON RestoreObject TO bareos; -GRANT ALL ON Quota TO bareos; -GRANT ALL ON NDMPLevelMap TO bareos; -GRANT ALL ON NDMPJobEnvironment TO bareos; -GRANT ALL ON DeviceStats TO bareos; -GRANT ALL ON JobStats TO bareos; - --- For sequences ON those tables -GRANT SELECT, UPDATE ON filename_filenameid_seq TO bareos; -GRANT SELECT, UPDATE ON path_pathid_seq TO bareos; -GRANT SELECT, UPDATE ON fileset_filesetid_seq TO bareos; -GRANT SELECT, UPDATE ON pool_poolid_seq TO bareos; -GRANT SELECT, UPDATE ON client_clientid_seq TO bareos; -GRANT SELECT, UPDATE ON media_mediaid_seq TO bareos; -GRANT SELECT, UPDATE ON job_jobid_seq TO bareos; -GRANT SELECT, UPDATE ON file_fileid_seq TO bareos; -GRANT SELECT, UPDATE ON jobmedia_jobmediaid_seq TO bareos; -GRANT SELECT, UPDATE ON basefiles_baseid_seq TO bareos; -GRANT SELECT, UPDATE ON storage_storageid_seq TO bareos; -GRANT SELECT, UPDATE ON mediatype_mediatypeid_seq TO bareos; -GRANT SELECT, UPDATE ON device_deviceid_seq TO bareos; -GRANT SELECT, UPDATE ON location_locationid_seq TO bareos; -GRANT SELECT, UPDATE ON locationlog_loclogid_seq TO bareos; -GRANT SELECT, UPDATE ON log_logid_seq TO bareos; -GRANT SELECT, UPDATE ON restoreobject_restoreobjectid_seq TO bareos; diff --git a/tests/travis/pgsql/make_tables.sql b/tests/travis/pgsql/make_tables.sql deleted file mode 100644 index 63bdc1e5..00000000 --- a/tests/travis/pgsql/make_tables.sql +++ /dev/null @@ -1,477 +0,0 @@ -CREATE TABLE Filename -( - FilenameId SERIAL NOT NULL, - Name TEXT NOT NULL, - PRIMARY KEY (FilenameId) -); - -ALTER TABLE Filename ALTER COLUMN Name SET STATISTICS 1000; -CREATE UNIQUE INDEX filename_name_idx ON Filename (Name); - -CREATE TABLE Path -( - PathId SERIAL NOT NULL, - Path TEXT NOT NULL, - PRIMARY KEY (PathId) -); - -ALTER TABLE Path ALTER COLUMN Path SET STATISTICS 1000; -CREATE UNIQUE INDEX path_name_idx ON Path (Path); - --- We strongly recommend to avoid the temptation to add new indexes. --- In general, these will cause very significant performance --- problems in other areas. A better approch is to carefully check --- that all your memory configuation parameters are --- suitable for the size of your installation. If you backup --- millions of files, you need to adapt the database memory --- configuration parameters concerning sorting, joining and global --- memory. By DEFAULT, sort and join parameters are very small --- (sometimes 8Kb), and having sufficient memory specified by those --- parameters is extremely important to run fast. - --- In File table --- FileIndex can be 0 for FT_DELETED files --- FileNameId can link to Filename.Name='' for directories -CREATE TABLE File -( - FileId BIGSERIAL NOT NULL, - FileIndex INTEGER NOT NULL DEFAULT 0, - JobId INTEGER NOT NULL, - PathId INTEGER NOT NULL, - FilenameId INTEGER NOT NULL, - DeltaSeq SMALLINT NOT NULL DEFAULT 0, - MarkId INTEGER NOT NULL DEFAULT 0, - LStat TEXT NOT NULL, - Md5 TEXT NOT NULL, - PRIMARY KEY (FileId) -); - -CREATE INDEX file_jpfid_idx ON File (JobId, PathId, FilenameId); -CREATE INDEX file_jobid_idx ON File (JobId); - --- --- Add this if you have a good number of job --- that run at the same time --- ALTER SEQUENCE file_fileid_seq CACHE 1000; - --- --- Possibly add one or more of the following indexes --- if your Verifies are too slow, but they can slow down --- backups. --- --- CREATE INDEX file_pathid_idx ON file(pathid); --- CREATE INDEX file_filenameid_idx ON file(filenameid); - -CREATE TABLE RestoreObject ( - RestoreObjectId SERIAL NOT NULL, - ObjectName TEXT NOT NULL, - RestoreObject BYTEA NOT NULL, - PluginName TEXT NOT NULL, - ObjectLength INTEGER DEFAULT 0, - ObjectFullLength INTEGER DEFAULT 0, - ObjectIndex INTEGER DEFAULT 0, - ObjectType INTEGER DEFAULT 0, - FileIndex INTEGER DEFAULT 0, - JobId INTEGER, - ObjectCompression INTEGER DEFAULT 0, - PRIMARY KEY(RestoreObjectId) -); -CREATE INDEX restore_jobid_idx ON RestoreObject(JobId); - -CREATE TABLE Job -( - JobId SERIAL NOT NULL, - Job TEXT NOT NULL, - Name TEXT NOT NULL, - Type CHAR(1) NOT NULL, - Level CHAR(1) NOT NULL, - ClientId INTEGER DEFAULT 0, - JobStatus CHAR(1) NOT NULL, - SchedTime TIMESTAMP WITHOUT TIME ZONE, - StartTime TIMESTAMP WITHOUT TIME ZONE, - EndTime TIMESTAMP WITHOUT TIME ZONE, - RealEndTime TIMESTAMP WITHOUT TIME ZONE, - JobTDate BIGINT DEFAULT 0, - VolSessionId INTEGER DEFAULT 0, - volSessionTime INTEGER DEFAULT 0, - JobFiles INTEGER DEFAULT 0, - JobBytes BIGINT DEFAULT 0, - ReadBytes BIGINT DEFAULT 0, - JobErrors INTEGER DEFAULT 0, - JobMissingFiles INTEGER DEFAULT 0, - PoolId INTEGER DEFAULT 0, - FilesetId INTEGER DEFAULT 0, - PriorJobid INTEGER DEFAULT 0, - PurgedFiles SMALLINT DEFAULT 0, - HasBase SMALLINT DEFAULT 0, - HasCache SMALLINT DEFAULT 0, - Reviewed SMALLINT DEFAULT 0, - Comment TEXT, - PRIMARY KEY (JobId) -); - -CREATE INDEX job_name_idx ON job (Name); - --- Create a table like Job for long term statistics -CREATE TABLE JobHisto (LIKE Job); -CREATE INDEX jobhisto_idx ON JobHisto (StartTime); - -CREATE TABLE Location ( - LocationId SERIAL NOT NULL, - Location TEXT NOT NULL, - Cost INTEGER DEFAULT 0, - Enabled SMALLINT, - PRIMARY KEY (LocationId) -); - -CREATE TABLE Fileset -( - FileSetId SERIAL NOT NULL, - Fileset TEXT NOT NULL, - Md5 TEXT NOT NULL, - CreateTime TIMESTAMP WITHOUT TIME ZONE NOT NULL, - PRIMARY KEY (filesetid) -); - -CREATE INDEX fileset_name_idx ON fileset (fileset); - -CREATE TABLE JobMedia -( - JobMediaId SERIAL NOT NULL, - JobId INTEGER NOT NULL, - MediaId INTEGER NOT NULL, - FirstIndex INTEGER DEFAULT 0, - LastIndex INTEGER DEFAULT 0, - StartFile INTEGER DEFAULT 0, - EndFile INTEGER DEFAULT 0, - StartBlock BIGINT DEFAULT 0, - EndBlock BIGINT DEFAULT 0, - VolIndex INTEGER DEFAULT 0, - PRIMARY KEY (jobmediaid) -); - -CREATE INDEX job_media_job_id_media_id_idx ON jobmedia (JobId, MediaId); - -CREATE TABLE Media -( - MediaId SERIAL NOT NULL, - VolumeName TEXT NOT NULL, - Slot INTEGER DEFAULT 0, - PoolId INTEGER DEFAULT 0, - MediaType TEXT NOT NULL, - MediaTypeId INTEGER DEFAULT 0, - LabelType INTEGER DEFAULT 0, - FirstWritten TIMESTAMP WITHOUT TIME ZONE, - LastWritten TIMESTAMP WITHOUT TIME ZONE, - LabelDate TIMESTAMP WITHOUT TIME ZONE, - VolJobs INTEGER DEFAULT 0, - VolFiles INTEGER DEFAULT 0, - VolBlocks INTEGER DEFAULT 0, - VolMounts INTEGER DEFAULT 0, - VolBytes BIGINT DEFAULT 0, - VolErrors INTEGER DEFAULT 0, - VolWrites INTEGER DEFAULT 0, - VolCapacityBytes BIGINT DEFAULT 0, - VolStatus TEXT NOT NULL - CHECK (VolStatus IN ('Full', 'Archive', 'Append', - 'Recycle', 'Purged', 'Read-Only', 'Disabled', - 'Error', 'Busy', 'Used', 'Cleaning', 'Scratch')), - Enabled SMALLINT DEFAULT 1, - Recycle SMALLINT DEFAULT 0, - ActionOnPurge SMALLINT DEFAULT 0, - VolRetention BIGINT DEFAULT 0, - VolUseDuration BIGINT DEFAULT 0, - MaxVolJobs INTEGER DEFAULT 0, - MaxVolFiles INTEGER DEFAULT 0, - MaxVolBytes BIGINT DEFAULT 0, - InChanger SMALLINT DEFAULT 0, - StorageId INTEGER DEFAULT 0, - DeviceId INTEGER DEFAULT 0, - MediaAddressing SMALLINT DEFAULT 0, - VolReadTime BIGINT DEFAULT 0, - VolWriteTime BIGINT DEFAULT 0, - EndFile INTEGER DEFAULT 0, - EndBlock BIGINT DEFAULT 0, - LocationId INTEGER DEFAULT 0, - RecycleCount INTEGER DEFAULT 0, - MinBlockSize INTEGER DEFAULT 0, - MaxBlockSize INTEGER DEFAULT 0, - InitialWrite TIMESTAMP WITHOUT TIME ZONE, - ScratchPoolId INTEGER DEFAULT 0, - RecyclePoolId INTEGER DEFAULT 0, - EncryptionKey TEXT, - Comment TEXT, - PRIMARY KEY (MediaId) -); - -CREATE UNIQUE INDEX media_volumename_id ON Media (VolumeName); -CREATE INDEX media_poolid_idx ON Media (PoolId); - -CREATE TABLE MediaType ( - MediaTypeId SERIAL, - MediaType TEXT NOT NULL, - ReadOnly INTEGER DEFAULT 0, - PRIMARY KEY(MediaTypeId) -); - -CREATE TABLE Storage ( - StorageId SERIAL, - Name TEXT NOT NULL, - AutoChanger INTEGER DEFAULT 0, - PRIMARY KEY(StorageId) -); - -CREATE TABLE Device ( - DeviceId SERIAL, - Name TEXT NOT NULL, - MediaTypeId INTEGER NOT NULL, - StorageId INTEGER NOT NULL, - DevMounts INTEGER NOT NULL DEFAULT 0, - DevReadBytes BIGINT NOT NULL DEFAULT 0, - DevWriteBytes BIGINT NOT NULL DEFAULT 0, - DevReadBytesSinceCleaning BIGINT NOT NULL DEFAULT 0, - DevWriteBytesSinceCleaning BIGINT NOT NULL DEFAULT 0, - DevReadTime BIGINT NOT NULL DEFAULT 0, - DevWriteTime BIGINT NOT NULL DEFAULT 0, - DevReadTimeSinceCleaning BIGINT NOT NULL DEFAULT 0, - DevWriteTimeSinceCleaning BIGINT NOT NULL DEFAULT 0, - CleaningDate TIMESTAMP WITHOUT TIME ZONE, - CleaningPeriod BIGINT NOT NULL DEFAULT 0, - PRIMARY KEY(DeviceId) -); - -CREATE TABLE Pool -( - PoolId SERIAL NOT NULL, - Name TEXT NOT NULL, - NumVols INTEGER DEFAULT 0, - MaxVols INTEGER DEFAULT 0, - UseOnce SMALLINT DEFAULT 0, - UseCatalog SMALLINT DEFAULT 0, - AcceptAnyVolume SMALLINT DEFAULT 0, - VolRetention BIGINT DEFAULT 0, - VolUseDuration BIGINT DEFAULT 0, - MaxVolJobs INTEGER DEFAULT 0, - MaxVolFiles INTEGER DEFAULT 0, - MaxVolBytes BIGINT DEFAULT 0, - AutoPrune SMALLINT DEFAULT 0, - Recycle SMALLINT DEFAULT 0, - ActionOnPurge SMALLINT DEFAULT 0, - PoolType TEXT - CHECK (PoolType IN ('Backup', 'Copy', 'Cloned', 'Archive', - 'Migration', 'Scratch')), - LabelType INTEGER DEFAULT 0, - LabelFormat TEXT NOT NULL, - Enabled SMALLINT DEFAULT 1, - ScratchPoolId INTEGER DEFAULT 0, - RecyclePoolId INTEGER DEFAULT 0, - NextPoolId INTEGER DEFAULT 0, - MinBlockSize INTEGER DEFAULT 0, - MaxBlockSize INTEGER DEFAULT 0, - MigrationHighBytes BIGINT DEFAULT 0, - MigrationLowBytes BIGINT DEFAULT 0, - MigrationTime BIGINT DEFAULT 0, - PRIMARY KEY (PoolId) -); - -CREATE INDEX pool_name_idx ON Pool (Name); - -CREATE TABLE Client -( - ClientId SERIAL NOT NULL, - Name TEXT NOT NULL, - UName TEXT NOT NULL, - AutoPrune SMALLINT DEFAULT 0, - FileRetention BIGINT DEFAULT 0, - JobRetention BIGINT DEFAULT 0, - PRIMARY KEY (ClientId) -); - -CREATE UNIQUE INDEX client_name_idx ON Client (Name); - -CREATE TABLE Log -( - LogId SERIAL NOT NULL, - JobId INTEGER NOT NULL, - Time TIMESTAMP WITHOUT TIME ZONE, - LogText TEXT NOT NULL, - PRIMARY KEY (LogId) -); -CREATE INDEX log_name_idx ON Log (JobId); - -CREATE TABLE LocationLog ( - LocLogId SERIAL NOT NULL, - Date TIMESTAMP WITHOUT TIME ZONE, - Comment TEXT NOT NULL, - MediaId INTEGER DEFAULT 0, - LocationId INTEGER DEFAULT 0, - NewVolStatus TEXT NOT NULL - CHECK (NewVolStatus IN ('Full', 'Archive', 'Append', - 'Recycle', 'Purged', 'Read-Only', 'Disabled', - 'Error', 'Busy', 'Used', 'Cleaning', 'Scratch')), - newenabled SMALLINT, - PRIMARY KEY(LocLogId) -); - -CREATE TABLE counters -( - Counter TEXT NOT NULL, - MinValue INTEGER DEFAULT 0, - MaxValue INTEGER DEFAULT 0, - CurrentValue INTEGER DEFAULT 0, - wrapcounter TEXT NOT NULL, - PRIMARY KEY (Counter) -); - -CREATE TABLE basefiles -( - BaseId SERIAL NOT NULL, - JobId INTEGER NOT NULL, - FileId BIGINT NOT NULL, - FileIndex INTEGER, - BaseJobId INTEGER, - PRIMARY KEY (BaseId) -); - -CREATE INDEX basefiles_jobid_idx ON BaseFiles (JobId); - -CREATE TABLE UnsavedFiles -( - UnsavedId INTEGER NOT NULL, - JobId INTEGER NOT NULL, - PathId INTEGER NOT NULL, - FilenameId INTEGER NOT NULL, - PRIMARY KEY (UnsavedId) -); - -CREATE TABLE CDImages -( - MediaId INTEGER NOT NULL, - LastBurn TIMESTAMP WITHOUT TIME ZONE NOT NULL, - PRIMARY KEY (MediaId) -); - -CREATE TABLE PathHierarchy -( - PathId INTEGER NOT NULL, - PPathId INTEGER NOT NULL, - CONSTRAINT pathhierarchy_pkey PRIMARY KEY (PathId) -); - -CREATE INDEX pathhierarchy_ppathid - ON PathHierarchy (PPathId); - -CREATE TABLE PathVisibility -( - PathId INTEGER NOT NULL, - JobId INTEGER NOT NULL, - Size BIGINT DEFAULT 0, - Files INTEGER DEFAULT 0, - CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId) -); -CREATE INDEX pathvisibility_jobid - ON PathVisibility (JobId); - -CREATE TABLE version -( - VersionId INTEGER NOT NULL -); - -CREATE TABLE Status ( - JobStatus CHAR(1) NOT NULL, - JobStatusLong TEXT, - Severity INTEGER, - PRIMARY KEY (JobStatus) -); - -CREATE TABLE Quota ( - ClientId INTEGER NOT NULL, - GraceTime BIGINT DEFAULT 0, - QuotaLimit BIGINT DEFAULT 0, - PRIMARY KEY (ClientId) -); - -CREATE TABLE NDMPLevelMap ( - ClientId INTEGER NOT NULL, - FilesetId INTEGER DEFAULT 0, - FileSystem TEXT NOT NULL, - DumpLevel INTEGER NOT NULL, - CONSTRAINT NDMPLevelMap_pkey PRIMARY KEY (ClientId, FilesetId, FileSystem) -); - -CREATE TABLE NDMPJobEnvironment ( - JobId INTEGER NOT NULL, - FileIndex INTEGER NOT NULL, - EnvName TEXT NOT NULL, - EnvValue TEXT NOT NULL, - CONSTRAINT NDMPJobEnvironment_pkey PRIMARY KEY (JobId, FileIndex, EnvName) -); - -CREATE TABLE DeviceStats ( - SampleTime TIMESTAMP WITHOUT TIME ZONE NOT NULL, - ReadTime BIGINT NOT NULL DEFAULT 0, - WriteTime BIGINT NOT NULL DEFAULT 0, - ReadBytes BIGINT DEFAULT 0, - WriteBytes BIGINT DEFAULT 0, - Spool SMALLINT DEFAULT 0, - Waiting SMALLINT DEFAULT 0, - Writers SMALLINT DEFAULT 0, - MediaId INTEGER NOT NULL, - VolCatBytes BIGINT DEFAULT 0, - VolCatFiles BIGINT DEFAULT 0, - VolCatBlocks BIGINT DEFAULT 0 -); - -CREATE TABLE JobStats ( - SampleTime TIMESTAMP WITHOUT TIME ZONE NOT NULL, - JobId INTEGER NOT NULL, - JobFiles INTEGER DEFAULT 0, - JobBytes BIGINT DEFAULT 0 -); - -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('C', 'Created, not yet running',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('R', 'Running',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('B', 'Blocked',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('T', 'Completed successfully', 10); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('E', 'Terminated with errors', 25); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('e', 'Non-fatal error',20); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('f', 'Fatal error',100); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('D', 'Verify found differences',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('A', 'Canceled by user',90); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('F', 'Waiting for Client',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('S', 'Waiting for Storage daemon',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('m', 'Waiting for new media',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('M', 'Waiting for media mount',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('s', 'Waiting for storage resource',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('j', 'Waiting for job resource',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('c', 'Waiting for client resource',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('d', 'Waiting on maximum jobs',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('t', 'Waiting on start time',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('p', 'Waiting on higher priority jobs',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('a', 'SD despooling attributes',15); -INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES - ('i', 'Doing batch insert file records',15); - -INSERT INTO Version (VersionId) VALUES (2002); - --- Make sure we have appropriate permissions