We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Add a unit test for ApplicationPool's MaxPerApp option.
Hongli Lai (Phusion) (author)
Sat Nov 22 09:23:03 -0800 2008
commit  bdcc70bbb72e7c256fe2780cadb59754b71c36ff
tree    e530361239a79c42950ff3e03b275b013b08387a
parent  b8d4085fe808bf752f01084a4e37b5090096d4dc
...
17
18
19
 
 
 
 
20
21
22
...
17
18
19
20
21
22
23
24
25
26
0
@@ -17,6 +17,10 @@ namespace tut {
0
       pool = server->connect();
0
       pool2 = server->connect();
0
     }
0
+
0
+ ApplicationPoolPtr newPoolConnection() {
0
+ return server->connect();
0
+ }
0
   };
0
   
0
   DEFINE_TEST_GROUP(ApplicationPoolServer_ApplicationPoolTest);
...
358
359
360
361
 
362
363
364
 
 
 
 
 
 
 
 
 
 
 
 
 
365
366
367
...
438
439
440
441
442
443
444
...
358
359
360
 
361
362
363
 
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
...
450
451
452
 
 
453
454
0
@@ -358,10 +358,22 @@
0
   }
0
   
0
   TEST_METHOD(17) {
0
- // MaxPerApp must be respected.
0
+ // MaxPerApp is respected.
0
     pool->setMax(3);
0
     pool->setMaxPerApp(1);
0
- // TODO: how do we test this?
0
+
0
+ // We connect to stub/rack while it already has an instance with
0
+ // 1 request in its queue. Assert that the pool doesn't spawn
0
+ // another instance.
0
+ Application::SessionPtr session1 = spawnRackApp(pool, "stub/rack");
0
+ Application::SessionPtr session2 = spawnRackApp(pool2, "stub/rack");
0
+ ensure_equals(pool->getCount(), 1u);
0
+
0
+ // We connect to stub/wsgi. Assert that the pool spawns a new
0
+ // instance for this app.
0
+ ApplicationPoolPtr pool3(newPoolConnection());
0
+ Application::SessionPtr session3 = spawnWsgiApp(pool3, "stub/wsgi");
0
+ ensure_equals(pool->getCount(), 2u);
0
   }
0
   
0
   TEST_METHOD(18) {
0
@@ -438,7 +450,5 @@
0
     session.reset();
0
     thr.join();
0
   }
0
-
0
- // TODO: test maxIdleTime == 0
0
 
0
 #endif /* USE_TEMPLATE */
...
12
13
14
 
 
 
 
15
16
17
...
12
13
14
15
16
17
18
19
20
21
0
@@ -12,6 +12,10 @@ namespace tut {
0
       pool = ptr(new StandardApplicationPool("../bin/passenger-spawn-server"));
0
       pool2 = pool;
0
     }
0
+
0
+ ApplicationPoolPtr newPoolConnection() {
0
+ return pool;
0
+ }
0
   };
0
 
0
   DEFINE_TEST_GROUP(StandardApplicationPoolTest);

Comments

    No one has commented yet.