passenger 5.0.4 → 5.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +10 -0
- data/CHANGELOG +21 -0
- data/build/agents.rb +2 -2
- data/build/apache2.rb +6 -5
- data/build/common_library.rb +22 -7
- data/build/cxx_tests.rb +0 -3
- data/build/misc.rb +1 -1
- data/dev/parse_file_descriptor_log +119 -0
- data/doc/CloudLicensingConfiguration.html +387 -0
- data/doc/Design and Architecture.html +2430 -0
- data/doc/Packaging.html +488 -0
- data/doc/Security of user switching support.html +1833 -0
- data/doc/ServerOptimizationGuide.html +659 -0
- data/doc/ServerOptimizationGuide.txt.md +8 -0
- data/doc/Users guide Apache.html +9116 -0
- data/doc/Users guide Apache.idmap.txt +6 -2
- data/doc/Users guide Apache.txt +26 -7
- data/doc/Users guide Nginx.html +9025 -0
- data/doc/Users guide Nginx.idmap.txt +7 -3
- data/doc/Users guide Nginx.txt +29 -6
- data/doc/Users guide Standalone.html +3983 -0
- data/doc/Users guide.html +1748 -0
- data/doc/users_guide_snippets/installation.txt +4 -4
- data/ext/apache2/Configuration.cpp +16 -5
- data/ext/apache2/Configuration.hpp +4 -2
- data/ext/apache2/Hooks.cpp +44 -19
- data/ext/boost/libs/thread/src/pthread/once.cpp +2 -0
- data/ext/boost/libs/thread/src/pthread/once_atomic.cpp +6 -0
- data/ext/common/AgentsStarter.h +3 -2
- data/ext/common/ApplicationPool2/DirectSpawner.h +14 -4
- data/ext/common/ApplicationPool2/DummySpawner.h +12 -7
- data/ext/common/ApplicationPool2/Implementation.cpp +1 -1
- data/ext/common/ApplicationPool2/Process.h +2 -1
- data/ext/common/ApplicationPool2/Session.h +6 -6
- data/ext/common/ApplicationPool2/SmartSpawner.h +19 -4
- data/ext/common/ApplicationPool2/Socket.h +59 -27
- data/ext/common/ApplicationPool2/Spawner.h +2 -2
- data/ext/common/BackgroundEventLoop.cpp +6 -1
- data/ext/common/Constants.h +1 -1
- data/ext/common/EventedClient.h +1 -1
- data/ext/common/EventedServer.h +2 -2
- data/ext/common/FileDescriptor.h +25 -6
- data/ext/common/Logging.cpp +107 -52
- data/ext/common/Logging.h +146 -19
- data/ext/common/MessageClient.h +2 -2
- data/ext/common/MessageServer.h +3 -2
- data/ext/common/RandomGenerator.h +8 -7
- data/ext/common/SafeLibev.h +5 -1
- data/ext/common/ServerKit/AcceptLoadBalancer.h +9 -4
- data/ext/common/ServerKit/FdSinkChannel.h +5 -2
- data/ext/common/ServerKit/FdSourceChannel.h +5 -2
- data/ext/common/ServerKit/FileBufferedChannel.h +2 -0
- data/ext/common/ServerKit/FileBufferedFdSinkChannel.h +7 -2
- data/ext/common/ServerKit/HttpServer.h +6 -0
- data/ext/common/ServerKit/Server.h +40 -3
- data/ext/common/StaticString.h +20 -0
- data/ext/common/UnionStation/Connection.h +3 -1
- data/ext/common/UnionStation/Core.h +6 -4
- data/ext/common/Utils.cpp +4 -3
- data/ext/common/Utils/DateParsing.h +19 -5
- data/ext/common/Utils/FastStringStream.h +183 -0
- data/ext/common/Utils/IOUtils.cpp +47 -28
- data/ext/common/Utils/IOUtils.h +56 -12
- data/ext/common/Utils/MessagePassing.h +3 -3
- data/ext/common/Utils/ProcessMetricsCollector.h +2 -2
- data/ext/common/Utils/ScopeGuard.h +16 -5
- data/ext/common/Utils/SpeedMeter.h +2 -2
- data/ext/common/Utils/StrIntUtils.cpp +6 -6
- data/ext/common/Utils/StrIntUtils.h +2 -1
- data/ext/common/agents/Base.cpp +56 -4
- data/ext/common/agents/Base.h +2 -1
- data/ext/common/agents/HelperAgent/AdminServer.h +122 -11
- data/ext/common/agents/HelperAgent/Main.cpp +16 -5
- data/ext/common/agents/HelperAgent/OptionParser.h +7 -1
- data/ext/common/agents/HelperAgent/RequestHandler.h +1 -1
- data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +10 -1
- data/ext/common/agents/HelperAgent/RequestHandler/Request.h +8 -0
- data/ext/common/agents/HelperAgent/RequestHandler/TurboCaching.h +4 -3
- data/ext/common/agents/LoggingAgent/AdminServer.h +57 -11
- data/ext/common/agents/LoggingAgent/LoggingServer.h +3 -3
- data/ext/common/agents/LoggingAgent/Main.cpp +11 -3
- data/ext/common/agents/Watchdog/AdminServer.h +53 -11
- data/ext/common/agents/Watchdog/AgentWatcher.cpp +3 -3
- data/ext/common/agents/Watchdog/Main.cpp +13 -6
- data/ext/libeio/ecb.h +1 -1
- data/ext/libev/ev.c +13 -1
- data/ext/libev/ev.h +3 -0
- data/ext/nginx/Configuration.c +28 -6
- data/ext/nginx/Configuration.h +2 -1
- data/ext/nginx/ngx_http_passenger_module.c +5 -4
- data/ext/oxt/dynamic_thread_group.hpp +38 -5
- data/lib/phusion_passenger.rb +1 -1
- data/lib/phusion_passenger/common_library.rb +9 -5
- data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
- data/lib/phusion_passenger/packaging.rb +23 -37
- data/passenger.gemspec +21 -21
- metadata +4 -453
- metadata.gz.asc +7 -7
- data/.gitignore +0 -68
- data/.travis.yml +0 -16
- data/Gemfile +0 -17
- data/Gemfile.lock +0 -39
- data/Vagrantfile +0 -54
- data/debian.template/README.Debian +0 -15
- data/debian.template/changelog +0 -316
- data/debian.template/compat +0 -1
- data/debian.template/control.erb +0 -91
- data/debian.template/copyright +0 -385
- data/debian.template/libapache2-mod-passenger.install +0 -3
- data/debian.template/libapache2-mod-passenger.postinst +0 -36
- data/debian.template/libapache2-mod-passenger.prerm +0 -15
- data/debian.template/locations.ini.erb +0 -14
- data/debian.template/passenger-dev.install.erb +0 -3
- data/debian.template/passenger-doc.install.erb +0 -2
- data/debian.template/passenger.conf +0 -6
- data/debian.template/passenger.docs +0 -4
- data/debian.template/passenger.install.erb +0 -14
- data/debian.template/passenger.load +0 -3
- data/debian.template/passenger.manpages +0 -3
- data/debian.template/patches/series +0 -0
- data/debian.template/rules.erb +0 -76
- data/debian.template/source/format +0 -1
- data/ext/common/EventedBufferedInput.h +0 -458
- data/packaging/rpm/LICENSE.txt +0 -19
- data/packaging/rpm/Makefile +0 -13
- data/packaging/rpm/README.md +0 -41
- data/packaging/rpm/Vagrantfile +0 -38
- data/packaging/rpm/Vagrantfile.centos +0 -30
- data/packaging/rpm/build +0 -170
- data/packaging/rpm/create_project +0 -41
- data/packaging/rpm/git_update +0 -88
- data/packaging/rpm/image/Dockerfile +0 -37
- data/packaging/rpm/image/Gemfile +0 -3
- data/packaging/rpm/image/Gemfile.lock +0 -12
- data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +0 -19
- data/packaging/rpm/image/amazon2014-i386.cfg +0 -96
- data/packaging/rpm/image/amazon2014-x86_64.cfg +0 -96
- data/packaging/rpm/image/site-defaults.cfg +0 -168
- data/packaging/rpm/internal/build_tasks.rb +0 -238
- data/packaging/rpm/internal/dummygpg +0 -11
- data/packaging/rpm/internal/exec_build +0 -42
- data/packaging/rpm/internal/get_distro_arch +0 -14
- data/packaging/rpm/internal/get_distro_id +0 -10
- data/packaging/rpm/internal/git_update +0 -27
- data/packaging/rpm/internal/inituidgid +0 -17
- data/packaging/rpm/internal/my_init +0 -344
- data/packaging/rpm/internal/python27 +0 -3
- data/packaging/rpm/internal/repo_update +0 -46
- data/packaging/rpm/internal/setuser +0 -26
- data/packaging/rpm/internal/tracking_helper +0 -40
- data/packaging/rpm/jenkins_release +0 -99
- data/packaging/rpm/lib/build_tasks_support.rb +0 -402
- data/packaging/rpm/lib/preprocessor.rb +0 -341
- data/packaging/rpm/nginx_spec/404.html +0 -119
- data/packaging/rpm/nginx_spec/50x.html +0 -119
- data/packaging/rpm/nginx_spec/index.html +0 -116
- data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +0 -13
- data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade +0 -13
- data/packaging/rpm/nginx_spec/nginx-upgrade.8 +0 -151
- data/packaging/rpm/nginx_spec/nginx.conf +0 -131
- data/packaging/rpm/nginx_spec/nginx.init +0 -144
- data/packaging/rpm/nginx_spec/nginx.logrotate +0 -13
- data/packaging/rpm/nginx_spec/nginx.service +0 -15
- data/packaging/rpm/nginx_spec/nginx.spec.template +0 -560
- data/packaging/rpm/nginx_spec/nginx.sysconfig +0 -4
- data/packaging/rpm/nginx_spec/passenger.conf +0 -9
- data/packaging/rpm/nginx_spec/poweredby.png +0 -0
- data/packaging/rpm/passenger_spec/apache-passenger.conf.in +0 -26
- data/packaging/rpm/passenger_spec/config.json +0 -30
- data/packaging/rpm/passenger_spec/passenger.logrotate +0 -7
- data/packaging/rpm/passenger_spec/passenger.spec.template +0 -478
- data/packaging/rpm/passenger_spec/passenger_dynamic_thread_group.patch +0 -16
- data/packaging/rpm/passenger_spec/passenger_tests_default_config_example.patch +0 -44
- data/packaging/rpm/passenger_spec/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -21
- data/packaging/rpm/repo_update +0 -114
- data/packaging/rpm/setup-system +0 -61
- data/packaging/rpm/shell +0 -10
- data/test/.rspec +0 -4
- data/test/config.json.example +0 -42
- data/test/config.json.rpm-automation +0 -15
- data/test/config.json.travis +0 -15
- data/test/config.json.vagrant +0 -30
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +0 -124
- data/test/cxx/ApplicationPool2/OptionsTest.cpp +0 -30
- data/test/cxx/ApplicationPool2/PoolTest.cpp +0 -2062
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +0 -130
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +0 -243
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +0 -823
- data/test/cxx/BufferedIOTest.cpp +0 -364
- data/test/cxx/CachedFileStatTest.cpp +0 -402
- data/test/cxx/CxxTestMain.cpp +0 -181
- data/test/cxx/DataStructures/LStringTest.cpp +0 -275
- data/test/cxx/DataStructures/StringKeyTableTest.cpp +0 -199
- data/test/cxx/DateParsingTest.cpp +0 -75
- data/test/cxx/DechunkerTest.cpp +0 -250
- data/test/cxx/EventedBufferedInputTest.cpp +0 -758
- data/test/cxx/EventedClientTest.cpp +0 -523
- data/test/cxx/FileChangeCheckerTest.cpp +0 -331
- data/test/cxx/FileDescriptorTest.cpp +0 -69
- data/test/cxx/FilterSupportTest.cpp +0 -433
- data/test/cxx/IOUtilsTest.cpp +0 -861
- data/test/cxx/MemoryKit/MbufTest.cpp +0 -213
- data/test/cxx/MessageIOTest.cpp +0 -360
- data/test/cxx/MessagePassingTest.cpp +0 -81
- data/test/cxx/MessageReadersWritersTest.cpp +0 -576
- data/test/cxx/MessageServerTest.cpp +0 -393
- data/test/cxx/ProcessMetricsCollectorTest.cpp +0 -123
- data/test/cxx/RequestHandlerTest.cpp +0 -1463
- data/test/cxx/ResponseCacheTest.cpp +0 -322
- data/test/cxx/ServerKit/ChannelTest.cpp +0 -1467
- data/test/cxx/ServerKit/CookieUtilsTest.cpp +0 -274
- data/test/cxx/ServerKit/FileBufferedChannelTest.cpp +0 -992
- data/test/cxx/ServerKit/HeaderTableTest.cpp +0 -177
- data/test/cxx/ServerKit/HttpServerTest.cpp +0 -1580
- data/test/cxx/ServerKit/ServerTest.cpp +0 -408
- data/test/cxx/StaticStringTest.cpp +0 -220
- data/test/cxx/StringMapTest.cpp +0 -131
- data/test/cxx/SystemTimeTest.cpp +0 -37
- data/test/cxx/TemplateTest.cpp +0 -118
- data/test/cxx/TestSupport.cpp +0 -207
- data/test/cxx/TestSupport.h +0 -333
- data/test/cxx/UnionStationTest.cpp +0 -741
- data/test/cxx/Utils/StrIntUtilsTest.cpp +0 -39
- data/test/cxx/UtilsTest.cpp +0 -672
- data/test/cxx/VariantMapTest.cpp +0 -191
- data/test/gdbinit.example +0 -34
- data/test/integration_tests/apache2_tests.rb +0 -585
- data/test/integration_tests/downloaded_binaries_tests.rb +0 -185
- data/test/integration_tests/native_packaging_spec.rb +0 -368
- data/test/integration_tests/nginx_tests.rb +0 -402
- data/test/integration_tests/shared/example_webapp_tests.rb +0 -289
- data/test/integration_tests/source_packaging_test.rb +0 -201
- data/test/integration_tests/spec_helper.rb +0 -22
- data/test/integration_tests/standalone_tests.rb +0 -392
- data/test/node/line_reader_spec.js +0 -338
- data/test/node/spec_helper.js +0 -65
- data/test/oxt/backtrace_test.cpp +0 -88
- data/test/oxt/counter.hpp +0 -55
- data/test/oxt/dynamic_thread_group_test.cpp +0 -131
- data/test/oxt/oxt_test_main.cpp +0 -27
- data/test/oxt/spin_lock_test.cpp +0 -59
- data/test/oxt/syscall_interruption_test.cpp +0 -39
- data/test/ruby/debug_logging_spec.rb +0 -145
- data/test/ruby/message_channel_spec.rb +0 -196
- data/test/ruby/rack/loader_spec.rb +0 -42
- data/test/ruby/rack/preloader_spec.rb +0 -48
- data/test/ruby/rails3.0/loader_spec.rb +0 -26
- data/test/ruby/rails3.0/preloader_spec.rb +0 -32
- data/test/ruby/rails3.1/loader_spec.rb +0 -26
- data/test/ruby/rails3.1/preloader_spec.rb +0 -32
- data/test/ruby/rails3.2/loader_spec.rb +0 -26
- data/test/ruby/rails3.2/preloader_spec.rb +0 -32
- data/test/ruby/rails4.0/loader_spec.rb +0 -28
- data/test/ruby/rails4.0/preloader_spec.rb +0 -34
- data/test/ruby/rails4.1/loader_spec.rb +0 -28
- data/test/ruby/rails4.1/preloader_spec.rb +0 -34
- data/test/ruby/request_handler_spec.rb +0 -747
- data/test/ruby/shared/loader_sharedspec.rb +0 -247
- data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +0 -357
- data/test/ruby/shared/ruby_loader_sharedspec.rb +0 -55
- data/test/ruby/spec_helper.rb +0 -114
- data/test/ruby/standalone/runtime_installer_spec.rb +0 -402
- data/test/ruby/union_station_spec.rb +0 -288
- data/test/ruby/utils/file_system_watcher_spec.rb +0 -229
- data/test/ruby/utils/hosts_file_parser.rb +0 -258
- data/test/ruby/utils/tee_input_spec.rb +0 -235
- data/test/ruby/utils/unseekable_socket_spec.rb +0 -66
- data/test/ruby/utils_spec.rb +0 -41
- data/test/stub/apache2/httpd.conf.erb +0 -122
- data/test/stub/apache2/mime.types +0 -748
- data/test/stub/garbage1.dat +0 -0
- data/test/stub/garbage2.dat +0 -0
- data/test/stub/garbage3.dat +0 -0
- data/test/stub/http_request.yml +0 -23
- data/test/stub/index.html +0 -1
- data/test/stub/nginx/koi-utf +0 -109
- data/test/stub/nginx/koi-win +0 -103
- data/test/stub/nginx/mime.types +0 -70
- data/test/stub/nginx/nginx.conf.erb +0 -70
- data/test/stub/nginx/win-utf +0 -126
- data/test/stub/node/app.js +0 -133
- data/test/stub/node/public/.gitignore +0 -0
- data/test/stub/node/tmp/.gitignore +0 -0
- data/test/stub/rack/config.ru +0 -95
- data/test/stub/rack/library.rb +0 -16
- data/test/stub/rack/public/.gitignore +0 -0
- data/test/stub/rack/start.rb +0 -52
- data/test/stub/rack/tmp/.gitignore +0 -0
- data/test/stub/rails3.0/.gitignore +0 -4
- data/test/stub/rails3.0/Gemfile +0 -22
- data/test/stub/rails3.0/Gemfile.lock +0 -80
- data/test/stub/rails3.0/Rakefile +0 -10
- data/test/stub/rails3.0/app/controllers/application_controller.rb +0 -4
- data/test/stub/rails3.0/app/helpers/application_helper.rb +0 -2
- data/test/stub/rails3.0/app/views/layouts/application.html.erb +0 -14
- data/test/stub/rails3.0/config.ru +0 -4
- data/test/stub/rails3.0/config/application.rb +0 -48
- data/test/stub/rails3.0/config/boot.rb +0 -13
- data/test/stub/rails3.0/config/database.yml +0 -22
- data/test/stub/rails3.0/config/environment.rb +0 -5
- data/test/stub/rails3.0/config/environments/development.rb +0 -19
- data/test/stub/rails3.0/config/environments/production.rb +0 -48
- data/test/stub/rails3.0/config/environments/test.rb +0 -32
- data/test/stub/rails3.0/config/initializers/backtrace_silencers.rb +0 -7
- data/test/stub/rails3.0/config/initializers/inflections.rb +0 -10
- data/test/stub/rails3.0/config/initializers/mime_types.rb +0 -5
- data/test/stub/rails3.0/config/initializers/passenger.rb +0 -2
- data/test/stub/rails3.0/config/initializers/secret_token.rb +0 -7
- data/test/stub/rails3.0/config/initializers/session_store.rb +0 -8
- data/test/stub/rails3.0/config/locales/en.yml +0 -5
- data/test/stub/rails3.0/config/routes.rb +0 -58
- data/test/stub/rails3.0/db/seeds.rb +0 -7
- data/test/stub/rails3.0/doc/README_FOR_APP +0 -2
- data/test/stub/rails3.0/lib/tasks/.gitkeep +0 -0
- data/test/stub/rails3.0/log/.gitignore +0 -0
- data/test/stub/rails3.0/public/404.html +0 -26
- data/test/stub/rails3.0/public/422.html +0 -26
- data/test/stub/rails3.0/public/500.html +0 -26
- data/test/stub/rails3.0/public/favicon.ico +0 -0
- data/test/stub/rails3.0/public/index.html +0 -279
- data/test/stub/rails3.0/public/robots.txt +0 -5
- data/test/stub/rails3.0/public/stylesheets/.gitkeep +0 -0
- data/test/stub/rails3.0/script/rails +0 -9
- data/test/stub/rails3.0/test/performance/browsing_test.rb +0 -9
- data/test/stub/rails3.0/test/test_helper.rb +0 -13
- data/test/stub/rails3.0/vendor/plugins/.gitkeep +0 -0
- data/test/stub/rails3.1/.gitignore +0 -15
- data/test/stub/rails3.1/Gemfile +0 -37
- data/test/stub/rails3.1/Gemfile.lock +0 -115
- data/test/stub/rails3.1/README +0 -261
- data/test/stub/rails3.1/Rakefile +0 -7
- data/test/stub/rails3.1/app/assets/images/rails.png +0 -0
- data/test/stub/rails3.1/app/assets/stylesheets/application.css +0 -7
- data/test/stub/rails3.1/app/controllers/application_controller.rb +0 -3
- data/test/stub/rails3.1/app/helpers/application_helper.rb +0 -2
- data/test/stub/rails3.1/app/mailers/.gitkeep +0 -0
- data/test/stub/rails3.1/app/models/.gitkeep +0 -0
- data/test/stub/rails3.1/app/views/layouts/application.html.erb +0 -14
- data/test/stub/rails3.1/config.ru +0 -4
- data/test/stub/rails3.1/config/application.rb +0 -48
- data/test/stub/rails3.1/config/boot.rb +0 -6
- data/test/stub/rails3.1/config/database.yml +0 -25
- data/test/stub/rails3.1/config/environment.rb +0 -5
- data/test/stub/rails3.1/config/environments/development.rb +0 -30
- data/test/stub/rails3.1/config/environments/production.rb +0 -60
- data/test/stub/rails3.1/config/environments/test.rb +0 -39
- data/test/stub/rails3.1/config/initializers/backtrace_silencers.rb +0 -7
- data/test/stub/rails3.1/config/initializers/inflections.rb +0 -10
- data/test/stub/rails3.1/config/initializers/mime_types.rb +0 -5
- data/test/stub/rails3.1/config/initializers/passenger.rb +0 -2
- data/test/stub/rails3.1/config/initializers/secret_token.rb +0 -7
- data/test/stub/rails3.1/config/initializers/session_store.rb +0 -8
- data/test/stub/rails3.1/config/initializers/wrap_parameters.rb +0 -14
- data/test/stub/rails3.1/config/locales/en.yml +0 -5
- data/test/stub/rails3.1/config/routes.rb +0 -58
- data/test/stub/rails3.1/db/seeds.rb +0 -7
- data/test/stub/rails3.1/doc/README_FOR_APP +0 -2
- data/test/stub/rails3.1/lib/assets/.gitkeep +0 -0
- data/test/stub/rails3.1/lib/tasks/.gitkeep +0 -0
- data/test/stub/rails3.1/log/.gitkeep +0 -0
- data/test/stub/rails3.1/public/404.html +0 -26
- data/test/stub/rails3.1/public/422.html +0 -26
- data/test/stub/rails3.1/public/500.html +0 -26
- data/test/stub/rails3.1/public/favicon.ico +0 -0
- data/test/stub/rails3.1/public/index.html +0 -241
- data/test/stub/rails3.1/public/robots.txt +0 -5
- data/test/stub/rails3.1/script/rails +0 -6
- data/test/stub/rails3.1/test/fixtures/.gitkeep +0 -0
- data/test/stub/rails3.1/test/functional/.gitkeep +0 -0
- data/test/stub/rails3.1/test/integration/.gitkeep +0 -0
- data/test/stub/rails3.1/test/performance/browsing_test.rb +0 -12
- data/test/stub/rails3.1/test/test_helper.rb +0 -13
- data/test/stub/rails3.1/test/unit/.gitkeep +0 -0
- data/test/stub/rails3.1/vendor/assets/stylesheets/.gitkeep +0 -0
- data/test/stub/rails3.1/vendor/plugins/.gitkeep +0 -0
- data/test/stub/rails3.2/.gitignore +0 -15
- data/test/stub/rails3.2/Gemfile +0 -39
- data/test/stub/rails3.2/Gemfile.lock +0 -113
- data/test/stub/rails3.2/Rakefile +0 -7
- data/test/stub/rails3.2/app/assets/images/rails.png +0 -0
- data/test/stub/rails3.2/app/assets/stylesheets/application.css +0 -13
- data/test/stub/rails3.2/app/controllers/application_controller.rb +0 -3
- data/test/stub/rails3.2/app/helpers/application_helper.rb +0 -2
- data/test/stub/rails3.2/app/mailers/.gitkeep +0 -0
- data/test/stub/rails3.2/app/models/.gitkeep +0 -0
- data/test/stub/rails3.2/app/views/layouts/application.html.erb +0 -14
- data/test/stub/rails3.2/config.ru +0 -4
- data/test/stub/rails3.2/config/application.rb +0 -62
- data/test/stub/rails3.2/config/boot.rb +0 -6
- data/test/stub/rails3.2/config/database.yml +0 -25
- data/test/stub/rails3.2/config/environment.rb +0 -5
- data/test/stub/rails3.2/config/environments/development.rb +0 -37
- data/test/stub/rails3.2/config/environments/production.rb +0 -67
- data/test/stub/rails3.2/config/environments/test.rb +0 -37
- data/test/stub/rails3.2/config/initializers/backtrace_silencers.rb +0 -7
- data/test/stub/rails3.2/config/initializers/inflections.rb +0 -15
- data/test/stub/rails3.2/config/initializers/mime_types.rb +0 -5
- data/test/stub/rails3.2/config/initializers/passenger.rb +0 -2
- data/test/stub/rails3.2/config/initializers/secret_token.rb +0 -7
- data/test/stub/rails3.2/config/initializers/session_store.rb +0 -8
- data/test/stub/rails3.2/config/initializers/wrap_parameters.rb +0 -14
- data/test/stub/rails3.2/config/locales/en.yml +0 -5
- data/test/stub/rails3.2/config/routes.rb +0 -58
- data/test/stub/rails3.2/db/seeds.rb +0 -7
- data/test/stub/rails3.2/doc/README_FOR_APP +0 -2
- data/test/stub/rails3.2/lib/assets/.gitkeep +0 -0
- data/test/stub/rails3.2/lib/tasks/.gitkeep +0 -0
- data/test/stub/rails3.2/log/.gitkeep +0 -0
- data/test/stub/rails3.2/public/404.html +0 -26
- data/test/stub/rails3.2/public/422.html +0 -26
- data/test/stub/rails3.2/public/500.html +0 -25
- data/test/stub/rails3.2/public/favicon.ico +0 -0
- data/test/stub/rails3.2/public/index.html +0 -241
- data/test/stub/rails3.2/public/robots.txt +0 -5
- data/test/stub/rails3.2/script/rails +0 -6
- data/test/stub/rails3.2/test/fixtures/.gitkeep +0 -0
- data/test/stub/rails3.2/test/functional/.gitkeep +0 -0
- data/test/stub/rails3.2/test/integration/.gitkeep +0 -0
- data/test/stub/rails3.2/test/performance/browsing_test.rb +0 -12
- data/test/stub/rails3.2/test/test_helper.rb +0 -13
- data/test/stub/rails3.2/test/unit/.gitkeep +0 -0
- data/test/stub/rails3.2/vendor/assets/stylesheets/.gitkeep +0 -0
- data/test/stub/rails3.2/vendor/plugins/.gitkeep +0 -0
- data/test/stub/rails4.0/.gitignore +0 -16
- data/test/stub/rails4.0/Gemfile +0 -45
- data/test/stub/rails4.0/Gemfile.lock +0 -126
- data/test/stub/rails4.0/README.rdoc +0 -28
- data/test/stub/rails4.0/Rakefile +0 -6
- data/test/stub/rails4.0/app/assets/images/.keep +0 -0
- data/test/stub/rails4.0/app/assets/javascripts/application.js +0 -16
- data/test/stub/rails4.0/app/assets/stylesheets/application.css +0 -13
- data/test/stub/rails4.0/app/controllers/application_controller.rb +0 -5
- data/test/stub/rails4.0/app/controllers/concerns/.keep +0 -0
- data/test/stub/rails4.0/app/helpers/application_helper.rb +0 -2
- data/test/stub/rails4.0/app/mailers/.keep +0 -0
- data/test/stub/rails4.0/app/models/.keep +0 -0
- data/test/stub/rails4.0/app/models/concerns/.keep +0 -0
- data/test/stub/rails4.0/app/views/layouts/application.html.erb +0 -14
- data/test/stub/rails4.0/bin/bundle +0 -3
- data/test/stub/rails4.0/bin/rails +0 -4
- data/test/stub/rails4.0/bin/rake +0 -4
- data/test/stub/rails4.0/config.ru +0 -4
- data/test/stub/rails4.0/config/application.rb +0 -23
- data/test/stub/rails4.0/config/boot.rb +0 -4
- data/test/stub/rails4.0/config/database.yml +0 -25
- data/test/stub/rails4.0/config/environment.rb +0 -5
- data/test/stub/rails4.0/config/environments/development.rb +0 -29
- data/test/stub/rails4.0/config/environments/production.rb +0 -80
- data/test/stub/rails4.0/config/environments/test.rb +0 -36
- data/test/stub/rails4.0/config/initializers/backtrace_silencers.rb +0 -7
- data/test/stub/rails4.0/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/stub/rails4.0/config/initializers/inflections.rb +0 -16
- data/test/stub/rails4.0/config/initializers/mime_types.rb +0 -5
- data/test/stub/rails4.0/config/initializers/passenger.rb +0 -2
- data/test/stub/rails4.0/config/initializers/secret_token.rb +0 -12
- data/test/stub/rails4.0/config/initializers/session_store.rb +0 -3
- data/test/stub/rails4.0/config/initializers/wrap_parameters.rb +0 -14
- data/test/stub/rails4.0/config/locales/en.yml +0 -23
- data/test/stub/rails4.0/config/routes.rb +0 -57
- data/test/stub/rails4.0/db/seeds.rb +0 -7
- data/test/stub/rails4.0/lib/assets/.keep +0 -0
- data/test/stub/rails4.0/lib/tasks/.keep +0 -0
- data/test/stub/rails4.0/log/.keep +0 -0
- data/test/stub/rails4.0/public/404.html +0 -58
- data/test/stub/rails4.0/public/422.html +0 -58
- data/test/stub/rails4.0/public/500.html +0 -57
- data/test/stub/rails4.0/public/favicon.ico +0 -0
- data/test/stub/rails4.0/public/robots.txt +0 -5
- data/test/stub/rails4.0/test/controllers/.keep +0 -0
- data/test/stub/rails4.0/test/fixtures/.keep +0 -0
- data/test/stub/rails4.0/test/helpers/.keep +0 -0
- data/test/stub/rails4.0/test/integration/.keep +0 -0
- data/test/stub/rails4.0/test/mailers/.keep +0 -0
- data/test/stub/rails4.0/test/models/.keep +0 -0
- data/test/stub/rails4.0/test/test_helper.rb +0 -15
- data/test/stub/rails4.0/vendor/assets/javascripts/.keep +0 -0
- data/test/stub/rails4.0/vendor/assets/stylesheets/.keep +0 -0
- data/test/stub/rails4.1/.gitignore +0 -16
- data/test/stub/rails4.1/Gemfile +0 -45
- data/test/stub/rails4.1/Gemfile.lock +0 -129
- data/test/stub/rails4.1/README.rdoc +0 -28
- data/test/stub/rails4.1/Rakefile +0 -6
- data/test/stub/rails4.1/app/assets/images/.keep +0 -0
- data/test/stub/rails4.1/app/assets/javascripts/application.js +0 -16
- data/test/stub/rails4.1/app/assets/stylesheets/application.css +0 -13
- data/test/stub/rails4.1/app/controllers/application_controller.rb +0 -5
- data/test/stub/rails4.1/app/controllers/concerns/.keep +0 -0
- data/test/stub/rails4.1/app/helpers/application_helper.rb +0 -2
- data/test/stub/rails4.1/app/mailers/.keep +0 -0
- data/test/stub/rails4.1/app/models/.keep +0 -0
- data/test/stub/rails4.1/app/models/concerns/.keep +0 -0
- data/test/stub/rails4.1/app/views/layouts/application.html.erb +0 -14
- data/test/stub/rails4.1/bin/bundle +0 -3
- data/test/stub/rails4.1/bin/rails +0 -4
- data/test/stub/rails4.1/bin/rake +0 -4
- data/test/stub/rails4.1/config.ru +0 -4
- data/test/stub/rails4.1/config/application.rb +0 -23
- data/test/stub/rails4.1/config/boot.rb +0 -4
- data/test/stub/rails4.1/config/database.yml +0 -25
- data/test/stub/rails4.1/config/environment.rb +0 -5
- data/test/stub/rails4.1/config/environments/development.rb +0 -29
- data/test/stub/rails4.1/config/environments/production.rb +0 -80
- data/test/stub/rails4.1/config/environments/test.rb +0 -36
- data/test/stub/rails4.1/config/initializers/backtrace_silencers.rb +0 -7
- data/test/stub/rails4.1/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/stub/rails4.1/config/initializers/inflections.rb +0 -16
- data/test/stub/rails4.1/config/initializers/mime_types.rb +0 -5
- data/test/stub/rails4.1/config/initializers/passenger.rb +0 -5
- data/test/stub/rails4.1/config/initializers/secret_token.rb +0 -12
- data/test/stub/rails4.1/config/initializers/session_store.rb +0 -3
- data/test/stub/rails4.1/config/initializers/wrap_parameters.rb +0 -14
- data/test/stub/rails4.1/config/locales/en.yml +0 -23
- data/test/stub/rails4.1/config/routes.rb +0 -57
- data/test/stub/rails4.1/db/seeds.rb +0 -7
- data/test/stub/rails4.1/lib/assets/.keep +0 -0
- data/test/stub/rails4.1/lib/tasks/.keep +0 -0
- data/test/stub/rails4.1/log/.keep +0 -0
- data/test/stub/rails4.1/public/404.html +0 -58
- data/test/stub/rails4.1/public/422.html +0 -58
- data/test/stub/rails4.1/public/500.html +0 -57
- data/test/stub/rails4.1/public/favicon.ico +0 -0
- data/test/stub/rails4.1/public/robots.txt +0 -5
- data/test/stub/rails4.1/test/controllers/.keep +0 -0
- data/test/stub/rails4.1/test/fixtures/.keep +0 -0
- data/test/stub/rails4.1/test/helpers/.keep +0 -0
- data/test/stub/rails4.1/test/integration/.keep +0 -0
- data/test/stub/rails4.1/test/mailers/.keep +0 -0
- data/test/stub/rails4.1/test/models/.keep +0 -0
- data/test/stub/rails4.1/test/test_helper.rb +0 -15
- data/test/stub/rails4.1/vendor/assets/javascripts/.keep +0 -0
- data/test/stub/rails4.1/vendor/assets/stylesheets/.keep +0 -0
- data/test/stub/start_error.pl +0 -24
- data/test/stub/upload_data.txt +0 -494
- data/test/stub/wsgi/passenger_wsgi.py +0 -212
- data/test/stub/wsgi/public/.gitignore +0 -0
- data/test/stub/wsgi/tmp/.gitignore +0 -0
- data/test/support/allocate_memory.c +0 -14
- data/test/support/apache2_controller.rb +0 -258
- data/test/support/multipart.rb +0 -62
- data/test/support/nginx_controller.rb +0 -97
- data/test/support/placebo-preloader.rb +0 -88
- data/test/support/test_helper.rb +0 -455
- data/test/support/valgrind.h +0 -2539
- data/test/tut/tut.h +0 -1310
- data/test/tut/tut_reporter.h +0 -256
- data/test/valgrind-osx.supp +0 -7
data/test/cxx/TestSupport.h
DELETED
@@ -1,333 +0,0 @@
|
|
1
|
-
#ifndef _TEST_SUPPORT_H_
|
2
|
-
#define _TEST_SUPPORT_H_
|
3
|
-
|
4
|
-
#include <sys/stat.h>
|
5
|
-
#include <sys/types.h>
|
6
|
-
#include <iostream>
|
7
|
-
#include <string>
|
8
|
-
#include <vector>
|
9
|
-
#include <exception>
|
10
|
-
#include <cstdio>
|
11
|
-
#include <cerrno>
|
12
|
-
#include <cstring>
|
13
|
-
#include <ctime>
|
14
|
-
#include <unistd.h>
|
15
|
-
#include <utime.h>
|
16
|
-
|
17
|
-
#include <oxt/thread.hpp>
|
18
|
-
#include <oxt/tracable_exception.hpp>
|
19
|
-
|
20
|
-
#include "../tut/tut.h"
|
21
|
-
#include <ResourceLocator.h>
|
22
|
-
#include <InstanceDirectory.h>
|
23
|
-
#include <BackgroundEventLoop.h>
|
24
|
-
#include <Exceptions.h>
|
25
|
-
#include <Utils.h>
|
26
|
-
#include <Utils/SystemTime.h>
|
27
|
-
#include <Utils/json-forwards.h>
|
28
|
-
|
29
|
-
extern "C" {
|
30
|
-
struct ev_loop;
|
31
|
-
struct ev_async;
|
32
|
-
}
|
33
|
-
|
34
|
-
namespace Passenger {
|
35
|
-
class SafeLibev;
|
36
|
-
}
|
37
|
-
|
38
|
-
namespace TestSupport {
|
39
|
-
|
40
|
-
using namespace std;
|
41
|
-
using namespace Passenger;
|
42
|
-
using namespace oxt;
|
43
|
-
|
44
|
-
|
45
|
-
#define SHOW_EXCEPTION_BACKTRACE(code) \
|
46
|
-
do { \
|
47
|
-
try { \
|
48
|
-
code \
|
49
|
-
} catch (const tracable_exception &e) { \
|
50
|
-
cerr << e.what() << "\n" << e.backtrace(); \
|
51
|
-
throw; \
|
52
|
-
} \
|
53
|
-
} while (0)
|
54
|
-
|
55
|
-
#define EVENTUALLY2(deadlineMsec, sleepTimeMsec, code) \
|
56
|
-
do { \
|
57
|
-
unsigned long long deadlineTime = SystemTime::getMsec(true) + deadlineMsec; \
|
58
|
-
bool result = false; \
|
59
|
-
while (!result && SystemTime::getMsec(true) < deadlineTime) { \
|
60
|
-
{ \
|
61
|
-
code \
|
62
|
-
} \
|
63
|
-
if (!result) { \
|
64
|
-
usleep(sleepTimeMsec * 1000); \
|
65
|
-
} \
|
66
|
-
} \
|
67
|
-
if (!result) { \
|
68
|
-
fail("EVENTUALLY(" #code ") failed"); \
|
69
|
-
} \
|
70
|
-
} while (0)
|
71
|
-
|
72
|
-
#define EVENTUALLY(deadlineSec, code) EVENTUALLY2(deadlineSec * 1000, 10, code)
|
73
|
-
|
74
|
-
#define SHOULD_NEVER_HAPPEN(deadline, code) \
|
75
|
-
do { \
|
76
|
-
unsigned long long deadlineTime = SystemTime::getMsec(true) + deadline; \
|
77
|
-
bool result = false; \
|
78
|
-
while (!result && SystemTime::getMsec(true) < deadlineTime) { \
|
79
|
-
code \
|
80
|
-
if (!result) { \
|
81
|
-
usleep(10000); \
|
82
|
-
} \
|
83
|
-
} \
|
84
|
-
if (result) { \
|
85
|
-
fail("SHOULD_NEVER_HAPPEN(" #code ") failed"); \
|
86
|
-
} \
|
87
|
-
} while (0)
|
88
|
-
|
89
|
-
// Do not run some tests in the Vagrant development environment because
|
90
|
-
// they don't work over NFS.
|
91
|
-
#define DONT_RUN_IN_VAGRANT() \
|
92
|
-
do { \
|
93
|
-
if (getenv("PASSENGER_VAGRANT_ENVIRONMENT") != NULL) { \
|
94
|
-
return; \
|
95
|
-
} \
|
96
|
-
} while (false)
|
97
|
-
|
98
|
-
|
99
|
-
extern ResourceLocator *resourceLocator;
|
100
|
-
extern Json::Value testConfig;
|
101
|
-
|
102
|
-
|
103
|
-
/**
|
104
|
-
* Create an instance directory with default parameters, suitable for unit testing.
|
105
|
-
*/
|
106
|
-
void createInstanceDir(InstanceDirectoryPtr &instanceDir);
|
107
|
-
|
108
|
-
void initializeLibeio();
|
109
|
-
void shutdownLibeio();
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Writes zeroes into the given file descriptor its buffer is full (i.e.
|
113
|
-
* the next write will block).
|
114
|
-
*
|
115
|
-
* @throws SystemException
|
116
|
-
*/
|
117
|
-
void writeUntilFull(int fd);
|
118
|
-
|
119
|
-
/**
|
120
|
-
* Look for 'toFind' inside the given file, replace it with 'replaceWith' and write
|
121
|
-
* the result back to the file. Only the first occurence of 'toFind' is replaced.
|
122
|
-
*
|
123
|
-
* @throws FileSystemException
|
124
|
-
*/
|
125
|
-
void replaceStringInFile(const char *filename, const string &toFind, const string &replaceWith);
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Returns whether 'str' contains the given substring.
|
129
|
-
*/
|
130
|
-
bool containsSubstring(const StaticString &str, const StaticString &substr);
|
131
|
-
|
132
|
-
/**
|
133
|
-
* Writes the given data into the given file.
|
134
|
-
*
|
135
|
-
* @throws FileSystemException
|
136
|
-
*/
|
137
|
-
void writeFile(const string &filename, const string &contents);
|
138
|
-
|
139
|
-
/**
|
140
|
-
* Touch the given file: create the file if it doesn't exist, update its
|
141
|
-
* timestamp if it does. If the <tt>timestamp</tt> argument is -1, then
|
142
|
-
* the current system time will be used, otherwise the given timestamp
|
143
|
-
* will be used.
|
144
|
-
*
|
145
|
-
* @throws FileSystemException
|
146
|
-
*/
|
147
|
-
void touchFile(const char *filename, time_t timestamp = (time_t) - 1);
|
148
|
-
|
149
|
-
/**
|
150
|
-
* Returns all filenames in the given directory.
|
151
|
-
*/
|
152
|
-
vector<string> listDir(const string &path);
|
153
|
-
|
154
|
-
/**
|
155
|
-
* Returns the name of the primary group of the given user.
|
156
|
-
*/
|
157
|
-
string getPrimaryGroupName(const string &username);
|
158
|
-
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Class which creates a temporary directory of the given name, and deletes
|
162
|
-
* it upon destruction.
|
163
|
-
*/
|
164
|
-
class TempDir {
|
165
|
-
private:
|
166
|
-
string name;
|
167
|
-
bool ignoreRemoveErrors;
|
168
|
-
public:
|
169
|
-
TempDir(const string &name, bool _ignoreRemoveErrors = false) {
|
170
|
-
this->name = name;
|
171
|
-
if (mkdir(name.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0 && errno != EEXIST) {
|
172
|
-
int e = errno;
|
173
|
-
string message = "Cannot create directory '";
|
174
|
-
message.append(name);
|
175
|
-
message.append("'");
|
176
|
-
throw FileSystemException(message, e, name);
|
177
|
-
}
|
178
|
-
ignoreRemoveErrors = _ignoreRemoveErrors;
|
179
|
-
}
|
180
|
-
|
181
|
-
~TempDir() {
|
182
|
-
if (ignoreRemoveErrors) {
|
183
|
-
try {
|
184
|
-
removeDirTree(name);
|
185
|
-
} catch (const RuntimeException &) {
|
186
|
-
// Do nothing.
|
187
|
-
}
|
188
|
-
} else {
|
189
|
-
removeDirTree(name);
|
190
|
-
}
|
191
|
-
}
|
192
|
-
};
|
193
|
-
|
194
|
-
|
195
|
-
/**
|
196
|
-
* Creates a temporary copy of the given directory. This copy is deleted
|
197
|
-
* upon object destruction.
|
198
|
-
*/
|
199
|
-
class TempDirCopy {
|
200
|
-
private:
|
201
|
-
string dir;
|
202
|
-
public:
|
203
|
-
TempDirCopy(const string &source, const string &dest) {
|
204
|
-
dir = dest;
|
205
|
-
removeDirTree(dest);
|
206
|
-
|
207
|
-
char command[1024];
|
208
|
-
snprintf(command, sizeof(command), "cp -pR \"%s\" \"%s\"",
|
209
|
-
source.c_str(), dest.c_str());
|
210
|
-
pid_t pid = fork();
|
211
|
-
if (pid == 0) {
|
212
|
-
resetSignalHandlersAndMask();
|
213
|
-
disableMallocDebugging();
|
214
|
-
closeAllFileDescriptors(2);
|
215
|
-
execlp("/bin/sh", "/bin/sh", "-c", command, (char * const) 0);
|
216
|
-
_exit(1);
|
217
|
-
} else if (pid == -1) {
|
218
|
-
int e = errno;
|
219
|
-
throw SystemException("Cannot fork()", e);
|
220
|
-
} else {
|
221
|
-
waitpid(pid, NULL, 0);
|
222
|
-
}
|
223
|
-
}
|
224
|
-
|
225
|
-
~TempDirCopy() {
|
226
|
-
removeDirTree(dir);
|
227
|
-
}
|
228
|
-
};
|
229
|
-
|
230
|
-
|
231
|
-
/**
|
232
|
-
* Class which deletes the given file upon destruction.
|
233
|
-
*/
|
234
|
-
class DeleteFileEventually {
|
235
|
-
private:
|
236
|
-
string filename;
|
237
|
-
public:
|
238
|
-
DeleteFileEventually(const string &filename, bool deleteNow = true) {
|
239
|
-
this->filename = filename;
|
240
|
-
if (deleteNow) {
|
241
|
-
unlink(filename.c_str());
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
~DeleteFileEventually() {
|
246
|
-
unlink(filename.c_str());
|
247
|
-
}
|
248
|
-
};
|
249
|
-
|
250
|
-
|
251
|
-
/**
|
252
|
-
* Spawns a thread which will be interrupted and joined when this TempThread
|
253
|
-
* object is destroyed.
|
254
|
-
*/
|
255
|
-
class TempThread {
|
256
|
-
public:
|
257
|
-
oxt::thread thread;
|
258
|
-
bool joined;
|
259
|
-
|
260
|
-
TempThread(boost::function<void ()> func)
|
261
|
-
: thread(boost::bind(runAndPrintExceptions, func, true)),
|
262
|
-
joined(false)
|
263
|
-
{ }
|
264
|
-
|
265
|
-
~TempThread() {
|
266
|
-
if (!joined) {
|
267
|
-
thread.interrupt_and_join();
|
268
|
-
}
|
269
|
-
}
|
270
|
-
|
271
|
-
void join() {
|
272
|
-
thread.join();
|
273
|
-
joined = true;
|
274
|
-
}
|
275
|
-
};
|
276
|
-
|
277
|
-
|
278
|
-
class AtomicInt {
|
279
|
-
private:
|
280
|
-
mutable boost::mutex lock;
|
281
|
-
int val;
|
282
|
-
public:
|
283
|
-
AtomicInt() {
|
284
|
-
val = 0;
|
285
|
-
}
|
286
|
-
|
287
|
-
AtomicInt(int value) {
|
288
|
-
val = value;
|
289
|
-
}
|
290
|
-
|
291
|
-
AtomicInt(const AtomicInt &other) {
|
292
|
-
val = other.val;
|
293
|
-
}
|
294
|
-
|
295
|
-
int get() const {
|
296
|
-
boost::lock_guard<boost::mutex> l(lock);
|
297
|
-
return val;
|
298
|
-
}
|
299
|
-
|
300
|
-
void set(int value) {
|
301
|
-
boost::lock_guard<boost::mutex> l(lock);
|
302
|
-
val = value;
|
303
|
-
}
|
304
|
-
|
305
|
-
AtomicInt &operator=(int value) {
|
306
|
-
set(value);
|
307
|
-
return *this;
|
308
|
-
}
|
309
|
-
|
310
|
-
AtomicInt &operator++() {
|
311
|
-
boost::lock_guard<boost::mutex> l(lock);
|
312
|
-
val++;
|
313
|
-
return *this;
|
314
|
-
}
|
315
|
-
|
316
|
-
AtomicInt operator++(int) {
|
317
|
-
boost::lock_guard<boost::mutex> l(lock);
|
318
|
-
AtomicInt temp(*this);
|
319
|
-
val++;
|
320
|
-
return temp;
|
321
|
-
}
|
322
|
-
|
323
|
-
operator int() const {
|
324
|
-
return get();
|
325
|
-
}
|
326
|
-
};
|
327
|
-
|
328
|
-
|
329
|
-
} // namespace TestSupport
|
330
|
-
|
331
|
-
using namespace TestSupport;
|
332
|
-
|
333
|
-
#endif /* _TEST_SUPPORT_H_ */
|
@@ -1,741 +0,0 @@
|
|
1
|
-
#include <TestSupport.h>
|
2
|
-
#include <UnionStation/Core.h>
|
3
|
-
#include <UnionStation/Transaction.h>
|
4
|
-
#include <MessageClient.h>
|
5
|
-
#include <agents/LoggingAgent/LoggingServer.h>
|
6
|
-
#include <Utils/MessageIO.h>
|
7
|
-
|
8
|
-
#include <boost/bind.hpp>
|
9
|
-
#include <boost/shared_ptr.hpp>
|
10
|
-
#include <oxt/thread.hpp>
|
11
|
-
#include <set>
|
12
|
-
|
13
|
-
using namespace Passenger;
|
14
|
-
using namespace Passenger::UnionStation;
|
15
|
-
using namespace std;
|
16
|
-
using namespace oxt;
|
17
|
-
|
18
|
-
namespace tut {
|
19
|
-
struct UnionStationTest {
|
20
|
-
static const unsigned long long YESTERDAY = 1263299017000000ull; // January 12, 2009, 12:23:37 UTC
|
21
|
-
static const unsigned long long TODAY = 1263385422000000ull; // January 13, 2009, 12:23:42 UTC
|
22
|
-
static const unsigned long long TOMORROW = 1263471822000000ull; // January 14, 2009, 12:23:42 UTC
|
23
|
-
#define TODAY_TXN_ID "cjb8n-abcd"
|
24
|
-
#define TODAY_TIMESTAMP_STR "cftz90m3k0"
|
25
|
-
|
26
|
-
InstanceDirectoryPtr instanceDir;
|
27
|
-
string socketFilename;
|
28
|
-
string socketAddress;
|
29
|
-
string dumpFile;
|
30
|
-
AccountsDatabasePtr accountsDatabase;
|
31
|
-
ev::dynamic_loop eventLoop;
|
32
|
-
FileDescriptor serverFd;
|
33
|
-
LoggingServerPtr server;
|
34
|
-
boost::shared_ptr<oxt::thread> serverThread;
|
35
|
-
CorePtr core, core2, core3, core4;
|
36
|
-
|
37
|
-
UnionStationTest() {
|
38
|
-
createInstanceDir(instanceDir);
|
39
|
-
socketFilename = instanceDir->getPath() + "/logging.socket";
|
40
|
-
socketAddress = "unix:" + socketFilename;
|
41
|
-
dumpFile = instanceDir->getPath() + "/log.txt";
|
42
|
-
accountsDatabase = ptr(new AccountsDatabase());
|
43
|
-
accountsDatabase->add("test", "1234", false);
|
44
|
-
setLogLevel(LVL_ERROR);
|
45
|
-
|
46
|
-
startLoggingServer();
|
47
|
-
core = make_shared<Core>(socketAddress, "test", "1234",
|
48
|
-
"localhost");
|
49
|
-
core2 = make_shared<Core>(socketAddress, "test", "1234",
|
50
|
-
"localhost");
|
51
|
-
core3 = make_shared<Core>(socketAddress, "test", "1234",
|
52
|
-
"localhost");
|
53
|
-
core4 = make_shared<Core>(socketAddress, "test", "1234",
|
54
|
-
"localhost");
|
55
|
-
}
|
56
|
-
|
57
|
-
~UnionStationTest() {
|
58
|
-
stopLoggingServer();
|
59
|
-
SystemTime::releaseAll();
|
60
|
-
setLogLevel(DEFAULT_LOG_LEVEL);
|
61
|
-
}
|
62
|
-
|
63
|
-
void startLoggingServer(const boost::function<void ()> &initFunc = boost::function<void ()>()) {
|
64
|
-
VariantMap options;
|
65
|
-
options.set("analytics_dump_file", dumpFile);
|
66
|
-
serverFd = createUnixServer(socketFilename.c_str());
|
67
|
-
server = ptr(new LoggingServer(eventLoop,
|
68
|
-
serverFd, accountsDatabase, options));
|
69
|
-
if (initFunc) {
|
70
|
-
initFunc();
|
71
|
-
}
|
72
|
-
serverThread = ptr(new oxt::thread(
|
73
|
-
boost::bind(&UnionStationTest::runLoop, this)
|
74
|
-
));
|
75
|
-
}
|
76
|
-
|
77
|
-
void stopLoggingServer(bool destroy = true) {
|
78
|
-
if (serverThread != NULL) {
|
79
|
-
MessageClient client;
|
80
|
-
client.connect(socketAddress, "test", "1234");
|
81
|
-
client.write("exit", "immediately", NULL);
|
82
|
-
joinLoggingServer(destroy);
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
void joinLoggingServer(bool destroy = true) {
|
87
|
-
serverThread->join();
|
88
|
-
serverThread.reset();
|
89
|
-
if (destroy) {
|
90
|
-
server.reset();
|
91
|
-
}
|
92
|
-
unlink(socketFilename.c_str());
|
93
|
-
}
|
94
|
-
|
95
|
-
void runLoop() {
|
96
|
-
eventLoop.loop();
|
97
|
-
serverFd.close();
|
98
|
-
}
|
99
|
-
|
100
|
-
string timestampString(unsigned long long timestamp) {
|
101
|
-
char str[2 * sizeof(unsigned long long) + 1];
|
102
|
-
integerToHexatri<unsigned long long>(timestamp, str);
|
103
|
-
return str;
|
104
|
-
}
|
105
|
-
|
106
|
-
MessageClient createConnection(bool sendInitCommand = true) {
|
107
|
-
MessageClient client;
|
108
|
-
vector<string> args;
|
109
|
-
client.connect(socketAddress, "test", "1234");
|
110
|
-
if (sendInitCommand) {
|
111
|
-
client.write("init", "localhost", NULL);
|
112
|
-
client.read(args);
|
113
|
-
}
|
114
|
-
return client;
|
115
|
-
}
|
116
|
-
|
117
|
-
string readDumpFile() {
|
118
|
-
return readAll(dumpFile);
|
119
|
-
}
|
120
|
-
};
|
121
|
-
|
122
|
-
DEFINE_TEST_GROUP(UnionStationTest);
|
123
|
-
|
124
|
-
|
125
|
-
/*********** Logging interface tests ***********/
|
126
|
-
|
127
|
-
TEST_METHOD(1) {
|
128
|
-
// Test logging of new transaction.
|
129
|
-
SystemTime::forceAll(YESTERDAY);
|
130
|
-
|
131
|
-
TransactionPtr log = core->newTransaction("foobar");
|
132
|
-
log->message("hello");
|
133
|
-
log->message("world");
|
134
|
-
log->flushToDiskAfterClose(true);
|
135
|
-
|
136
|
-
ensure(!core->isNull());
|
137
|
-
ensure(!log->isNull());
|
138
|
-
|
139
|
-
log.reset();
|
140
|
-
|
141
|
-
string data = readDumpFile();
|
142
|
-
ensure(data.find("hello\n") != string::npos);
|
143
|
-
ensure(data.find("world\n") != string::npos);
|
144
|
-
}
|
145
|
-
|
146
|
-
TEST_METHOD(2) {
|
147
|
-
// Test logging of existing transaction.
|
148
|
-
SystemTime::forceAll(YESTERDAY);
|
149
|
-
|
150
|
-
TransactionPtr log = core->newTransaction("foobar");
|
151
|
-
log->message("message 1");
|
152
|
-
log->flushToDiskAfterClose(true);
|
153
|
-
|
154
|
-
TransactionPtr log2 = core2->continueTransaction(log->getTxnId(),
|
155
|
-
log->getGroupName(), log->getCategory());
|
156
|
-
log2->message("message 2");
|
157
|
-
log2->flushToDiskAfterClose(true);
|
158
|
-
|
159
|
-
log.reset();
|
160
|
-
log2.reset();
|
161
|
-
|
162
|
-
string data = readDumpFile();
|
163
|
-
ensure("(1)", data.find("message 1\n") != string::npos);
|
164
|
-
ensure("(2)", data.find("message 2\n") != string::npos);
|
165
|
-
}
|
166
|
-
|
167
|
-
TEST_METHOD(3) {
|
168
|
-
// Test logging with different points in time.
|
169
|
-
SystemTime::forceAll(YESTERDAY);
|
170
|
-
TransactionPtr log = core->newTransaction("foobar");
|
171
|
-
log->message("message 1");
|
172
|
-
SystemTime::forceAll(TODAY);
|
173
|
-
log->message("message 2");
|
174
|
-
log->flushToDiskAfterClose(true);
|
175
|
-
|
176
|
-
SystemTime::forceAll(TOMORROW);
|
177
|
-
TransactionPtr log2 = core2->continueTransaction(log->getTxnId(),
|
178
|
-
log->getGroupName(), log->getCategory());
|
179
|
-
log2->message("message 3");
|
180
|
-
log2->flushToDiskAfterClose(true);
|
181
|
-
|
182
|
-
TransactionPtr log3 = core3->newTransaction("foobar");
|
183
|
-
log3->message("message 4");
|
184
|
-
log3->flushToDiskAfterClose(true);
|
185
|
-
|
186
|
-
log.reset();
|
187
|
-
log2.reset();
|
188
|
-
log3.reset();
|
189
|
-
|
190
|
-
string data = readDumpFile();
|
191
|
-
ensure("(1)", data.find(timestampString(YESTERDAY) + " 1 message 1\n") != string::npos);
|
192
|
-
ensure("(2)", data.find(timestampString(TODAY) + " 2 message 2\n") != string::npos);
|
193
|
-
ensure("(3)", data.find(timestampString(TOMORROW) + " 4 message 3\n") != string::npos);
|
194
|
-
ensure("(4)", data.find(timestampString(TOMORROW) + " 1 message 4\n") != string::npos);
|
195
|
-
}
|
196
|
-
|
197
|
-
TEST_METHOD(4) {
|
198
|
-
// newTransaction() and continueTransaction() write an ATTACH message
|
199
|
-
// to the log file, while UnionStation::Transaction writes a DETACH message upon
|
200
|
-
// destruction.
|
201
|
-
SystemTime::forceAll(YESTERDAY);
|
202
|
-
TransactionPtr log = core->newTransaction("foobar");
|
203
|
-
|
204
|
-
SystemTime::forceAll(TODAY);
|
205
|
-
TransactionPtr log2 = core2->continueTransaction(log->getTxnId(),
|
206
|
-
log->getGroupName(), log->getCategory());
|
207
|
-
log2->flushToDiskAfterClose(true);
|
208
|
-
log2.reset();
|
209
|
-
|
210
|
-
SystemTime::forceAll(TOMORROW);
|
211
|
-
log->flushToDiskAfterClose(true);
|
212
|
-
log.reset();
|
213
|
-
|
214
|
-
string data = readDumpFile();
|
215
|
-
ensure("(1)", data.find(timestampString(YESTERDAY) + " 0 ATTACH\n") != string::npos);
|
216
|
-
ensure("(2)", data.find(timestampString(TODAY) + " 1 ATTACH\n") != string::npos);
|
217
|
-
ensure("(3)", data.find(timestampString(TODAY) + " 2 DETACH\n") != string::npos);
|
218
|
-
ensure("(4)", data.find(timestampString(TOMORROW) + " 3 DETACH\n") != string::npos);
|
219
|
-
}
|
220
|
-
|
221
|
-
TEST_METHOD(5) {
|
222
|
-
// newTransaction() generates a new ID, while continueTransaction()
|
223
|
-
// reuses the ID.
|
224
|
-
TransactionPtr log = core->newTransaction("foobar");
|
225
|
-
TransactionPtr log2 = core2->newTransaction("foobar");
|
226
|
-
TransactionPtr log3 = core3->continueTransaction(log->getTxnId(),
|
227
|
-
log->getGroupName(), log->getCategory());
|
228
|
-
TransactionPtr log4 = core4->continueTransaction(log2->getTxnId(),
|
229
|
-
log2->getGroupName(), log2->getCategory());
|
230
|
-
|
231
|
-
ensure_equals(log->getTxnId(), log3->getTxnId());
|
232
|
-
ensure_equals(log2->getTxnId(), log4->getTxnId());
|
233
|
-
ensure(log->getTxnId() != log2->getTxnId());
|
234
|
-
}
|
235
|
-
|
236
|
-
TEST_METHOD(6) {
|
237
|
-
// An empty UnionStation::Transaction doesn't do anything.
|
238
|
-
UnionStation::Transaction log;
|
239
|
-
ensure(log.isNull());
|
240
|
-
log.message("hello world");
|
241
|
-
ensure_equals(getFileType(dumpFile), FT_NONEXISTANT);
|
242
|
-
}
|
243
|
-
|
244
|
-
TEST_METHOD(7) {
|
245
|
-
// An empty UnionStation::Core doesn't do anything.
|
246
|
-
UnionStation::Core core;
|
247
|
-
ensure(core.isNull());
|
248
|
-
|
249
|
-
TransactionPtr log = core.newTransaction("foo");
|
250
|
-
ensure(log->isNull());
|
251
|
-
log->message("hello world");
|
252
|
-
ensure_equals(getFileType(dumpFile), FT_NONEXISTANT);
|
253
|
-
}
|
254
|
-
|
255
|
-
TEST_METHOD(11) {
|
256
|
-
// newTransaction() does not reconnect to the server for a short
|
257
|
-
// period of time if connecting failed
|
258
|
-
core->setReconnectTimeout(60 * 1000000);
|
259
|
-
|
260
|
-
SystemTime::forceAll(TODAY);
|
261
|
-
stopLoggingServer();
|
262
|
-
ensure(core->newTransaction("foobar")->isNull());
|
263
|
-
|
264
|
-
SystemTime::forceAll(TODAY + 30 * 1000000);
|
265
|
-
startLoggingServer();
|
266
|
-
ensure(core->newTransaction("foobar")->isNull());
|
267
|
-
|
268
|
-
SystemTime::forceAll(TODAY + 61 * 1000000);
|
269
|
-
ensure(!core->newTransaction("foobar")->isNull());
|
270
|
-
}
|
271
|
-
|
272
|
-
TEST_METHOD(12) {
|
273
|
-
// If the logging server crashed and was restarted then
|
274
|
-
// newTransaction() and continueTransaction() print a warning and return
|
275
|
-
// a null log object. One of the next newTransaction()/continueTransaction()
|
276
|
-
// calls will reestablish the connection when the connection timeout
|
277
|
-
// has passed.
|
278
|
-
SystemTime::forceAll(TODAY);
|
279
|
-
TransactionPtr log, log2;
|
280
|
-
|
281
|
-
log = core->newTransaction("foobar");
|
282
|
-
core2->continueTransaction(log->getTxnId(), "foobar");
|
283
|
-
log.reset(); // Check connection back into the pool.
|
284
|
-
stopLoggingServer();
|
285
|
-
startLoggingServer();
|
286
|
-
|
287
|
-
log = core->newTransaction("foobar");
|
288
|
-
ensure("(1)", log->isNull());
|
289
|
-
log2 = core2->continueTransaction("some-id", "foobar");
|
290
|
-
ensure("(2)", log2->isNull());
|
291
|
-
|
292
|
-
SystemTime::forceAll(TODAY + 60000000);
|
293
|
-
log = core->newTransaction("foobar");
|
294
|
-
ensure("(3)", !log->isNull());
|
295
|
-
log2 = core2->continueTransaction(log->getTxnId(), "foobar");
|
296
|
-
ensure("(4)", !log2->isNull());
|
297
|
-
log2->message("hello");
|
298
|
-
log2->flushToDiskAfterClose(true);
|
299
|
-
log.reset();
|
300
|
-
log2.reset();
|
301
|
-
|
302
|
-
EVENTUALLY(3,
|
303
|
-
result = readDumpFile().find("hello\n") != string::npos;
|
304
|
-
);
|
305
|
-
}
|
306
|
-
|
307
|
-
TEST_METHOD(13) {
|
308
|
-
// continueTransaction() does not reconnect to the server for a short
|
309
|
-
// period of time if connecting failed
|
310
|
-
core->setReconnectTimeout(60 * 1000000);
|
311
|
-
core2->setReconnectTimeout(60 * 1000000);
|
312
|
-
|
313
|
-
SystemTime::forceAll(TODAY);
|
314
|
-
TransactionPtr log = core->newTransaction("foobar");
|
315
|
-
core2->continueTransaction(log->getTxnId(), "foobar");
|
316
|
-
stopLoggingServer();
|
317
|
-
ensure(core2->continueTransaction(log->getTxnId(), "foobar")->isNull());
|
318
|
-
|
319
|
-
SystemTime::forceAll(TODAY + 30 * 1000000);
|
320
|
-
startLoggingServer();
|
321
|
-
ensure(core2->continueTransaction(log->getTxnId(), "foobar")->isNull());
|
322
|
-
|
323
|
-
SystemTime::forceAll(TODAY + 61 * 1000000);
|
324
|
-
ensure(!core2->continueTransaction(log->getTxnId(), "foobar")->isNull());
|
325
|
-
}
|
326
|
-
|
327
|
-
TEST_METHOD(14) {
|
328
|
-
// If a client disconnects from the logging server then all its
|
329
|
-
// transactions that are no longer referenced and have crash protection enabled
|
330
|
-
// will be closed and written to the sink.
|
331
|
-
MessageClient client1 = createConnection();
|
332
|
-
MessageClient client2 = createConnection();
|
333
|
-
MessageClient client3 = createConnection();
|
334
|
-
vector<string> args;
|
335
|
-
|
336
|
-
SystemTime::forceAll(TODAY);
|
337
|
-
|
338
|
-
client1.write("openTransaction",
|
339
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
340
|
-
"-", "true", "true", NULL);
|
341
|
-
client1.read(args);
|
342
|
-
client2.write("openTransaction",
|
343
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
344
|
-
"-", "true", NULL);
|
345
|
-
client2.write("log", TODAY_TXN_ID, "1000", NULL);
|
346
|
-
client2.writeScalar("hello world");
|
347
|
-
client2.write("flush", NULL);
|
348
|
-
client2.read(args);
|
349
|
-
client2.disconnect();
|
350
|
-
SHOULD_NEVER_HAPPEN(100,
|
351
|
-
// Transaction still has references open, so should not yet be written to sink.
|
352
|
-
result = readDumpFile().find("hello world") != string::npos;
|
353
|
-
);
|
354
|
-
|
355
|
-
client1.disconnect();
|
356
|
-
client3.write("flush", NULL);
|
357
|
-
client3.read(args);
|
358
|
-
EVENTUALLY(5,
|
359
|
-
result = readDumpFile().find("hello world") != string::npos;
|
360
|
-
);
|
361
|
-
}
|
362
|
-
|
363
|
-
TEST_METHOD(15) {
|
364
|
-
// If a client disconnects from the logging server then all its
|
365
|
-
// transactions that are no longer referenced and don't have crash
|
366
|
-
// protection enabled will be closed and discarded.
|
367
|
-
MessageClient client1 = createConnection();
|
368
|
-
MessageClient client2 = createConnection();
|
369
|
-
MessageClient client3 = createConnection();
|
370
|
-
vector<string> args;
|
371
|
-
|
372
|
-
SystemTime::forceAll(TODAY);
|
373
|
-
|
374
|
-
client1.write("openTransaction",
|
375
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
376
|
-
"-", "false", "true", NULL);
|
377
|
-
client1.read(args);
|
378
|
-
client2.write("openTransaction",
|
379
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
380
|
-
"-", "false", NULL);
|
381
|
-
client2.write("flush", NULL);
|
382
|
-
client2.read(args);
|
383
|
-
client2.disconnect();
|
384
|
-
client1.disconnect();
|
385
|
-
client3.write("flush", NULL);
|
386
|
-
client3.read(args);
|
387
|
-
SHOULD_NEVER_HAPPEN(500,
|
388
|
-
result = fileExists(dumpFile) && !readDumpFile().empty();
|
389
|
-
);
|
390
|
-
}
|
391
|
-
|
392
|
-
TEST_METHOD(16) {
|
393
|
-
// Upon server shutdown, all transaction that have crash protection enabled
|
394
|
-
// will be closed and written to to the sink.
|
395
|
-
MessageClient client1 = createConnection();
|
396
|
-
MessageClient client2 = createConnection();
|
397
|
-
vector<string> args;
|
398
|
-
|
399
|
-
SystemTime::forceAll(TODAY);
|
400
|
-
|
401
|
-
client1.write("openTransaction",
|
402
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
403
|
-
"-", "true", "true", NULL);
|
404
|
-
client1.read(args);
|
405
|
-
client2.write("openTransaction",
|
406
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
407
|
-
"-", "true", NULL);
|
408
|
-
client2.write("flush", NULL);
|
409
|
-
client2.read(args);
|
410
|
-
|
411
|
-
stopLoggingServer();
|
412
|
-
EVENTUALLY(5,
|
413
|
-
result = fileExists(dumpFile) && !readDumpFile().empty();
|
414
|
-
);
|
415
|
-
}
|
416
|
-
|
417
|
-
TEST_METHOD(17) {
|
418
|
-
// Upon server shutdown, all transaction that don't have crash protection
|
419
|
-
// enabled will be discarded.
|
420
|
-
MessageClient client1 = createConnection();
|
421
|
-
MessageClient client2 = createConnection();
|
422
|
-
vector<string> args;
|
423
|
-
|
424
|
-
SystemTime::forceAll(TODAY);
|
425
|
-
|
426
|
-
client1.write("openTransaction",
|
427
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
428
|
-
"-", "false", "true", NULL);
|
429
|
-
client1.read(args);
|
430
|
-
client2.write("openTransaction",
|
431
|
-
TODAY_TXN_ID, "foobar", "", "requests", TODAY_TIMESTAMP_STR,
|
432
|
-
"-", "false", NULL);
|
433
|
-
client2.write("flush", NULL);
|
434
|
-
client2.read(args);
|
435
|
-
|
436
|
-
stopLoggingServer();
|
437
|
-
SHOULD_NEVER_HAPPEN(200,
|
438
|
-
result = fileExists(dumpFile) && !readDumpFile().empty();
|
439
|
-
);
|
440
|
-
}
|
441
|
-
|
442
|
-
TEST_METHOD(18) {
|
443
|
-
// Test DataStoreId
|
444
|
-
{
|
445
|
-
// Empty construction.
|
446
|
-
DataStoreId id;
|
447
|
-
ensure_equals(id.getGroupName(), "");
|
448
|
-
ensure_equals(id.getNodeName(), "");
|
449
|
-
ensure_equals(id.getCategory(), "");
|
450
|
-
}
|
451
|
-
{
|
452
|
-
// Normal construction.
|
453
|
-
DataStoreId id("ab", "cd", "ef");
|
454
|
-
ensure_equals(id.getGroupName(), "ab");
|
455
|
-
ensure_equals(id.getNodeName(), "cd");
|
456
|
-
ensure_equals(id.getCategory(), "ef");
|
457
|
-
}
|
458
|
-
{
|
459
|
-
// Copy constructor.
|
460
|
-
DataStoreId id("ab", "cd", "ef");
|
461
|
-
DataStoreId id2(id);
|
462
|
-
ensure_equals(id2.getGroupName(), "ab");
|
463
|
-
ensure_equals(id2.getNodeName(), "cd");
|
464
|
-
ensure_equals(id2.getCategory(), "ef");
|
465
|
-
}
|
466
|
-
{
|
467
|
-
// Assignment operator.
|
468
|
-
DataStoreId id("ab", "cd", "ef");
|
469
|
-
DataStoreId id2;
|
470
|
-
id2 = id;
|
471
|
-
ensure_equals(id2.getGroupName(), "ab");
|
472
|
-
ensure_equals(id2.getNodeName(), "cd");
|
473
|
-
ensure_equals(id2.getCategory(), "ef");
|
474
|
-
|
475
|
-
DataStoreId id3("gh", "ij", "kl");
|
476
|
-
id3 = id;
|
477
|
-
ensure_equals(id3.getGroupName(), "ab");
|
478
|
-
ensure_equals(id3.getNodeName(), "cd");
|
479
|
-
ensure_equals(id3.getCategory(), "ef");
|
480
|
-
}
|
481
|
-
{
|
482
|
-
// < operator
|
483
|
-
DataStoreId id, id2;
|
484
|
-
ensure(!(id < id2));
|
485
|
-
|
486
|
-
id = DataStoreId("ab", "cd", "ef");
|
487
|
-
id2 = DataStoreId("ab", "cd", "ef");
|
488
|
-
ensure(!(id < id2));
|
489
|
-
|
490
|
-
id = DataStoreId("ab", "cd", "ef");
|
491
|
-
id2 = DataStoreId("bb", "cd", "ef");
|
492
|
-
ensure(id < id2);
|
493
|
-
|
494
|
-
id = DataStoreId("ab", "cd", "ef");
|
495
|
-
id2 = DataStoreId();
|
496
|
-
ensure(id2 < id);
|
497
|
-
|
498
|
-
id = DataStoreId();
|
499
|
-
id2 = DataStoreId("ab", "cd", "ef");
|
500
|
-
ensure(id < id2);
|
501
|
-
}
|
502
|
-
{
|
503
|
-
// == operator
|
504
|
-
ensure(DataStoreId() == DataStoreId());
|
505
|
-
ensure(DataStoreId("ab", "cd", "ef") == DataStoreId("ab", "cd", "ef"));
|
506
|
-
ensure(!(DataStoreId("ab", "cd", "ef") == DataStoreId()));
|
507
|
-
ensure(!(DataStoreId("ab", "cd", "ef") == DataStoreId("ab", "cd", "e")));
|
508
|
-
ensure(!(DataStoreId("ab", "cd", "ef") == DataStoreId("ab", "c", "ef")));
|
509
|
-
ensure(!(DataStoreId("ab", "cd", "ef") == DataStoreId("a", "cd", "ef")));
|
510
|
-
}
|
511
|
-
}
|
512
|
-
|
513
|
-
TEST_METHOD(22) {
|
514
|
-
// The destructor flushes all data.
|
515
|
-
TransactionPtr log = core->newTransaction("foobar");
|
516
|
-
log->message("hello world");
|
517
|
-
log.reset();
|
518
|
-
stopLoggingServer();
|
519
|
-
|
520
|
-
struct stat buf;
|
521
|
-
ensure_equals(stat(dumpFile.c_str(), &buf), 0);
|
522
|
-
ensure(buf.st_size > 0);
|
523
|
-
}
|
524
|
-
|
525
|
-
TEST_METHOD(23) {
|
526
|
-
// The 'flush' command flushes all data.
|
527
|
-
SystemTime::forceAll(YESTERDAY);
|
528
|
-
|
529
|
-
TransactionPtr log = core->newTransaction("foobar");
|
530
|
-
log->message("hello world");
|
531
|
-
log.reset();
|
532
|
-
|
533
|
-
ConnectionPtr connection = core->checkoutConnection();
|
534
|
-
vector<string> args;
|
535
|
-
writeArrayMessage(connection->fd, "flush", NULL);
|
536
|
-
ensure(readArrayMessage(connection->fd, args));
|
537
|
-
ensure_equals(args.size(), 1u);
|
538
|
-
ensure_equals(args[0], "ok");
|
539
|
-
|
540
|
-
struct stat buf;
|
541
|
-
ensure_equals(stat(dumpFile.c_str(), &buf), 0);
|
542
|
-
ensure(buf.st_size > 0);
|
543
|
-
}
|
544
|
-
|
545
|
-
TEST_METHOD(24) {
|
546
|
-
// A transaction's data is not written out by the server
|
547
|
-
// until the transaction is fully closed.
|
548
|
-
SystemTime::forceAll(YESTERDAY);
|
549
|
-
vector<string> args;
|
550
|
-
|
551
|
-
TransactionPtr log = core->newTransaction("foobar");
|
552
|
-
log->message("hello world");
|
553
|
-
|
554
|
-
TransactionPtr log2 = core2->continueTransaction(log->getTxnId(),
|
555
|
-
log->getGroupName(), log->getCategory());
|
556
|
-
log2->message("message 2");
|
557
|
-
log2.reset();
|
558
|
-
|
559
|
-
ConnectionPtr connection = core->checkoutConnection();
|
560
|
-
writeArrayMessage(connection->fd, "flush", NULL);
|
561
|
-
ensure(readArrayMessage(connection->fd, args));
|
562
|
-
|
563
|
-
connection = core2->checkoutConnection();
|
564
|
-
writeArrayMessage(connection->fd, "flush", NULL);
|
565
|
-
ensure(readArrayMessage(connection->fd, args));
|
566
|
-
|
567
|
-
struct stat buf;
|
568
|
-
ensure_equals(stat(dumpFile.c_str(), &buf), 0);
|
569
|
-
ensure_equals(buf.st_size, (off_t) 0);
|
570
|
-
}
|
571
|
-
|
572
|
-
TEST_METHOD(25) {
|
573
|
-
// The 'exit' command causes the logging server to exit some time after
|
574
|
-
// the last client has disconnected. New clients are still accepted
|
575
|
-
// as long as the server hasn't exited.
|
576
|
-
SystemTime::forceAll(YESTERDAY);
|
577
|
-
vector<string> args;
|
578
|
-
|
579
|
-
MessageClient client = createConnection();
|
580
|
-
|
581
|
-
MessageClient client2 = createConnection();
|
582
|
-
client2.write("exit", NULL);
|
583
|
-
ensure("(1)", client2.read(args));
|
584
|
-
ensure_equals(args.size(), 1u);
|
585
|
-
ensure_equals(args[0], "Passed security");
|
586
|
-
ensure("(2)", client2.read(args));
|
587
|
-
ensure_equals(args.size(), 1u);
|
588
|
-
ensure_equals(args[0], "exit command received");
|
589
|
-
client2.disconnect();
|
590
|
-
|
591
|
-
// Not exited yet: there is still a client.
|
592
|
-
client2 = createConnection();
|
593
|
-
client2.write("ping", NULL);
|
594
|
-
ensure("(3)", client2.read(args));
|
595
|
-
client2.disconnect();
|
596
|
-
|
597
|
-
client.disconnect();
|
598
|
-
setLogLevel(LVL_CRIT);
|
599
|
-
usleep(25000); // Give server some time to process the connection closes.
|
600
|
-
|
601
|
-
// No clients now, but we can still connect because the timeout
|
602
|
-
// hasn't passed yet.
|
603
|
-
SystemTime::forceAll(YESTERDAY + 1000000);
|
604
|
-
SHOULD_NEVER_HAPPEN(250,
|
605
|
-
try {
|
606
|
-
close(connectToUnixServer(socketFilename));
|
607
|
-
result = false;
|
608
|
-
} catch (const SystemException &) {
|
609
|
-
result = true;
|
610
|
-
}
|
611
|
-
);
|
612
|
-
|
613
|
-
usleep(50000); // Give server some time to process the connection closes.
|
614
|
-
|
615
|
-
// It'll be gone in a few seconds.
|
616
|
-
SystemTime::forceAll(YESTERDAY + 1000000 + 5000000);
|
617
|
-
usleep(100000); // Give server some time to run the timer.
|
618
|
-
try {
|
619
|
-
close(connectToUnixServer(socketFilename));
|
620
|
-
fail("(4)");
|
621
|
-
} catch (const SystemException &) {
|
622
|
-
// Success
|
623
|
-
}
|
624
|
-
|
625
|
-
joinLoggingServer();
|
626
|
-
}
|
627
|
-
|
628
|
-
TEST_METHOD(26) {
|
629
|
-
// The 'exit semi-gracefully' command causes the logging server to
|
630
|
-
// refuse new clients while exiting some time after the last client has
|
631
|
-
// disconnected.
|
632
|
-
SystemTime::forceAll(YESTERDAY);
|
633
|
-
vector<string> args;
|
634
|
-
|
635
|
-
MessageClient client = createConnection();
|
636
|
-
|
637
|
-
MessageClient client2 = createConnection();
|
638
|
-
client2.write("exit", "semi-gracefully", NULL);
|
639
|
-
client2.disconnect();
|
640
|
-
|
641
|
-
// New connections are refused.
|
642
|
-
client2 = createConnection();
|
643
|
-
ensure("(1)", !client2.read(args));
|
644
|
-
|
645
|
-
client.disconnect();
|
646
|
-
setLogLevel(LVL_CRIT);
|
647
|
-
usleep(50000); // Give server some time to process the connection closes.
|
648
|
-
|
649
|
-
// It'll be gone in a few seconds.
|
650
|
-
SystemTime::forceAll(YESTERDAY + 1000000 + 5000000);
|
651
|
-
usleep(100000); // Give server some time to run the timer.
|
652
|
-
try {
|
653
|
-
close(connectToUnixServer(socketFilename));
|
654
|
-
fail("(2)");
|
655
|
-
} catch (const SystemException &) {
|
656
|
-
// Success
|
657
|
-
}
|
658
|
-
|
659
|
-
joinLoggingServer();
|
660
|
-
}
|
661
|
-
|
662
|
-
TEST_METHOD(27) {
|
663
|
-
// The 'exit immediately' command causes the logging server to
|
664
|
-
// immediately exit. Open transactions are not automatically
|
665
|
-
// closed and written out, even those with crash protection
|
666
|
-
// turned on.
|
667
|
-
SystemTime::forceAll(YESTERDAY);
|
668
|
-
|
669
|
-
TransactionPtr log = core->newTransaction("foobar");
|
670
|
-
log->message("hello world");
|
671
|
-
log.reset();
|
672
|
-
|
673
|
-
MessageClient client = createConnection();
|
674
|
-
client.write("exit", "immediately", NULL);
|
675
|
-
client.disconnect();
|
676
|
-
|
677
|
-
// Assertion: the following doesn't block.
|
678
|
-
joinLoggingServer();
|
679
|
-
}
|
680
|
-
|
681
|
-
TEST_METHOD(28) {
|
682
|
-
// UnionStation::Core treats a server that's semi-gracefully exiting as
|
683
|
-
// one that's refusing connections.
|
684
|
-
SystemTime::forceAll(YESTERDAY);
|
685
|
-
|
686
|
-
MessageClient client = createConnection();
|
687
|
-
client.write("exit", "semi-gracefully", NULL);
|
688
|
-
client.disconnect();
|
689
|
-
|
690
|
-
TransactionPtr log = core->newTransaction("foobar");
|
691
|
-
ensure(log->isNull());
|
692
|
-
}
|
693
|
-
|
694
|
-
TEST_METHOD(29) {
|
695
|
-
// One can supply a custom node name per openTransaction command.
|
696
|
-
MessageClient client1 = createConnection();
|
697
|
-
vector<string> args;
|
698
|
-
|
699
|
-
SystemTime::forceAll(TODAY);
|
700
|
-
|
701
|
-
client1.write("openTransaction",
|
702
|
-
TODAY_TXN_ID, "foobar", "remote", "requests", TODAY_TIMESTAMP_STR,
|
703
|
-
"-", "true", NULL);
|
704
|
-
client1.write("closeTransaction", TODAY_TXN_ID, TODAY_TIMESTAMP_STR, NULL);
|
705
|
-
client1.write("flush", NULL);
|
706
|
-
client1.read(args);
|
707
|
-
client1.disconnect();
|
708
|
-
|
709
|
-
ensure(fileExists(dumpFile));
|
710
|
-
}
|
711
|
-
|
712
|
-
TEST_METHOD(30) {
|
713
|
-
// A transaction is only written to the sink if it passes all given filters.
|
714
|
-
// Test logging of new transaction.
|
715
|
-
SystemTime::forceAll(YESTERDAY);
|
716
|
-
|
717
|
-
TransactionPtr log = core->newTransaction("foobar", "requests", "-",
|
718
|
-
"uri == \"/foo\""
|
719
|
-
"\1"
|
720
|
-
"uri != \"/bar\"");
|
721
|
-
log->message("URI: /foo");
|
722
|
-
log->message("transaction 1");
|
723
|
-
log->flushToDiskAfterClose(true);
|
724
|
-
log.reset();
|
725
|
-
|
726
|
-
log = core->newTransaction("foobar", "requests", "-",
|
727
|
-
"uri == \"/foo\""
|
728
|
-
"\1"
|
729
|
-
"uri == \"/bar\"");
|
730
|
-
log->message("URI: /foo");
|
731
|
-
log->message("transaction 2");
|
732
|
-
log->flushToDiskAfterClose(true);
|
733
|
-
log.reset();
|
734
|
-
|
735
|
-
string data = readDumpFile();
|
736
|
-
ensure("(1)", data.find("transaction 1\n") != string::npos);
|
737
|
-
ensure("(2)", data.find("transaction 2\n") == string::npos);
|
738
|
-
}
|
739
|
-
|
740
|
-
/************************************/
|
741
|
-
}
|