• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

concurrent use of database

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been thinking on how to automate the booking of the same flight at the same time. I want to test the concurrent use of the datanbase.Any ideas?
Prakash
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,there are some discussions about your content,you may look through the forum to get it.very particular
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have been thinking on how to automate the booking of the same flight at the same time. I want to test the concurrent use of the datanbase.Any ideas?


Create a test class which spawns 20 thread, each thread representing a remote client. Let each thread reserve 1 seat on a particular flight, 100 times in a row. If at the end of the run the seat count is reduced by exactly 2000 seats, you pass.
Eugene.
 
Prakash Krishnamurthy
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks eugene.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If at the end of the run the seat count is reduced by exactly 2000 seats, you pass.


However if there wern't 2000 seats to begin with, and you end up with 2000 seats being booked then either you failed or your test scenario wasn't quite right
You probably need to test the locking mechanism, which would require you to have the business logic in the threads - lock a record / confirm number of seats available / decrement count / unlock record (if you have implemented the business logic at the client side not the server side).
You could then try starting with an initial seat count of 3999, reducing by two seats at a time. At the end of the run, one of your threads should have complained that there were not enough seats available, and you should have one seat left in the table.
The tests can get far more involved than this as well
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do we need start this test on at least two pc or one is enough?
 
Andrew Monkhouse
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Larry,
You should try to limit your testing to one area only. So your first tests should just be for databse concurrency with local access.
The next sets of tests should test via your network methodology, so your tests should call the same RMI classes and methods, or the same Serialised Sockets classes and methods as your real application.
Unless you are using client machine specific data in your database (or locking) methods, you should not have to test from different machines. You should still only be testing your database concurrency at this point.
The testing from multiple machines is a seperate set of tests, unrelated to the database concurrency issues. The exception is as I mentioned before - if you are using connection data in your databse access or locking, then you would then have to test it (e.g. if you were using sockets and decided to use the client port number as unique ID (really bad idea) then you would need to test networking as part of your tests.
You do need to test the entire deliverable later to make sure that they are not tied to specific machines (so have the server on one machine & the client on another), and test the client on as many different operating systems as possible.
Regards, Andrew
 
Larry Li
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Andrew, really helpful.
 
and POOF! You're gone! But look, this tiny ad is still here:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic