diff --git a/Testing/Dashboard/CMakeLists.txt b/Testing/Dashboard/CMakeLists.txt index 85e1fb47a084569b852c7ccdae81b32b6efd4347..244b8d862e71723c82cb1539df163350ade6a0fe 100644 --- a/Testing/Dashboard/CMakeLists.txt +++ b/Testing/Dashboard/CMakeLists.txt @@ -1,16 +1,5 @@ # --------------------------------------------------------------------- -# Settings -mark_as_advanced( ELASTIX_DASHBOARD_HOST ) -set( ELASTIX_DASHBOARD_HOST "elastix" ) - -mark_as_advanced( ELASTIX_DASHBOARD_ELASTICSEARCH_PORT ) -set( ELASTIX_DASHBOARD_ELASTICSEARCH_PORT 9200 ) - -mark_as_advanced( ELASTIX_DASHBOARD_LOGSTASH_PORT ) -set( ELASTIX_DASHBOARD_LOGSTASH_PORT 5043 ) - -mark_as_advanced( ELASTIX_DASHBOARD_KIBANA_PORT ) -set( ELASTIX_DASHBOARD_KIBANA_PORT 5601 ) +# Dashboard configuration mark_as_advanced( ELASTIX_DASHBOARD_SOURCE_DIR ) set( ELASTIX_DASHBOARD_SOURCE_DIR "${CMAKE_SOURCE_DIR}/Testing/Dashboard" ) @@ -29,25 +18,33 @@ set( ELASTIX_DASHBOARD_VOLUME "${ELASTIX_DASHBOARD_BINARY_DIR}/Data" ) if( NOT EXISTS "${ELASTIX_DASHBOARD_VOLUME}" ) message( STATUS - "ELASTIX_DASHBOARD_VOLUME points to the default ${CMAKE_BINARY_DIR}/Testing/Dashboard/Data path in your build directory. Point to another directory on your local machine to ensure dashboard state is saved between builds." + "ELASTIX_DASHBOARD_VOLUME points to the default ${CMAKE_BINARY_DIR}/Testing/Dashboard/Data path in your build directory. In production you should point this variable to a safe directory outside the build tree." ) file( MAKE_DIRECTORY "${ELASTIX_DASHBOARD_VOLUME}" ) endif() -# --------------------------------------------------------------------- -# Configure +# Test/Benchmark results will be forwarded to this IP. You will probably +# have change this in order to match docker settings on your own machine. +mark_as_advanced( ELASTIX_DASHBOARD_IP ) +set( ELASTIX_DASHBOARD_IP "192.168.59.103" ) + +configure_file( + ${ELASTIX_DASHBOARD_SOURCE_DIR}/elxDashboard.yml.in + ${ELASTIX_DASHBOARD_BINARY_DIR}/elxDashboard.yml +) + configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/docker-compose.yml.in - ${ELASTIX_DASHBOARD_BINARY_DIR}/docker-compose.yml + ${ELASTIX_DASHBOARD_SOURCE_DIR}/elxLogstashForwarder.yml.in + ${ELASTIX_DASHBOARD_BINARY_DIR}/elxLogstashForwarder.yml ) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/elxLogstash.conf.in - ${ELASTIX_DASHBOARD_BINARY_DIR}/elxLogstash/elxLogstash.conf + ${ELASTIX_DASHBOARD_SOURCE_DIR}/elxLogstash.conf.in + ${ELASTIX_DASHBOARD_BINARY_DIR}/Logstash/elxLogstash.conf ) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/elxLogstashForwarder.conf.in - ${ELASTIX_DASHBOARD_BINARY_DIR}/elxLogstashForwarder.conf + ${ELASTIX_DASHBOARD_SOURCE_DIR}/elxLogstashForwarder.json.in + ${ELASTIX_DASHBOARD_BINARY_DIR}/elxLogstashForwarder.json ) \ No newline at end of file diff --git a/Testing/Dashboard/docker-compose.yml.in b/Testing/Dashboard/elxDashboard.yml.in similarity index 57% rename from Testing/Dashboard/docker-compose.yml.in rename to Testing/Dashboard/elxDashboard.yml.in index 6faad275504d0b5fb4cdcf708d106f40254be8d9..2a33780a078730391c0c00878592053255bebc42 100644 --- a/Testing/Dashboard/docker-compose.yml.in +++ b/Testing/Dashboard/elxDashboard.yml.in @@ -2,7 +2,7 @@ elastix: image: willdurand/elk ports: - "80:80" - - "@ELASTIX_DASHBOARD_LOGSTASH_PORT@:@ELASTIX_DASHBOARD_LOGSTASH_PORT@" + - "5043:5043" volumes_from: - data @@ -11,7 +11,4 @@ data: volumes: - @ELASTIX_DASHBOARD_SOURCE_DIR@:/etc/ssl - @ELASTIX_DASHBOARD_VOLUME@:/data - - @ELASTIX_DASHBOARD_BINARY_DIR@/elxLogstash:/etc/logstash - - - \ No newline at end of file + - @ELASTIX_DASHBOARD_BINARY_DIR@/Logstash:/etc/logstash diff --git a/Testing/Dashboard/elxLogstash.conf.in b/Testing/Dashboard/elxLogstash.conf.in index 454a843007c028b8d2d62c1eb5a08264289ab53e..d6c885f293768edd3fc6223159454910d67ae814 100644 --- a/Testing/Dashboard/elxLogstash.conf.in +++ b/Testing/Dashboard/elxLogstash.conf.in @@ -1,6 +1,6 @@ input { lumberjack { - port => @ELASTIX_DASHBOARD_LOGSTASH_PORT@ + port => 5043 ssl_certificate => "/etc/ssl/@ELASTIX_DASHBOARD_LOGSTASH_CERTIFICATE@" ssl_key => "/etc/ssl/@ELASTIX_DASHBOARD_LOGSTASH_RSA_PRIVATE_KEY@" } diff --git a/Testing/Dashboard/elxLogstashForwarder.conf.in b/Testing/Dashboard/elxLogstashForwarder.conf.in deleted file mode 100644 index 923c158e35a2f8666a5316bc81446d4bd429365b..0000000000000000000000000000000000000000 --- a/Testing/Dashboard/elxLogstashForwarder.conf.in +++ /dev/null @@ -1,20 +0,0 @@ -{ - "network": { - "servers": [ "@ELASTIX_DASHBOARD_HOST@:@ELASTIX_DASHBOARD_LOGSTASH_PORT@" ], - "timeout": 15, - "ssl certificate": "@ELASTIX_DASHBOARD_SOURCE_DIR@/@ELASTIX_DASHBOARD_LOGSTASH_CERTIFICATE@", - "ssl key": "@ELASTIX_DASHBOARD_SOURCE_DIR@/@ELASTIX_DASHBOARD_LOGSTASH_RSA_PRIVATE_KEY@", - "ssl ca": "@ELASTIX_DASHBOARD_SOURCE_DIR@/@ELASTIX_DASHBOARD_LOGSTASH_CERTIFICATE@" - }, - "files": [ - { - "paths": [ - "@CMAKE_BINARY_DIR@/Testing/Unit/*.xml" - ], - "fields": { - "type": "unittest", - "lib": "elastix" - } - } - ] -} diff --git a/Testing/Dashboard/elxLogstashForwarder.json.in b/Testing/Dashboard/elxLogstashForwarder.json.in new file mode 100644 index 0000000000000000000000000000000000000000..bf2b7c6d7f38d1c5ffe567ab2c1dd063ae1179c0 --- /dev/null +++ b/Testing/Dashboard/elxLogstashForwarder.json.in @@ -0,0 +1,29 @@ +{ + "network": { + "servers": [ "elastix:5043" ], + "timeout": 15, + "ssl certificate": "/etc/ssl/@ELASTIX_DASHBOARD_LOGSTASH_CERTIFICATE@", + "ssl key": "/etc/ssl/@ELASTIX_DASHBOARD_LOGSTASH_RSA_PRIVATE_KEY@", + "ssl ca": "/etc/ssl/@ELASTIX_DASHBOARD_LOGSTASH_CERTIFICATE@" + }, + "files": [ + { + "paths": [ + "/var/unit/*.xml" + ], + "fields": { + "type": "unittest", + "lib": "elastix" + } + }, + { + "paths": [ + "/var/benchmark/*.xml" + ], + "fields": { + "type": "benchmark", + "lib": "elastix" + } + } + ] +} diff --git a/Testing/Dashboard/elxLogstashForwarder.yml.in b/Testing/Dashboard/elxLogstashForwarder.yml.in new file mode 100644 index 0000000000000000000000000000000000000000..adad1dfbfeed530af41a0ff87256e119d61bc260 --- /dev/null +++ b/Testing/Dashboard/elxLogstashForwarder.yml.in @@ -0,0 +1,14 @@ +forwarder: + image: willdurand/logstash-forwarder + extra_hosts: + - "elastix:@ELASTIX_DASHBOARD_IP@" + volumes_from: + - data + +data: + image: busybox + volumes: + - @ELASTIX_DASHBOARD_BINARY_DIR@/elxLogstashForwarder.json:/etc/logstash-forwarder/config.json + - @ELASTIX_DASHBOARD_SOURCE_DIR@:/etc/ssl + - @CMAKE_BINARY_DIR@/Testing/Unit:/var/unit + - @CMAKE_BINARY_DIR@/Testing/Benchmark:/var/benchmark diff --git a/Testing/Unit/CMakeLists.txt b/Testing/Unit/CMakeLists.txt index 0e92b5a3dcfdaae64617d9dd983efeb558214089..17d66ca7225d3a1e017d817ac8d8e7c40d11be70 100644 --- a/Testing/Unit/CMakeLists.txt +++ b/Testing/Unit/CMakeLists.txt @@ -1,24 +1,42 @@ -#--------------------------------------------------------------------- +# --------------------------------------------------------------------- # To add a test to the build system, append it to the list below. # Any GoogleTests in these files are automatically added to CTest and -# the Kibana dashboard. +# the elastix dashboard. set( ElastixUnitTestFilenames elxExampleUnitTest.cxx + itkRegistration.cxx ) -#--------------------------------------------------------------------- +# --------------------------------------------------------------------- # Set data directories set( ELASTIX_UNITTEST_INPUT_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Input ) +set( ELASTIX_UNITTEST_OUTPUT_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Output ) set( ELASTIX_UNITTEST_BASELINE_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Baseline ) +if( NOT EXISTS ${ELASTIX_UNITTEST_OUTPUT_DATA_DIR} ) + file( MAKE_DIRECTORY ${ELASTIX_UNITTEST_OUTPUT_DATA_DIR} ) +endif() + +if( NOT EXISTS ${ELASTIX_UNITTEST_OUTPUT_DATA_DIR} ) + message( FATAL_ERROR + "Could not create directory for output data. Make sure elastix has permission to write to disk." + ) +endif() + configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/elxTestHarness.h.in - ${CMAKE_CURRENT_BINARY_DIR}/elxTestHarness.h + ${CMAKE_CURRENT_SOURCE_DIR}/elxDataDirectories.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/elxDataDirectories.h ESCAPE_QUOTES ) # Build tests +add_library( DataManager elxDataManager.cxx ) + +list( APPEND TEST_LIBRARIES + DataManager +) + foreach( ElastixUnitTestFilename ${ElastixUnitTestFilenames} ) # Build tests executables string( REPLACE ".cxx" "" ElastixUnitTest ${ElastixUnitTestFilename} ) diff --git a/Testing/Unit/elxDataDirectories.h b/Testing/Unit/elxDataDirectories.h new file mode 100644 index 0000000000000000000000000000000000000000..9f2b7ef3eeaf6c66923099c297779d8476b96857 --- /dev/null +++ b/Testing/Unit/elxDataDirectories.h @@ -0,0 +1,8 @@ +#ifndef __elxTestDataDirectories_h +#define __elxTestDataDirectories_h + +#define ELASTIX_UNITTEST_INPUT_DATA_DIR "/Users/kasper/Development/build/SuperElastix/Elastix-build/Testing/Unit/Data/Input" +#define ELASTIX_UNITTEST_OUTPUT_DATA_DIR "/Users/kasper/Development/build/SuperElastix/Elastix-build/Testing/Unit/Data/Output" +#define ELASTIX_UNITTEST_BASELINE_DATA_DIR "/Users/kasper/Development/build/SuperElastix/Elastix-build/Testing/Unit/Data/Baseline" + +#endif // __elxTestDataDirectories_h diff --git a/Testing/Unit/elxDataDirectories.h.in b/Testing/Unit/elxDataDirectories.h.in new file mode 100644 index 0000000000000000000000000000000000000000..835845d15b56febeb9f8d8ca19b81b8a344555b3 --- /dev/null +++ b/Testing/Unit/elxDataDirectories.h.in @@ -0,0 +1,8 @@ +#ifndef __elxTestDataDirectories_h +#define __elxTestDataDirectories_h + +#define ELASTIX_UNITTEST_INPUT_DATA_DIR "@ELASTIX_UNITTEST_INPUT_DATA_DIR@" +#define ELASTIX_UNITTEST_OUTPUT_DATA_DIR "@ELASTIX_UNITTEST_OUTPUT_DATA_DIR@" +#define ELASTIX_UNITTEST_BASELINE_DATA_DIR "@ELASTIX_UNITTEST_BASELINE_DATA_DIR@" + +#endif // __elxTestDataDirectories_h \ No newline at end of file diff --git a/Testing/Unit/elxDataManager.cxx b/Testing/Unit/elxDataManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e9aa4e4afd6f58cc26420fdd947bfbc29817cae9 --- /dev/null +++ b/Testing/Unit/elxDataManager.cxx @@ -0,0 +1,30 @@ +#ifndef __DataManager_cxx +#define __DataManager_cxx + +#include "elxDataManager.h" + +std::string +DataManager +::GetInput( const std::string filename ) const +{ + const std::string path = this->GetInputDirectory() + this->GetPathSeparator() + filename; + return path; +} + +std::string +DataManager +::GetOutput( const std::string filename ) const +{ + const std::string path = this->GetOutputDirectory() + this->GetPathSeparator() + filename; + return path; +} + +std::string +DataManager +::GetBaseline( const std::string filename ) const +{ + const std::string path = this->GetBaselineDirectory() + this->GetPathSeparator() + filename; + return path; +} + +#endif // __elxTestData_cxx \ No newline at end of file diff --git a/Testing/Unit/elxDataManager.h b/Testing/Unit/elxDataManager.h new file mode 100644 index 0000000000000000000000000000000000000000..61d4dcade79545c7c85210f663d9ca07390e3f5c --- /dev/null +++ b/Testing/Unit/elxDataManager.h @@ -0,0 +1,47 @@ +#ifndef __DataManager_h +#define __DataManager_h + +#include <string> + +#include "itkMacro.h" +#include "itkProcessObject.h" + +#include "elxDataDirectories.h" + +class DataManager +{ +public: + + DataManager() + { + this->m_InputDirectory = ELASTIX_UNITTEST_INPUT_DATA_DIR; + this->m_OutputDirectory = ELASTIX_UNITTEST_OUTPUT_DATA_DIR; + this->m_BaselineDirectory = ELASTIX_UNITTEST_BASELINE_DATA_DIR; + } + + std::string GetInputDirectory( void ) const { return this->m_InputDirectory; }; + std::string GetOutputDirectory( void ) const { return this->m_InputDirectory; }; + std::string GetBaselineDirectory( void ) const { return this->m_InputDirectory; }; + + std::string GetInput( const std::string filename ) const; + std::string GetOutput( const std::string filename ) const; + std::string GetBaseline( const std::string filename ) const; + + std::string GetPathSeparator () const + { +#ifdef WIN32 + return ";"; +#else + return ":"; +#endif + } + +private: + + std::string m_InputDirectory; + std::string m_BaselineDirectory; + std::string m_OutputDirectory; + +}; + +#endif // #define __DataManager_h \ No newline at end of file diff --git a/Testing/Unit/elxExampleUnitTest.cxx b/Testing/Unit/elxExampleUnitTest.cxx index 725fa981e0ae8768ee500485f613190eb9edecea..f9ffd22ea257a7954d09c9e4554df86957f1e69b 100644 --- a/Testing/Unit/elxExampleUnitTest.cxx +++ b/Testing/Unit/elxExampleUnitTest.cxx @@ -17,24 +17,25 @@ TEST( GoogleTest, Example0 ) TEST( GoogleTest, Example1 ) { - // Record random number between 0 and 9 - int MetricValue = rand() % 10; - RecordProperty("MetricValue", MetricValue); - ASSERT_TRUE( true ); + // Record random number between 0 and 9 + int MetricValue = rand() % 10; + RecordProperty("MetricValue", MetricValue); + ASSERT_TRUE( true ); } TEST( GoogleTest, Example2 ) { - // Record random number between 10 and 19 - int MetricValue = rand() % 10 + 10; - RecordProperty("MetricValue", MetricValue); - ASSERT_TRUE( true ); + // Record random number between 10 and 19 + int MetricValue = rand() % 10 + 10; + RecordProperty("MetricValue", MetricValue); + RecordProperty("OverlapCoefficient", 1); + ASSERT_TRUE( true ); } TEST( GoogleTest, Example3 ) { - // Record random number between 20 and 29 - int MetricValue = rand() % 10 + 20; - RecordProperty("MetricValue", MetricValue); - ASSERT_TRUE( true ); -} \ No newline at end of file + // Record random number between 20 and 29 + int MetricValue = rand() % 10 + 20; + RecordProperty("MetricValue", MetricValue); + ASSERT_TRUE( true ); +} diff --git a/Testing/Unit/elxTestHarness.h.in b/Testing/Unit/elxTestHarness.h.in deleted file mode 100644 index 8bdb97a716b0e259a1016dabd86123a5311d3244..0000000000000000000000000000000000000000 --- a/Testing/Unit/elxTestHarness.h.in +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __ElastixTestHarness_h -#define __ElastixTestHarness_h - -#define ELASTIX_UNITTEST_INPUT_DATA_DIR "@ELASTIX_UNITTEST_INPUT_DATA_DIR@" -#define ELASTIX_INITTEST_BASELINE_DATA_DIR "@ELASTIX_UNITTEST_BASELINE_DATA_DIR@" - -#endif // __ElastixTestHarness_h \ No newline at end of file diff --git a/Testing/Unit/itkRegistration.cxx b/Testing/Unit/itkRegistration.cxx new file mode 100644 index 0000000000000000000000000000000000000000..449ed7bd286373d1d15e2d5769b6ccf9b16d3715 --- /dev/null +++ b/Testing/Unit/itkRegistration.cxx @@ -0,0 +1,29 @@ +#include "itkImage.h" +#include "itkImageFileReader.h" +#include "elxDataManager.h" +#include "gtest/gtest.h" + +class itkRegistration : public ::testing::Test { +public: + virtual void SetUp() + { + DataManager dataManager; + typedef itk::ImageFileReader< ImageType > ReaderType; + + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName( dataManager.GetInput( "BrainProtonDensitySliceR10X13Y17.png" ) ); + inputImage = reader->GetOutput(); + + reader->SetFileName( dataManager.GetBaseline( "BrainProtonDensitySlice.png" ) ); + baselineImage = reader->GetOutput(); + } + + typedef itk::Image< unsigned int, 2 > ImageType; + ImageType::Pointer inputImage; + ImageType::Pointer baselineImage; +}; + +TEST_F( itkRegistration, Affine2D ) +{ + ASSERT_TRUE( true ); +}