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.

Files changed (550) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +10 -0
  5. data/CHANGELOG +21 -0
  6. data/build/agents.rb +2 -2
  7. data/build/apache2.rb +6 -5
  8. data/build/common_library.rb +22 -7
  9. data/build/cxx_tests.rb +0 -3
  10. data/build/misc.rb +1 -1
  11. data/dev/parse_file_descriptor_log +119 -0
  12. data/doc/CloudLicensingConfiguration.html +387 -0
  13. data/doc/Design and Architecture.html +2430 -0
  14. data/doc/Packaging.html +488 -0
  15. data/doc/Security of user switching support.html +1833 -0
  16. data/doc/ServerOptimizationGuide.html +659 -0
  17. data/doc/ServerOptimizationGuide.txt.md +8 -0
  18. data/doc/Users guide Apache.html +9116 -0
  19. data/doc/Users guide Apache.idmap.txt +6 -2
  20. data/doc/Users guide Apache.txt +26 -7
  21. data/doc/Users guide Nginx.html +9025 -0
  22. data/doc/Users guide Nginx.idmap.txt +7 -3
  23. data/doc/Users guide Nginx.txt +29 -6
  24. data/doc/Users guide Standalone.html +3983 -0
  25. data/doc/Users guide.html +1748 -0
  26. data/doc/users_guide_snippets/installation.txt +4 -4
  27. data/ext/apache2/Configuration.cpp +16 -5
  28. data/ext/apache2/Configuration.hpp +4 -2
  29. data/ext/apache2/Hooks.cpp +44 -19
  30. data/ext/boost/libs/thread/src/pthread/once.cpp +2 -0
  31. data/ext/boost/libs/thread/src/pthread/once_atomic.cpp +6 -0
  32. data/ext/common/AgentsStarter.h +3 -2
  33. data/ext/common/ApplicationPool2/DirectSpawner.h +14 -4
  34. data/ext/common/ApplicationPool2/DummySpawner.h +12 -7
  35. data/ext/common/ApplicationPool2/Implementation.cpp +1 -1
  36. data/ext/common/ApplicationPool2/Process.h +2 -1
  37. data/ext/common/ApplicationPool2/Session.h +6 -6
  38. data/ext/common/ApplicationPool2/SmartSpawner.h +19 -4
  39. data/ext/common/ApplicationPool2/Socket.h +59 -27
  40. data/ext/common/ApplicationPool2/Spawner.h +2 -2
  41. data/ext/common/BackgroundEventLoop.cpp +6 -1
  42. data/ext/common/Constants.h +1 -1
  43. data/ext/common/EventedClient.h +1 -1
  44. data/ext/common/EventedServer.h +2 -2
  45. data/ext/common/FileDescriptor.h +25 -6
  46. data/ext/common/Logging.cpp +107 -52
  47. data/ext/common/Logging.h +146 -19
  48. data/ext/common/MessageClient.h +2 -2
  49. data/ext/common/MessageServer.h +3 -2
  50. data/ext/common/RandomGenerator.h +8 -7
  51. data/ext/common/SafeLibev.h +5 -1
  52. data/ext/common/ServerKit/AcceptLoadBalancer.h +9 -4
  53. data/ext/common/ServerKit/FdSinkChannel.h +5 -2
  54. data/ext/common/ServerKit/FdSourceChannel.h +5 -2
  55. data/ext/common/ServerKit/FileBufferedChannel.h +2 -0
  56. data/ext/common/ServerKit/FileBufferedFdSinkChannel.h +7 -2
  57. data/ext/common/ServerKit/HttpServer.h +6 -0
  58. data/ext/common/ServerKit/Server.h +40 -3
  59. data/ext/common/StaticString.h +20 -0
  60. data/ext/common/UnionStation/Connection.h +3 -1
  61. data/ext/common/UnionStation/Core.h +6 -4
  62. data/ext/common/Utils.cpp +4 -3
  63. data/ext/common/Utils/DateParsing.h +19 -5
  64. data/ext/common/Utils/FastStringStream.h +183 -0
  65. data/ext/common/Utils/IOUtils.cpp +47 -28
  66. data/ext/common/Utils/IOUtils.h +56 -12
  67. data/ext/common/Utils/MessagePassing.h +3 -3
  68. data/ext/common/Utils/ProcessMetricsCollector.h +2 -2
  69. data/ext/common/Utils/ScopeGuard.h +16 -5
  70. data/ext/common/Utils/SpeedMeter.h +2 -2
  71. data/ext/common/Utils/StrIntUtils.cpp +6 -6
  72. data/ext/common/Utils/StrIntUtils.h +2 -1
  73. data/ext/common/agents/Base.cpp +56 -4
  74. data/ext/common/agents/Base.h +2 -1
  75. data/ext/common/agents/HelperAgent/AdminServer.h +122 -11
  76. data/ext/common/agents/HelperAgent/Main.cpp +16 -5
  77. data/ext/common/agents/HelperAgent/OptionParser.h +7 -1
  78. data/ext/common/agents/HelperAgent/RequestHandler.h +1 -1
  79. data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +10 -1
  80. data/ext/common/agents/HelperAgent/RequestHandler/Request.h +8 -0
  81. data/ext/common/agents/HelperAgent/RequestHandler/TurboCaching.h +4 -3
  82. data/ext/common/agents/LoggingAgent/AdminServer.h +57 -11
  83. data/ext/common/agents/LoggingAgent/LoggingServer.h +3 -3
  84. data/ext/common/agents/LoggingAgent/Main.cpp +11 -3
  85. data/ext/common/agents/Watchdog/AdminServer.h +53 -11
  86. data/ext/common/agents/Watchdog/AgentWatcher.cpp +3 -3
  87. data/ext/common/agents/Watchdog/Main.cpp +13 -6
  88. data/ext/libeio/ecb.h +1 -1
  89. data/ext/libev/ev.c +13 -1
  90. data/ext/libev/ev.h +3 -0
  91. data/ext/nginx/Configuration.c +28 -6
  92. data/ext/nginx/Configuration.h +2 -1
  93. data/ext/nginx/ngx_http_passenger_module.c +5 -4
  94. data/ext/oxt/dynamic_thread_group.hpp +38 -5
  95. data/lib/phusion_passenger.rb +1 -1
  96. data/lib/phusion_passenger/common_library.rb +9 -5
  97. data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
  98. data/lib/phusion_passenger/packaging.rb +23 -37
  99. data/passenger.gemspec +21 -21
  100. metadata +4 -453
  101. metadata.gz.asc +7 -7
  102. data/.gitignore +0 -68
  103. data/.travis.yml +0 -16
  104. data/Gemfile +0 -17
  105. data/Gemfile.lock +0 -39
  106. data/Vagrantfile +0 -54
  107. data/debian.template/README.Debian +0 -15
  108. data/debian.template/changelog +0 -316
  109. data/debian.template/compat +0 -1
  110. data/debian.template/control.erb +0 -91
  111. data/debian.template/copyright +0 -385
  112. data/debian.template/libapache2-mod-passenger.install +0 -3
  113. data/debian.template/libapache2-mod-passenger.postinst +0 -36
  114. data/debian.template/libapache2-mod-passenger.prerm +0 -15
  115. data/debian.template/locations.ini.erb +0 -14
  116. data/debian.template/passenger-dev.install.erb +0 -3
  117. data/debian.template/passenger-doc.install.erb +0 -2
  118. data/debian.template/passenger.conf +0 -6
  119. data/debian.template/passenger.docs +0 -4
  120. data/debian.template/passenger.install.erb +0 -14
  121. data/debian.template/passenger.load +0 -3
  122. data/debian.template/passenger.manpages +0 -3
  123. data/debian.template/patches/series +0 -0
  124. data/debian.template/rules.erb +0 -76
  125. data/debian.template/source/format +0 -1
  126. data/ext/common/EventedBufferedInput.h +0 -458
  127. data/packaging/rpm/LICENSE.txt +0 -19
  128. data/packaging/rpm/Makefile +0 -13
  129. data/packaging/rpm/README.md +0 -41
  130. data/packaging/rpm/Vagrantfile +0 -38
  131. data/packaging/rpm/Vagrantfile.centos +0 -30
  132. data/packaging/rpm/build +0 -170
  133. data/packaging/rpm/create_project +0 -41
  134. data/packaging/rpm/git_update +0 -88
  135. data/packaging/rpm/image/Dockerfile +0 -37
  136. data/packaging/rpm/image/Gemfile +0 -3
  137. data/packaging/rpm/image/Gemfile.lock +0 -12
  138. data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +0 -19
  139. data/packaging/rpm/image/amazon2014-i386.cfg +0 -96
  140. data/packaging/rpm/image/amazon2014-x86_64.cfg +0 -96
  141. data/packaging/rpm/image/site-defaults.cfg +0 -168
  142. data/packaging/rpm/internal/build_tasks.rb +0 -238
  143. data/packaging/rpm/internal/dummygpg +0 -11
  144. data/packaging/rpm/internal/exec_build +0 -42
  145. data/packaging/rpm/internal/get_distro_arch +0 -14
  146. data/packaging/rpm/internal/get_distro_id +0 -10
  147. data/packaging/rpm/internal/git_update +0 -27
  148. data/packaging/rpm/internal/inituidgid +0 -17
  149. data/packaging/rpm/internal/my_init +0 -344
  150. data/packaging/rpm/internal/python27 +0 -3
  151. data/packaging/rpm/internal/repo_update +0 -46
  152. data/packaging/rpm/internal/setuser +0 -26
  153. data/packaging/rpm/internal/tracking_helper +0 -40
  154. data/packaging/rpm/jenkins_release +0 -99
  155. data/packaging/rpm/lib/build_tasks_support.rb +0 -402
  156. data/packaging/rpm/lib/preprocessor.rb +0 -341
  157. data/packaging/rpm/nginx_spec/404.html +0 -119
  158. data/packaging/rpm/nginx_spec/50x.html +0 -119
  159. data/packaging/rpm/nginx_spec/index.html +0 -116
  160. data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +0 -13
  161. data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
  162. data/packaging/rpm/nginx_spec/nginx-upgrade +0 -13
  163. data/packaging/rpm/nginx_spec/nginx-upgrade.8 +0 -151
  164. data/packaging/rpm/nginx_spec/nginx.conf +0 -131
  165. data/packaging/rpm/nginx_spec/nginx.init +0 -144
  166. data/packaging/rpm/nginx_spec/nginx.logrotate +0 -13
  167. data/packaging/rpm/nginx_spec/nginx.service +0 -15
  168. data/packaging/rpm/nginx_spec/nginx.spec.template +0 -560
  169. data/packaging/rpm/nginx_spec/nginx.sysconfig +0 -4
  170. data/packaging/rpm/nginx_spec/passenger.conf +0 -9
  171. data/packaging/rpm/nginx_spec/poweredby.png +0 -0
  172. data/packaging/rpm/passenger_spec/apache-passenger.conf.in +0 -26
  173. data/packaging/rpm/passenger_spec/config.json +0 -30
  174. data/packaging/rpm/passenger_spec/passenger.logrotate +0 -7
  175. data/packaging/rpm/passenger_spec/passenger.spec.template +0 -478
  176. data/packaging/rpm/passenger_spec/passenger_dynamic_thread_group.patch +0 -16
  177. data/packaging/rpm/passenger_spec/passenger_tests_default_config_example.patch +0 -44
  178. data/packaging/rpm/passenger_spec/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -21
  179. data/packaging/rpm/repo_update +0 -114
  180. data/packaging/rpm/setup-system +0 -61
  181. data/packaging/rpm/shell +0 -10
  182. data/test/.rspec +0 -4
  183. data/test/config.json.example +0 -42
  184. data/test/config.json.rpm-automation +0 -15
  185. data/test/config.json.travis +0 -15
  186. data/test/config.json.vagrant +0 -30
  187. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +0 -124
  188. data/test/cxx/ApplicationPool2/OptionsTest.cpp +0 -30
  189. data/test/cxx/ApplicationPool2/PoolTest.cpp +0 -2062
  190. data/test/cxx/ApplicationPool2/ProcessTest.cpp +0 -130
  191. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +0 -243
  192. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +0 -823
  193. data/test/cxx/BufferedIOTest.cpp +0 -364
  194. data/test/cxx/CachedFileStatTest.cpp +0 -402
  195. data/test/cxx/CxxTestMain.cpp +0 -181
  196. data/test/cxx/DataStructures/LStringTest.cpp +0 -275
  197. data/test/cxx/DataStructures/StringKeyTableTest.cpp +0 -199
  198. data/test/cxx/DateParsingTest.cpp +0 -75
  199. data/test/cxx/DechunkerTest.cpp +0 -250
  200. data/test/cxx/EventedBufferedInputTest.cpp +0 -758
  201. data/test/cxx/EventedClientTest.cpp +0 -523
  202. data/test/cxx/FileChangeCheckerTest.cpp +0 -331
  203. data/test/cxx/FileDescriptorTest.cpp +0 -69
  204. data/test/cxx/FilterSupportTest.cpp +0 -433
  205. data/test/cxx/IOUtilsTest.cpp +0 -861
  206. data/test/cxx/MemoryKit/MbufTest.cpp +0 -213
  207. data/test/cxx/MessageIOTest.cpp +0 -360
  208. data/test/cxx/MessagePassingTest.cpp +0 -81
  209. data/test/cxx/MessageReadersWritersTest.cpp +0 -576
  210. data/test/cxx/MessageServerTest.cpp +0 -393
  211. data/test/cxx/ProcessMetricsCollectorTest.cpp +0 -123
  212. data/test/cxx/RequestHandlerTest.cpp +0 -1463
  213. data/test/cxx/ResponseCacheTest.cpp +0 -322
  214. data/test/cxx/ServerKit/ChannelTest.cpp +0 -1467
  215. data/test/cxx/ServerKit/CookieUtilsTest.cpp +0 -274
  216. data/test/cxx/ServerKit/FileBufferedChannelTest.cpp +0 -992
  217. data/test/cxx/ServerKit/HeaderTableTest.cpp +0 -177
  218. data/test/cxx/ServerKit/HttpServerTest.cpp +0 -1580
  219. data/test/cxx/ServerKit/ServerTest.cpp +0 -408
  220. data/test/cxx/StaticStringTest.cpp +0 -220
  221. data/test/cxx/StringMapTest.cpp +0 -131
  222. data/test/cxx/SystemTimeTest.cpp +0 -37
  223. data/test/cxx/TemplateTest.cpp +0 -118
  224. data/test/cxx/TestSupport.cpp +0 -207
  225. data/test/cxx/TestSupport.h +0 -333
  226. data/test/cxx/UnionStationTest.cpp +0 -741
  227. data/test/cxx/Utils/StrIntUtilsTest.cpp +0 -39
  228. data/test/cxx/UtilsTest.cpp +0 -672
  229. data/test/cxx/VariantMapTest.cpp +0 -191
  230. data/test/gdbinit.example +0 -34
  231. data/test/integration_tests/apache2_tests.rb +0 -585
  232. data/test/integration_tests/downloaded_binaries_tests.rb +0 -185
  233. data/test/integration_tests/native_packaging_spec.rb +0 -368
  234. data/test/integration_tests/nginx_tests.rb +0 -402
  235. data/test/integration_tests/shared/example_webapp_tests.rb +0 -289
  236. data/test/integration_tests/source_packaging_test.rb +0 -201
  237. data/test/integration_tests/spec_helper.rb +0 -22
  238. data/test/integration_tests/standalone_tests.rb +0 -392
  239. data/test/node/line_reader_spec.js +0 -338
  240. data/test/node/spec_helper.js +0 -65
  241. data/test/oxt/backtrace_test.cpp +0 -88
  242. data/test/oxt/counter.hpp +0 -55
  243. data/test/oxt/dynamic_thread_group_test.cpp +0 -131
  244. data/test/oxt/oxt_test_main.cpp +0 -27
  245. data/test/oxt/spin_lock_test.cpp +0 -59
  246. data/test/oxt/syscall_interruption_test.cpp +0 -39
  247. data/test/ruby/debug_logging_spec.rb +0 -145
  248. data/test/ruby/message_channel_spec.rb +0 -196
  249. data/test/ruby/rack/loader_spec.rb +0 -42
  250. data/test/ruby/rack/preloader_spec.rb +0 -48
  251. data/test/ruby/rails3.0/loader_spec.rb +0 -26
  252. data/test/ruby/rails3.0/preloader_spec.rb +0 -32
  253. data/test/ruby/rails3.1/loader_spec.rb +0 -26
  254. data/test/ruby/rails3.1/preloader_spec.rb +0 -32
  255. data/test/ruby/rails3.2/loader_spec.rb +0 -26
  256. data/test/ruby/rails3.2/preloader_spec.rb +0 -32
  257. data/test/ruby/rails4.0/loader_spec.rb +0 -28
  258. data/test/ruby/rails4.0/preloader_spec.rb +0 -34
  259. data/test/ruby/rails4.1/loader_spec.rb +0 -28
  260. data/test/ruby/rails4.1/preloader_spec.rb +0 -34
  261. data/test/ruby/request_handler_spec.rb +0 -747
  262. data/test/ruby/shared/loader_sharedspec.rb +0 -247
  263. data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +0 -357
  264. data/test/ruby/shared/ruby_loader_sharedspec.rb +0 -55
  265. data/test/ruby/spec_helper.rb +0 -114
  266. data/test/ruby/standalone/runtime_installer_spec.rb +0 -402
  267. data/test/ruby/union_station_spec.rb +0 -288
  268. data/test/ruby/utils/file_system_watcher_spec.rb +0 -229
  269. data/test/ruby/utils/hosts_file_parser.rb +0 -258
  270. data/test/ruby/utils/tee_input_spec.rb +0 -235
  271. data/test/ruby/utils/unseekable_socket_spec.rb +0 -66
  272. data/test/ruby/utils_spec.rb +0 -41
  273. data/test/stub/apache2/httpd.conf.erb +0 -122
  274. data/test/stub/apache2/mime.types +0 -748
  275. data/test/stub/garbage1.dat +0 -0
  276. data/test/stub/garbage2.dat +0 -0
  277. data/test/stub/garbage3.dat +0 -0
  278. data/test/stub/http_request.yml +0 -23
  279. data/test/stub/index.html +0 -1
  280. data/test/stub/nginx/koi-utf +0 -109
  281. data/test/stub/nginx/koi-win +0 -103
  282. data/test/stub/nginx/mime.types +0 -70
  283. data/test/stub/nginx/nginx.conf.erb +0 -70
  284. data/test/stub/nginx/win-utf +0 -126
  285. data/test/stub/node/app.js +0 -133
  286. data/test/stub/node/public/.gitignore +0 -0
  287. data/test/stub/node/tmp/.gitignore +0 -0
  288. data/test/stub/rack/config.ru +0 -95
  289. data/test/stub/rack/library.rb +0 -16
  290. data/test/stub/rack/public/.gitignore +0 -0
  291. data/test/stub/rack/start.rb +0 -52
  292. data/test/stub/rack/tmp/.gitignore +0 -0
  293. data/test/stub/rails3.0/.gitignore +0 -4
  294. data/test/stub/rails3.0/Gemfile +0 -22
  295. data/test/stub/rails3.0/Gemfile.lock +0 -80
  296. data/test/stub/rails3.0/Rakefile +0 -10
  297. data/test/stub/rails3.0/app/controllers/application_controller.rb +0 -4
  298. data/test/stub/rails3.0/app/helpers/application_helper.rb +0 -2
  299. data/test/stub/rails3.0/app/views/layouts/application.html.erb +0 -14
  300. data/test/stub/rails3.0/config.ru +0 -4
  301. data/test/stub/rails3.0/config/application.rb +0 -48
  302. data/test/stub/rails3.0/config/boot.rb +0 -13
  303. data/test/stub/rails3.0/config/database.yml +0 -22
  304. data/test/stub/rails3.0/config/environment.rb +0 -5
  305. data/test/stub/rails3.0/config/environments/development.rb +0 -19
  306. data/test/stub/rails3.0/config/environments/production.rb +0 -48
  307. data/test/stub/rails3.0/config/environments/test.rb +0 -32
  308. data/test/stub/rails3.0/config/initializers/backtrace_silencers.rb +0 -7
  309. data/test/stub/rails3.0/config/initializers/inflections.rb +0 -10
  310. data/test/stub/rails3.0/config/initializers/mime_types.rb +0 -5
  311. data/test/stub/rails3.0/config/initializers/passenger.rb +0 -2
  312. data/test/stub/rails3.0/config/initializers/secret_token.rb +0 -7
  313. data/test/stub/rails3.0/config/initializers/session_store.rb +0 -8
  314. data/test/stub/rails3.0/config/locales/en.yml +0 -5
  315. data/test/stub/rails3.0/config/routes.rb +0 -58
  316. data/test/stub/rails3.0/db/seeds.rb +0 -7
  317. data/test/stub/rails3.0/doc/README_FOR_APP +0 -2
  318. data/test/stub/rails3.0/lib/tasks/.gitkeep +0 -0
  319. data/test/stub/rails3.0/log/.gitignore +0 -0
  320. data/test/stub/rails3.0/public/404.html +0 -26
  321. data/test/stub/rails3.0/public/422.html +0 -26
  322. data/test/stub/rails3.0/public/500.html +0 -26
  323. data/test/stub/rails3.0/public/favicon.ico +0 -0
  324. data/test/stub/rails3.0/public/index.html +0 -279
  325. data/test/stub/rails3.0/public/robots.txt +0 -5
  326. data/test/stub/rails3.0/public/stylesheets/.gitkeep +0 -0
  327. data/test/stub/rails3.0/script/rails +0 -9
  328. data/test/stub/rails3.0/test/performance/browsing_test.rb +0 -9
  329. data/test/stub/rails3.0/test/test_helper.rb +0 -13
  330. data/test/stub/rails3.0/vendor/plugins/.gitkeep +0 -0
  331. data/test/stub/rails3.1/.gitignore +0 -15
  332. data/test/stub/rails3.1/Gemfile +0 -37
  333. data/test/stub/rails3.1/Gemfile.lock +0 -115
  334. data/test/stub/rails3.1/README +0 -261
  335. data/test/stub/rails3.1/Rakefile +0 -7
  336. data/test/stub/rails3.1/app/assets/images/rails.png +0 -0
  337. data/test/stub/rails3.1/app/assets/stylesheets/application.css +0 -7
  338. data/test/stub/rails3.1/app/controllers/application_controller.rb +0 -3
  339. data/test/stub/rails3.1/app/helpers/application_helper.rb +0 -2
  340. data/test/stub/rails3.1/app/mailers/.gitkeep +0 -0
  341. data/test/stub/rails3.1/app/models/.gitkeep +0 -0
  342. data/test/stub/rails3.1/app/views/layouts/application.html.erb +0 -14
  343. data/test/stub/rails3.1/config.ru +0 -4
  344. data/test/stub/rails3.1/config/application.rb +0 -48
  345. data/test/stub/rails3.1/config/boot.rb +0 -6
  346. data/test/stub/rails3.1/config/database.yml +0 -25
  347. data/test/stub/rails3.1/config/environment.rb +0 -5
  348. data/test/stub/rails3.1/config/environments/development.rb +0 -30
  349. data/test/stub/rails3.1/config/environments/production.rb +0 -60
  350. data/test/stub/rails3.1/config/environments/test.rb +0 -39
  351. data/test/stub/rails3.1/config/initializers/backtrace_silencers.rb +0 -7
  352. data/test/stub/rails3.1/config/initializers/inflections.rb +0 -10
  353. data/test/stub/rails3.1/config/initializers/mime_types.rb +0 -5
  354. data/test/stub/rails3.1/config/initializers/passenger.rb +0 -2
  355. data/test/stub/rails3.1/config/initializers/secret_token.rb +0 -7
  356. data/test/stub/rails3.1/config/initializers/session_store.rb +0 -8
  357. data/test/stub/rails3.1/config/initializers/wrap_parameters.rb +0 -14
  358. data/test/stub/rails3.1/config/locales/en.yml +0 -5
  359. data/test/stub/rails3.1/config/routes.rb +0 -58
  360. data/test/stub/rails3.1/db/seeds.rb +0 -7
  361. data/test/stub/rails3.1/doc/README_FOR_APP +0 -2
  362. data/test/stub/rails3.1/lib/assets/.gitkeep +0 -0
  363. data/test/stub/rails3.1/lib/tasks/.gitkeep +0 -0
  364. data/test/stub/rails3.1/log/.gitkeep +0 -0
  365. data/test/stub/rails3.1/public/404.html +0 -26
  366. data/test/stub/rails3.1/public/422.html +0 -26
  367. data/test/stub/rails3.1/public/500.html +0 -26
  368. data/test/stub/rails3.1/public/favicon.ico +0 -0
  369. data/test/stub/rails3.1/public/index.html +0 -241
  370. data/test/stub/rails3.1/public/robots.txt +0 -5
  371. data/test/stub/rails3.1/script/rails +0 -6
  372. data/test/stub/rails3.1/test/fixtures/.gitkeep +0 -0
  373. data/test/stub/rails3.1/test/functional/.gitkeep +0 -0
  374. data/test/stub/rails3.1/test/integration/.gitkeep +0 -0
  375. data/test/stub/rails3.1/test/performance/browsing_test.rb +0 -12
  376. data/test/stub/rails3.1/test/test_helper.rb +0 -13
  377. data/test/stub/rails3.1/test/unit/.gitkeep +0 -0
  378. data/test/stub/rails3.1/vendor/assets/stylesheets/.gitkeep +0 -0
  379. data/test/stub/rails3.1/vendor/plugins/.gitkeep +0 -0
  380. data/test/stub/rails3.2/.gitignore +0 -15
  381. data/test/stub/rails3.2/Gemfile +0 -39
  382. data/test/stub/rails3.2/Gemfile.lock +0 -113
  383. data/test/stub/rails3.2/Rakefile +0 -7
  384. data/test/stub/rails3.2/app/assets/images/rails.png +0 -0
  385. data/test/stub/rails3.2/app/assets/stylesheets/application.css +0 -13
  386. data/test/stub/rails3.2/app/controllers/application_controller.rb +0 -3
  387. data/test/stub/rails3.2/app/helpers/application_helper.rb +0 -2
  388. data/test/stub/rails3.2/app/mailers/.gitkeep +0 -0
  389. data/test/stub/rails3.2/app/models/.gitkeep +0 -0
  390. data/test/stub/rails3.2/app/views/layouts/application.html.erb +0 -14
  391. data/test/stub/rails3.2/config.ru +0 -4
  392. data/test/stub/rails3.2/config/application.rb +0 -62
  393. data/test/stub/rails3.2/config/boot.rb +0 -6
  394. data/test/stub/rails3.2/config/database.yml +0 -25
  395. data/test/stub/rails3.2/config/environment.rb +0 -5
  396. data/test/stub/rails3.2/config/environments/development.rb +0 -37
  397. data/test/stub/rails3.2/config/environments/production.rb +0 -67
  398. data/test/stub/rails3.2/config/environments/test.rb +0 -37
  399. data/test/stub/rails3.2/config/initializers/backtrace_silencers.rb +0 -7
  400. data/test/stub/rails3.2/config/initializers/inflections.rb +0 -15
  401. data/test/stub/rails3.2/config/initializers/mime_types.rb +0 -5
  402. data/test/stub/rails3.2/config/initializers/passenger.rb +0 -2
  403. data/test/stub/rails3.2/config/initializers/secret_token.rb +0 -7
  404. data/test/stub/rails3.2/config/initializers/session_store.rb +0 -8
  405. data/test/stub/rails3.2/config/initializers/wrap_parameters.rb +0 -14
  406. data/test/stub/rails3.2/config/locales/en.yml +0 -5
  407. data/test/stub/rails3.2/config/routes.rb +0 -58
  408. data/test/stub/rails3.2/db/seeds.rb +0 -7
  409. data/test/stub/rails3.2/doc/README_FOR_APP +0 -2
  410. data/test/stub/rails3.2/lib/assets/.gitkeep +0 -0
  411. data/test/stub/rails3.2/lib/tasks/.gitkeep +0 -0
  412. data/test/stub/rails3.2/log/.gitkeep +0 -0
  413. data/test/stub/rails3.2/public/404.html +0 -26
  414. data/test/stub/rails3.2/public/422.html +0 -26
  415. data/test/stub/rails3.2/public/500.html +0 -25
  416. data/test/stub/rails3.2/public/favicon.ico +0 -0
  417. data/test/stub/rails3.2/public/index.html +0 -241
  418. data/test/stub/rails3.2/public/robots.txt +0 -5
  419. data/test/stub/rails3.2/script/rails +0 -6
  420. data/test/stub/rails3.2/test/fixtures/.gitkeep +0 -0
  421. data/test/stub/rails3.2/test/functional/.gitkeep +0 -0
  422. data/test/stub/rails3.2/test/integration/.gitkeep +0 -0
  423. data/test/stub/rails3.2/test/performance/browsing_test.rb +0 -12
  424. data/test/stub/rails3.2/test/test_helper.rb +0 -13
  425. data/test/stub/rails3.2/test/unit/.gitkeep +0 -0
  426. data/test/stub/rails3.2/vendor/assets/stylesheets/.gitkeep +0 -0
  427. data/test/stub/rails3.2/vendor/plugins/.gitkeep +0 -0
  428. data/test/stub/rails4.0/.gitignore +0 -16
  429. data/test/stub/rails4.0/Gemfile +0 -45
  430. data/test/stub/rails4.0/Gemfile.lock +0 -126
  431. data/test/stub/rails4.0/README.rdoc +0 -28
  432. data/test/stub/rails4.0/Rakefile +0 -6
  433. data/test/stub/rails4.0/app/assets/images/.keep +0 -0
  434. data/test/stub/rails4.0/app/assets/javascripts/application.js +0 -16
  435. data/test/stub/rails4.0/app/assets/stylesheets/application.css +0 -13
  436. data/test/stub/rails4.0/app/controllers/application_controller.rb +0 -5
  437. data/test/stub/rails4.0/app/controllers/concerns/.keep +0 -0
  438. data/test/stub/rails4.0/app/helpers/application_helper.rb +0 -2
  439. data/test/stub/rails4.0/app/mailers/.keep +0 -0
  440. data/test/stub/rails4.0/app/models/.keep +0 -0
  441. data/test/stub/rails4.0/app/models/concerns/.keep +0 -0
  442. data/test/stub/rails4.0/app/views/layouts/application.html.erb +0 -14
  443. data/test/stub/rails4.0/bin/bundle +0 -3
  444. data/test/stub/rails4.0/bin/rails +0 -4
  445. data/test/stub/rails4.0/bin/rake +0 -4
  446. data/test/stub/rails4.0/config.ru +0 -4
  447. data/test/stub/rails4.0/config/application.rb +0 -23
  448. data/test/stub/rails4.0/config/boot.rb +0 -4
  449. data/test/stub/rails4.0/config/database.yml +0 -25
  450. data/test/stub/rails4.0/config/environment.rb +0 -5
  451. data/test/stub/rails4.0/config/environments/development.rb +0 -29
  452. data/test/stub/rails4.0/config/environments/production.rb +0 -80
  453. data/test/stub/rails4.0/config/environments/test.rb +0 -36
  454. data/test/stub/rails4.0/config/initializers/backtrace_silencers.rb +0 -7
  455. data/test/stub/rails4.0/config/initializers/filter_parameter_logging.rb +0 -4
  456. data/test/stub/rails4.0/config/initializers/inflections.rb +0 -16
  457. data/test/stub/rails4.0/config/initializers/mime_types.rb +0 -5
  458. data/test/stub/rails4.0/config/initializers/passenger.rb +0 -2
  459. data/test/stub/rails4.0/config/initializers/secret_token.rb +0 -12
  460. data/test/stub/rails4.0/config/initializers/session_store.rb +0 -3
  461. data/test/stub/rails4.0/config/initializers/wrap_parameters.rb +0 -14
  462. data/test/stub/rails4.0/config/locales/en.yml +0 -23
  463. data/test/stub/rails4.0/config/routes.rb +0 -57
  464. data/test/stub/rails4.0/db/seeds.rb +0 -7
  465. data/test/stub/rails4.0/lib/assets/.keep +0 -0
  466. data/test/stub/rails4.0/lib/tasks/.keep +0 -0
  467. data/test/stub/rails4.0/log/.keep +0 -0
  468. data/test/stub/rails4.0/public/404.html +0 -58
  469. data/test/stub/rails4.0/public/422.html +0 -58
  470. data/test/stub/rails4.0/public/500.html +0 -57
  471. data/test/stub/rails4.0/public/favicon.ico +0 -0
  472. data/test/stub/rails4.0/public/robots.txt +0 -5
  473. data/test/stub/rails4.0/test/controllers/.keep +0 -0
  474. data/test/stub/rails4.0/test/fixtures/.keep +0 -0
  475. data/test/stub/rails4.0/test/helpers/.keep +0 -0
  476. data/test/stub/rails4.0/test/integration/.keep +0 -0
  477. data/test/stub/rails4.0/test/mailers/.keep +0 -0
  478. data/test/stub/rails4.0/test/models/.keep +0 -0
  479. data/test/stub/rails4.0/test/test_helper.rb +0 -15
  480. data/test/stub/rails4.0/vendor/assets/javascripts/.keep +0 -0
  481. data/test/stub/rails4.0/vendor/assets/stylesheets/.keep +0 -0
  482. data/test/stub/rails4.1/.gitignore +0 -16
  483. data/test/stub/rails4.1/Gemfile +0 -45
  484. data/test/stub/rails4.1/Gemfile.lock +0 -129
  485. data/test/stub/rails4.1/README.rdoc +0 -28
  486. data/test/stub/rails4.1/Rakefile +0 -6
  487. data/test/stub/rails4.1/app/assets/images/.keep +0 -0
  488. data/test/stub/rails4.1/app/assets/javascripts/application.js +0 -16
  489. data/test/stub/rails4.1/app/assets/stylesheets/application.css +0 -13
  490. data/test/stub/rails4.1/app/controllers/application_controller.rb +0 -5
  491. data/test/stub/rails4.1/app/controllers/concerns/.keep +0 -0
  492. data/test/stub/rails4.1/app/helpers/application_helper.rb +0 -2
  493. data/test/stub/rails4.1/app/mailers/.keep +0 -0
  494. data/test/stub/rails4.1/app/models/.keep +0 -0
  495. data/test/stub/rails4.1/app/models/concerns/.keep +0 -0
  496. data/test/stub/rails4.1/app/views/layouts/application.html.erb +0 -14
  497. data/test/stub/rails4.1/bin/bundle +0 -3
  498. data/test/stub/rails4.1/bin/rails +0 -4
  499. data/test/stub/rails4.1/bin/rake +0 -4
  500. data/test/stub/rails4.1/config.ru +0 -4
  501. data/test/stub/rails4.1/config/application.rb +0 -23
  502. data/test/stub/rails4.1/config/boot.rb +0 -4
  503. data/test/stub/rails4.1/config/database.yml +0 -25
  504. data/test/stub/rails4.1/config/environment.rb +0 -5
  505. data/test/stub/rails4.1/config/environments/development.rb +0 -29
  506. data/test/stub/rails4.1/config/environments/production.rb +0 -80
  507. data/test/stub/rails4.1/config/environments/test.rb +0 -36
  508. data/test/stub/rails4.1/config/initializers/backtrace_silencers.rb +0 -7
  509. data/test/stub/rails4.1/config/initializers/filter_parameter_logging.rb +0 -4
  510. data/test/stub/rails4.1/config/initializers/inflections.rb +0 -16
  511. data/test/stub/rails4.1/config/initializers/mime_types.rb +0 -5
  512. data/test/stub/rails4.1/config/initializers/passenger.rb +0 -5
  513. data/test/stub/rails4.1/config/initializers/secret_token.rb +0 -12
  514. data/test/stub/rails4.1/config/initializers/session_store.rb +0 -3
  515. data/test/stub/rails4.1/config/initializers/wrap_parameters.rb +0 -14
  516. data/test/stub/rails4.1/config/locales/en.yml +0 -23
  517. data/test/stub/rails4.1/config/routes.rb +0 -57
  518. data/test/stub/rails4.1/db/seeds.rb +0 -7
  519. data/test/stub/rails4.1/lib/assets/.keep +0 -0
  520. data/test/stub/rails4.1/lib/tasks/.keep +0 -0
  521. data/test/stub/rails4.1/log/.keep +0 -0
  522. data/test/stub/rails4.1/public/404.html +0 -58
  523. data/test/stub/rails4.1/public/422.html +0 -58
  524. data/test/stub/rails4.1/public/500.html +0 -57
  525. data/test/stub/rails4.1/public/favicon.ico +0 -0
  526. data/test/stub/rails4.1/public/robots.txt +0 -5
  527. data/test/stub/rails4.1/test/controllers/.keep +0 -0
  528. data/test/stub/rails4.1/test/fixtures/.keep +0 -0
  529. data/test/stub/rails4.1/test/helpers/.keep +0 -0
  530. data/test/stub/rails4.1/test/integration/.keep +0 -0
  531. data/test/stub/rails4.1/test/mailers/.keep +0 -0
  532. data/test/stub/rails4.1/test/models/.keep +0 -0
  533. data/test/stub/rails4.1/test/test_helper.rb +0 -15
  534. data/test/stub/rails4.1/vendor/assets/javascripts/.keep +0 -0
  535. data/test/stub/rails4.1/vendor/assets/stylesheets/.keep +0 -0
  536. data/test/stub/start_error.pl +0 -24
  537. data/test/stub/upload_data.txt +0 -494
  538. data/test/stub/wsgi/passenger_wsgi.py +0 -212
  539. data/test/stub/wsgi/public/.gitignore +0 -0
  540. data/test/stub/wsgi/tmp/.gitignore +0 -0
  541. data/test/support/allocate_memory.c +0 -14
  542. data/test/support/apache2_controller.rb +0 -258
  543. data/test/support/multipart.rb +0 -62
  544. data/test/support/nginx_controller.rb +0 -97
  545. data/test/support/placebo-preloader.rb +0 -88
  546. data/test/support/test_helper.rb +0 -455
  547. data/test/support/valgrind.h +0 -2539
  548. data/test/tut/tut.h +0 -1310
  549. data/test/tut/tut_reporter.h +0 -256
  550. data/test/valgrind-osx.supp +0 -7
@@ -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
- }